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 16

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
               ('0', std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec), -- 1 nothing
175
               ('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec0),  -- 2 sec/set
176
               ('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec1),  -- 3 sec/set
177
               ('1', std_logic_vector'("01010"), std_logic_vector'("111"), test_px, set_qty, test_sec2),  -- 4 sec/set
178
               ('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec3),  -- 5 too many sec/set 
179
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1),   -- 6 incoming px 
180
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, zz_qty, other_sec),   -- 7 incoming px (wrong security)
181
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), other_px, test_qty, test_sec1),   -- 8 incoming px (too low sale price)
182
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1) ); -- 9 incoming px (part qty)
183
         type output_pattern_array is array (natural range <>) of output_pattern_type;
184
           constant output_patterns : output_pattern_array :=
185
             ( (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 0 reset
186
               (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 1 nothing
187
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0001")),  -- 2 sec/set
188
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0002")),  -- 3 sec/set
189
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0003")),  -- 4 sec/set
190 16 stvhawes
               (std_logic_vector'("11111"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 5 bad sec/set (too many)
191 15 stvhawes
               (std_logic_vector'("11100"), std_logic_vector'("000"), test_px, test_qty, test_sec1, test_id),  -- 6 incoming px
192 16 stvhawes
               (std_logic_vector'("11110"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 7 incoming px (wrong security)
193 15 stvhawes
               (std_logic_vector'("11101"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 8 incoming px (too low sale price)
194
               (std_logic_vector'("11100"), std_logic_vector'("000"), test_px, remain_qty, test_sec1, test_id) );  -- 9 incoming px (part qty)
195
   begin
196
        write (l, String'("Exercising search_control"));
197
        writeline (output, l);
198
        RX_CLK <= '0';
199
        wait for 1 ns;
200
 
201
           --  Check each pattern.
202
           for i in input_patterns'range loop
203
              --  Set the inputs.
204
              search_px_valid_i <= input_patterns(i).search_px_valid_i;
205
              search_px_type_i <= input_patterns(i).search_px_type_i;
206
              search_buy_sell_i <= input_patterns(i).search_buy_sell_i;
207
              search_px_i <= input_patterns(i).search_px_i;
208
              search_qty_i <= input_patterns(i).search_qty_i;
209
              search_sec_i <= input_patterns(i).search_sec_i;
210
              --search_id_i <= input_patterns(i).search_id_i;
211
              --  Clock once for the results.
212
              RX_CLK <= '1';
213
              wait for 1 ns;
214
              --  Check the outputs.
215 16 stvhawes
              res := 0;
216
              for r in 0 to 4 loop
217
                 if order_px_valid_o = '1' then
218
                    write(l, i);
219
                    writeline (output, l);
220
                    assert order_px_type_o = output_patterns(i).order_px_type_o report "search_control_wrapper: bad px type" severity error;
221
                    assert order_buy_sell_o = output_patterns(i).order_buy_sell_o report "search_control_wrapper: bad buy_sell" severity error;
222
                    assert order_px_o = output_patterns(i).order_px_o report "search_control_wrapper: bad px" severity error;
223
                    assert order_qty_o = output_patterns(i).order_qty_o report "search_control_wrapper: bad qty" severity error;
224
                    assert order_sec_o = output_patterns(i).order_sec_o report "search_control_wrapper: bad sec" severity error;
225
                    assert order_id_o = output_patterns(i).order_id_o report "search_control_wrapper: bad id" severity error;
226
                    res := res + 1;
227
                 end if;
228
                 --  Clock down.
229
                 RX_CLK <= '0';
230
                 wait for 1 ns;
231
                 search_px_valid_i <= '0';
232
                 RX_CLK <= '1';
233
                 wait for 1 ns;
234
              end loop;
235
              assert res = 1 report "search_control_wrapper: wrong number of results from input pattern message" severity error;
236
 
237 15 stvhawes
              RX_CLK <= '0';
238
              wait for 1 ns;
239
           end loop;
240
      --     assert false report "end of test" severity note;
241
 
242
        write (l, String'("Done search_control"));
243
        writeline (output, l);
244
 
245
        wait;
246
        end process;
247
     end behaviour;
248
 

powered by: WebSVN 2.1.0

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