URL
https://opencores.org/ocsvn/open_hitter/open_hitter/trunk
Subversion Repositories open_hitter
Compare Revisions
- This comparison shows the changes necessary to convert path
/open_hitter/trunk/rtl
- from Rev 13 to Rev 14
- ↔ Reverse comparison
Rev 13 → Rev 14
/vhdl/search_item.vhd
56,6 → 56,7
use ieee.numeric_std.ALL; |
|
entity search_item is |
generic ( item_id: std_logic_vector(15 downto 0) ); |
port ( |
RX_CLK: in std_logic; |
-- control flag(s) on the incoming bus |
108,36 → 109,54
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier |
b2_id <= (others => 'Z'); -- unique/identifier/counter |
-- |
b2_px_type <= std_logic_vector'(std_logic_vector'("00000")); |
state <= 8; |
b2_px_type <= std_logic_vector'("ZZZZZ"); |
state <= 16; |
|
elsif b1_px_type = std_logic_vector'("00110") then |
-- do set store from incoming price |
store_px_type <= b1_px_type; |
store_buy_sell <= b1_buy_sell; |
store_px <= b1_px; |
store_qty <= b1_qty; |
store_sec <= b1_sec; |
store_id <= b1_id; |
-- |
b2_px_type <= std_logic_vector'(std_logic_vector'("00000")); |
state <= 8; |
if store_buy_sell = b1_buy_sell and |
store_sec = b1_sec then |
-- do set store from incoming price |
store_px_type <= b1_px_type; |
-- store_buy_sell <= b1_buy_sell; |
store_px <= b1_px; |
store_qty <= b1_qty; |
-- store_sec <= b1_sec; |
store_id <= b1_id; |
-- |
b2_px_type <= std_logic_vector'(std_logic_vector'("00110")); |
state <= 8; |
end if; |
|
elsif b1_px_type = std_logic_vector'("0101") then |
elsif b1_px_type = std_logic_vector'("01010") then |
if item_id = b1_id then |
-- do set store and security from incoming price |
store_px_type <= b1_px_type; |
store_buy_sell <= b1_buy_sell; |
store_px <= b1_px; |
store_qty <= b1_qty; |
store_sec <= b1_sec; |
store_id <= b1_id; |
-- |
b2_px_type <= b1_px_type; |
b2_id <= item_id; |
state <= 8; |
end if; |
|
elsif b1_px_type = std_logic_vector'("11100") then |
-- incoming price, register it and start the state machine |
if (store_sec /= b1_sec or store_buy_sell = b1_buy_sell or store_px_type /= std_logic_vector'(std_logic_vector'("0110")) ) then |
-- not this store_item instance no action, also stop anything that might be going on |
state <= 14; |
if (store_sec /= b1_sec or store_buy_sell = b1_buy_sell ) then |
-- not this store_item instance no action |
null; |
elsif (to_integer(unsigned(store_qty)) = 0 or to_integer(unsigned(b1_qty)) = 0 or |
(store_buy_sell = std_logic_vector'("111") and store_px < b1_px) or |
(store_buy_sell = std_logic_vector'("000") and store_px > b1_px) ) then |
-- no deal: this is the correct store_item but there's no match |
b2_px_type <= std_logic_vector'(std_logic_vector'("00000")); |
state <= 8; |
b2_px_type <= std_logic_vector'(std_logic_vector'("11101")); |
else |
-- send a return order |
b2_px_type <= std_logic_vector'("1010"); |
b2_buy_sell <= store_buy_sell; -- 111 buy, 000 sell |
b2_sec <= store_sec; -- 7x 8bits securities identifier |
b2_id <= store_id; -- unique/identifier/counter |
b2_px <= b1_px; -- price |
-- b2_qty <= |
if b1_qty < store_qty then |
145,8 → 164,6
else |
b2_qty <= store_qty; |
end if; -- quantity |
b2_sec <= store_sec; -- 7x 8bits securities identifier |
b2_id <= store_id; -- unique/identifier/counter |
-- update the store |
-- store_qty |
if (b1_qty < store_qty) then |
153,9 → 170,10
store_qty <= std_logic_vector(to_unsigned( to_integer(unsigned(store_qty)) - to_integer(unsigned(b1_qty)) ,16 )); |
else |
store_qty <= (others => '0'); |
state <= 1; |
end if; |
b2_px_type <= std_logic_vector'(std_logic_vector'("11100")); |
end if; |
state <= 8; |
|
else |
-- no action |
165,7 → 183,7
else -- b1_px_valid |
-- no incoming b1_px so check for state machine actions |
case state is |
when 1 => |
when 8 => |
-- sent return order, so clean up |
b2_px_type <= (others => 'Z'); |
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell |
173,13 → 191,10
b2_qty <= (others => 'Z'); -- quantity |
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier |
b2_id <= (others => 'Z'); -- unique/identifier/counter |
-- |
b2_px_type <= std_logic_vector'("ZZZZZ"); |
state <= 16; |
|
when 8 => |
-- correct store_item but there was no match |
b2_px_type <= std_logic_vector'("ZZZZZ"); |
state <= 16; |
|
when others => null; |
end case; -- state |
|