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

Subversion Repositories open_hitter

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /open_hitter/trunk
    from Rev 13 to Rev 14
    Reverse comparison

Rev 13 → Rev 14

/bench/vhdl/search_item_wrapper.vhd
59,7 → 59,8
 
architecture behaviour of search_item_wrapper is
component search_item
port (
generic ( item_id: std_logic_vector(15 downto 0) );
port (
RX_CLK: in std_logic;
-- control flag(s) on the incoming bus
b1_px_valid: in std_logic;
77,7 → 78,7
b2_qty: out std_logic_vector(15 downto 0); -- quantity
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
);
);
end component;
for search_item_0: search_item use entity work.search_item;
signal RX_CLK: std_logic;
98,8 → 99,10
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
begin
search_item_0: search_item port map (
RX_CLK => RX_CLK,
search_item_0: search_item
generic map ( item_id => std_logic_vector'("0110011001100110") )
port map (
RX_CLK => RX_CLK,
-- control flag(s) on the incoming bus
b1_px_valid => b1_px_valid,
-- pxdata: in price_packet
152,26 → 155,29
constant remain_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000000100");
constant test_sec: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA543332178DC");
constant test_id: std_logic_vector(15 downto 0) := std_logic_vector'("0110011001100110");
constant other_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000110000000");
constant other_id: std_logic_vector(15 downto 0) := std_logic_vector'("0000010001100010");
constant other_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000001110");
constant other_sec: std_logic_vector(55 downto 0) := std_logic_vector'(X"CDC423354634AA");
type input_pattern_array is array (natural range <>) of input_pattern_type;
constant input_patterns : input_pattern_array :=
( ('1', std_logic_vector'("00000"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- reset
('0', std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- nothing
('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec, zz_id), -- sec/set
('1', std_logic_vector'("00101"), std_logic_vector'("111"), test_px, test_qty, test_sec, zz_id), -- incoming px
('1', std_logic_vector'("00101"), std_logic_vector'("111"), test_px, zz_qty, other_sec, zz_id), -- incoming px (wrong security)
('1', std_logic_vector'("00101"), std_logic_vector'("111"), other_px, test_qty, test_sec, zz_id), -- incoming px (hight price)
('0', std_logic_vector'("00101"), std_logic_vector'("111"), test_px, test_qty, test_sec, zz_id) ); -- incoming px (part qty)
( ('1', std_logic_vector'("00000"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 0 reset
('0', std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 1 nothing
('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec, other_id), -- 2 bad sec/set
('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec, test_id), -- 3 sec/set
('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec, zz_id), -- 4 incoming px
('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, zz_qty, other_sec, zz_id), -- 5 incoming px (wrong security)
('1', std_logic_vector'("11100"), std_logic_vector'("111"), other_px, test_qty, test_sec, zz_id), -- 6 incoming px (too low sale price)
('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec, zz_id) ); -- 7 incoming px (part qty)
type output_pattern_array is array (natural range <>) of output_pattern_type;
constant output_patterns : output_pattern_array :=
( (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- reset
(std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- nothing
(std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec, test_id), -- sec/set
(std_logic_vector'("00101"), std_logic_vector'("000"), test_px, test_qty, test_sec, test_id), -- incoming px
(std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- incoming px (wrong security)
(std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- incoming px (high price)
(std_logic_vector'("00101"), std_logic_vector'("000"), test_px, remain_qty, test_sec, test_id) ); -- incoming px (part qty)
( (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 0 reset
(std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 1 nothing
(std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 2 nothing (bad sec/set)
(std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, test_id), -- 3 sec/set
(std_logic_vector'("11100"), std_logic_vector'("000"), test_px, test_qty, test_sec, test_id), -- 4 incoming px
(std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 5 incoming px (wrong security)
(std_logic_vector'("11101"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 6 incoming px (too low sale price)
(std_logic_vector'("11100"), std_logic_vector'("000"), test_px, remain_qty, test_sec, test_id) ); -- 7 incoming px (part qty)
 
begin
write (l, String'("Exercising search_item"));
204,6 → 210,11
-- Clock down.
RX_CLK <= '0';
wait for 1 ns;
b1_px_valid <= '0';
RX_CLK <= '1';
wait for 1 ns;
RX_CLK <= '0';
wait for 1 ns;
end loop;
-- assert false report "end of test" severity note;
/bench/vhdl/build.sh
3,6 → 3,7
# analysis
ghdl -a ../../rtl/vhdl/parse_price.vhd
ghdl -a ../../rtl/vhdl/search_item.vhd
ghdl -a ../../rtl/vhdl/search_control.vhd
#
ghdl -a ../../sim/rtl_sim/src/parse_price_sim.vhd
ghdl -a ../../sim/rtl_sim/src/hitter_sim.vhd
/rtl/vhdl/search_item.vhd
56,6 → 56,7
use ieee.numeric_std.ALL;
 
entity search_item is
generic ( item_id: std_logic_vector(15 downto 0) );
port (
RX_CLK: in std_logic;
-- control flag(s) on the incoming bus
108,36 → 109,54
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
--
b2_px_type <= std_logic_vector'(std_logic_vector'("00000"));
state <= 8;
b2_px_type <= std_logic_vector'("ZZZZZ");
state <= 16;
 
elsif b1_px_type = std_logic_vector'("00110") then
-- do set store from incoming price
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'("00000"));
state <= 8;
if store_buy_sell = b1_buy_sell and
store_sec = b1_sec then
-- do set store from incoming price
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'("0101") then
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_px <= b1_px;
store_qty <= b1_qty;
store_sec <= b1_sec;
store_id <= b1_id;
--
b2_px_type <= b1_px_type;
b2_id <= item_id;
state <= 8;
end if;
 
elsif b1_px_type = std_logic_vector'("11100") then
-- 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
-- not this store_item instance no action, also stop anything that might be going on
state <= 14;
if (store_sec /= b1_sec or store_buy_sell = b1_buy_sell ) then
-- not this store_item instance no action
null;
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'("000") and store_px > b1_px) ) then
-- no deal: this is the correct store_item but there's no match
b2_px_type <= std_logic_vector'(std_logic_vector'("00000"));
state <= 8;
b2_px_type <= std_logic_vector'(std_logic_vector'("11101"));
else
-- send a return order
b2_px_type <= std_logic_vector'("1010");
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_qty <=
if b1_qty < store_qty then
145,8 → 164,6
else
b2_qty <= store_qty;
end if; -- quantity
b2_sec <= store_sec; -- 7x 8bits securities identifier
b2_id <= store_id; -- unique/identifier/counter
-- update the store
-- store_qty
if (b1_qty < store_qty) then
153,9 → 170,10
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;
end if;
b2_px_type <= std_logic_vector'(std_logic_vector'("11100"));
end if;
state <= 8;
 
else
-- no action
165,7 → 183,7
else -- b1_px_valid
-- no incoming b1_px so check for state machine actions
case state is
when 1 =>
when 8 =>
-- sent return order, so clean up
b2_px_type <= (others => 'Z');
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
173,13 → 191,10
b2_qty <= (others => 'Z'); -- quantity
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
--
b2_px_type <= std_logic_vector'("ZZZZZ");
state <= 16;
 
when 8 =>
-- correct store_item but there was no match
b2_px_type <= std_logic_vector'("ZZZZZ");
state <= 16;
 
when others => null;
end case; -- state

powered by: WebSVN 2.1.0

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