OpenCores
URL https://opencores.org/ocsvn/open_hitter/open_hitter/trunk

Subversion Repositories open_hitter

[/] [open_hitter/] [trunk/] [rtl/] [vhdl/] [search_control.vhd] - Diff between revs 16 and 17

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 16 Rev 17
Line 56... Line 56...
--// \$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.
 
 
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;
Line 105... Line 106...
                    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;
       -- for search_item_0: search_item use entity work.search_item;
   for search_item_1: search_item use entity work.search_item;
      signal searchitems_count : integer := 0;
      signal searchitems_count : integer := 0;
      --
      --
      signal state : integer range 0 to 16 := 16;
      signal state : integer range 0 to 16 := 16;
 
      --
 
      --signal RX_CLK: std_logic;
   -- pxdata: store price_packet
   -- pxdata: store price_packet
      signal store_px_type: std_logic_vector(4 downto 0) := (others => '0');
      signal store_px_type: std_logic_vector(4 downto 0) := (others => 'Z');
      signal store_buy_sell: std_logic_vector(2 downto 0) := (others => '0');   -- 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 => '0');     -- price
      signal store_px: std_logic_vector(15 downto 0) := (others => 'Z');     -- price
      signal store_qty: std_logic_vector(15 downto 0) := (others => '0');    -- quantity
      signal store_qty: std_logic_vector(15 downto 0) := (others => 'Z');    -- quantity
      signal store_sec: std_logic_vector(55 downto 0) := (others => '0');    -- 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 => '0');     -- 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: b1 price_packet
   -- pxdata: b1 price_packet
      signal b1_px_type: std_logic_vector(4 downto 0) := (others => '0');
      signal b1_px_type: std_logic_vector(4 downto 0) := (others => 'Z');
      signal b1_buy_sell: std_logic_vector(2 downto 0) := (others => '0');   -- 111 buy, 000 sell
      signal b1_buy_sell: std_logic_vector(2 downto 0) := (others => 'Z');   -- 111 buy, 000 sell
      signal b1_px: std_logic_vector(15 downto 0) := (others => '0');     -- price
      signal b1_px: std_logic_vector(15 downto 0) := (others => 'Z');     -- price
      signal b1_qty: std_logic_vector(15 downto 0) := (others => '0');    -- quantity
      signal b1_qty: std_logic_vector(15 downto 0) := (others => 'Z');    -- quantity
      signal b1_sec: std_logic_vector(55 downto 0) := (others => '0');    -- 7x 8bits securities identifier
      signal b1_sec: std_logic_vector(55 downto 0) := (others => 'Z');    -- 7x 8bits securities identifier
      signal b1_id: std_logic_vector(15 downto 0) := (others => '0');     -- unique/identifier/counter
      signal b1_id: std_logic_vector(15 downto 0) := (others => 'Z');     -- unique/identifier/counter
   -- pxdata: b2 price_packet
   -- pxdata: b2 price_packet
      signal b2_px_type: std_logic_vector(4 downto 0) := (others => '0');
      signal b2_px_type: std_logic_vector(4 downto 0) := (others => 'Z');
      signal b2_buy_sell: std_logic_vector(2 downto 0) := (others => '0');   -- 111 buy, 000 sell
      signal b2_buy_sell: std_logic_vector(2 downto 0) := (others => 'Z');   -- 111 buy, 000 sell
      signal b2_px: std_logic_vector(15 downto 0) := (others => '0');     -- price
      signal b2_px: std_logic_vector(15 downto 0) := (others => 'Z');     -- price
      signal b2_qty: std_logic_vector(15 downto 0) := (others => '0');    -- quantity
      signal b2_qty: std_logic_vector(15 downto 0) := (others => 'Z');    -- quantity
      signal b2_sec: std_logic_vector(55 downto 0) := (others => '0');    -- 7x 8bits securities identifier
      signal b2_sec: std_logic_vector(55 downto 0) := (others => 'Z');    -- 7x 8bits securities identifier
      signal b2_id: std_logic_vector(15 downto 0) := (others => '0');     -- unique/identifier/counter
      signal b2_id: std_logic_vector(15 downto 0) := (others => 'Z');     -- unique/identifier/counter
begin
 
      items_array : for iter_id in 0 to searchitems - 1 generate
 
      begin
      begin
         cell_item : entity work.search_item
  --    items_array : for iter_id in 0 to 5 generate --  searchitems - 1 generate
            generic map ( item_id => std_logic_vector(to_unsigned(iter_id,16)) )
  --      begin
 
      --    cell_item: entity work.search_item
 
            search_item_1 : search_item
 
      --      generic map ( item_id => std_logic_vector'(X"0000"))  --  std_logic_vector(to_unsigned(iter_id,16)) )
 
            generic map ( item_id => (others => '0'))   --    std_logic_vector'(X"0000"))  --  std_logic_vector(to_unsigned(iter_id,16)) )
            port map (
            port map (
                         RX_CLK => RX_CLK,
                         RX_CLK => RX_CLK,
                         b1_px_valid => b1_px_valid,
                         b1_px_valid => b1_px_valid,
                         b1_px_type => b1_px_type, b1_buy_sell => b1_buy_sell, b1_px => b1_px, b1_qty => b1_qty, b1_sec => b1_sec, b1_id => b2_id,
                         b1_px_type => b1_px_type, b1_buy_sell => b1_buy_sell, b1_px => b1_px, b1_qty => b1_qty, b1_sec => b1_sec, b1_id => b1_id,
                         b2_px_type => b2_px_type, b2_buy_sell => b2_buy_sell, b2_px => b2_px, b2_qty => b2_qty, b2_sec => b2_sec, b2_id => b2_id
                         b2_px_type => b2_px_type, b2_buy_sell => b2_buy_sell, b2_px => b2_px, b2_qty => b2_qty, b2_sec => b2_sec, b2_id => b2_id
                     );
                     );
      end generate items_array;
  --      end generate items_array;
 
 
 
  -- RX_CLK <= RX_CLK;   
 
 
   match: process (RX_CLK) is
   match: process (RX_CLK) is
 
--        variable l : line;
   begin
   begin
      if rising_edge(RX_CLK) then
      --if rising_edge(RX_CLK) then
 
      if falling_edge(RX_CLK) then
 
--        write (l, String'("  Rising Edge "));
 
--                for j in b2_id'range loop
 
--                    write(l, std_logic'image(b2_id(j)) );
 
--                 end loop;
 
--        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 => 'Z');
                   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_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
Line 170... Line 187...
                   b1_px_valid <= '1';
                   b1_px_valid <= '1';
                   --
                   --
                   searchitems_count <= 0;
                   searchitems_count <= 0;
                   state <= 8;
                   state <= 8;
 
 
 
            -- purely for test
 
            elsif search_px_type_i = std_logic_vector'("01010") then
 
                         -- send the new security setting
 
                         b1_px_type  <= std_logic_vector'("01010");
 
                         b1_buy_sell <= store_buy_sell;
 
                         b1_px       <= store_px;
 
                         b1_qty      <= store_qty;
 
                         b1_sec      <= store_sec;
 
                         b1_id       <= std_logic_vector'(X"0000"); -- std_logic_vector(to_unsigned(searchitems_count,16));
 
                         b1_px_valid <= '1';
 
                         state <= 4;   -- increment items counter / send success
 
--        write (l, String'("  State=6 "));
 
--                for j in b2_id'range loop
 
--                    write(l, std_logic'image(b2_id(j)) );
 
--                 end loop;
 
--        writeline (output, l);
 
 
            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.
 
                   -- do set bus b1 and store from incoming price 
 
                   b1_px_type  <= search_px_type_i;
 
                   b1_buy_sell <= search_buy_sell_i;
 
                   b1_px       <= search_px_i;
 
                   b1_qty      <= search_qty_i;
 
                   b1_sec      <= search_sec_i;
 
                   b1_id       <= (others => 'Z');
 
                   b1_px_valid <= '1';
                   -- do set store from incoming price 
                   -- do set store from incoming price 
                   store_px_type  <= b1_px_type;
                   store_px_type  <= search_px_type_i;
                   store_buy_sell <= b1_buy_sell;
                   store_buy_sell <= search_buy_sell_i;
                   store_px       <= b1_px;
                   store_px       <= search_px_i;
                   store_qty      <= b1_qty;
                   store_qty      <= search_qty_i;
                   store_sec      <= b1_sec;
                   store_sec      <= search_sec_i;
                   store_id       <= b1_id;
                   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 <= 6;
                   state <= 8;
 
 
 
            elsif search_px_type_i = std_logic_vector'("00101") then
            elsif search_px_type_i = std_logic_vector'("00101") 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
                      -- not this store_item instance no action, also stop anything that might be going on
                      -- not this store_item instance no action, also stop anything that might be going on
Line 217... Line 259...
                         state <= 1;
                         state <= 1;
                      end  if;
                      end  if;
                   end if;
                   end if;
 
 
            else
            else
               -- no action
               -- no action - flash up Z's
               null;
                   order_px_type_o  <= (others => 'Z');
 
                   order_buy_sell_o <= (others => 'Z');   -- 111 buy, 000 sell
 
                   order_px_o       <= (others => 'Z');   -- price
 
                   order_qty_o      <= (others => 'Z');   -- quantity
 
                   order_sec_o      <= (others => 'Z');   -- 7x 8bits securities identifier
 
                   order_id_o       <= (others => 'Z');   -- unique/identifier/counter
 
                   order_px_valid_o <= '1';
 
                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
                   b2_px_type  <= (others => 'Z');
                   order_px_type_o  <= (others => 'Z');
                   b2_buy_sell <= (others => 'Z');    -- 111 buy, 000 sell
                   order_buy_sell_o <= (others => 'Z');    -- 111 buy, 000 sell
                   b2_px       <= (others => 'Z');    -- price
                   order_px_o       <= (others => 'Z');    -- price
                   b2_qty      <= (others => 'Z');    -- quantity
                   order_qty_o      <= (others => 'Z');    -- quantity
                   b2_sec      <= (others => 'Z');    -- 7x 8bits securities identifier
                   order_sec_o      <= (others => 'Z');    -- 7x 8bits securities identifier
                   b2_id       <= (others => 'Z');    -- unique/identifier/counter
                   order_id_o       <= (others => 'Z');    -- unique/identifier/counter
                   state <= 16;
                   state <= 16;
 
 
 
               when 6 =>
 
                   -- sent query to set px and qty for a given security
 
                   if b2_px_type = std_logic_vector'("00110") then
 
                      -- it's a known security and the value has been set
 
                      order_px_type_o <= b2_px_type;
 
                      order_px_valid_o <= '1';
 
                      state <= 8;    -- reset next cycle
 
                   else
 
                      -- no response, it's a new security+buysell
 
                      if searchitems_count = searchitems-1 then
 
                         -- all search_items are filled - can't store this item
 
                         order_px_type_o <= std_logic_vector'("11111");
 
                         order_px_valid_o <= '1';
 
                         b1_px_valid <= '0';
 
                         state <= 8;    -- reset next cycle
 
                      else
 
                         -- send the new security setting
 
                         b1_px_type  <= std_logic_vector'("01010");
 
                         b1_buy_sell <= store_buy_sell;
 
                         b1_px       <= store_px;
 
                         b1_qty      <= store_qty;
 
                         b1_sec      <= store_sec;
 
                         b1_id       <= std_logic_vector'(X"0000"); -- std_logic_vector(to_unsigned(searchitems_count,16));
 
                         b1_px_valid <= '1';
 
                         state <= 4;   -- increment items counter / send success
 
                      end if;
 
                   end if;
 
 
 
               when 4 =>
 
                   -- have set a new item, increment count and return
 
                   searchitems_count <= searchitems_count + 1;
 
                   order_px_type_o  <= std_logic_vector'("01010");  -- b2_px_type;     --
 
                   order_buy_sell_o <= (others => 'Z');
 
                   order_px_o       <= (others => 'Z');
 
                   order_qty_o      <= (others => 'Z');
 
                   order_sec_o      <= (others => 'Z');
 
                   order_id_o       <= b2_id;
 
                   --
 
                   order_px_valid_o <= '1';
 
                   b1_px_valid <= '0';
 
                   state <= 8;    -- reset next cycle
 
--        write (l, String'("  State=4 "));
 
--                for j in b2_id'range loop
 
--                    write(l, std_logic'image(b2_id(j)) );
 
--                 end loop;
 
--        writeline (output, l);
 
 
               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'("ZZZZZ");
                   order_px_type_o <= std_logic_vector'("ZZZZZ");
                   state <= 16;
 
                   order_px_valid_o <= '0';
                   order_px_valid_o <= '0';
 
                   -- reset b1
 
                   b1_px_type  <= (others => 'Z');
 
                   b1_buy_sell <= (others => 'Z');
 
                   b1_px       <= (others => 'Z');
 
                   b1_qty      <= (others => 'Z');
 
                   b1_sec      <= (others => 'Z');
 
                   b1_id       <= (others => 'Z');
 
                   b1_px_valid <= '0';
 
                   --
 
                   state <= 16;
 
 
               when others => null;
               when others => null;
            end case;   -- state
            end case;   -- state
 
 
            if (state < 16) then
      --      if (state < 16) then
               state <= state + 1;
      --         state <= state + 1;
            end if;
      --      end if;
 
 
         end if;     -- search_px_valid_i
         end if;     -- search_px_valid_i
 
 
      end if;
      end if;
   end process match;
   end process match;
 
 
 
--              b1_id       <=  std_logic_vector'(X"1010");  -- testing
 
 
end search_control_implementation;
end search_control_implementation;
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.