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

Subversion Repositories open_hitter

[/] [open_hitter/] [trunk/] [bench/] [vhdl/] [search_control_wrapper.vhd] - Blame information for rev 18

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 stvhawes
--////////////////////////////////////////////////////////////////////
2
--//                                                              ////
3
--// search_control_wrapper.vhd                                   ////
4
--//                                                              ////
5
--// This file is part of the open_hitter opencores effort.       ////
6
--// <http://www.opencores.org/cores/open_hitter/>                ////
7
--//                                                              ////
8
--// Module Description:                                          ////
9
--// Simulation program (non-synthesizable)                       ////
10
--// Drives auto regression tests via NSEW button actions and     ////
11
--// NSEW LED reporting                                           ////
12
--// target env: ghdl <attrib required>                           ////
13
--//                                                              ////
14
--// To Do:                                                       ////
15
--//                                                              ////
16
--// Author(s):                                                   ////
17
--// - Stephen Hawes                                              ////
18
--//                                                              ////
19
--////////////////////////////////////////////////////////////////////
20
--//                                                              ////
21
--// Copyright (C) 2015 Stephen Hawes and OPENCORES.ORG           ////
22
--//                                                              ////
23
--// This source file may be used and distributed without         ////
24
--// restriction provided that this copyright statement is not    ////
25
--// removed from the file and that any derivative work contains  ////
26
--// the original copyright notice and the associated disclaimer. ////
27
--//                                                              ////
28
--// This source file is free software; you can redistribute it   ////
29
--// and/or modify it under the terms of the GNU Lesser General   ////
30
--// Public License as published by the Free Software Foundation; ////
31
--// either version 2.1 of the License, or (at your option) any   ////
32
--// later version.                                               ////
33
--//                                                              ////
34
--// This source is distributed in the hope that it will be       ////
35
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
36
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
37
--// PURPOSE. See the GNU Lesser General Public License for more  ////
38
--// details.                                                     ////
39
--//                                                              ////
40
--// You should have received a copy of the GNU Lesser General    ////
41
--// Public License along with this source; if not, download it   ////
42
--// from <http://www.opencores.org/lgpl.shtml>                   ////
43
--//                                                              ////
44
--////////////////////////////////////////////////////////////////////
45
--//
46
--// \$Id\$  TAKE OUT THE \'s and this comment in order to get this to work
47
--//
48
--// CVS Revision History
49
--//
50
--// \$Log\$  TAKE OUT THE \'s and this comment in order to get this to work
51
--//
52
library ieee;
53
use ieee.std_logic_1164.all;
54
use ieee.numeric_std.ALL;
55
use std.textio.all; --  Imports the standard textio package.
56
 
57
entity search_control_wrapper is
58
end search_control_wrapper;
59
 
60
architecture behaviour of search_control_wrapper is
61
   component search_control is
62
      generic ( searchitems : integer );
63
      port (
64
           RX_CLK: in std_logic;
65
           -- control flag(s) on the incoming bus
66
              search_px_valid_i: in std_logic;
67
           -- pxdata: in price_packet
68
              search_px_type_i: in std_logic_vector(4 downto 0);
69
              search_buy_sell_i: in std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
70
              search_px_i: in std_logic_vector(15 downto 0);     -- price
71
              search_qty_i: in std_logic_vector(15 downto 0);    -- quantity
72
              search_sec_i: in std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
73
              search_id_i: in std_logic_vector(15 downto 0);    -- unique/identifier/counter
74
           -- pxdata: out price_packet
75
              order_px_type_o: out std_logic_vector(4 downto 0);
76
              order_buy_sell_o: out std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
77
              order_px_o: out std_logic_vector(15 downto 0);     -- price
78
              order_qty_o: out std_logic_vector(15 downto 0);    -- quantity
79
              order_sec_o: out std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
80
              order_id_o: out std_logic_vector(15 downto 0);     -- unique/identifier/counter
81
           -- control flag(s) on the outgoing bus
82
              order_px_valid_o: out std_logic
83
      );
84
   end component;
85
   for search_control_0: search_control use entity work.search_control;
86
        signal RX_CLK: std_logic;
87
        -- control flag(s) on the incoming bus
88
           signal search_px_valid_i: std_logic;
89
        -- pxdata: in price_packet
90
           signal search_px_type_i: std_logic_vector(4 downto 0);
91
           signal search_buy_sell_i: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
92
           signal search_px_i: std_logic_vector(15 downto 0);     -- price
93
           signal search_qty_i: std_logic_vector(15 downto 0);    -- quantity
94
           signal search_sec_i: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
95
           signal search_id_i: std_logic_vector(15 downto 0);    -- unique/identifier/counter
96
        -- pxdata: out price_packet
97
           signal order_px_type_o: std_logic_vector(4 downto 0);
98
           signal order_buy_sell_o: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
99
           signal order_px_o: std_logic_vector(15 downto 0);     -- price
100
           signal order_qty_o: std_logic_vector(15 downto 0);    -- quantity
101
           signal order_sec_o: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
102
           signal order_id_o: std_logic_vector(15 downto 0);     -- unique/identifier/counter
103 16 stvhawes
        -- control
104
           signal order_px_valid_o: std_logic;
105 15 stvhawes
   begin
106
        search_control_0: search_control
107 18 stvhawes
           generic map ( searchitems => 4 )   -- for test case when full at 4 orders
108 15 stvhawes
           port map (
109
              RX_CLK => RX_CLK,
110
           -- control flag(s) on the incoming bus
111
              search_px_valid_i => search_px_valid_i,
112
           -- pxdata: in price_packet
113
              search_px_type_i => search_px_type_i,
114
              search_buy_sell_i => search_buy_sell_i,
115
              search_px_i => search_px_i,
116
              search_qty_i => search_qty_i,
117
              search_sec_i => search_sec_i,
118
              search_id_i => search_id_i,
119
           -- pxdata: out price_packet
120
              order_px_type_o => order_px_type_o,
121
              order_buy_sell_o => order_buy_sell_o,
122
              order_px_o => order_px_o,
123
              order_qty_o => order_qty_o,
124
              order_sec_o => order_sec_o,
125 16 stvhawes
              order_id_o => order_id_o,
126
           -- control
127
              order_px_valid_o => order_px_valid_o
128 15 stvhawes
           );
129 18 stvhawes
 
130 15 stvhawes
   process
131
        variable l : line;
132 16 stvhawes
        variable res : integer;
133 15 stvhawes
 
134
        type input_pattern_type is record
135
           -- control flag(s) on the incoming bus
136
              search_px_valid_i: std_logic;
137
           -- pxdata: in price_packet
138
              search_px_type_i: std_logic_vector(4 downto 0);
139
              search_buy_sell_i: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
140
              search_px_i: std_logic_vector(15 downto 0);     -- price
141
              search_qty_i: std_logic_vector(15 downto 0);    -- quantity
142
              search_sec_i: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
143
              -- search_id_i: std_logic_vector(15 downto 0);    -- unique/identifier/counter
144
         end record;
145
         type output_pattern_type is record
146
            -- pxdata: out price_packet
147
              order_px_type_o: std_logic_vector(4 downto 0);
148
              order_buy_sell_o: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
149
              order_px_o: std_logic_vector(15 downto 0);     -- price
150
              order_qty_o: std_logic_vector(15 downto 0);    -- quantity
151
              order_sec_o: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
152
              order_id_o: std_logic_vector(15 downto 0);      -- unique/identifier/counter
153
         end record;
154
 
155
         --  The patterns to apply.
156
         constant zz_px: std_logic_vector(15 downto 0) := (others => 'Z');
157
         constant zz_qty: std_logic_vector(15 downto 0) := (others => 'Z');
158
         constant zz_sec: std_logic_vector(55 downto 0) := (others => 'Z');
159
         constant zz_id: std_logic_vector(15 downto 0) := (others => 'Z');
160
         constant set_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000010000");
161
         constant test_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000011100000");
162
         constant test_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000001100");
163
         constant remain_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000000100");
164
         constant test_sec0: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA544223478DC");
165
         constant test_sec1: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA543332178DC");
166
         constant test_sec2: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA234234378DC");
167
         constant test_sec3: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA534534578DC");
168
         constant test_id: std_logic_vector(15 downto 0) := std_logic_vector'("0110011001100110");
169
         constant other_id: std_logic_vector(15 downto 0) := std_logic_vector'("0000010001100010");
170
         constant other_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000001110");
171
         constant other_sec: std_logic_vector(55 downto 0) := std_logic_vector'(X"CDC423354634AA");
172
         type input_pattern_array is array (natural range <>) of input_pattern_type;
173
           constant input_patterns : input_pattern_array :=
174
             ( ('1', std_logic_vector'("00000"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec), -- 0 reset
175 17 stvhawes
               ('1', std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec), -- 1 nothing
176
               ('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec0),  -- 2 sec/set
177
               ('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec1),  -- 3 sec/set
178
               ('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec1),  -- 4 sec/set - repeat
179
               ('1', std_logic_vector'("00110"), std_logic_vector'("111"), test_px, set_qty, test_sec2),  -- 5 sec/set
180
               ('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec2),  -- 6 sec/set - diff buysell
181
               ('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec3),  -- 7 too many sec/set 
182
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1),   -- 8 incoming px 
183
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, zz_qty, other_sec),   -- 9 incoming px (wrong security)
184
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), other_px, test_qty, test_sec1),   -- 10incoming px (too low sale price)
185
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1) ); -- 11incoming px (part qty)
186 15 stvhawes
         type output_pattern_array is array (natural range <>) of output_pattern_type;
187
           constant output_patterns : output_pattern_array :=
188 17 stvhawes
             ( (std_logic_vector'("00000"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 0 reset
189 15 stvhawes
               (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 1 nothing
190 17 stvhawes
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0000")),  -- 2 sec/set
191
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0001")),  -- 3 sec/set
192
               (std_logic_vector'("00110"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0001")),  -- 4 sec/set
193
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0002")),  -- 5 sec/set
194
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0003")),  -- 6 sec/set
195
               (std_logic_vector'("11111"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 7 bad sec/set (too many)
196 18 stvhawes
               (std_logic_vector'("11100"), std_logic_vector'("000"), test_px, test_qty, test_sec1, std_logic_vector'(X"0001")),  -- 8 incoming px
197 17 stvhawes
               (std_logic_vector'("11110"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 9 incoming px (wrong security)
198
               (std_logic_vector'("11101"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 10incoming px (too low sale price)
199 18 stvhawes
               (std_logic_vector'("11100"), std_logic_vector'("000"), test_px, remain_qty, test_sec1, std_logic_vector'(X"0001")) );  -- 11incoming px (part qty)
200 15 stvhawes
   begin
201 18 stvhawes
        -- diagnostics (uncomment)
202
        -- write (l, String'("Exercising search_control"));
203
        -- writeline (output, l);
204
        RX_CLK <= '0';
205 17 stvhawes
        wait for 1 us;
206 15 stvhawes
 
207
           --  Check each pattern.
208
           for i in input_patterns'range loop
209 18 stvhawes
              -- diagnostics (uncomment)
210
              -- write (l, String'("Wrapper start loop i: "));
211
              -- write (l, i);
212
              -- writeline (output, l);
213
 
214 15 stvhawes
              --  Set the inputs.
215
              search_px_valid_i <= input_patterns(i).search_px_valid_i;
216
              search_px_type_i <= input_patterns(i).search_px_type_i;
217
              search_buy_sell_i <= input_patterns(i).search_buy_sell_i;
218
              search_px_i <= input_patterns(i).search_px_i;
219
              search_qty_i <= input_patterns(i).search_qty_i;
220
              search_sec_i <= input_patterns(i).search_sec_i;
221
              --search_id_i <= input_patterns(i).search_id_i;
222 18 stvhawes
              --  Clock once for the results (rising edge)
223
              RX_CLK <= '1';
224 17 stvhawes
              wait for 1 us;
225
              search_px_valid_i <= '0';
226 15 stvhawes
              --  Check the outputs.
227 16 stvhawes
              res := 0;
228 17 stvhawes
              for r in 0 to 3 loop
229 18 stvhawes
                 -- diagnostics (uncomment)
230
                 -- write (l, String'("  Wrapper wait results r: "));
231
                 -- write (l, r);
232
                 -- write (l, String'(" order_px_valid_o: "));
233
                 -- write (l, std_logic'image(order_px_valid_o));
234
                 -- writeline (output, l);
235 16 stvhawes
                 if order_px_valid_o = '1' then
236 17 stvhawes
                    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;
237
                    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;
238
                    assert order_px_o = output_patterns(i).order_px_o report "search_control_wrapper: test: " & integer'image(i) & " bad px" severity error;
239
                    assert order_qty_o = output_patterns(i).order_qty_o report "search_control_wrapper: test: " & integer'image(i) & " bad qty" severity error;
240
                    assert order_sec_o = output_patterns(i).order_sec_o report "search_control_wrapper: test: " & integer'image(i) & " bad sec" severity error;
241
                    assert order_id_o = output_patterns(i).order_id_o report "search_control_wrapper: test: " & integer'image(i) & " bad id" severity error;
242 16 stvhawes
                    res := res + 1;
243
                 end if;
244 18 stvhawes
                 --  Clock down
245
                 RX_CLK <= '0';
246
                 wait for 1 us;
247 17 stvhawes
                 RX_CLK <= '1';
248
                 wait for 1 us;
249 16 stvhawes
              end loop;
250 17 stvhawes
              assert res = 1 report "search_control_wrapper: test: " & integer'image(i) & " wrong number of results from input pattern message" severity error;
251 16 stvhawes
 
252 18 stvhawes
              RX_CLK <= '0';
253 17 stvhawes
              wait for 1 us;
254 15 stvhawes
           end loop;
255
 
256
        write (l, String'("Done search_control"));
257
        writeline (output, l);
258
 
259
        wait;
260
        end process;
261
     end behaviour;
262
 

powered by: WebSVN 2.1.0

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