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
    from Rev 16 to Rev 17
    Reverse comparison

Rev 16 → Rev 17

/trunk/bench/vhdl/search_item_wrapper.vhd
80,7 → 80,7
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;
-- for search_item_0: search_item use entity work.search_item;
signal RX_CLK: std_logic;
-- control flag(s) on the incoming bus
signal b1_px_valid: std_logic;
120,6 → 120,7
b2_sec => b2_sec,
b2_id => b2_id
);
 
process
variable l : line;
 
180,13 → 181,13
(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"));
writeline (output, l);
RX_CLK <= '0';
wait for 1 ns;
write (l, String'("Exercising search_item"));
writeline (output, l);
RX_CLK <= '0';
wait for 1 ns;
 
-- Check each pattern.
for i in input_patterns'range loop
-- Check each pattern.
for i in input_patterns'range loop
-- Set the inputs.
b1_px_valid <= input_patterns(i).b1_px_valid;
b1_px_type <= input_patterns(i).b1_px_type;
199,29 → 200,19
RX_CLK <= '1';
wait for 1 ns;
-- Check the outputs.
write(l, i);
writeline (output, l);
assert b2_px_type = output_patterns(i).b2_px_type report "search_item_wrapper: bad px type" severity error;
assert b2_buy_sell = output_patterns(i).b2_buy_sell report "search_item_wrapper: bad buy_sell" severity error;
assert b2_px = output_patterns(i).b2_px report "search_item_wrapper: bad px" severity error;
assert b2_qty = output_patterns(i).b2_qty report "search_item_wrapper: bad qty" severity error;
assert b2_sec = output_patterns(i).b2_sec report "search_item_wrapper: bad sec" severity error;
assert b2_id = output_patterns(i).b2_id report "search_item_wrapper: bad id" severity error;
assert b2_px_type = output_patterns(i).b2_px_type report "search_item_wrapper: test: " & integer'image(i) & " bad px type" severity error;
assert b2_buy_sell = output_patterns(i).b2_buy_sell report "search_item_wrapper: test: " & integer'image(i) & " bad buy_sell" severity error;
assert b2_px = output_patterns(i).b2_px report "search_item_wrapper: test: " & integer'image(i) & " bad px" severity error;
assert b2_qty = output_patterns(i).b2_qty report "search_item_wrapper: test: " & integer'image(i) & " bad qty" severity error;
assert b2_sec = output_patterns(i).b2_sec report "search_item_wrapper: test: " & integer'image(i) & " bad sec" severity error;
assert b2_id = output_patterns(i).b2_id report "search_item_wrapper: test: " & integer'image(i) & " bad id" severity error;
-- 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;
write (l, String'("Done search_item"));
writeline (output, l);
end loop;
write (l, String'("Done search_item"));
writeline (output, l);
wait;
end process;
end behaviour;
 
wait;
end process;
end behaviour;
 
/trunk/bench/vhdl/search_control_wrapper.vhd
171,32 → 171,38
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), -- 0 reset
('0', std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec), -- 1 nothing
('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec0), -- 2 sec/set
('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec1), -- 3 sec/set
('1', std_logic_vector'("01010"), std_logic_vector'("111"), test_px, set_qty, test_sec2), -- 4 sec/set
('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec3), -- 5 too many sec/set
('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1), -- 6 incoming px
('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, zz_qty, other_sec), -- 7 incoming px (wrong security)
('1', std_logic_vector'("11100"), std_logic_vector'("111"), other_px, test_qty, test_sec1), -- 8 incoming px (too low sale price)
('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1) ); -- 9 incoming px (part qty)
('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec0), -- 0 pre
('1', std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec), -- 1 nothing
('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec0), -- 2 sec/set
('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec1), -- 3 sec/set
('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec1), -- 4 sec/set - repeat
('1', std_logic_vector'("00110"), std_logic_vector'("111"), test_px, set_qty, test_sec2), -- 5 sec/set
('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec2), -- 6 sec/set - diff buysell
('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec3), -- 7 too many sec/set
('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1), -- 8 incoming px
('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, zz_qty, other_sec), -- 9 incoming px (wrong security)
('1', std_logic_vector'("11100"), std_logic_vector'("111"), other_px, test_qty, test_sec1), -- 10incoming px (too low sale price)
('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1) ); -- 11incoming 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), -- 0 reset
( (std_logic_vector'("00000"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 0 reset
(std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0000")), -- 0 pre
(std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 1 nothing
(std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0001")), -- 2 sec/set
(std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0002")), -- 3 sec/set
(std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0003")), -- 4 sec/set
(std_logic_vector'("11111"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 5 bad sec/set (too many)
(std_logic_vector'("11100"), std_logic_vector'("000"), test_px, test_qty, test_sec1, test_id), -- 6 incoming px
(std_logic_vector'("11110"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 7 incoming px (wrong security)
(std_logic_vector'("11101"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 8 incoming px (too low sale price)
(std_logic_vector'("11100"), std_logic_vector'("000"), test_px, remain_qty, test_sec1, test_id) ); -- 9 incoming px (part qty)
(std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0000")), -- 2 sec/set
(std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0001")), -- 3 sec/set
(std_logic_vector'("00110"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0001")), -- 4 sec/set
(std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0002")), -- 5 sec/set
(std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0003")), -- 6 sec/set
(std_logic_vector'("11111"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 7 bad sec/set (too many)
(std_logic_vector'("11100"), std_logic_vector'("000"), test_px, test_qty, test_sec1, test_id), -- 8 incoming px
(std_logic_vector'("11110"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 9 incoming px (wrong security)
(std_logic_vector'("11101"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- 10incoming px (too low sale price)
(std_logic_vector'("11100"), std_logic_vector'("000"), test_px, remain_qty, test_sec1, test_id) ); -- 11incoming px (part qty)
begin
write (l, String'("Exercising search_control"));
writeline (output, l);
RX_CLK <= '0';
wait for 1 ns;
RX_CLK <= '1';
wait for 1 us;
 
-- Check each pattern.
for i in input_patterns'range loop
208,36 → 214,33
search_qty_i <= input_patterns(i).search_qty_i;
search_sec_i <= input_patterns(i).search_sec_i;
--search_id_i <= input_patterns(i).search_id_i;
-- Clock once for the results.
RX_CLK <= '1';
wait for 1 ns;
-- Clock once for the results (falling edge)
RX_CLK <= '0';
wait for 1 us;
search_px_valid_i <= '0';
-- Check the outputs.
res := 0;
for r in 0 to 4 loop
for r in 0 to 3 loop
if order_px_valid_o = '1' then
write(l, i);
writeline (output, l);
assert order_px_type_o = output_patterns(i).order_px_type_o report "search_control_wrapper: bad px type" severity error;
assert order_buy_sell_o = output_patterns(i).order_buy_sell_o report "search_control_wrapper: bad buy_sell" severity error;
assert order_px_o = output_patterns(i).order_px_o report "search_control_wrapper: bad px" severity error;
assert order_qty_o = output_patterns(i).order_qty_o report "search_control_wrapper: bad qty" severity error;
assert order_sec_o = output_patterns(i).order_sec_o report "search_control_wrapper: bad sec" severity error;
assert order_id_o = output_patterns(i).order_id_o report "search_control_wrapper: bad id" severity error;
assert order_px_type_o = output_patterns(i).order_px_type_o report "search_control_wrapper: test: " & integer'image(i) & " bad px type" severity error;
assert order_buy_sell_o = output_patterns(i).order_buy_sell_o report "search_control_wrapper: test: " & integer'image(i) & " bad buy_sell" severity error;
assert order_px_o = output_patterns(i).order_px_o report "search_control_wrapper: test: " & integer'image(i) & " bad px" severity error;
assert order_qty_o = output_patterns(i).order_qty_o report "search_control_wrapper: test: " & integer'image(i) & " bad qty" severity error;
assert order_sec_o = output_patterns(i).order_sec_o report "search_control_wrapper: test: " & integer'image(i) & " bad sec" severity error;
assert order_id_o = output_patterns(i).order_id_o report "search_control_wrapper: test: " & integer'image(i) & " bad id" severity error;
res := res + 1;
end if;
-- Clock down.
-- Clock up
RX_CLK <= '1';
wait for 1 us;
RX_CLK <= '0';
wait for 1 ns;
search_px_valid_i <= '0';
RX_CLK <= '1';
wait for 1 ns;
wait for 1 us;
end loop;
assert res = 1 report "search_control_wrapper: wrong number of results from input pattern message" severity error;
assert res = 1 report "search_control_wrapper: test: " & integer'image(i) & " wrong number of results from input pattern message" severity error;
 
RX_CLK <= '0';
wait for 1 ns;
RX_CLK <= '1';
wait for 1 us;
end loop;
-- assert false report "end of test" severity note;
write (l, String'("Done search_control"));
writeline (output, l);
/trunk/bench/vhdl/search_items_wrapper.vhd
0,0 → 1,225
--////////////////////////////////////////////////////////////////////
--// ////
--// search_items_wrapper.vhd ////
--// ////
--// This file is part of the open_hitter opencores effort. ////
--// <http://www.opencores.org/cores/open_hitter/> ////
--// ////
--// Module Description: ////
--// Simulation program (non-synthesizable) ////
--// Drives auto regression tests via NSEW button actions and ////
--// NSEW LED reporting ////
--// target env: ghdl <attrib required> ////
--// TEST EXTENSION OF SEARCH_ITEM_WRAPPER ////
--// ////
--// To Do: ////
--// ////
--// Author(s): ////
--// - Stephen Hawes ////
--// ////
--////////////////////////////////////////////////////////////////////
--// ////
--// Copyright (C) 2015 Stephen Hawes and OPENCORES.ORG ////
--// ////
--// This source file may be used and distributed without ////
--// restriction provided that this copyright statement is not ////
--// removed from the file and that any derivative work contains ////
--// the original copyright notice and the associated disclaimer. ////
--// ////
--// This source file is free software; you can redistribute it ////
--// and/or modify it under the terms of the GNU Lesser General ////
--// Public License as published by the Free Software Foundation; ////
--// either version 2.1 of the License, or (at your option) any ////
--// later version. ////
--// ////
--// This source is distributed in the hope that it will be ////
--// useful, but WITHOUT ANY WARRANTY; without even the implied ////
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
--// PURPOSE. See the GNU Lesser General Public License for more ////
--// details. ////
--// ////
--// You should have received a copy of the GNU Lesser General ////
--// Public License along with this source; if not, download it ////
--// from <http://www.opencores.org/lgpl.shtml> ////
--// ////
--////////////////////////////////////////////////////////////////////
--//
--// \$Id\$ TAKE OUT THE \'s and this comment in order to get this to work
--//
--// CVS Revision History
--//
--// \$Log\$ TAKE OUT THE \'s and this comment in order to get this to work
--//
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.ALL;
use std.textio.all; -- Imports the standard textio package.
 
entity search_items_wrapper is
end search_items_wrapper;
 
architecture behaviour of search_items_wrapper is
component search_item
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;
-- pxdata: in price_packet
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_px: in std_logic_vector(15 downto 0); -- price
b1_qty: in std_logic_vector(15 downto 0); -- quantity
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
-- pxdata: out price_packet
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_px: out std_logic_vector(15 downto 0); -- price
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: searchs_item use entity work.search_item;
signal RX_CLK: std_logic;
-- control flag(s) on the incoming bus
signal b1_px_valid: std_logic;
-- pxdata: in price_packet
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_px: std_logic_vector(15 downto 0); -- price
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_id: std_logic_vector(15 downto 0); -- unique/identifier/counter
-- pxdata: out price_packet
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_px: std_logic_vector(15 downto 0); -- price
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_id: std_logic_vector(15 downto 0); -- unique/identifier/counter
begin
items_array : for iter_id in 0 to 5 generate -- searchitems - 1 generate
begin
cell_item: entity work.search_item
-- search_item_0: search_item
-- generic map ( item_id => std_logic_vector'("0110011001100110") )
-- generic map ( item_id => std_logic_vector'(X"0000"))
generic map ( item_id => std_logic_vector(to_unsigned(iter_id,16)) )
port map (
RX_CLK => RX_CLK,
-- control flag(s) on the incoming bus
b1_px_valid => b1_px_valid,
-- pxdata: in price_packet
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,
-- pxdata: out price_packet
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;
 
process
variable l : line;
 
type input_pattern_type is record
-- control flag(s) on the incoming bus
b1_px_valid: std_logic;
-- pxdata: in price_packet
b1_px_type: std_logic_vector(4 downto 0);
b1_buy_sell: std_logic_vector(2 downto 0); -- 111 buy, 000 sell
b1_px: std_logic_vector(15 downto 0); -- price
b1_qty: std_logic_vector(15 downto 0); -- quantity
b1_sec: std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
b1_id: std_logic_vector(15 downto 0); -- unique/identifier/counter
end record;
type output_pattern_type is record
-- pxdata: out price_packet
b2_px_type: std_logic_vector(4 downto 0);
b2_buy_sell: std_logic_vector(2 downto 0); -- 111 buy, 000 sell
b2_px: std_logic_vector(15 downto 0); -- price
b2_qty: std_logic_vector(15 downto 0); -- quantity
b2_sec: std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
b2_id: std_logic_vector(15 downto 0); -- unique/identifier/counter
end record;
 
-- The patterns to apply.
constant zz_px: std_logic_vector(15 downto 0) := (others => 'Z');
constant zz_qty: std_logic_vector(15 downto 0) := (others => 'Z');
constant zz_sec: std_logic_vector(55 downto 0) := (others => 'Z');
constant zz_id: std_logic_vector(15 downto 0) := (others => 'Z');
constant set_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000010000");
constant test_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000011100000");
constant test_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000001100");
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'(X"0002"); --- std_logic_vector'("0110011001100110");
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), -- 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), -- 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_items"));
writeline (output, l);
RX_CLK <= '0';
wait for 1 ns;
 
-- Check each pattern.
for i in input_patterns'range loop
-- Set the inputs.
b1_px_valid <= input_patterns(i).b1_px_valid;
b1_px_type <= input_patterns(i).b1_px_type;
b1_buy_sell<= input_patterns(i).b1_buy_sell;
b1_px <= input_patterns(i).b1_px;
b1_qty <= input_patterns(i).b1_qty;
b1_sec <= input_patterns(i).b1_sec;
b1_id <= input_patterns(i).b1_id;
-- Clock once for the results.
RX_CLK <= '1';
wait for 1 ns;
-- Check the outputs.
assert b2_px_type = output_patterns(i).b2_px_type report "search_item_wrapper: test: " & integer'image(i) & " bad px type" severity error;
assert b2_buy_sell = output_patterns(i).b2_buy_sell report "search_item_wrapper: test: " & integer'image(i) & " bad buy_sell" severity error;
assert b2_px = output_patterns(i).b2_px report "search_item_wrapper: test: " & integer'image(i) & " bad px" severity error;
assert b2_qty = output_patterns(i).b2_qty report "search_item_wrapper: test: " & integer'image(i) & " bad qty" severity error;
assert b2_sec = output_patterns(i).b2_sec report "search_item_wrapper: test: " & integer'image(i) & " bad sec" severity error;
assert b2_id = output_patterns(i).b2_id report "search_item_wrapper: test: " & integer'image(i) & " bad id" severity error;
-- Clock down.
RX_CLK <= '0';
wait for 1 ns;
end loop;
write (l, String'("Done search_items"));
writeline (output, l);
wait;
end process;
end behaviour;
 
/trunk/bench/vhdl/build.sh
26,7 → 26,12
#ghdl -r hitter_wrapper
 
ghdl -e search_item_wrapper
#ghdl -r search_item_wrapper
ghdl -r search_item_wrapper
 
ghdl -e search_control_wrapper
ghdl -r search_control_wrapper
 
ghdl -a search_items_wrapper.vhd
ghdl -e search_items_wrapper
ghdl -r search_items_wrapper
 
/trunk/rtl/vhdl/search_item.vhd
10,8 → 10,8
--// buses perform the multiplex and are experienced by each item ////
--// as b1_* - input to search_item ////
--// b2_* - output from search_item ////
--// there is also a small state-machine in each search_item. ////
--// For now, the count of number of states is fixed, per px_type ////
--// this version of search_item is stateless i.e. can be queried ////
--// every clock cycle ////
--// ////
--// To Do: ////
--// ////
54,6 → 54,7
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.ALL;
--use std.textio.all; -- Imports the standard textio package.
 
entity search_item is
generic ( item_id: std_logic_vector(15 downto 0) );
79,20 → 80,33
end search_item;
 
architecture search_item_implementation of search_item is
signal state : integer range 0 to 16 := 16;
-- signal state : integer range 0 to 16 := 16;
signal requires_reset: std_logic := '0';
-- pxdata: out price_packet
signal store_px_type: std_logic_vector(4 downto 0) := (others => '0');
signal store_buy_sell: std_logic_vector(2 downto 0) := (others => '0'); -- 111 buy, 000 sell
signal store_px: std_logic_vector(15 downto 0) := (others => '0'); -- price
signal store_qty: std_logic_vector(15 downto 0) := (others => '0'); -- quantity
signal store_sec: std_logic_vector(55 downto 0) := (others => '0'); -- 7x 8bits securities identifier
signal store_id: std_logic_vector(15 downto 0) := (others => '0'); -- unique/identifier/counter
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_px: std_logic_vector(15 downto 0) := (others => 'Z'); -- price
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
begin
match: process (RX_CLK) is
-- variable l : line;
begin
if rising_edge(RX_CLK) then
-- if falling_edge(RX_CLK) then
if b1_px_valid = '1' then
 
-- write (l, String'(" Item Rising Edge "));
-- for j in b1_id'range loop
-- write(l, std_logic'image(b1_id(j)) );
-- end loop;
-- write (l, String'(" instruction: "));
-- for j in b1_px_type'range loop
-- write(l, std_logic'image(b1_px_type(j)) );
-- end loop;
-- writeline ( output, l);
 
 
if b1_px_type = std_logic_vector'("00000") then
-- do reset store and outputs
store_px_type <= (others => '0');
100,7 → 114,6
store_px <= (others => '0'); -- price
store_qty <= (others => '0'); -- quantity
store_sec <= (others => '0'); -- 7x 8bits securities identifier
-- not reset / generic store_id <= (others => '0'); -- unique/identifier/counter
--
b2_px_type <= (others => 'Z');
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
109,8 → 122,7
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
--
b2_px_type <= std_logic_vector'("ZZZZZ");
state <= 16;
requires_reset <= '0';
 
elsif b1_px_type = std_logic_vector'("00110") then
if store_buy_sell = b1_buy_sell and
120,11 → 132,24
-- 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;
b2_buy_sell <= (others => 'Z');
b2_px <= (others => 'Z');
b2_qty <= (others => 'Z');
b2_sec <= (others => 'Z');
b2_id <= (others => 'Z');
requires_reset <= '1';
else
if requires_reset = '1' then
b2_px_type <= (others => 'Z');
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
b2_px <= (others => 'Z'); -- price
b2_qty <= (others => 'Z'); -- quantity
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
requires_reset <= '0';
end if;
end if;
 
elsif b1_px_type = std_logic_vector'("01010") then
135,28 → 160,54
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;
b2_px_type <= std_logic_vector'(std_logic_vector'("01010"));
b2_buy_sell <= (others => 'Z');
b2_px <= (others => 'Z');
b2_qty <= (others => 'Z');
b2_sec <= (others => 'Z');
b2_id <= item_id;
requires_reset <= '1';
else
if requires_reset = '1' then
b2_px_type <= (others => 'Z');
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
b2_px <= (others => 'Z'); -- price
b2_qty <= (others => 'Z'); -- quantity
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
requires_reset <= '0';
end if;
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 ) then
-- not this store_item instance no action
null;
if requires_reset = '1' then
b2_px_type <= (others => 'Z');
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
b2_px <= (others => 'Z'); -- price
b2_qty <= (others => 'Z'); -- quantity
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
requires_reset <= '0';
end if;
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'("11101"));
b2_px_type <= std_logic_vector'(std_logic_vector'("11101"));
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
b2_px <= (others => 'Z'); -- price
b2_qty <= (others => 'Z'); -- quantity
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
requires_reset <= '1';
else
-- send a return order
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_id <= item_id; -- unique/identifier/counter
b2_px <= b1_px; -- price
-- b2_qty <=
if b1_qty < store_qty then
172,38 → 223,36
store_qty <= (others => '0');
end if;
b2_px_type <= std_logic_vector'(std_logic_vector'("11100"));
requires_reset <= '1';
end if;
state <= 8;
 
else
-- no action
null;
if requires_reset = '1' then
b2_px_type <= (others => 'Z');
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
b2_px <= (others => 'Z'); -- price
b2_qty <= (others => 'Z'); -- quantity
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
requires_reset <= '0';
end if;
end if; -- b1_px_type
 
else -- b1_px_valid
-- no incoming b1_px so check for state machine actions
case state is
when 8 =>
-- sent return order, so clean up
b2_px_type <= (others => 'Z');
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
b2_px <= (others => 'Z'); -- price
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 others => null;
end case; -- state
if (state < 16) then
state <= state + 1;
if requires_reset = '1' then
b2_px_type <= (others => 'Z');
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
b2_px <= (others => 'Z'); -- price
b2_qty <= (others => 'Z'); -- quantity
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
requires_reset <= '0';
end if;
end if; -- b1_px_valid
-- b2_id <= std_logic_vector'(X"0000"); -- testing
 
end if; -- b1_px_valid
end if;
end process match;
 
/trunk/rtl/vhdl/search_control.vhd
58,6 → 58,7
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.ALL;
--use std.textio.all; -- Imports the standard textio package.
 
entity search_control is
generic ( searchitems : integer );
107,58 → 108,74
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;
for search_item_1: search_item use entity work.search_item;
signal searchitems_count : integer := 0;
--
signal state : integer range 0 to 16 := 16;
--
--signal RX_CLK: std_logic;
-- pxdata: store price_packet
signal store_px_type: std_logic_vector(4 downto 0) := (others => '0');
signal store_buy_sell: std_logic_vector(2 downto 0) := (others => '0'); -- 111 buy, 000 sell
signal store_px: std_logic_vector(15 downto 0) := (others => '0'); -- price
signal store_qty: std_logic_vector(15 downto 0) := (others => '0'); -- quantity
signal store_sec: std_logic_vector(55 downto 0) := (others => '0'); -- 7x 8bits securities identifier
signal store_id: std_logic_vector(15 downto 0) := (others => '0'); -- unique/identifier/counter
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_px: std_logic_vector(15 downto 0) := (others => 'Z'); -- price
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_id: std_logic_vector(15 downto 0) := (others => 'Z'); -- unique/identifier/counter
-- control flag(s) on the incoming bus
signal b1_px_valid: std_logic;
-- pxdata: b1 price_packet
signal b1_px_type: std_logic_vector(4 downto 0) := (others => '0');
signal b1_buy_sell: std_logic_vector(2 downto 0) := (others => '0'); -- 111 buy, 000 sell
signal b1_px: std_logic_vector(15 downto 0) := (others => '0'); -- price
signal b1_qty: std_logic_vector(15 downto 0) := (others => '0'); -- quantity
signal b1_sec: std_logic_vector(55 downto 0) := (others => '0'); -- 7x 8bits securities identifier
signal b1_id: std_logic_vector(15 downto 0) := (others => '0'); -- unique/identifier/counter
signal b1_px_type: std_logic_vector(4 downto 0) := (others => 'Z');
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 => 'Z'); -- price
signal b1_qty: std_logic_vector(15 downto 0) := (others => 'Z'); -- quantity
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 => 'Z'); -- unique/identifier/counter
-- pxdata: b2 price_packet
signal b2_px_type: std_logic_vector(4 downto 0) := (others => '0');
signal b2_buy_sell: std_logic_vector(2 downto 0) := (others => '0'); -- 111 buy, 000 sell
signal b2_px: std_logic_vector(15 downto 0) := (others => '0'); -- price
signal b2_qty: std_logic_vector(15 downto 0) := (others => '0'); -- quantity
signal b2_sec: std_logic_vector(55 downto 0) := (others => '0'); -- 7x 8bits securities identifier
signal b2_id: std_logic_vector(15 downto 0) := (others => '0'); -- unique/identifier/counter
signal b2_px_type: std_logic_vector(4 downto 0) := (others => 'Z');
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 => 'Z'); -- price
signal b2_qty: std_logic_vector(15 downto 0) := (others => 'Z'); -- quantity
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 => 'Z'); -- unique/identifier/counter
begin
items_array : for iter_id in 0 to searchitems - 1 generate
begin
cell_item : entity work.search_item
generic map ( item_id => std_logic_vector(to_unsigned(iter_id,16)) )
-- items_array : for iter_id in 0 to 5 generate -- searchitems - 1 generate
-- 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 (
RX_CLK => RX_CLK,
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
);
end generate items_array;
-- end generate items_array;
 
-- RX_CLK <= RX_CLK;
 
match: process (RX_CLK) is
-- variable l : line;
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_type_i = std_logic_vector'("00000") then
-- 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_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');
order_px_valid_o <= '1';
--
b1_px_type <= (others => '0');
172,17 → 189,42
searchitems_count <= 0;
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
-- 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
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;
store_px_type <= search_px_type_i;
store_buy_sell <= search_buy_sell_i;
store_px <= search_px_i;
store_qty <= search_qty_i;
store_sec <= search_sec_i;
store_id <= search_id_i;
--b2_px_type <= std_logic_vector'(std_logic_vector'("00000"));
state <= 6;
 
elsif search_px_type_i = std_logic_vector'("00101") then
-- incoming price, register it and start the state machine
219,8 → 261,15
end if;
 
else
-- no action
null;
-- no action - flash up Z's
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
 
else -- search_px_valid_i
228,26 → 277,82
case state is
when 1 =>
-- sent return order, so clean up
b2_px_type <= (others => 'Z');
b2_buy_sell <= (others => 'Z'); -- 111 buy, 000 sell
b2_px <= (others => 'Z'); -- price
b2_qty <= (others => 'Z'); -- quantity
b2_sec <= (others => 'Z'); -- 7x 8bits securities identifier
b2_id <= (others => 'Z'); -- unique/identifier/counter
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
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 =>
-- correct store_item but there was no match
b2_px_type <= std_logic_vector'("ZZZZZ");
-- correct store_item but there was no match
order_px_type_o <= std_logic_vector'("ZZZZZ");
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;
order_px_valid_o <= '0';
 
when others => null;
end case; -- state
if (state < 16) then
state <= state + 1;
end if;
-- if (state < 16) then
-- state <= state + 1;
-- end if;
 
end if; -- search_px_valid_i
254,5 → 359,7
end if;
end process match;
 
-- b1_id <= std_logic_vector'(X"1010"); -- testing
 
end search_control_implementation;
 

powered by: WebSVN 2.1.0

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