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 13 and 14

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

Rev 13 Rev 14
Line 54... Line 54...
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;
 
 
entity search_item is
entity search_item is
 
   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
Line 106... Line 107...
                   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'("00000"));
                   b2_px_type <= std_logic_vector'("ZZZZZ");
                   state <= 8;
                   state <= 16;
 
 
            elsif b1_px_type = std_logic_vector'("00110") then
            elsif b1_px_type = std_logic_vector'("00110") then
 
                  if store_buy_sell = b1_buy_sell and
 
                     store_sec      = b1_sec  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_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'("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_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'("00000"));
                       b2_px_type <= b1_px_type;
 
                       b2_id      <= item_id;
                   state <= 8;
                   state <= 8;
 
                   end if;
 
 
            elsif b1_px_type = std_logic_vector'("0101") then
            elsif b1_px_type = std_logic_vector'("11100") 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 ) then
                      -- not this store_item instance no action, also stop anything that might be going on
                      -- not this store_item instance no action
                      state <= 14;
                      null;
                   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'("00000"));
                      b2_px_type <= std_logic_vector'(std_logic_vector'("11101"));
                      state <= 8;
 
                   else
                   else
                      -- send a return order
                      -- send a return order
                      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_sec <= store_sec;                                          -- 7x 8bits securities identifier
 
                      b2_id <= store_id;                                            -- unique/identifier/counter
                      b2_px <= b1_px;                   -- price
                      b2_px <= b1_px;                   -- price
                      -- b2_qty <= 
                      -- b2_qty <= 
                      if b1_qty < store_qty then
                      if b1_qty < store_qty then
                         b2_qty <= b1_qty;
                         b2_qty <= b1_qty;
                      else
                      else
                         b2_qty <= store_qty;
                         b2_qty <= store_qty;
                      end if;    -- quantity
                      end if;    -- quantity
                      b2_sec <= store_sec;                                          -- 7x 8bits securities identifier
 
                      b2_id <= store_id;                                            -- unique/identifier/counter
 
                      -- update the store
                      -- update the store
                      -- store_qty
                      -- store_qty
                      if (b1_qty < store_qty) then
                      if (b1_qty < store_qty) then
                         store_qty <= std_logic_vector(to_unsigned( to_integer(unsigned(store_qty)) - to_integer(unsigned(b1_qty)) ,16 ));
                         store_qty <= std_logic_vector(to_unsigned( to_integer(unsigned(store_qty)) - to_integer(unsigned(b1_qty)) ,16 ));
                      else
                      else
                         store_qty <= (others => '0');
                         store_qty <= (others => '0');
                         state <= 1;
 
                      end  if;
                      end  if;
 
                      b2_px_type <= std_logic_vector'(std_logic_vector'("11100"));
                   end if;
                   end if;
 
                   state <= 8;
 
 
            else
            else
               -- no action
               -- no action
               null;
               null;
            end if;   -- b1_px_type
            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 8 =>
                   -- sent return order, so clean up
                   -- sent return order, so clean up
                   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;
                   --
 
 
               when 8 =>
 
                    -- correct store_item but there was no match
 
                    b2_px_type <= std_logic_vector'("ZZZZZ");
                    b2_px_type <= std_logic_vector'("ZZZZZ");
                   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.