Line 88... |
Line 88... |
signal store_id: std_logic_vector(15 downto 0) := (others => '0'); -- unique/identifier/counter
|
signal store_id: std_logic_vector(15 downto 0) := (others => '0'); -- unique/identifier/counter
|
begin
|
begin
|
match: process (RX_CLK) is
|
match: process (RX_CLK) is
|
begin
|
begin
|
if rising_edge(RX_CLK) then
|
if rising_edge(RX_CLK) then
|
if b1_px_valid = '0' then
|
if b1_px_valid = '1' then
|
|
|
if b1_px_type = std_logic_vector'("0000") then
|
if b1_px_type = std_logic_vector'("00000") then
|
-- do reset store and outputs
|
-- do reset store and outputs
|
store_px_type <= (others => '0');
|
store_px_type <= (others => '0');
|
store_buy_sell <= (others => '0'); -- 111 buy, 000 sell
|
store_buy_sell <= (others => '0'); -- 111 buy, 000 sell
|
store_px <= (others => '0'); -- price
|
store_px <= (others => '0'); -- price
|
store_qty <= (others => '0'); -- quantity
|
store_qty <= (others => '0'); -- quantity
|
store_sec <= (others => '0'); -- 7x 8bits securities identifier
|
store_sec <= (others => '0'); -- 7x 8bits securities identifier
|
store_id <= (others => '0'); -- unique/identifier/counter
|
-- not reset / generic store_id <= (others => '0'); -- unique/identifier/counter
|
--
|
--
|
b2_px_type <= (others => 'Z');
|
b2_px_type <= (others => 'Z');
|
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
|
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
|
b2_px <= (others => 'Z'); -- price
|
b2_px <= (others => 'Z'); -- price
|
b2_qty <= (others => 'Z'); -- quantity
|
b2_qty <= (others => 'Z'); -- quantity
|
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
|
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
|
b2_id <= (others => 'Z'); -- unique/identifier/counter
|
b2_id <= (others => 'Z'); -- unique/identifier/counter
|
--
|
--
|
b2_px_type <= std_logic_vector'(std_logic_vector'("0000"));
|
b2_px_type <= std_logic_vector'(std_logic_vector'("00000"));
|
state <= 8;
|
state <= 8;
|
|
|
elsif b1_px_type = std_logic_vector'("0110") then
|
elsif b1_px_type = std_logic_vector'("00110") then
|
-- do set store from incoming price
|
-- do set store from incoming price
|
store_px_type <= b1_px_type;
|
store_px_type <= b1_px_type;
|
store_buy_sell <= b1_buy_sell;
|
store_buy_sell <= b1_buy_sell;
|
store_px <= b1_px;
|
store_px <= b1_px;
|
store_qty <= b1_qty;
|
store_qty <= b1_qty;
|
store_sec <= b1_sec;
|
store_sec <= b1_sec;
|
store_id <= b1_id;
|
store_id <= b1_id;
|
--
|
--
|
b2_px_type <= std_logic_vector'(std_logic_vector'("0000"));
|
b2_px_type <= std_logic_vector'(std_logic_vector'("00000"));
|
state <= 8;
|
state <= 8;
|
|
|
elsif b1_px_type = std_logic_vector'("0101") then
|
elsif b1_px_type = std_logic_vector'("0101") then
|
-- incoming price, register it and start the state machine
|
-- 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
|
if (store_sec /= b1_sec or store_buy_sell = b1_buy_sell or store_px_type /= std_logic_vector'(std_logic_vector'("0110")) ) then
|
Line 130... |
Line 130... |
state <= 14;
|
state <= 14;
|
elsif (to_integer(unsigned(store_qty)) = 0 or to_integer(unsigned(b1_qty)) = 0 or
|
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'("111") and store_px < b1_px) or
|
(store_buy_sell = std_logic_vector'("000") and store_px > b1_px) ) then
|
(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
|
-- no deal: this is the correct store_item but there's no match
|
b2_px_type <= std_logic_vector'(std_logic_vector'("0000"));
|
b2_px_type <= std_logic_vector'(std_logic_vector'("00000"));
|
state <= 8;
|
state <= 8;
|
else
|
else
|
-- send a return order
|
-- send a return order
|
b2_px_type <= std_logic_vector'("1010");
|
b2_px_type <= std_logic_vector'("1010");
|
b2_buy_sell <= store_buy_sell; -- 111 buy, 000 sell
|
b2_buy_sell <= store_buy_sell; -- 111 buy, 000 sell
|
Line 175... |
Line 175... |
b2_id <= (others => 'Z'); -- unique/identifier/counter
|
b2_id <= (others => 'Z'); -- unique/identifier/counter
|
state <= 16;
|
state <= 16;
|
|
|
when 8 =>
|
when 8 =>
|
-- correct store_item but there was no match
|
-- correct store_item but there was no match
|
b2_px_type <= std_logic_vector'("ZZZZ");
|
b2_px_type <= std_logic_vector'("ZZZZZ");
|
state <= 16;
|
state <= 16;
|
|
|
when others => null;
|
when others => null;
|
end case; -- state
|
end case; -- state
|
|
|