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 17

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
           generic map ( searchitems => 3 )
108
           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
   process
130
        variable l : line;
131 16 stvhawes
        variable res : integer;
132 15 stvhawes
 
133
        type input_pattern_type is record
134
           -- control flag(s) on the incoming bus
135
              search_px_valid_i: std_logic;
136
           -- pxdata: in price_packet
137
              search_px_type_i: std_logic_vector(4 downto 0);
138
              search_buy_sell_i: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
139
              search_px_i: std_logic_vector(15 downto 0);     -- price
140
              search_qty_i: std_logic_vector(15 downto 0);    -- quantity
141
              search_sec_i: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
142
              -- search_id_i: std_logic_vector(15 downto 0);    -- unique/identifier/counter
143
         end record;
144
         type output_pattern_type is record
145
            -- pxdata: out price_packet
146
              order_px_type_o: std_logic_vector(4 downto 0);
147
              order_buy_sell_o: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
148
              order_px_o: std_logic_vector(15 downto 0);     -- price
149
              order_qty_o: std_logic_vector(15 downto 0);    -- quantity
150
              order_sec_o: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
151
              order_id_o: std_logic_vector(15 downto 0);      -- unique/identifier/counter
152
         end record;
153
 
154
         --  The patterns to apply.
155
         constant zz_px: std_logic_vector(15 downto 0) := (others => 'Z');
156
         constant zz_qty: std_logic_vector(15 downto 0) := (others => 'Z');
157
         constant zz_sec: std_logic_vector(55 downto 0) := (others => 'Z');
158
         constant zz_id: std_logic_vector(15 downto 0) := (others => 'Z');
159
         constant set_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000010000");
160
         constant test_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000011100000");
161
         constant test_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000001100");
162
         constant remain_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000000100");
163
         constant test_sec0: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA544223478DC");
164
         constant test_sec1: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA543332178DC");
165
         constant test_sec2: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA234234378DC");
166
         constant test_sec3: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA534534578DC");
167
         constant test_id: std_logic_vector(15 downto 0) := std_logic_vector'("0110011001100110");
168
         constant other_id: std_logic_vector(15 downto 0) := std_logic_vector'("0000010001100010");
169
         constant other_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000001110");
170
         constant other_sec: std_logic_vector(55 downto 0) := std_logic_vector'(X"CDC423354634AA");
171
         type input_pattern_array is array (natural range <>) of input_pattern_type;
172
           constant input_patterns : input_pattern_array :=
173
             ( ('1', std_logic_vector'("00000"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec), -- 0 reset
174 17 stvhawes
              ('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec0), -- 0 pre
175
               ('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
              (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0000")),  -- 0 pre
190 15 stvhawes
               (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 1 nothing
191 17 stvhawes
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0000")),  -- 2 sec/set
192
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0001")),  -- 3 sec/set
193
               (std_logic_vector'("00110"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0001")),  -- 4 sec/set
194
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0002")),  -- 5 sec/set
195
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0003")),  -- 6 sec/set
196
               (std_logic_vector'("11111"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 7 bad sec/set (too many)
197
               (std_logic_vector'("11100"), std_logic_vector'("000"), test_px, test_qty, test_sec1, test_id),  -- 8 incoming px
198
               (std_logic_vector'("11110"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 9 incoming px (wrong security)
199
               (std_logic_vector'("11101"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 10incoming px (too low sale price)
200
               (std_logic_vector'("11100"), std_logic_vector'("000"), test_px, remain_qty, test_sec1, test_id) );  -- 11incoming px (part qty)
201 15 stvhawes
   begin
202
        write (l, String'("Exercising search_control"));
203
        writeline (output, l);
204 17 stvhawes
        RX_CLK <= '1';
205
        wait for 1 us;
206 15 stvhawes
 
207
           --  Check each pattern.
208
           for i in input_patterns'range loop
209
              --  Set the inputs.
210
              search_px_valid_i <= input_patterns(i).search_px_valid_i;
211
              search_px_type_i <= input_patterns(i).search_px_type_i;
212
              search_buy_sell_i <= input_patterns(i).search_buy_sell_i;
213
              search_px_i <= input_patterns(i).search_px_i;
214
              search_qty_i <= input_patterns(i).search_qty_i;
215
              search_sec_i <= input_patterns(i).search_sec_i;
216
              --search_id_i <= input_patterns(i).search_id_i;
217 17 stvhawes
              --  Clock once for the results (falling edge)
218
              RX_CLK <= '0';
219
              wait for 1 us;
220
              search_px_valid_i <= '0';
221 15 stvhawes
              --  Check the outputs.
222 16 stvhawes
              res := 0;
223 17 stvhawes
              for r in 0 to 3 loop
224 16 stvhawes
                 if order_px_valid_o = '1' then
225 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;
226
                    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;
227
                    assert order_px_o = output_patterns(i).order_px_o report "search_control_wrapper: test: " & integer'image(i) & " bad px" severity error;
228
                    assert order_qty_o = output_patterns(i).order_qty_o report "search_control_wrapper: test: " & integer'image(i) & " bad qty" severity error;
229
                    assert order_sec_o = output_patterns(i).order_sec_o report "search_control_wrapper: test: " & integer'image(i) & " bad sec" severity error;
230
                    assert order_id_o = output_patterns(i).order_id_o report "search_control_wrapper: test: " & integer'image(i) & " bad id" severity error;
231 16 stvhawes
                    res := res + 1;
232
                 end if;
233 17 stvhawes
                 --  Clock up
234
                 RX_CLK <= '1';
235
                 wait for 1 us;
236 16 stvhawes
                 RX_CLK <= '0';
237 17 stvhawes
                 wait for 1 us;
238 16 stvhawes
              end loop;
239 17 stvhawes
              assert res = 1 report "search_control_wrapper: test: " & integer'image(i) & " wrong number of results from input pattern message" severity error;
240 16 stvhawes
 
241 17 stvhawes
              RX_CLK <= '1';
242
              wait for 1 us;
243 15 stvhawes
           end loop;
244
 
245
        write (l, String'("Done search_control"));
246
        writeline (output, l);
247
 
248
        wait;
249
        end process;
250
     end behaviour;
251
 

powered by: WebSVN 2.1.0

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