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 15

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
   begin
104
        search_control_0: search_control
105
           generic map ( searchitems => 3 )
106
           port map (
107
              RX_CLK => RX_CLK,
108
           -- control flag(s) on the incoming bus
109
              search_px_valid_i => search_px_valid_i,
110
           -- pxdata: in price_packet
111
              search_px_type_i => search_px_type_i,
112
              search_buy_sell_i => search_buy_sell_i,
113
              search_px_i => search_px_i,
114
              search_qty_i => search_qty_i,
115
              search_sec_i => search_sec_i,
116
              search_id_i => search_id_i,
117
           -- pxdata: out price_packet
118
              order_px_type_o => order_px_type_o,
119
              order_buy_sell_o => order_buy_sell_o,
120
              order_px_o => order_px_o,
121
              order_qty_o => order_qty_o,
122
              order_sec_o => order_sec_o,
123
              order_id_o => order_id_o
124
           );
125
   process
126
        variable l : line;
127
 
128
        type input_pattern_type is record
129
           -- control flag(s) on the incoming bus
130
              search_px_valid_i: std_logic;
131
           -- pxdata: in price_packet
132
              search_px_type_i: std_logic_vector(4 downto 0);
133
              search_buy_sell_i: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
134
              search_px_i: std_logic_vector(15 downto 0);     -- price
135
              search_qty_i: std_logic_vector(15 downto 0);    -- quantity
136
              search_sec_i: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
137
              -- search_id_i: std_logic_vector(15 downto 0);    -- unique/identifier/counter
138
         end record;
139
         type output_pattern_type is record
140
            -- pxdata: out price_packet
141
              order_px_type_o: std_logic_vector(4 downto 0);
142
              order_buy_sell_o: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
143
              order_px_o: std_logic_vector(15 downto 0);     -- price
144
              order_qty_o: std_logic_vector(15 downto 0);    -- quantity
145
              order_sec_o: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
146
              order_id_o: std_logic_vector(15 downto 0);      -- unique/identifier/counter
147
         end record;
148
 
149
         --  The patterns to apply.
150
         constant zz_px: std_logic_vector(15 downto 0) := (others => 'Z');
151
         constant zz_qty: std_logic_vector(15 downto 0) := (others => 'Z');
152
         constant zz_sec: std_logic_vector(55 downto 0) := (others => 'Z');
153
         constant zz_id: std_logic_vector(15 downto 0) := (others => 'Z');
154
         constant set_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000010000");
155
         constant test_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000011100000");
156
         constant test_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000001100");
157
         constant remain_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000000100");
158
         constant test_sec0: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA544223478DC");
159
         constant test_sec1: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA543332178DC");
160
         constant test_sec2: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA234234378DC");
161
         constant test_sec3: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA534534578DC");
162
         constant test_id: std_logic_vector(15 downto 0) := std_logic_vector'("0110011001100110");
163
         constant other_id: std_logic_vector(15 downto 0) := std_logic_vector'("0000010001100010");
164
         constant other_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000001110");
165
         constant other_sec: std_logic_vector(55 downto 0) := std_logic_vector'(X"CDC423354634AA");
166
         type input_pattern_array is array (natural range <>) of input_pattern_type;
167
           constant input_patterns : input_pattern_array :=
168
             ( ('1', std_logic_vector'("00000"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec), -- 0 reset
169
               ('0', std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec), -- 1 nothing
170
               ('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec0),  -- 2 sec/set
171
               ('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec1),  -- 3 sec/set
172
               ('1', std_logic_vector'("01010"), std_logic_vector'("111"), test_px, set_qty, test_sec2),  -- 4 sec/set
173
               ('1', std_logic_vector'("01010"), std_logic_vector'("000"), test_px, set_qty, test_sec3),  -- 5 too many sec/set 
174
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1),   -- 6 incoming px 
175
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, zz_qty, other_sec),   -- 7 incoming px (wrong security)
176
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), other_px, test_qty, test_sec1),   -- 8 incoming px (too low sale price)
177
               ('1', std_logic_vector'("11100"), std_logic_vector'("111"), test_px, test_qty, test_sec1) ); -- 9 incoming px (part qty)
178
         type output_pattern_array is array (natural range <>) of output_pattern_type;
179
           constant output_patterns : output_pattern_array :=
180
             ( (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 0 reset
181
               (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 1 nothing
182
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0001")),  -- 2 sec/set
183
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0002")),  -- 3 sec/set
184
               (std_logic_vector'("01010"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, std_logic_vector'(X"0003")),  -- 4 sec/set
185
               (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 5 bad sec/set (too many)
186
               (std_logic_vector'("11100"), std_logic_vector'("000"), test_px, test_qty, test_sec1, test_id),  -- 6 incoming px
187
               (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 7 incoming px (wrong security)
188
               (std_logic_vector'("11101"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- 8 incoming px (too low sale price)
189
               (std_logic_vector'("11100"), std_logic_vector'("000"), test_px, remain_qty, test_sec1, test_id) );  -- 9 incoming px (part qty)
190
 
191
   begin
192
        write (l, String'("Exercising search_control"));
193
        writeline (output, l);
194
        RX_CLK <= '0';
195
        wait for 1 ns;
196
 
197
           --  Check each pattern.
198
           for i in input_patterns'range loop
199
              --  Set the inputs.
200
              search_px_valid_i <= input_patterns(i).search_px_valid_i;
201
              search_px_type_i <= input_patterns(i).search_px_type_i;
202
              search_buy_sell_i <= input_patterns(i).search_buy_sell_i;
203
              search_px_i <= input_patterns(i).search_px_i;
204
              search_qty_i <= input_patterns(i).search_qty_i;
205
              search_sec_i <= input_patterns(i).search_sec_i;
206
              --search_id_i <= input_patterns(i).search_id_i;
207
              --  Clock once for the results.
208
              RX_CLK <= '1';
209
              wait for 1 ns;
210
              --  Check the outputs.
211
              write(l, i);
212
              writeline (output, l);
213
              assert order_px_type_o = output_patterns(i).order_px_type_o report "search_item_wrapper: bad px type" severity error;
214
              assert order_buy_sell_o = output_patterns(i).order_buy_sell_o report "search_item_wrapper: bad buy_sell" severity error;
215
              assert order_px_o = output_patterns(i).order_px_o report "search_item_wrapper: bad px" severity error;
216
              assert order_qty_o = output_patterns(i).order_qty_o report "search_item_wrapper: bad qty" severity error;
217
              assert order_sec_o = output_patterns(i).order_sec_o report "search_item_wrapper: bad sec" severity error;
218
              assert order_id_o = output_patterns(i).order_id_o report "search_item_wrapper: bad id" severity error;
219
              --  Clock down.
220
              RX_CLK <= '0';
221
              wait for 1 ns;
222
              search_px_valid_i <= '0';
223
              RX_CLK <= '1';
224
              wait for 1 ns;
225
              RX_CLK <= '0';
226
              wait for 1 ns;
227
           end loop;
228
      --     assert false report "end of test" severity note;
229
 
230
        write (l, String'("Done search_control"));
231
        writeline (output, l);
232
 
233
        wait;
234
        end process;
235
     end behaviour;
236
 

powered by: WebSVN 2.1.0

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