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

Subversion Repositories open_hitter

[/] [open_hitter/] [trunk/] [bench/] [vhdl/] [search_item_wrapper.vhd] - Blame information for rev 13

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

Line No. Rev Author Line
1 12 stvhawes
--////////////////////////////////////////////////////////////////////
2
--//                                                              ////
3
--// search_item.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_item_wrapper is
58
end search_item_wrapper;
59
 
60
architecture behaviour of search_item_wrapper is
61
   component search_item
62
   port (
63
        RX_CLK: in std_logic;
64
        -- control flag(s) on the incoming bus
65
           b1_px_valid: in std_logic;
66
        -- pxdata: in price_packet
67
           b1_px_type: in std_logic_vector(4 downto 0);
68
           b1_buy_sell: in std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
69
           b1_px: in std_logic_vector(15 downto 0);     -- price
70
           b1_qty: in std_logic_vector(15 downto 0);    -- quantity
71
           b1_sec: in std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
72
           b1_id: in std_logic_vector(15 downto 0);    -- unique/identifier/counter
73
        -- pxdata: out price_packet
74
           b2_px_type: out std_logic_vector(4 downto 0);
75
           b2_buy_sell: out std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
76
           b2_px: out std_logic_vector(15 downto 0);     -- price
77
           b2_qty: out std_logic_vector(15 downto 0);    -- quantity
78
           b2_sec: out std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
79
           b2_id: out std_logic_vector(15 downto 0)      -- unique/identifier/counter
80
   );
81
   end component;
82
   for search_item_0: search_item use entity work.search_item;
83
        signal RX_CLK: std_logic;
84
        -- control flag(s) on the incoming bus
85
           signal b1_px_valid: std_logic;
86
        -- pxdata: in price_packet
87
           signal b1_px_type: std_logic_vector(4 downto 0);
88
           signal b1_buy_sell: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
89
           signal b1_px: std_logic_vector(15 downto 0);     -- price
90
           signal b1_qty: std_logic_vector(15 downto 0);    -- quantity
91
           signal b1_sec: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
92
           signal b1_id: std_logic_vector(15 downto 0);    -- unique/identifier/counter
93
        -- pxdata: out price_packet
94
           signal b2_px_type: std_logic_vector(4 downto 0);
95
           signal b2_buy_sell: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
96
           signal b2_px: std_logic_vector(15 downto 0);     -- price
97
           signal b2_qty: std_logic_vector(15 downto 0);    -- quantity
98
           signal b2_sec: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
99
           signal b2_id: std_logic_vector(15 downto 0);     -- unique/identifier/counter
100
   begin
101
        search_item_0: search_item port map (
102
           RX_CLK => RX_CLK,
103
           -- control flag(s) on the incoming bus
104
              b1_px_valid => b1_px_valid,
105
           -- pxdata: in price_packet
106
              b1_px_type => b1_px_type,
107
              b1_buy_sell => b1_buy_sell,
108
              b1_px => b1_px,
109
              b1_qty => b1_qty,
110
              b1_sec => b1_sec,
111
              b1_id => b1_id,
112
           -- pxdata: out price_packet
113
              b2_px_type => b2_px_type,
114
              b2_buy_sell => b2_buy_sell,
115
              b2_px => b2_px,
116
              b2_qty => b2_qty,
117
              b2_sec => b2_sec,
118
              b2_id => b2_id
119
           );
120
   process
121
        variable l : line;
122
 
123
        type input_pattern_type is record
124
           -- control flag(s) on the incoming bus
125
              b1_px_valid: std_logic;
126
           -- pxdata: in price_packet
127
              b1_px_type: std_logic_vector(4 downto 0);
128
              b1_buy_sell: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
129
              b1_px: std_logic_vector(15 downto 0);     -- price
130
              b1_qty: std_logic_vector(15 downto 0);    -- quantity
131
              b1_sec: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
132
              b1_id: std_logic_vector(15 downto 0);    -- unique/identifier/counter
133
         end record;
134
         type output_pattern_type is record
135
            -- pxdata: out price_packet
136
              b2_px_type: std_logic_vector(4 downto 0);
137
              b2_buy_sell: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
138
              b2_px: std_logic_vector(15 downto 0);     -- price
139
              b2_qty: std_logic_vector(15 downto 0);    -- quantity
140
              b2_sec: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
141
              b2_id: std_logic_vector(15 downto 0);      -- unique/identifier/counter
142
         end record;
143
 
144
         --  The patterns to apply.
145 13 stvhawes
         constant zz_px: std_logic_vector(15 downto 0) := (others => 'Z');
146
         constant zz_qty: std_logic_vector(15 downto 0) := (others => 'Z');
147
         constant zz_sec: std_logic_vector(55 downto 0) := (others => 'Z');
148
         constant zz_id: std_logic_vector(15 downto 0) := (others => 'Z');
149
         constant set_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000010000");
150
         constant test_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000011100000");
151
         constant test_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000001100");
152
         constant remain_qty: std_logic_vector(15 downto 0) := std_logic_vector'("0000000000000100");
153
         constant test_sec: std_logic_vector(55 downto 0) := std_logic_vector'(X"ABA543332178DC");
154
         constant test_id: std_logic_vector(15 downto 0) := std_logic_vector'("0110011001100110");
155
         constant other_px: std_logic_vector(15 downto 0) := std_logic_vector'("0000000110000000");
156
         constant other_sec: std_logic_vector(55 downto 0) := std_logic_vector'(X"CDC423354634AA");
157 12 stvhawes
         type input_pattern_array is array (natural range <>) of input_pattern_type;
158 13 stvhawes
           constant input_patterns : input_pattern_array :=
159
             ( ('1', std_logic_vector'("00000"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- reset
160
               ('0', std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id), -- nothing
161
               ('1', std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec, zz_id),  -- sec/set
162
               ('1', std_logic_vector'("00101"), std_logic_vector'("111"), test_px, test_qty, test_sec, zz_id),   -- incoming px 
163
               ('1', std_logic_vector'("00101"), std_logic_vector'("111"), test_px, zz_qty, other_sec, zz_id),   -- incoming px (wrong security)
164
               ('1', std_logic_vector'("00101"), std_logic_vector'("111"), other_px, test_qty, test_sec, zz_id),   -- incoming px (hight price)
165
               ('0', std_logic_vector'("00101"), std_logic_vector'("111"), test_px, test_qty, test_sec, zz_id) ); -- incoming px (part qty)
166 12 stvhawes
         type output_pattern_array is array (natural range <>) of output_pattern_type;
167 13 stvhawes
           constant output_patterns : output_pattern_array :=
168
             ( (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- reset
169
               (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- nothing
170
               (std_logic_vector'("00110"), std_logic_vector'("000"), test_px, set_qty, test_sec, test_id),  -- sec/set
171
               (std_logic_vector'("00101"), std_logic_vector'("000"), test_px, test_qty, test_sec, test_id),  -- incoming px
172
               (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- incoming px (wrong security)
173
               (std_logic_vector'("ZZZZZ"), std_logic_vector'("ZZZ"), zz_px, zz_qty, zz_sec, zz_id),  -- incoming px (high price)
174
               (std_logic_vector'("00101"), std_logic_vector'("000"), test_px, remain_qty, test_sec, test_id) );  -- incoming px (part qty)
175 12 stvhawes
 
176
   begin
177
        write (l, String'("Exercising search_item"));
178
        writeline (output, l);
179 13 stvhawes
        RX_CLK <= '0';
180
        wait for 1 ns;
181 12 stvhawes
 
182
           --  Check each pattern.
183 13 stvhawes
           for i in input_patterns'range loop
184 12 stvhawes
              --  Set the inputs.
185 13 stvhawes
              b1_px_valid <= input_patterns(i).b1_px_valid;
186
              b1_px_type <= input_patterns(i).b1_px_type;
187
              b1_buy_sell<= input_patterns(i).b1_buy_sell;
188
              b1_px <= input_patterns(i).b1_px;
189
              b1_qty <= input_patterns(i).b1_qty;
190
              b1_sec <= input_patterns(i).b1_sec;
191
              b1_id <= input_patterns(i).b1_id;
192
              --  Clock once for the results.
193
              RX_CLK <= '1';
194
              wait for 1 ns;
195 12 stvhawes
              --  Check the outputs.
196 13 stvhawes
              write(l, i);
197
              writeline (output, l);
198
              assert b2_px_type = output_patterns(i).b2_px_type report "search_item_wrapper: bad px type" severity error;
199
              assert b2_buy_sell = output_patterns(i).b2_buy_sell report "search_item_wrapper: bad buy_sell" severity error;
200
              assert b2_px = output_patterns(i).b2_px report "search_item_wrapper: bad px" severity error;
201
              assert b2_qty = output_patterns(i).b2_qty report "search_item_wrapper: bad qty" severity error;
202
              assert b2_sec = output_patterns(i).b2_sec report "search_item_wrapper: bad sec" severity error;
203
              assert b2_id = output_patterns(i).b2_id report "search_item_wrapper: bad id" severity error;
204
              --  Clock down.
205
              RX_CLK <= '0';
206
              wait for 1 ns;
207
           end loop;
208 12 stvhawes
      --     assert false report "end of test" severity note;
209
 
210
        write (l, String'("Done search_item"));
211
        writeline (output, l);
212
 
213
        wait;
214
        end process;
215
     end behaviour;
216
 

powered by: WebSVN 2.1.0

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