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
/
- from Rev 17 to Rev 18
- ↔ Reverse comparison
Rev 17 → Rev 18
/open_hitter/trunk/bench/vhdl/search_item_wrapper.vhd
183,7 → 183,7
begin |
write (l, String'("Exercising search_item")); |
writeline (output, l); |
RX_CLK <= '0'; |
RX_CLK <= '1'; |
wait for 1 ns; |
|
-- Check each pattern. |
196,8 → 196,8
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'; |
-- Clock once (falling edge) for the results. |
RX_CLK <= '0'; |
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; |
207,7 → 207,7
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'; |
RX_CLK <= '1'; |
wait for 1 ns; |
end loop; |
write (l, String'("Done search_item")); |
/open_hitter/trunk/bench/vhdl/search_control_wrapper.vhd
104,7 → 104,7
signal order_px_valid_o: std_logic; |
begin |
search_control_0: search_control |
generic map ( searchitems => 3 ) |
generic map ( searchitems => 4 ) -- for test case when full at 4 orders |
port map ( |
RX_CLK => RX_CLK, |
-- control flag(s) on the incoming bus |
126,6 → 126,7
-- control |
order_px_valid_o => order_px_valid_o |
); |
|
process |
variable l : line; |
variable res : integer; |
171,7 → 172,6
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 |
('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 |
186,7 → 186,6
type output_pattern_array is array (natural range <>) of output_pattern_type; |
constant output_patterns : output_pattern_array := |
( (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"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 |
194,18 → 193,24
(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'("11100"), std_logic_vector'("000"), test_px, test_qty, test_sec1, std_logic_vector'(X"0001")), -- 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) |
(std_logic_vector'("11100"), std_logic_vector'("000"), test_px, remain_qty, test_sec1, std_logic_vector'(X"0001")) ); -- 11incoming px (part qty) |
begin |
write (l, String'("Exercising search_control")); |
writeline (output, l); |
RX_CLK <= '1'; |
-- diagnostics (uncomment) |
-- write (l, String'("Exercising search_control")); |
-- writeline (output, l); |
RX_CLK <= '0'; |
wait for 1 us; |
|
-- Check each pattern. |
for i in input_patterns'range loop |
-- diagnostics (uncomment) |
-- write (l, String'("Wrapper start loop i: ")); |
-- write (l, i); |
-- writeline (output, l); |
|
-- Set the inputs. |
search_px_valid_i <= input_patterns(i).search_px_valid_i; |
search_px_type_i <= input_patterns(i).search_px_type_i; |
214,13 → 219,19
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 (falling edge) |
RX_CLK <= '0'; |
-- Clock once for the results (rising edge) |
RX_CLK <= '1'; |
wait for 1 us; |
search_px_valid_i <= '0'; |
-- Check the outputs. |
res := 0; |
for r in 0 to 3 loop |
-- diagnostics (uncomment) |
-- write (l, String'(" Wrapper wait results r: ")); |
-- write (l, r); |
-- write (l, String'(" order_px_valid_o: ")); |
-- write (l, std_logic'image(order_px_valid_o)); |
-- writeline (output, l); |
if order_px_valid_o = '1' then |
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; |
230,15 → 241,15
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 up |
-- Clock down |
RX_CLK <= '0'; |
wait for 1 us; |
RX_CLK <= '1'; |
wait for 1 us; |
RX_CLK <= '0'; |
wait for 1 us; |
end loop; |
assert res = 1 report "search_control_wrapper: test: " & integer'image(i) & " wrong number of results from input pattern message" severity error; |
|
RX_CLK <= '1'; |
RX_CLK <= '0'; |
wait for 1 us; |
end loop; |
|
/open_hitter/trunk/bench/vhdl/search_items_wrapper.vhd
56,6 → 56,10
use std.textio.all; -- Imports the standard textio package. |
|
entity search_items_wrapper is |
port ( |
RX_CLK: in std_logic; |
search_px_valid_i: in std_logic |
); |
end search_items_wrapper; |
|
architecture behaviour of search_items_wrapper is |
82,7 → 86,7
); |
end component; |
-- for search_item_0: searchs_item use entity work.search_item; |
signal RX_CLK: std_logic; |
--W signal RX_CLK: std_logic; |
-- control flag(s) on the incoming bus |
signal b1_px_valid: std_logic; |
-- pxdata: in price_packet |
100,12 → 104,13
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 |
-- items_array : for iter_id in 0 to 5 generate -- searchitems - 1 generate |
items_array : for iter_id in 2 to 2 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'(X"0002")) |
generic map ( item_id => std_logic_vector(to_unsigned(iter_id,16)) ) |
port map ( |
RX_CLK => RX_CLK, |
128,8 → 133,12
); |
end generate items_array; |
|
process |
--W process |
process (RX_CLK) is --W |
variable l : line; |
variable state : integer := 0; |
variable step : integer := 0; |
variable i : integer := 0; -- test |
|
type input_pattern_type is record |
-- control flag(s) on the incoming bus |
188,13 → 197,26
(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")); |
if rising_edge(RX_CLK) then --W |
write (l, String'("Exercising search_items_wrapper step: ")); |
write (l, step); |
write (l, String'(" test: ")); |
write (l, i); |
write (l, String'(" state: ")); |
write (l, state); |
write (l, String'(" b2_id: ")); |
write (l, String'(" b2_id: ")); |
for j in b2_id'range loop |
write(l, std_logic'image(b2_id(j)) ); |
end loop; |
writeline (output, l); |
RX_CLK <= '0'; |
wait for 1 ns; |
|
--W RX_CLK <= '0'; |
--W wait for 1 ns; |
|
-- Check each pattern. |
for i in input_patterns'range loop |
--W for i in input_patterns'range loop |
|
if state = 0 then --W |
-- Set the inputs. |
b1_px_valid <= input_patterns(i).b1_px_valid; |
b1_px_type <= input_patterns(i).b1_px_type; |
204,10 → 226,24
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; |
--W RX_CLK <= '1'; |
--W wait for 1 ns; |
state := 1; --W |
else -- state |
-- 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; |
if b2_px_type = output_patterns(i).b2_px_type then |
write (l, String'("search_item_wrapper: test: ")); |
write (l, step); |
write (l, String'(" OK px type")); |
writeline (output, l); |
else |
write (l, String'("search_item_wrapper: test: ")); |
write (l, step); |
write (l, String'(" BAD px type")); |
writeline (output, l); |
end if; |
|
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; |
214,12 → 250,18
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")); |
--W RX_CLK <= '0'; |
--W wait for 1 ns; |
state := 0; --W |
i := i + 1; --W |
end if; -- state --W |
--W end loop; |
write (l, String'("Done search_items_wrapper for step: ")); |
write (l, step); |
writeline (output, l); |
wait; |
step := step + 1; --W |
--W wait; |
end if; --W |
end process; |
end behaviour; |
|
/open_hitter/trunk/bench/vhdl/search_items_wrapper_wrapper.vhd
0,0 → 1,116
--//////////////////////////////////////////////////////////////////// |
--// //// |
--// search_items_wrapper_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> //// |
--// WRAP-TEST 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_wrapper is |
end search_items_wrapper_wrapper; |
|
architecture behaviour of search_items_wrapper_wrapper is |
component search_items_wrapper is |
port ( |
RX_CLK: in std_logic; |
search_px_valid_i: in std_logic |
); |
end component; |
for search_items_wrapper_1: search_items_wrapper use entity work.search_items_wrapper; |
|
signal RX_CLK: std_logic; |
signal search_px_valid_i: std_logic := '0'; |
|
begin |
search_items_wrapper_1 : search_items_wrapper |
port map ( |
RX_CLK => RX_CLK, |
search_px_valid_i => search_px_valid_i |
); |
|
process |
variable l : line; |
variable res : integer; |
begin |
write (l, String'("Exercising search_items_wrapper_wrapper")); |
writeline (output, l); |
RX_CLK <= '1'; |
wait for 1 us; |
|
-- for i in 0 to 3 loop -- input_patterns'range loop |
|
RX_CLK <= '0'; |
wait for 1 us; |
|
search_px_valid_i <= '1'; |
-- Check the outputs. |
res := 0; |
for r in 0 to 14 loop |
|
RX_CLK <= '1'; |
wait for 1 us; |
RX_CLK <= '0'; |
wait for 1 us; |
end loop; |
|
RX_CLK <= '1'; |
wait for 1 us; |
|
-- end loop; |
|
write (l, String'("Done search_items_wrapper_wrapper")); |
writeline (output, l); |
|
wait; |
end process; |
end behaviour; |
|
/open_hitter/trunk/bench/vhdl/build.sh
31,7 → 31,4
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 |
|
/open_hitter/trunk/rtl/vhdl/search_item.vhd
54,7 → 54,7
library ieee; |
use ieee.std_logic_1164.all; |
use ieee.numeric_std.ALL; |
--use std.textio.all; -- Imports the standard textio package. |
-- use std.textio.all; -- Imports the standard textio package. |
|
entity search_item is |
generic ( item_id: std_logic_vector(15 downto 0) ); |
82,7 → 82,7
architecture search_item_implementation of search_item is |
-- signal state : integer range 0 to 16 := 16; |
signal requires_reset: std_logic := '0'; |
-- pxdata: out price_packet |
-- pxdata: out price_packet |
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 |
90,23 → 90,29
signal store_sec: std_logic_vector(55 downto 0) := (others => 'Z'); -- 7x 8bits securities identifier |
begin |
match: process (RX_CLK) is |
-- variable l : line; |
-- variable l : line; |
begin |
if rising_edge(RX_CLK) then |
-- if falling_edge(RX_CLK) then |
if b1_px_valid = '1' then |
if falling_edge(RX_CLK) 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); |
-- diagnostic (uncomment) |
-- write (l, String'(" Item Falling Edge")); |
-- write (l, String'(" b1_px_type: ")); |
-- for j in b1_px_type'range loop |
-- write(l, std_logic'image(b1_px_type(j)) ); |
-- end loop; |
-- write (l, String'(" item_id: ")); |
-- for j in item_id'range loop |
-- write(l, std_logic'image(item_id(j)) ); |
-- end loop; |
-- write (l, String'(" b1_id: ")); |
-- for j in b1_id'range loop |
-- write(l, std_logic'image(b1_id(j)) ); |
-- end loop; |
-- write (l, String'(" b1_px_valid: ")); |
-- write (l, std_logic'image(b1_px_valid) ); |
-- writeline ( output, l); |
|
|
if b1_px_valid = '1' then |
if b1_px_type = std_logic_vector'("00000") then |
-- do reset store and outputs |
store_px_type <= (others => '0'); |
123,7 → 129,6
b2_id <= (others => 'Z'); -- unique/identifier/counter |
-- |
requires_reset <= '0'; |
|
elsif b1_px_type = std_logic_vector'("00110") then |
if store_buy_sell = b1_buy_sell and |
store_sec = b1_sec then |
138,7 → 143,7
b2_px <= (others => 'Z'); |
b2_qty <= (others => 'Z'); |
b2_sec <= (others => 'Z'); |
b2_id <= (others => 'Z'); |
b2_id <= item_id; |
requires_reset <= '1'; |
else |
if requires_reset = '1' then |
151,7 → 156,6
requires_reset <= '0'; |
end if; |
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 |
179,7 → 183,6
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 |
225,20 → 228,18
b2_px_type <= std_logic_vector'(std_logic_vector'("11100")); |
requires_reset <= '1'; |
end if; |
|
else |
-- no action |
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; |
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 |
if requires_reset = '1' then |
b2_px_type <= (others => 'Z'); |
250,11 → 251,7
requires_reset <= '0'; |
end if; |
end if; -- b1_px_valid |
|
-- b2_id <= std_logic_vector'(X"0000"); -- testing |
|
end if; |
end process match; |
|
end search_item_implementation; |
|
/open_hitter/trunk/rtl/vhdl/search_control.vhd
58,7 → 58,7
library ieee; |
use ieee.std_logic_1164.all; |
use ieee.numeric_std.ALL; |
--use std.textio.all; -- Imports the standard textio package. |
-- use std.textio.all; -- Imports the standard textio package. |
|
entity search_control is |
generic ( searchitems : integer ); |
65,56 → 65,52
port ( |
RX_CLK: in std_logic; |
-- control flag(s) on the incoming bus |
search_px_valid_i: in std_logic; |
search_px_valid_i: in std_logic; |
-- pxdata: in price_packet |
search_px_type_i: in std_logic_vector(4 downto 0); |
search_buy_sell_i: in std_logic_vector(2 downto 0); -- 111 buy, 000 sell |
search_px_i: in std_logic_vector(15 downto 0); -- price |
search_qty_i: in std_logic_vector(15 downto 0); -- quantity |
search_sec_i: in std_logic_vector(55 downto 0); -- 7x 8bits securities identifier |
search_id_i: in std_logic_vector(15 downto 0); -- unique/identifier/counter |
search_px_type_i: in std_logic_vector(4 downto 0); |
search_buy_sell_i: in std_logic_vector(2 downto 0); -- 111 buy, 000 sell |
search_px_i: in std_logic_vector(15 downto 0); -- price |
search_qty_i: in std_logic_vector(15 downto 0); -- quantity |
search_sec_i: in std_logic_vector(55 downto 0); -- 7x 8bits securities identifier |
search_id_i: in std_logic_vector(15 downto 0); -- unique/identifier/counter |
-- pxdata: out price_packet |
order_px_type_o: out std_logic_vector(4 downto 0); |
order_buy_sell_o: out std_logic_vector(2 downto 0); -- 111 buy, 000 sell |
order_px_o: out std_logic_vector(15 downto 0); -- price |
order_qty_o: out std_logic_vector(15 downto 0); -- quantity |
order_sec_o: out std_logic_vector(55 downto 0); -- 7x 8bits securities identifier |
order_id_o: out std_logic_vector(15 downto 0); -- unique/identifier/counter |
order_px_type_o: out std_logic_vector(4 downto 0); |
order_buy_sell_o: out std_logic_vector(2 downto 0); -- 111 buy, 000 sell |
order_px_o: out std_logic_vector(15 downto 0); -- price |
order_qty_o: out std_logic_vector(15 downto 0); -- quantity |
order_sec_o: out std_logic_vector(55 downto 0); -- 7x 8bits securities identifier |
order_id_o: out std_logic_vector(15 downto 0); -- unique/identifier/counter |
-- control flag(s) on the outgoing bus |
order_px_valid_o: out std_logic |
order_px_valid_o: out std_logic |
); |
end search_control; |
|
architecture search_control_implementation of search_control 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_1: search_item use entity work.search_item; |
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; |
signal searchitems_count : integer := 0; |
-- |
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 => '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 |
121,53 → 117,73
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 |
-- 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 => '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 => '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 |
-- 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_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 => 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; |
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)) ) |
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; |
|
-- RX_CLK <= RX_CLK; |
|
match: process (RX_CLK) is |
-- variable l : line; |
process (RX_CLK) is |
-- variable l : line; |
begin |
--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 rising_edge(RX_CLK) then |
|
-- diagnostic (uncomment) |
-- write (l, String'(" Control Rising Edge search_px_type_i: ")); |
-- for j in search_px_type_i'range loop |
-- write(l, std_logic'image(search_px_type_i(j)) ); |
-- end loop; |
-- write (l, String'(" search_px_valid_i: ")); |
-- write(l, std_logic'image(search_px_valid_i) ); |
-- write (l, String'(" state: ")); |
-- write(l, state ); |
-- write (l, String'(" b2_id: ")); |
-- for j in b2_id'range loop |
-- write(l, std_logic'image(b2_id(j)) ); |
-- end loop; |
-- write (l, String'(" b2_px_type: ")); |
-- for j in b2_px_type'range loop |
-- write(l, std_logic'image(b2_px_type(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 |
-- do reset store and outputs |
order_px_type_o <= (others => '0'); |
183,29 → 199,9
b1_px <= (others => '0'); -- price |
b1_qty <= (others => '0'); -- quantity |
b1_sec <= (others => '0'); -- 7x 8bits securities identifier |
-- b1_id <= (others => '0'); -- unique/identifier/counter |
b1_px_valid <= '1'; |
-- |
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 |
223,55 → 219,36
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 |
elsif search_px_type_i = 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; |
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; |
else |
-- send a return order |
b2_px_type <= std_logic_vector'("1010"); |
b2_buy_sell <= store_buy_sell; -- 111 buy, 000 sell |
b2_px <= b1_px; -- price |
-- b2_qty <= |
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 |
-- update the store |
-- 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; |
end if; |
end if; |
|
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 <= 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 <= 10; |
else |
-- 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; |
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 |
-- no incoming search_px_i so check for state machine actions |
case state is |
284,7 → 261,6
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 |
294,10 → 270,15
state <= 8; -- reset next cycle |
else |
-- no response, it's a new security+buysell |
if searchitems_count = searchitems-1 then |
if searchitems_count = searchitems then |
-- all search_items are filled - can't store this item |
order_px_type_o <= std_logic_vector'("11111"); |
order_px_valid_o <= '1'; |
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 |
b1_px_valid <= '0'; |
state <= 8; -- reset next cycle |
else |
307,12 → 288,11
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_id <= 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; |
326,12 → 306,6
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 |
order_px_type_o <= std_logic_vector'("ZZZZZ"); |
344,22 → 318,40
b1_sec <= (others => 'Z'); |
b1_id <= (others => 'Z'); |
b1_px_valid <= '0'; |
-- |
state <= 16; |
|
when 10 => |
if b2_px_type = std_logic_vector'("11100") then |
-- got a hit .. send it |
order_px_type_o <= std_logic_vector'("11100"); |
order_px_valid_o <= '1'; |
order_buy_sell_o <= b2_buy_sell; -- 111 buy, 000 sell |
order_px_o <= b2_px; -- price |
order_qty_o <= b2_qty; -- quantity |
order_sec_o <= b2_sec; -- 7x 8bits securities identifier |
order_id_o <= b2_id; -- unique/identifier/counter |
b1_px_valid <= '0'; |
state <= 8; -- reset next cycle |
else |
-- some kind of non-useful price |
order_buy_sell_o <= (others => 'Z'); |
order_px_o <= (others => 'Z'); |
order_qty_o <= (others => 'Z'); |
order_sec_o <= (others => 'Z'); |
order_id_o <= (others => 'Z'); |
if b2_px_type = std_logic_vector'("11101") then |
-- incoming px (too low sale price) |
order_px_type_o <= std_logic_vector'("11101"); |
else |
-- no match |
order_px_type_o <= std_logic_vector'("11110"); |
end if; |
order_px_valid_o <= '1'; |
b1_px_valid <= '0'; |
state <= 8; -- reset next cycle |
end if; |
when others => null; |
end case; -- state |
|
-- if (state < 16) then |
-- state <= state + 1; |
-- end if; |
|
end if; -- search_px_valid_i |
|
end if; |
end process match; |
|
-- b1_id <= std_logic_vector'(X"1010"); -- testing |
|
end process; |
end search_control_implementation; |
|