--////////////////////////////////////////////////////////////////////
|
--////////////////////////////////////////////////////////////////////
|
--// ////
|
--// ////
|
--// search_control.vhd ////
|
--// search_control.vhd ////
|
--// ////
|
--// ////
|
--// This file is part of the open_hitter opencores effort. ////
|
--// This file is part of the open_hitter opencores effort. ////
|
--// <http://www.opencores.org/cores/open_hitter/> ////
|
--// <http://www.opencores.org/cores/open_hitter/> ////
|
--// ////
|
--// ////
|
--// Module Description: ////
|
--// Module Description: ////
|
--// This is the multipelexed search's control item, used to set ////
|
--// This is the multipelexed search's control item, used to set ////
|
--// up, access and control the search. ////
|
--// up, access and control the search. ////
|
--// search_*_i - input to search_control ////
|
--// search_*_i - input to search_control ////
|
--// order_*_o - output from search_control ////
|
--// order_*_o - output from search_control ////
|
--// Buses perform the multiplex and are experienced by each item ////
|
--// Buses perform the multiplex and are experienced by each item ////
|
--// as b1_* - set by search_control, input to search_item ////
|
--// as b1_* - set by search_control, input to search_item ////
|
--// b2_* - output from search_item, read by search_control ////
|
--// b2_* - output from search_item, read by search_control ////
|
--// The state machine in search_control coordinates the search, ////
|
--// The state machine in search_control coordinates the search, ////
|
--// and the number of transitions is dependant on the incoming ////
|
--// and the number of transitions is dependant on the incoming ////
|
--// instruction (search_*_i). ////
|
--// instruction (search_*_i). ////
|
--// ////
|
--// ////
|
--// To Do: ////
|
--// To Do: ////
|
--// ////
|
--// ////
|
--// Author(s): ////
|
--// Author(s): ////
|
--// - Stephen Hawes ////
|
--// - Stephen Hawes ////
|
--// ////
|
--// ////
|
--////////////////////////////////////////////////////////////////////
|
--////////////////////////////////////////////////////////////////////
|
--// ////
|
--// ////
|
--// Copyright (C) 2015 Stephen Hawes and OPENCORES.ORG ////
|
--// Copyright (C) 2015 Stephen Hawes and OPENCORES.ORG ////
|
--// ////
|
--// ////
|
--// This source file may be used and distributed without ////
|
--// This source file may be used and distributed without ////
|
--// restriction provided that this copyright statement is not ////
|
--// restriction provided that this copyright statement is not ////
|
--// removed from the file and that any derivative work contains ////
|
--// removed from the file and that any derivative work contains ////
|
--// the original copyright notice and the associated disclaimer. ////
|
--// the original copyright notice and the associated disclaimer. ////
|
--// ////
|
--// ////
|
--// This source file is free software; you can redistribute it ////
|
--// This source file is free software; you can redistribute it ////
|
--// and/or modify it under the terms of the GNU Lesser General ////
|
--// and/or modify it under the terms of the GNU Lesser General ////
|
--// Public License as published by the Free Software Foundation; ////
|
--// Public License as published by the Free Software Foundation; ////
|
--// either version 2.1 of the License, or (at your option) any ////
|
--// either version 2.1 of the License, or (at your option) any ////
|
--// later version. ////
|
--// later version. ////
|
--// ////
|
--// ////
|
--// This source is distributed in the hope that it will be ////
|
--// This source is distributed in the hope that it will be ////
|
--// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
--// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
--// PURPOSE. See the GNU Lesser General Public License for more ////
|
--// PURPOSE. See the GNU Lesser General Public License for more ////
|
--// details. ////
|
--// details. ////
|
--// ////
|
--// ////
|
--// You should have received a copy of the GNU Lesser General ////
|
--// You should have received a copy of the GNU Lesser General ////
|
--// Public License along with this source; if not, download it ////
|
--// Public License along with this source; if not, download it ////
|
--// from <http://www.opencores.org/lgpl.shtml> ////
|
--// from <http://www.opencores.org/lgpl.shtml> ////
|
--// ////
|
--// ////
|
--////////////////////////////////////////////////////////////////////
|
--////////////////////////////////////////////////////////////////////
|
--//
|
--//
|
--// \$Id\$ TAKE OUT THE \'s and this comment in order to get this to work
|
--// \$Id\$ TAKE OUT THE \'s and this comment in order to get this to work
|
--//
|
--//
|
--// CVS Revision History
|
--// CVS Revision History
|
--//
|
--//
|
--// \$Log\$ TAKE OUT THE \'s and this comment in order to get this to work
|
--// \$Log\$ TAKE OUT THE \'s and this comment in order to get this to work
|
--//
|
--//
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.numeric_std.ALL;
|
use ieee.numeric_std.ALL;
|
-- use std.textio.all; -- Imports the standard textio package.
|
-- use std.textio.all; -- Imports the standard textio package.
|
|
|
entity search_control is
|
entity search_control is
|
generic ( searchitems : integer );
|
generic ( searchitems : integer );
|
port (
|
port (
|
RX_CLK: in std_logic;
|
RX_CLK: in std_logic;
|
-- control flag(s) on the incoming bus
|
-- control flag(s) on the incoming bus
|
search_px_valid_i: in std_logic;
|
search_px_valid_i: in std_logic;
|
-- pxdata: in price_packet
|
-- pxdata: in price_packet
|
search_px_type_i: in std_logic_vector(4 downto 0);
|
search_px_type_i: in std_logic_vector(4 downto 0);
|
search_buy_sell_i: in std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
search_buy_sell_i: in std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
search_px_i: in std_logic_vector(15 downto 0); -- price
|
search_px_i: in std_logic_vector(15 downto 0); -- price
|
search_qty_i: in std_logic_vector(15 downto 0); -- quantity
|
search_qty_i: in std_logic_vector(15 downto 0); -- quantity
|
search_sec_i: in std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
search_sec_i: in std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
search_id_i: in std_logic_vector(15 downto 0); -- unique/identifier/counter
|
search_id_i: in std_logic_vector(15 downto 0); -- unique/identifier/counter
|
-- pxdata: out price_packet
|
-- pxdata: out price_packet
|
order_px_type_o: out std_logic_vector(4 downto 0);
|
order_px_type_o: out std_logic_vector(4 downto 0);
|
order_buy_sell_o: out std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
order_buy_sell_o: out std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
order_px_o: out std_logic_vector(15 downto 0); -- price
|
order_px_o: out std_logic_vector(15 downto 0); -- price
|
order_qty_o: out std_logic_vector(15 downto 0); -- quantity
|
order_qty_o: out std_logic_vector(15 downto 0); -- quantity
|
order_sec_o: out std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
order_sec_o: out std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
order_id_o: out std_logic_vector(15 downto 0); -- unique/identifier/counter
|
order_id_o: out std_logic_vector(15 downto 0); -- unique/identifier/counter
|
-- control flag(s) on the outgoing bus
|
-- control flag(s) on the outgoing bus
|
order_px_valid_o: out std_logic
|
order_px_valid_o: out std_logic
|
);
|
);
|
end search_control;
|
end search_control;
|
|
|
architecture search_control_implementation of search_control is
|
architecture search_control_implementation of search_control is
|
component search_item
|
component search_item
|
generic ( item_id: std_logic_vector(15 downto 0) );
|
generic ( item_id: std_logic_vector(15 downto 0) );
|
port (
|
port (
|
RX_CLK: in std_logic;
|
RX_CLK: in std_logic;
|
-- control flag(s) on the incoming bus
|
-- control flag(s) on the incoming bus
|
b1_px_valid: in std_logic;
|
b1_px_valid: in std_logic;
|
-- pxdata: in price_packet
|
-- pxdata: in price_packet
|
b1_px_type: in std_logic_vector(4 downto 0);
|
b1_px_type: in std_logic_vector(4 downto 0);
|
b1_buy_sell: in std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
b1_buy_sell: in std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
b1_px: in std_logic_vector(15 downto 0); -- price
|
b1_px: in std_logic_vector(15 downto 0); -- price
|
b1_qty: in std_logic_vector(15 downto 0); -- quantity
|
b1_qty: in std_logic_vector(15 downto 0); -- quantity
|
b1_sec: in std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
b1_sec: in std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
b1_id: in std_logic_vector(15 downto 0); -- unique/identifier/counter
|
b1_id: in std_logic_vector(15 downto 0); -- unique/identifier/counter
|
-- pxdata: out price_packet
|
-- pxdata: out price_packet
|
b2_px_type: out std_logic_vector(4 downto 0);
|
b2_px_type: out std_logic_vector(4 downto 0);
|
b2_buy_sell: out std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
b2_buy_sell: out std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
b2_px: out std_logic_vector(15 downto 0); -- price
|
b2_px: out std_logic_vector(15 downto 0); -- price
|
b2_qty: out std_logic_vector(15 downto 0); -- quantity
|
b2_qty: out std_logic_vector(15 downto 0); -- quantity
|
b2_sec: out std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
b2_sec: out std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
b2_id: out std_logic_vector(15 downto 0) -- unique/identifier/counter
|
b2_id: out std_logic_vector(15 downto 0) -- unique/identifier/counter
|
);
|
);
|
end component;
|
end component;
|
signal searchitems_count : integer;
|
signal searchitems_count : integer;
|
signal state : integer range 0 to 16;
|
signal state : integer range 0 to 16;
|
-- pxdata: store price_packet
|
-- pxdata: store price_packet
|
signal store_px_type: std_logic_vector(4 downto 0) := (others => 'Z');
|
signal store_px_type: std_logic_vector(4 downto 0) := (others => 'Z');
|
signal store_buy_sell: std_logic_vector(2 downto 0) := (others => 'Z'); -- 111 buy, 000 sell
|
signal store_buy_sell: std_logic_vector(2 downto 0) := (others => 'Z'); -- 111 buy, 000 sell
|
signal store_px: std_logic_vector(15 downto 0) := (others => 'Z'); -- price
|
signal store_px: std_logic_vector(15 downto 0) := (others => 'Z'); -- price
|
signal store_qty: std_logic_vector(15 downto 0) := (others => 'Z'); -- quantity
|
signal store_qty: std_logic_vector(15 downto 0) := (others => 'Z'); -- quantity
|
signal store_sec: std_logic_vector(55 downto 0) := (others => 'Z'); -- 7x 8bits securities identifier
|
signal store_sec: std_logic_vector(55 downto 0) := (others => 'Z'); -- 7x 8bits securities identifier
|
signal store_id: std_logic_vector(15 downto 0) := (others => 'Z'); -- unique/identifier/counter
|
signal store_id: std_logic_vector(15 downto 0) := (others => 'Z'); -- unique/identifier/counter
|
-- control flag(s) on the incoming bus
|
-- control flag(s) on the incoming bus
|
signal b1_px_valid: std_logic;
|
signal b1_px_valid: std_logic;
|
-- pxdata: in price_packet
|
-- pxdata: in price_packet
|
signal b1_px_type: std_logic_vector(4 downto 0);
|
signal b1_px_type: std_logic_vector(4 downto 0);
|
signal b1_buy_sell: std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
signal b1_buy_sell: std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
signal b1_px: std_logic_vector(15 downto 0); -- price
|
signal b1_px: std_logic_vector(15 downto 0); -- price
|
signal b1_qty: std_logic_vector(15 downto 0); -- quantity
|
signal b1_qty: std_logic_vector(15 downto 0); -- quantity
|
signal b1_sec: std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
signal b1_sec: std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
signal b1_id: std_logic_vector(15 downto 0); -- unique/identifier/counter
|
signal b1_id: std_logic_vector(15 downto 0); -- unique/identifier/counter
|
-- pxdata: out price_packet
|
-- pxdata: out price_packet
|
signal b2_px_type: std_logic_vector(4 downto 0);
|
signal b2_px_type: std_logic_vector(4 downto 0);
|
signal b2_buy_sell: std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
signal b2_buy_sell: std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
signal b2_px: std_logic_vector(15 downto 0); -- price
|
signal b2_px: std_logic_vector(15 downto 0); -- price
|
signal b2_qty: std_logic_vector(15 downto 0); -- quantity
|
signal b2_qty: std_logic_vector(15 downto 0); -- quantity
|
signal b2_sec: std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
signal b2_sec: std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
signal b2_id: std_logic_vector(15 downto 0); -- unique/identifier/counter
|
signal b2_id: std_logic_vector(15 downto 0); -- unique/identifier/counter
|
begin
|
begin
|
items_array : for iter_id in 0 to searchitems-1 generate
|
items_array : for iter_id in 0 to searchitems-1 generate
|
begin
|
begin
|
cell_item: entity work.search_item
|
cell_item: entity work.search_item
|
generic map ( item_id => std_logic_vector(to_unsigned(iter_id,16)) )
|
generic map ( item_id => std_logic_vector(to_unsigned(iter_id,16)) )
|
port map (
|
port map (
|
RX_CLK => RX_CLK,
|
RX_CLK => RX_CLK,
|
-- control flag(s) on the incoming bus
|
-- control flag(s) on the incoming bus
|
b1_px_valid => b1_px_valid,
|
b1_px_valid => b1_px_valid,
|
-- pxdata: in price_packet
|
-- pxdata: in price_packet
|
b1_px_type => b1_px_type,
|
b1_px_type => b1_px_type,
|
b1_buy_sell => b1_buy_sell,
|
b1_buy_sell => b1_buy_sell,
|
b1_px => b1_px,
|
b1_px => b1_px,
|
b1_qty => b1_qty,
|
b1_qty => b1_qty,
|
b1_sec => b1_sec,
|
b1_sec => b1_sec,
|
b1_id => b1_id,
|
b1_id => b1_id,
|
-- pxdata: out price_packet
|
-- pxdata: out price_packet
|
b2_px_type => b2_px_type,
|
b2_px_type => b2_px_type,
|
b2_buy_sell => b2_buy_sell,
|
b2_buy_sell => b2_buy_sell,
|
b2_px => b2_px,
|
b2_px => b2_px,
|
b2_qty => b2_qty,
|
b2_qty => b2_qty,
|
b2_sec => b2_sec,
|
b2_sec => b2_sec,
|
b2_id => b2_id
|
b2_id => b2_id
|
);
|
);
|
end generate items_array;
|
end generate items_array;
|
|
|
process (RX_CLK) is
|
process (RX_CLK) is
|
-- variable l : line;
|
-- variable l : line;
|
begin
|
begin
|
if rising_edge(RX_CLK) then
|
if rising_edge(RX_CLK) then
|
|
|
-- diagnostic (uncomment)
|
-- diagnostic (uncomment)
|
-- write (l, String'(" Control Rising Edge search_px_type_i: "));
|
-- write (l, String'(" Control Rising Edge search_px_type_i: "));
|
-- for j in search_px_type_i'range loop
|
-- for j in search_px_type_i'range loop
|
-- write(l, std_logic'image(search_px_type_i(j)) );
|
-- write(l, std_logic'image(search_px_type_i(j)) );
|
-- end loop;
|
-- end loop;
|
-- write (l, String'(" search_px_valid_i: "));
|
-- write (l, String'(" search_px_valid_i: "));
|
-- write(l, std_logic'image(search_px_valid_i) );
|
-- write(l, std_logic'image(search_px_valid_i) );
|
-- write (l, String'(" state: "));
|
-- write (l, String'(" state: "));
|
-- write(l, state );
|
-- write(l, state );
|
-- write (l, String'(" b2_id: "));
|
-- write (l, String'(" b2_id: "));
|
-- for j in b2_id'range loop
|
-- for j in b2_id'range loop
|
-- write(l, std_logic'image(b2_id(j)) );
|
-- write(l, std_logic'image(b2_id(j)) );
|
-- end loop;
|
-- end loop;
|
-- write (l, String'(" b2_px_type: "));
|
-- write (l, String'(" b2_px_type: "));
|
-- for j in b2_px_type'range loop
|
-- for j in b2_px_type'range loop
|
-- write(l, std_logic'image(b2_px_type(j)) );
|
-- write(l, std_logic'image(b2_px_type(j)) );
|
-- end loop;
|
-- end loop;
|
-- writeline ( output, l);
|
-- writeline ( output, l);
|
|
|
if search_px_valid_i = '1' then
|
if search_px_valid_i = '1' then
|
if search_px_type_i = std_logic_vector'("00000") then
|
if search_px_type_i = std_logic_vector'("00000") then
|
-- do reset store and outputs
|
-- do reset store and outputs
|
order_px_type_o <= (others => '0');
|
order_px_type_o <= (others => '0');
|
order_buy_sell_o <= (others => 'Z'); -- 111 buy, 000 sell
|
order_buy_sell_o <= (others => 'Z'); -- 111 buy, 000 sell
|
order_px_o <= (others => 'Z'); -- price
|
order_px_o <= (others => 'Z'); -- price
|
order_qty_o <= (others => 'Z'); -- quantity
|
order_qty_o <= (others => 'Z'); -- quantity
|
order_sec_o <= (others => 'Z'); -- 7x 8bits securities identifier
|
order_sec_o <= (others => 'Z'); -- 7x 8bits securities identifier
|
order_id_o <= (others => 'Z');
|
order_id_o <= (others => 'Z');
|
order_px_valid_o <= '1';
|
order_px_valid_o <= '1';
|
--
|
--
|
b1_px_type <= (others => '0');
|
b1_px_type <= (others => '0');
|
b1_buy_sell <= (others => '0'); -- 111 buy, 000 sell
|
b1_buy_sell <= (others => '0'); -- 111 buy, 000 sell
|
b1_px <= (others => '0'); -- price
|
b1_px <= (others => '0'); -- price
|
b1_qty <= (others => '0'); -- quantity
|
b1_qty <= (others => '0'); -- quantity
|
b1_sec <= (others => '0'); -- 7x 8bits securities identifier
|
b1_sec <= (others => '0'); -- 7x 8bits securities identifier
|
b1_px_valid <= '1';
|
b1_px_valid <= '1';
|
searchitems_count <= 0;
|
searchitems_count <= 0;
|
state <= 8;
|
state <= 8;
|
elsif search_px_type_i = std_logic_vector'("00110") then
|
elsif search_px_type_i = std_logic_vector'("00110") then
|
-- it's an incoming order price/qty security/buysell setting.
|
-- it's an incoming order price/qty security/buysell setting.
|
-- do set bus b1 and store from incoming price
|
-- do set bus b1 and store from incoming price
|
b1_px_type <= search_px_type_i;
|
b1_px_type <= search_px_type_i;
|
b1_buy_sell <= search_buy_sell_i;
|
b1_buy_sell <= search_buy_sell_i;
|
b1_px <= search_px_i;
|
b1_px <= search_px_i;
|
b1_qty <= search_qty_i;
|
b1_qty <= search_qty_i;
|
b1_sec <= search_sec_i;
|
b1_sec <= search_sec_i;
|
b1_id <= (others => 'Z');
|
b1_id <= (others => 'Z');
|
b1_px_valid <= '1';
|
b1_px_valid <= '1';
|
-- do set store from incoming price
|
-- do set store from incoming price
|
store_px_type <= search_px_type_i;
|
store_px_type <= search_px_type_i;
|
store_buy_sell <= search_buy_sell_i;
|
store_buy_sell <= search_buy_sell_i;
|
store_px <= search_px_i;
|
store_px <= search_px_i;
|
store_qty <= search_qty_i;
|
store_qty <= search_qty_i;
|
store_sec <= search_sec_i;
|
store_sec <= search_sec_i;
|
store_id <= search_id_i;
|
store_id <= search_id_i;
|
state <= 6;
|
state <= 5;
|
elsif search_px_type_i = std_logic_vector'("11100") then
|
elsif search_px_type_i = std_logic_vector'("11100") then
|
-- incoming price, register it and start the state machine
|
-- incoming price, register it and start the state machine
|
b1_px_type <= search_px_type_i;
|
b1_px_type <= search_px_type_i;
|
b1_buy_sell <= search_buy_sell_i;
|
b1_buy_sell <= search_buy_sell_i;
|
b1_px <= search_px_i;
|
b1_px <= search_px_i;
|
b1_qty <= search_qty_i;
|
b1_qty <= search_qty_i;
|
b1_sec <= search_sec_i;
|
b1_sec <= search_sec_i;
|
b1_id <= (others => 'Z');
|
b1_id <= (others => 'Z');
|
b1_px_valid <= '1';
|
b1_px_valid <= '1';
|
-- do set store from incoming price
|
-- do set store from incoming price
|
store_px_type <= search_px_type_i;
|
store_px_type <= search_px_type_i;
|
store_buy_sell <= search_buy_sell_i;
|
store_buy_sell <= search_buy_sell_i;
|
store_px <= search_px_i;
|
store_px <= search_px_i;
|
store_qty <= search_qty_i;
|
store_qty <= search_qty_i;
|
store_sec <= search_sec_i;
|
store_sec <= search_sec_i;
|
store_id <= search_id_i;
|
store_id <= search_id_i;
|
--b2_px_type <= std_logic_vector'(std_logic_vector'("00000"));
|
--b2_px_type <= std_logic_vector'(std_logic_vector'("00000"));
|
state <= 10;
|
state <= 9;
|
else -- nothing 10000 (avoid ZZZZZ)
|
else -- nothing 10000 (avoid ZZZZZ)
|
-- no action - flash up Z's
|
-- no action - flash up Z's
|
order_px_type_o <= std_logic_vector'("10000"); -- avoiding ZZZZZ
|
order_px_type_o <= std_logic_vector'("10000"); -- avoiding ZZZZZ
|
order_buy_sell_o <= (others => 'Z'); -- 111 buy, 000 sell
|
order_buy_sell_o <= (others => 'Z'); -- 111 buy, 000 sell
|
order_px_o <= (others => 'Z'); -- price
|
order_px_o <= (others => 'Z'); -- price
|
order_qty_o <= (others => 'Z'); -- quantity
|
order_qty_o <= (others => 'Z'); -- quantity
|
order_sec_o <= (others => 'Z'); -- 7x 8bits securities identifier
|
order_sec_o <= (others => 'Z'); -- 7x 8bits securities identifier
|
order_id_o <= (others => 'Z'); -- unique/identifier/counter
|
order_id_o <= (others => 'Z'); -- unique/identifier/counter
|
order_px_valid_o <= '1';
|
order_px_valid_o <= '1';
|
state <= 8;
|
state <= 8;
|
end if; -- search_px_type
|
end if; -- search_px_type
|
else -- search_px_valid_i
|
else -- search_px_valid_i
|
-- no incoming search_px_i so check for state machine actions
|
-- no incoming search_px_i so check for state machine actions
|
case state is
|
case state is
|
when 1 =>
|
when 1 =>
|
-- sent return order, so clean up
|
-- sent return order, so clean up
|
order_px_type_o <= (others => 'Z');
|
order_px_type_o <= (others => 'Z');
|
order_buy_sell_o <= (others => 'Z'); -- 111 buy, 000 sell
|
order_buy_sell_o <= (others => 'Z'); -- 111 buy, 000 sell
|
order_px_o <= (others => 'Z'); -- price
|
order_px_o <= (others => 'Z'); -- price
|
order_qty_o <= (others => 'Z'); -- quantity
|
order_qty_o <= (others => 'Z'); -- quantity
|
order_sec_o <= (others => 'Z'); -- 7x 8bits securities identifier
|
order_sec_o <= (others => 'Z'); -- 7x 8bits securities identifier
|
order_id_o <= (others => 'Z'); -- unique/identifier/counter
|
order_id_o <= (others => 'Z'); -- unique/identifier/counter
|
state <= 16;
|
state <= 16;
|
|
when 5 =>
|
|
-- wait a clock cycle for search_item procesing
|
|
b1_px_valid <= '0';
|
|
state <= 6;
|
when 6 =>
|
when 6 =>
|
-- sent query to set px and qty for a given security
|
-- sent query to set px and qty for a given security
|
if b2_px_type = std_logic_vector'("00110") then
|
if b2_px_type = std_logic_vector'("00110") then
|
-- it's a known security and the value has been set
|
-- it's a known security and the value has been set
|
order_px_type_o <= b2_px_type;
|
order_px_type_o <= b2_px_type;
|
order_px_valid_o <= '1';
|
order_px_valid_o <= '1';
|
state <= 8; -- reset next cycle
|
state <= 8; -- reset next cycle
|
else
|
else
|
-- no response, it's a new security+buysell
|
-- no response, it's a new security+buysell
|
if searchitems_count = searchitems then
|
if searchitems_count = searchitems then
|
-- all search_items are filled - can't store this item
|
-- all search_items are filled - can't store this item
|
order_px_type_o <= std_logic_vector'("11111");
|
order_px_type_o <= std_logic_vector'("11111");
|
order_px_valid_o <= '1';
|
order_px_valid_o <= '1';
|
order_buy_sell_o <= (others => 'Z'); -- 111 buy, 000 sell
|
order_buy_sell_o <= (others => 'Z'); -- 111 buy, 000 sell
|
order_px_o <= (others => 'Z'); -- price
|
order_px_o <= (others => 'Z'); -- price
|
order_qty_o <= (others => 'Z'); -- quantity
|
order_qty_o <= (others => 'Z'); -- quantity
|
order_sec_o <= (others => 'Z'); -- 7x 8bits securities identifier
|
order_sec_o <= (others => 'Z'); -- 7x 8bits securities identifier
|
order_id_o <= (others => 'Z'); -- unique/identifier/counter
|
order_id_o <= (others => 'Z'); -- unique/identifier/counter
|
b1_px_valid <= '0';
|
b1_px_valid <= '0';
|
state <= 8; -- reset next cycle
|
state <= 8; -- reset next cycle
|
else
|
else
|
-- send the new security setting
|
-- send the new security setting
|
b1_px_type <= std_logic_vector'("01010");
|
b1_px_type <= std_logic_vector'("01010");
|
b1_buy_sell <= store_buy_sell;
|
b1_buy_sell <= store_buy_sell;
|
b1_px <= store_px;
|
b1_px <= store_px;
|
b1_qty <= store_qty;
|
b1_qty <= store_qty;
|
b1_sec <= store_sec;
|
b1_sec <= store_sec;
|
b1_id <= std_logic_vector(to_unsigned(searchitems_count,16));
|
b1_id <= std_logic_vector(to_unsigned(searchitems_count,16));
|
b1_px_valid <= '1';
|
b1_px_valid <= '1';
|
state <= 4; -- increment items counter / send success
|
state <= 3; -- increment items counter / send success
|
end if;
|
end if;
|
end if;
|
end if;
|
|
when 3 =>
|
|
-- wait a clock cycle for search_item procesing
|
|
b1_px_valid <= '0';
|
|
state <= 4;
|
when 4 =>
|
when 4 =>
|
-- have set a new item, increment count and return
|
-- have set a new item, increment count and return
|
searchitems_count <= searchitems_count + 1;
|
searchitems_count <= searchitems_count + 1;
|
order_px_type_o <= std_logic_vector'("01010"); -- b2_px_type; --
|
order_px_type_o <= std_logic_vector'("01010"); -- b2_px_type; --
|
order_buy_sell_o <= (others => 'Z');
|
order_buy_sell_o <= (others => 'Z');
|
order_px_o <= (others => 'Z');
|
order_px_o <= (others => 'Z');
|
order_qty_o <= (others => 'Z');
|
order_qty_o <= (others => 'Z');
|
order_sec_o <= (others => 'Z');
|
order_sec_o <= (others => 'Z');
|
order_id_o <= b2_id;
|
order_id_o <= b2_id;
|
--
|
--
|
order_px_valid_o <= '1';
|
order_px_valid_o <= '1';
|
b1_px_valid <= '0';
|
b1_px_valid <= '0';
|
state <= 8; -- reset next cycle
|
state <= 8; -- reset next cycle
|
when 8 =>
|
when 8 =>
|
-- correct store_item but there was no match
|
-- correct store_item but there was no match
|
order_px_type_o <= std_logic_vector'("ZZZZZ");
|
order_px_type_o <= std_logic_vector'("ZZZZZ");
|
order_px_valid_o <= '0';
|
order_px_valid_o <= '0';
|
-- reset b1
|
-- reset b1
|
b1_px_type <= (others => 'Z');
|
b1_px_type <= (others => 'Z');
|
b1_buy_sell <= (others => 'Z');
|
b1_buy_sell <= (others => 'Z');
|
b1_px <= (others => 'Z');
|
b1_px <= (others => 'Z');
|
b1_qty <= (others => 'Z');
|
b1_qty <= (others => 'Z');
|
b1_sec <= (others => 'Z');
|
b1_sec <= (others => 'Z');
|
b1_id <= (others => 'Z');
|
b1_id <= (others => 'Z');
|
b1_px_valid <= '0';
|
b1_px_valid <= '0';
|
state <= 16;
|
state <= 16;
|
|
when 9 =>
|
|
-- wait a clock cycle for search_item procesing
|
|
b1_px_valid <= '0';
|
|
state <= 10;
|
when 10 =>
|
when 10 =>
|
if b2_px_type = std_logic_vector'("11100") then
|
if b2_px_type = std_logic_vector'("11100") then
|
-- got a hit .. send it
|
-- got a hit .. send it
|
order_px_type_o <= std_logic_vector'("11100");
|
order_px_type_o <= std_logic_vector'("11100");
|
order_px_valid_o <= '1';
|
order_px_valid_o <= '1';
|
order_buy_sell_o <= b2_buy_sell; -- 111 buy, 000 sell
|
order_buy_sell_o <= b2_buy_sell; -- 111 buy, 000 sell
|
order_px_o <= b2_px; -- price
|
order_px_o <= b2_px; -- price
|
order_qty_o <= b2_qty; -- quantity
|
order_qty_o <= b2_qty; -- quantity
|
order_sec_o <= b2_sec; -- 7x 8bits securities identifier
|
order_sec_o <= b2_sec; -- 7x 8bits securities identifier
|
order_id_o <= b2_id; -- unique/identifier/counter
|
order_id_o <= b2_id; -- unique/identifier/counter
|
b1_px_valid <= '0';
|
b1_px_valid <= '0';
|
state <= 8; -- reset next cycle
|
state <= 8; -- reset next cycle
|
else
|
else
|
-- some kind of non-useful price
|
-- some kind of non-useful price
|
order_buy_sell_o <= (others => 'Z');
|
order_buy_sell_o <= (others => 'Z');
|
order_px_o <= (others => 'Z');
|
order_px_o <= (others => 'Z');
|
order_qty_o <= (others => 'Z');
|
order_qty_o <= (others => 'Z');
|
order_sec_o <= (others => 'Z');
|
order_sec_o <= (others => 'Z');
|
order_id_o <= (others => 'Z');
|
order_id_o <= (others => 'Z');
|
if b2_px_type = std_logic_vector'("11101") then
|
if b2_px_type = std_logic_vector'("11101") then
|
-- incoming px (too low sale price)
|
-- incoming px (too low sale price)
|
order_px_type_o <= std_logic_vector'("11101");
|
order_px_type_o <= std_logic_vector'("11101");
|
else
|
else
|
-- no match
|
-- no match
|
order_px_type_o <= std_logic_vector'("11110");
|
order_px_type_o <= std_logic_vector'("11110");
|
end if;
|
end if;
|
order_px_valid_o <= '1';
|
order_px_valid_o <= '1';
|
b1_px_valid <= '0';
|
b1_px_valid <= '0';
|
state <= 8; -- reset next cycle
|
state <= 8; -- reset next cycle
|
end if;
|
end if;
|
when others => null;
|
when others => null;
|
end case; -- state
|
end case; -- state
|
end if; -- search_px_valid_i
|
end if; -- search_px_valid_i
|
end if;
|
end if;
|
end process;
|
end process;
|
end search_control_implementation;
|
end search_control_implementation;
|
|
|