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

Subversion Repositories open_hitter

[/] [open_hitter/] [trunk/] [rtl/] [vhdl/] [search_item.vhd] - Diff between revs 11 and 12

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

Rev 11 Rev 12
Line 51... Line 51...
--//
--//
--// \$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;
 
 
entity search_item is
entity search_item is
   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: out std_logic_vector(4 downto 0);
           b1_px_type: in std_logic_vector(4 downto 0);
           b1_buy_sell: out 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: out std_logic_vector(15 downto 0);     -- price
           b1_px: in std_logic_vector(15 downto 0);     -- price
           b1_qty: out std_logic_vector(15 downto 0);    -- quantity
           b1_qty: in std_logic_vector(15 downto 0);    -- quantity
           b1_sec: out 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: out 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 search_item;
end search_item;
 
 
architecture search_item_implementation of search_item is
architecture search_item_implementation of search_item is
      signal state : integer range 0 to 16 := 16;
      signal state : integer range 0 to 16 := 16;
Line 87... 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 then
         if b1_px_valid = '0' then
 
 
            case b1_px_type is
            if b1_px_type = std_logic_vector'("0000") then
               when '0000' =>
 
                   -- 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
Line 106... Line 106...
                   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 <== '0000';
                   b2_px_type <= std_logic_vector'(std_logic_vector'("0000"));
                   state <= 8;
                   state <= 8;
 
 
               when '0110' =>
            elsif b1_px_type = std_logic_vector'("0110") 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 <== '0000';
                   b2_px_type <= std_logic_vector'(std_logic_vector'("0000"));
                   state <= 8;
                   state <= 8;
 
 
               when '0101' =>
            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 != '0110')
                   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
                      state <= 14;
                      state <= 14;
                   elsif (store_qty == 0 or b1_qty == 0 or
                   elsif (to_integer(unsigned(store_qty)) = 0 or to_integer(unsigned(b1_qty)) = 0 or
                             (store_buy_sell == '111' and store_px < b1_px) or
                             (store_buy_sell = std_logic_vector'("111") and store_px < b1_px) or
                             (store_buy_sell == '000' and store_px > b1_px) )
                             (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 <== '0000';
                      b2_px_type <= std_logic_vector'(std_logic_vector'("0000"));
                      state <= 8;
                      state <= 8;
                   else
                   else
                      -- send a return order
                      -- send a return order
                      b2_px_type <= '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
                      b2_px <= b1_px;                   -- price
                      b2_px <= b1_px;                   -- price
                      b2_qty <= b1_qty when (b1_qty < store_qty) else store_qty;    -- quantity
                      -- b2_qty <= 
                      b2_sec <= store_sec:                                          -- 7x 8bits securities identifier
                      if b1_qty < store_qty then
 
                         b2_qty <= b1_qty;
 
                      else
 
                         b2_qty <= store_qty;
 
                      end if;    -- quantity
 
                      b2_sec <= store_sec;                                          -- 7x 8bits securities identifier
                      b2_id <= store_id;                                            -- unique/identifier/counter
                      b2_id <= store_id;                                            -- unique/identifier/counter
                      -- update the store
                      -- update the store
                      store_qty <= (store_qty-b1_qty) when (b1_qty < store_qty) else 0;
                      -- store_qty
 
                      if (b1_qty < store_qty) then
 
                         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;
                      state <= 1;
                   end if;
                   end if;
 
                   end if;
 
 
               when others => null;
            else
            end case;   -- b1_px_type
               -- no action
 
               null;
 
            end if;   -- b1_px_type
 
 
         else     -- b1_px_valid
         else     -- b1_px_valid
            -- no incoming b1_px so check for state machine actions
            -- no incoming b1_px so check for state machine actions
            case state is
            case state is
               when 1 =>
               when 1 =>
Line 158... Line 170...
                   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
                   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 <== 'ZZZZ';
                    b2_px_type <= std_logic_vector'("ZZZZ");
                   state <= 16;
                   state <= 16;
 
 
               when others => null;
               when others => null;
            end case;   -- state
            end case;   -- state
 
 

powered by: WebSVN 2.1.0

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