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

Subversion Repositories pltbutils

[/] [pltbutils/] [trunk/] [bench/] [vhdl/] [tb_pltbutils.vhd] - Blame information for rev 99

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

Line No. Rev Author Line
1 2 pela
----------------------------------------------------------------------
2
----                                                              ----
3
---- PlTbUtils Testbench                                          ----
4
----                                                              ----
5
---- This file is part of the PlTbUtils project                   ----
6
---- http://opencores.org/project,pltbutils                       ----
7
----                                                              ----
8
---- Description                                                  ----
9
---- PlTbUtils is a collection of functions, procedures and       ----
10
---- components for easily creating stimuli and checking response ----
11
---- in automatic self-checking testbenches.                      ----
12
----                                                              ----
13
---- This is a testbench file, which is used to verify            ----
14
---- - pltbutils_func_pkg                                         ----
15
---- - pltbutils_comp                                           ----
16
---- This testbench is NOT selfchecking or automatic.             ----
17
---- Manually check the transcript and waveform, when simulating. ----
18
---- It prints some informative text in the transcript, to help   ----
19
---- with the manual inspection.                                  ----
20
----                                                              ----
21
----                                                              ----
22
---- To Do:                                                       ----
23
---- -                                                            ----
24
----                                                              ----
25
---- Author(s):                                                   ----
26 97 pela
---- - Per Larsson, pela.opencores@gmail.com                      ----
27 2 pela
----                                                              ----
28
----------------------------------------------------------------------
29
----                                                              ----
30 38 pela
---- Copyright (C) 2013-2014 Authors and OPENCORES.ORG            ----
31 2 pela
----                                                              ----
32
---- This source file may be used and distributed without         ----
33
---- restriction provided that this copyright statement is not    ----
34
---- removed from the file and that any derivative work contains  ----
35
---- the original copyright notice and the associated disclaimer. ----
36
----                                                              ----
37
---- This source file is free software; you can redistribute it   ----
38
---- and/or modify it under the terms of the GNU Lesser General   ----
39
---- Public License as published by the Free Software Foundation; ----
40
---- either version 2.1 of the License, or (at your option) any   ----
41
---- later version.                                               ----
42
----                                                              ----
43
---- This source is distributed in the hope that it will be       ----
44
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
45
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
46
---- PURPOSE. See the GNU Lesser General Public License for more  ----
47
---- details.                                                     ----
48
----                                                              ----
49
---- You should have received a copy of the GNU Lesser General    ----
50
---- Public License along with this source; if not, download it   ----
51
---- from http://www.opencores.org/lgpl.shtml                     ----
52
----                                                              ----
53
----------------------------------------------------------------------
54
library ieee;
55
use ieee.std_logic_1164.all;
56
use ieee.numeric_std.all;
57
use std.textio.all;
58
use work.txt_util.all;
59
use work.pltbutils_func_pkg.all;
60
use work.pltbutils_comp_pkg.all;
61
 
62
entity tb_pltbutils is
63
  generic (
64
    G_CLK_PERIOD  : time := 10 ns
65
  );
66
end entity tb_pltbutils;
67
 
68
architecture bhv of tb_pltbutils is
69
 
70
  -- Simulation status- and control signals
71 38 pela
  -- for accessing .stop_sim and for viewing in waveform window
72
  signal pltbs          : pltbs_t := C_PLTBS_INIT;
73 2 pela
 
74
  -- Expected number of checks and number of errors to be reported
75
  -- by pltbutils. The counting is made by variables, but the
76
  -- variables are copied to these signals for easier viewing in
77
  -- the simulator's waveform window.
78
  signal expected_checks_cnt : integer := 0;
79
  signal expected_errors_cnt : integer := 0;
80
 
81
  -- DUT stimuli and response signals
82
  signal clk            : std_logic;
83
  signal clk_cnt        : integer := 0;
84
  signal clk_cnt_clr    : boolean := false;
85
  signal s_i            : integer;
86
  signal s_sl           : std_logic;
87
  signal s_slv          : std_logic_vector(7 downto 0);
88
  signal s_u            : unsigned(7 downto 0);
89
  signal s_s            : unsigned(7 downto 0);
90 99 pela
  signal s_b            : boolean;
91
  signal s_time         : time;
92 89 pela
  signal s_str_exp      : string(1 to 44);
93
  signal s_str1         : string(1 to 44);
94
  signal s_str2         : string(1 to 44);
95
  signal s_str3         : string(1 to 43);
96
  signal s_str4         : string(1 to 45);
97 2 pela
 
98
begin
99
 
100
  -- Clock generator
101
  clkgen0 : pltbutils_clkgen
102
    generic map(
103
      G_PERIOD      => G_CLK_PERIOD
104
    )
105
    port map(
106
      clk_o         => clk,
107 38 pela
      stop_sim_i    => pltbs.stop_sim
108 2 pela
    );
109
 
110
  -- Clock cycle counter
111
  p_clk_cnt : process (clk_cnt_clr, clk)
112
  begin
113
    if clk_cnt_clr then
114
      clk_cnt <= 0;
115
    elsif rising_edge(clk) then
116
      clk_cnt <= clk_cnt + 1;
117
    end if;
118
  end process p_clk_cnt;
119
 
120
  -- Testcase
121
  p_tc1 : process
122 38 pela
    variable pltbv                 : pltbv_t := C_PLTBV_INIT;
123 25 pela
    variable v_expected_tests_cnt  : integer := 0;
124 2 pela
    variable v_expected_checks_cnt : integer := 0;
125
    variable v_expected_errors_cnt : integer := 0;
126
  begin
127
 
128
    print("<Testing startsim()>");
129 38 pela
    startsim("tc1", pltbv, pltbs);
130 2 pela
    wait until rising_edge(clk);
131 38 pela
    assert (pltbv.test_num = 0) and (pltbs.test_num  = 0)
132 2 pela
      report "test_num after startsim() incorrect"
133
      severity error;
134
    print("<Done testing startsim()>");
135
 
136 25 pela
    print("<Testing starttest() with auto-incrementing test_num>");
137 38 pela
    starttest("TestName1", pltbv, pltbs);
138 25 pela
    v_expected_tests_cnt := v_expected_tests_cnt + 1;
139 2 pela
    wait until rising_edge(clk);
140 38 pela
    assert (pltbv.test_num = 1) and (pltbs.test_num  = 1)
141 25 pela
      report "test_num after starttest() incorrect"
142 2 pela
      severity error;
143 25 pela
    print("<Done testing starttest() with auto-incrementing test_num()>");
144 2 pela
 
145 25 pela
    print("<Testing endtest()>");
146 38 pela
    endtest(pltbv, pltbs);
147 25 pela
    print("<Done testing endtest()>");
148
 
149
    print("<Testing starttest() with explicit test_num>");
150 38 pela
    starttest(3, "TestName2", pltbv, pltbs);
151 25 pela
    v_expected_tests_cnt := v_expected_tests_cnt + 1;
152 2 pela
    wait until rising_edge(clk);
153 38 pela
    assert (pltbv.test_num = 3) and (pltbs.test_num  = 3)
154 2 pela
      report "test_num after startsim() incorrect"
155
      severity error;
156 25 pela
    print("<Done testing starttest() with explicit test_num>");
157 2 pela
 
158
    print("<Testing waitclks()>");
159
    clk_cnt_clr <= true;
160
    wait until rising_edge(clk);
161
    clk_cnt_clr <= false;
162
    wait until rising_edge(clk);
163 38 pela
    waitclks(10, clk, pltbv, pltbs);
164 2 pela
    assert clk_cnt = 10
165
      report "clk_cnt after waitclks() incorrect:" & integer'image(clk_cnt) &
166
             " expected:" & integer'image(10)
167
      severity error;
168
    print("<Done testing waitclks()>");
169
 
170
    print("<Testing check() integer>");
171
    s_i <= 0;
172
    wait until rising_edge(clk);
173 38 pela
    check("Testing correct integer = 0", s_i, 0, pltbv, pltbs);
174 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
175
    expected_checks_cnt   <= v_expected_checks_cnt;
176
    s_i <= 1;
177
    wait until rising_edge(clk);
178 38 pela
    check("Testing correct integer = 1", s_i, 1, pltbv, pltbs);
179 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
180
    expected_checks_cnt   <= v_expected_checks_cnt;
181
    s_i <= 17;
182
    wait until rising_edge(clk);
183 38 pela
    check("Testing incorrect integer = 17", s_i, 18, pltbv, pltbs);
184 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
185
    expected_checks_cnt   <= v_expected_checks_cnt;
186
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
187
    expected_errors_cnt   <= v_expected_errors_cnt;
188
    s_i <= -1;
189
    wait until rising_edge(clk);
190 38 pela
    check("Testing negative integer = -1", s_i, -1, pltbv, pltbs);
191 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
192 99 pela
    expected_checks_cnt   <= v_expected_checks_cnt;
193 2 pela
    print("<Done testing check() integer>");
194
 
195
    print("<Testing check() std_logic>");
196
    s_sl <= '0';
197
    wait until rising_edge(clk);
198 38 pela
    check("Testing correct std_logic = '0'", s_sl, '0', pltbv, pltbs);
199 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
200
    expected_checks_cnt   <= v_expected_checks_cnt;
201
    s_sl <= '1';
202
    wait until rising_edge(clk);
203 38 pela
    check("Testing correct std_logic = '1'", s_sl, '1', pltbv, pltbs);
204 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
205
    expected_checks_cnt   <= v_expected_checks_cnt;
206
    s_sl <= 'X';
207
    wait until rising_edge(clk);
208 38 pela
    check("Testing incorrect std_logic = '1'", s_sl, '1', pltbv, pltbs);
209 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
210
    expected_checks_cnt   <= v_expected_checks_cnt;
211
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
212
    expected_errors_cnt   <= v_expected_errors_cnt;
213
    print("<Done testing check() std_logic>");
214
 
215
    print("<Testing check() std_logic against integer>");
216
    s_sl <= '0';
217
    wait until rising_edge(clk);
218 38 pela
    check("Testing correct std_logic = '0'", s_sl, 0, pltbv, pltbs);
219 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
220
    expected_checks_cnt   <= v_expected_checks_cnt;
221
    s_sl <= '1';
222
    wait until rising_edge(clk);
223 38 pela
    check("Testing correct std_logic = '1'", s_sl, 1, pltbv, pltbs);
224 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
225
    expected_checks_cnt   <= v_expected_checks_cnt;
226
    s_sl <= 'X';
227
    wait until rising_edge(clk);
228 38 pela
    check("Testing incorrect std_logic = '1'", s_sl, 1, pltbv, pltbs);
229 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
230
    expected_checks_cnt   <= v_expected_checks_cnt;
231
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
232
    expected_errors_cnt   <= v_expected_errors_cnt;
233
    s_sl <= '1';
234
    wait until rising_edge(clk);
235 38 pela
    check("Testing std_logic = '1' with incorrect expected", s_sl, 2, pltbv, pltbs);
236 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
237
    expected_checks_cnt   <= v_expected_checks_cnt;
238
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
239
    expected_errors_cnt   <= v_expected_errors_cnt;
240
    print("<Done testing check() std_logic against integer>");
241
 
242
    print("<Testing check() std_logic_vector>");
243
    s_slv <= x"00";
244
    wait until rising_edge(clk);
245 38 pela
    check("Testing correct std_logic_vector = x'00'", s_slv, x"00", pltbv, pltbs);
246 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
247
    expected_checks_cnt   <= v_expected_checks_cnt;
248
    s_slv <= x"47";
249
    wait until rising_edge(clk);
250 38 pela
    check("Testing correct std_logic_vector = x'47'", s_slv, x"47", pltbv, pltbs);
251 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
252
    expected_checks_cnt   <= v_expected_checks_cnt;
253
    s_slv <= x"11";
254
    wait until rising_edge(clk);
255 38 pela
    check("Testing incorrect std_logic_vector = x'11'", s_slv, x"10", pltbv, pltbs);
256 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
257
    expected_checks_cnt   <= v_expected_checks_cnt;
258
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
259
    expected_errors_cnt   <= v_expected_errors_cnt;
260
    print("<Done testing check() std_logic_vector>");
261
 
262
    print("<Testing check() std_logic_vector with mask>");
263
    s_slv <= x"47";
264
    wait until rising_edge(clk);
265 38 pela
    check("Testing std_logic_vector = x'47' with correct nibble mask", s_slv, x"57", x"0F", pltbv, pltbs);
266 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
267
    expected_checks_cnt   <= v_expected_checks_cnt;
268
    s_slv <= x"47";
269
    wait until rising_edge(clk);
270 38 pela
    check("Testing std_logic_vector = x'47' with incorrect nibble mask", s_slv, x"57", x"F0", pltbv, pltbs);
271 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
272
    expected_checks_cnt   <= v_expected_checks_cnt;
273
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
274
    expected_errors_cnt   <= v_expected_errors_cnt;
275
    print("<Done testing check() std_logic_vector with mask>");
276
 
277
    print("<Testing check() std_logic_vector against integer>");
278
    s_slv <= x"00";
279
    wait until rising_edge(clk);
280 38 pela
    check("Testing correct std_logic_vector = x'00'", s_slv, 0, pltbv, pltbs);
281 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
282
    expected_checks_cnt   <= v_expected_checks_cnt;
283
    s_slv <= x"47";
284
    wait until rising_edge(clk);
285 38 pela
    check("Testing correct std_logic_vector = x'47'", s_slv, 16#47#, pltbv, pltbs);
286 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
287
    expected_checks_cnt   <= v_expected_checks_cnt;
288
    s_slv <= x"11";
289
    wait until rising_edge(clk);
290 38 pela
    check("Testing incorrect std_logic_vector = x'11'", s_slv, 16#10#, pltbv, pltbs);
291 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
292
    expected_checks_cnt   <= v_expected_checks_cnt;
293
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
294
    expected_errors_cnt   <= v_expected_errors_cnt;
295
    s_slv <= x"FF";
296
    wait until rising_edge(clk);
297 38 pela
    check("Testing negative std_logic_vector = x'FF'", s_slv, -1, pltbv, pltbs);
298 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
299
    expected_checks_cnt   <= v_expected_checks_cnt;
300
    print("<Done testing check() std_logic_vector against integer>");
301
 
302
    print("<Testing check() std_logic_vector with mask against integer>");
303
    s_slv <= x"47";
304
    wait until rising_edge(clk);
305 38 pela
    check("Testing std_logic_vector = x'47' with correct nibble mask", s_slv, 16#57#, x"0F", pltbv, pltbs);
306 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
307
    expected_checks_cnt   <= v_expected_checks_cnt;
308
    s_slv <= x"47";
309
    wait until rising_edge(clk);
310 38 pela
    check("Testing std_logic_vector = x'47' with incorrect nibble mask", s_slv, 16#57#, x"F0", pltbv, pltbs);
311 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
312
    expected_checks_cnt   <= v_expected_checks_cnt;
313
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
314
    expected_errors_cnt   <= v_expected_errors_cnt;
315
    print("<Done testing check() std_logic_vector with mask against integer>");
316
 
317
    print("<Testing check() unsigned>");
318
    s_u <= x"00";
319
    wait until rising_edge(clk);
320 38 pela
    check("Testing correct unsigned = x'00'", s_u, x"00", pltbv, pltbs);
321 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
322
    expected_checks_cnt   <= v_expected_checks_cnt;
323
    s_u <= x"47";
324
    wait until rising_edge(clk);
325 38 pela
    check("Testing correct unsigned = x'47'", s_u, x"47", pltbv, pltbs);
326 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
327
    expected_checks_cnt   <= v_expected_checks_cnt;
328
    s_u <= x"11";
329
    wait until rising_edge(clk);
330 38 pela
    check("Testing incorrect unsigned = x'11'", s_u, x"10", pltbv, pltbs);
331 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
332
    expected_checks_cnt   <= v_expected_checks_cnt;
333
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
334
    expected_errors_cnt   <= v_expected_errors_cnt;
335
    print("<Done testing check() unsigned>");
336
 
337
    print("<Testing check() unsigned against integer>");
338
    s_u <= x"00";
339
    wait until rising_edge(clk);
340 38 pela
    check("Testing correct unsigned = x'00'", s_u, 0, pltbv, pltbs);
341 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
342
    expected_checks_cnt   <= v_expected_checks_cnt;
343
    s_u <= x"47";
344
    wait until rising_edge(clk);
345 38 pela
    check("Testing correct unsigned = x'47'", s_u, 16#47#, pltbv, pltbs);
346 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
347
    expected_checks_cnt   <= v_expected_checks_cnt;
348
    s_u <= x"11";
349
    wait until rising_edge(clk);
350 38 pela
    check("Testing incorrect unsigned = x'11'", s_u, 16#10#, pltbv, pltbs);
351 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
352
    expected_checks_cnt   <= v_expected_checks_cnt;
353
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
354
    expected_errors_cnt   <= v_expected_errors_cnt;
355
    print("<Done testing check() unsigned against integer>");
356
 
357
    print("<Testing check() signed>");
358
    s_s <= x"00";
359
    wait until rising_edge(clk);
360 38 pela
    check("Testing correct signed = x'00'", s_s, x"00", pltbv, pltbs);
361 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
362
    expected_checks_cnt   <= v_expected_checks_cnt;
363
    s_s <= x"47";
364
    wait until rising_edge(clk);
365 38 pela
    check("Testing correct signed = x'47'", s_s, x"47", pltbv, pltbs);
366 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
367
    expected_checks_cnt   <= v_expected_checks_cnt;
368
    s_s <= x"11";
369
    wait until rising_edge(clk);
370 38 pela
    check("Testing incorrect signed = x'11'", s_s, x"10", pltbv, pltbs);
371 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
372
    expected_checks_cnt   <= v_expected_checks_cnt;
373
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
374
    expected_errors_cnt   <= v_expected_errors_cnt;
375
    s_s <= x"FF";
376
    wait until rising_edge(clk);
377 38 pela
    check("Testing negative signed = x'FF'", s_s, x"FF", pltbv, pltbs);
378 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
379
    expected_checks_cnt   <= v_expected_checks_cnt;
380
    print("<Done testing check() signed>");
381
 
382
    print("<Testing check() signed against integer>");
383
    s_s <= x"00";
384
    wait until rising_edge(clk);
385 38 pela
    check("Testing correct signed = x'00'", s_s, 0, pltbv, pltbs);
386 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
387
    expected_checks_cnt   <= v_expected_checks_cnt;
388
    s_s <= x"47";
389
    wait until rising_edge(clk);
390 38 pela
    check("Testing correct signed = x'47'", s_s, 16#47#, pltbv, pltbs);
391 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
392
    expected_checks_cnt   <= v_expected_checks_cnt;
393
    s_s <= x"11";
394
    wait until rising_edge(clk);
395 38 pela
    check("Testing incorrect signed = x'11'", s_s, 16#10#, pltbv, pltbs);
396 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
397
    expected_checks_cnt   <= v_expected_checks_cnt;
398
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
399
    expected_errors_cnt   <= v_expected_errors_cnt;
400
    s_s <= x"FF";
401
    wait until rising_edge(clk);
402 99 pela
    print("NOTE: Skipping test with negative signed. There seem to be a bug in ModelSim.");
403 97 pela
    --print("The following check fails in ModelSim for unknown reason." &
404
    --      " It causes mismatch between expected number of errors" &
405
    --      " and the number presented by endsim()");
406
    --check("Testing negative signed = x'FF'", s_s, -1, pltbv, pltbs);
407
    --v_expected_checks_cnt := v_expected_checks_cnt + 1;    
408
    --expected_checks_cnt   <= v_expected_checks_cnt;
409 99 pela
    print("<Done testing check() signed against integer>");
410 2 pela
 
411 99 pela
    print("<Testing check() boolean>");
412
    s_b <= false;
413
    wait until rising_edge(clk);
414
    check("Testing correct boolean = false", s_b, false, pltbv, pltbs);
415
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
416
    expected_checks_cnt   <= v_expected_checks_cnt;
417
    s_b <= true;
418
    wait until rising_edge(clk);
419
    check("Testing correct boolean = true", s_b, true, pltbv, pltbs);
420
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
421
    expected_checks_cnt   <= v_expected_checks_cnt;
422
    s_b <= false;
423
    wait until rising_edge(clk);
424
    check("Testing incorrect boolean = true", s_b, true, pltbv, pltbs);
425
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
426
    expected_checks_cnt   <= v_expected_checks_cnt;
427
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
428
    expected_errors_cnt   <= v_expected_errors_cnt;
429
    print("<Done testing check() boolean>");
430
 
431
    print("<Testing check() boolean against integer>");
432
    s_b <= false;
433
    wait until rising_edge(clk);
434
    check("Testing correct boolean = false", s_b, 0, pltbv, pltbs);
435
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
436
    expected_checks_cnt   <= v_expected_checks_cnt;
437
    s_b <= true;
438
    wait until rising_edge(clk);
439
    check("Testing correct boolean = true", s_b, 1, pltbv, pltbs);
440
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
441
    expected_checks_cnt   <= v_expected_checks_cnt;
442
    s_b <= false;
443
    wait until rising_edge(clk);
444
    check("Testing incorrect boolean = true", s_b, 1, pltbv, pltbs);
445
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
446
    expected_checks_cnt   <= v_expected_checks_cnt;
447
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
448
    expected_errors_cnt   <= v_expected_errors_cnt;
449
    s_b <= true;
450
    wait until rising_edge(clk);
451
    check("Testing boolean = true with incorrect expected", s_b, 2, pltbv, pltbs);
452
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
453
    expected_checks_cnt   <= v_expected_checks_cnt;
454
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
455
    expected_errors_cnt   <= v_expected_errors_cnt;
456
    print("<Done testing check() boolean against integer>");
457
 
458
    print("<Testing check() time>");
459
    s_time <= 0 sec;
460
    wait until rising_edge(clk);
461
    check("Testing correct time = 0 sec", s_time, 0 sec, pltbv, pltbs);
462
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
463
    expected_checks_cnt   <= v_expected_checks_cnt;
464
    s_time <= 47 ns;
465
    wait until rising_edge(clk);
466
    check("Testing correct time = 47 ns", s_time, 47 ns, pltbv, pltbs);
467
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
468
    expected_checks_cnt   <= v_expected_checks_cnt;
469
    s_time <= 11 us;
470
    wait until rising_edge(clk);
471
    check("Testing incorrect time = 10 us", s_time, 10 us, pltbv, pltbs);
472
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
473
    expected_checks_cnt   <= v_expected_checks_cnt;
474
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
475
    expected_errors_cnt   <= v_expected_errors_cnt;
476
    print("<Done testing check() time>");
477
 
478
    print("<Testing check() time with tolerance>");
479
    s_time <= 0 sec;
480
    wait until rising_edge(clk);
481
    check("Testing correct unsigned = 0 sec +/- 0 sec", s_time, 0 sec, 0 sec, pltbv, pltbs);
482
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
483
    expected_checks_cnt   <= v_expected_checks_cnt;
484
    s_time <= 47 ns - 3 ns;
485
    wait until rising_edge(clk);
486
    check("Testing correct time = 47 ns +/- 5 ns", s_time, 47 ns, 5 ns, pltbv, pltbs);
487
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
488
    expected_checks_cnt   <= v_expected_checks_cnt;
489
    s_time <= 10 us + 7 us;
490
    wait until rising_edge(clk);
491
    check("Testing incorrect time = 10 us +/- 5 us", s_time, 10 us, 5 us, pltbv, pltbs);
492
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
493
    expected_checks_cnt   <= v_expected_checks_cnt;
494
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
495
    expected_errors_cnt   <= v_expected_errors_cnt;
496
    print("<Done testing check() time with tolerance>");
497
 
498 89 pela
    print("<Testing check() string>");
499
    s_str_exp   <= string'("The quick brown fox jumps over the lazy dog.");
500
    s_str1      <= string'("The quick brown fox jumps over the lazy dog.");
501
    s_str2      <= string'("The quick brown dog jumps over the lazy fox.");
502
    s_str3      <= string'("The quick brown fox jumps over the lazy dog");
503
    s_str4      <= string'("The quick brown fox jumps over the lazy dog..");
504
    wait until rising_edge(clk);
505
    check("Testing correct string", s_str1, s_str_exp, pltbv, pltbs);
506
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
507
    expected_checks_cnt   <= v_expected_checks_cnt;
508
    s_s <= x"47";
509
    wait until rising_edge(clk);
510
    check("Testing incorrect string with correct length", s_str2, s_str_exp, pltbv, pltbs);
511
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
512
    expected_checks_cnt   <= v_expected_checks_cnt;
513
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
514
    expected_errors_cnt   <= v_expected_errors_cnt;
515
    s_s <= x"11";
516
    wait until rising_edge(clk);
517
    check("Testing too short string", s_str3, s_str_exp, pltbv, pltbs);
518
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
519
    expected_checks_cnt   <= v_expected_checks_cnt;
520
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
521
    expected_errors_cnt   <= v_expected_errors_cnt;
522
    wait until rising_edge(clk);
523
    check("Testing too long string", s_str4, s_str_exp, pltbv, pltbs);
524
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
525
    expected_checks_cnt   <= v_expected_checks_cnt;
526
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
527
    expected_errors_cnt   <= v_expected_errors_cnt;
528
    print("<Done testing check() string>");
529
 
530 2 pela
    print("<Testing check() boolean expression>");
531
    s_i <= 0;
532
    wait until rising_edge(clk);
533 38 pela
    check("Testing correct boolean expression 0 = 16#00#", s_i = 16#00#, pltbv, pltbs);
534 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
535
    expected_checks_cnt   <= v_expected_checks_cnt;
536
    s_i <= 47;
537
    wait until rising_edge(clk);
538 38 pela
    check("Testing incorrect boolean expression 47 < 16#10#", s_i < 16#10#, pltbv, pltbs);
539 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
540
    expected_checks_cnt   <= v_expected_checks_cnt;
541
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
542
    expected_errors_cnt   <= v_expected_errors_cnt;
543
    print("<Done testing check() boolean expresson>");
544 25 pela
 
545
    print("<Testing endtest()>");
546 38 pela
    endtest(pltbv, pltbs);
547 25 pela
    print("<Done testing endtest()>");
548 2 pela
 
549
    wait until rising_edge(clk);
550
    print("<Testing endsim()>");
551 99 pela
    print("");
552 25 pela
    print("Expected number of tests:  " & str(v_expected_tests_cnt));
553 2 pela
    print("Expected number of checks: " & str(v_expected_checks_cnt));
554
    print("Expected number of errors: " & str(v_expected_errors_cnt));
555 99 pela
    if v_expected_errors_cnt = 0 then
556
      print("Expected result:           SUCCESS");
557
    else
558
      print("Expected result:           FAIL");
559
    end if;
560 2 pela
    wait until rising_edge(clk);
561 38 pela
    endsim(pltbv, pltbs, true);
562 2 pela
    wait until rising_edge(clk);
563
    print("<Done testing endsim()>");
564
    wait;
565
  end process p_tc1;
566
end architecture bhv;

powered by: WebSVN 2.1.0

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