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 17

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

powered by: WebSVN 2.1.0

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