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

Subversion Repositories pltbutils

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

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 101 pela
    G_SKIPTESTS   : std_logic_vector := (
65
                      '0', -- Dummy
66
                      '0', -- Test 1
67
                      '0', -- Test 2
68
                      '0', -- Test 3
69
                      '0', -- Test 4: NonSkipTest 
70
                      '1'  -- Test 5: SkipTest
71
                    );
72 2 pela
    G_CLK_PERIOD  : time := 10 ns
73
  );
74
end entity tb_pltbutils;
75
 
76
architecture bhv of tb_pltbutils is
77
 
78
  -- Simulation status- and control signals
79 38 pela
  -- for accessing .stop_sim and for viewing in waveform window
80
  signal pltbs          : pltbs_t := C_PLTBS_INIT;
81 2 pela
 
82
  -- Expected number of checks and number of errors to be reported
83
  -- by pltbutils. The counting is made by variables, but the
84
  -- variables are copied to these signals for easier viewing in
85
  -- the simulator's waveform window.
86
  signal expected_checks_cnt : integer := 0;
87
  signal expected_errors_cnt : integer := 0;
88
 
89
  -- DUT stimuli and response signals
90
  signal clk            : std_logic;
91
  signal clk_cnt        : integer := 0;
92
  signal clk_cnt_clr    : boolean := false;
93
  signal s_i            : integer;
94
  signal s_sl           : std_logic;
95
  signal s_slv          : std_logic_vector(7 downto 0);
96
  signal s_u            : unsigned(7 downto 0);
97
  signal s_s            : unsigned(7 downto 0);
98 99 pela
  signal s_b            : boolean;
99
  signal s_time         : time;
100 89 pela
  signal s_str_exp      : string(1 to 44);
101
  signal s_str1         : string(1 to 44);
102
  signal s_str2         : string(1 to 44);
103
  signal s_str3         : string(1 to 43);
104
  signal s_str4         : string(1 to 45);
105 2 pela
 
106
begin
107
 
108
  -- Clock generator
109
  clkgen0 : pltbutils_clkgen
110
    generic map(
111
      G_PERIOD      => G_CLK_PERIOD
112
    )
113
    port map(
114
      clk_o         => clk,
115 38 pela
      stop_sim_i    => pltbs.stop_sim
116 2 pela
    );
117
 
118
  -- Clock cycle counter
119
  p_clk_cnt : process (clk_cnt_clr, clk)
120
  begin
121
    if clk_cnt_clr then
122
      clk_cnt <= 0;
123
    elsif rising_edge(clk) then
124
      clk_cnt <= clk_cnt + 1;
125
    end if;
126
  end process p_clk_cnt;
127
 
128
  -- Testcase
129
  p_tc1 : process
130 38 pela
    variable pltbv                 : pltbv_t := C_PLTBV_INIT;
131 25 pela
    variable v_expected_tests_cnt  : integer := 0;
132 101 pela
    variable v_expected_skiptests_cnt : integer := 0;
133 2 pela
    variable v_expected_checks_cnt : integer := 0;
134
    variable v_expected_errors_cnt : integer := 0;
135
  begin
136
 
137
    print("<Testing startsim()>");
138 101 pela
    startsim("tc1", G_SKIPTESTS, pltbv, pltbs);
139 2 pela
    wait until rising_edge(clk);
140 38 pela
    assert (pltbv.test_num = 0) and (pltbs.test_num  = 0)
141 2 pela
      report "test_num after startsim() incorrect"
142
      severity error;
143
    print("<Done testing startsim()>");
144
 
145 25 pela
    print("<Testing starttest() with auto-incrementing test_num>");
146 101 pela
    starttest("StartTest1", pltbv, pltbs);
147 25 pela
    v_expected_tests_cnt := v_expected_tests_cnt + 1;
148 2 pela
    wait until rising_edge(clk);
149 38 pela
    assert (pltbv.test_num = 1) and (pltbs.test_num  = 1)
150 25 pela
      report "test_num after starttest() incorrect"
151 2 pela
      severity error;
152 25 pela
    print("<Done testing starttest() with auto-incrementing test_num()>");
153 2 pela
 
154 25 pela
    print("<Testing endtest()>");
155 38 pela
    endtest(pltbv, pltbs);
156 25 pela
    print("<Done testing endtest()>");
157
 
158
    print("<Testing starttest() with explicit test_num>");
159 101 pela
    starttest(3, "StartTest2", pltbv, pltbs);
160 25 pela
    v_expected_tests_cnt := v_expected_tests_cnt + 1;
161 2 pela
    wait until rising_edge(clk);
162 38 pela
    assert (pltbv.test_num = 3) and (pltbs.test_num  = 3)
163 2 pela
      report "test_num after startsim() incorrect"
164
      severity error;
165 25 pela
    print("<Done testing starttest() with explicit test_num>");
166 101 pela
 
167
    print("<Testing starttest() and is_test_active() for non-skipped test>");
168
    starttest(4, "NoSkipTest", pltbv, pltbs);
169
    if is_test_active(pltbv) then
170
      v_expected_tests_cnt := v_expected_tests_cnt + 1;
171
      wait until rising_edge(clk);
172
    else
173
      v_expected_skiptests_cnt := v_expected_skiptests_cnt + 1;
174
      wait until rising_edge(clk);
175
      assert false
176
        report "Executing test that should have been skipped"
177
        severity error;
178
    end if;
179
    endtest(pltbv, pltbs);
180
    print("<Done testing starttest() and is_test_active() for non-skipped test>");
181
 
182
    print("<Testing starttest() and is_test_active() for skipped test>");
183
    starttest(5, "SkipTest", pltbv, pltbs);
184
    if is_test_active(pltbv) then
185
      v_expected_tests_cnt := v_expected_tests_cnt + 1;
186
      wait until rising_edge(clk);
187
      assert false
188
        report "Executing test that should have been skipped"
189
        severity error;
190
    else
191
      --check("Checking if check() detects that it should not be called in skipped test", false, pltbv, pltbs);
192
      v_expected_skiptests_cnt := v_expected_skiptests_cnt + 1;
193
    end if;
194
    endtest(pltbv, pltbs);
195
    print("<Done testing starttest() and is_test_active() for skipped test>");
196 2 pela
 
197
    print("<Testing waitclks()>");
198
    clk_cnt_clr <= true;
199
    wait until rising_edge(clk);
200
    clk_cnt_clr <= false;
201
    wait until rising_edge(clk);
202 38 pela
    waitclks(10, clk, pltbv, pltbs);
203 2 pela
    assert clk_cnt = 10
204
      report "clk_cnt after waitclks() incorrect:" & integer'image(clk_cnt) &
205
             " expected:" & integer'image(10)
206
      severity error;
207
    print("<Done testing waitclks()>");
208
 
209
    print("<Testing check() integer>");
210
    s_i <= 0;
211
    wait until rising_edge(clk);
212 38 pela
    check("Testing correct integer = 0", s_i, 0, pltbv, pltbs);
213 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
214
    expected_checks_cnt   <= v_expected_checks_cnt;
215
    s_i <= 1;
216
    wait until rising_edge(clk);
217 38 pela
    check("Testing correct integer = 1", s_i, 1, pltbv, pltbs);
218 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
219
    expected_checks_cnt   <= v_expected_checks_cnt;
220
    s_i <= 17;
221
    wait until rising_edge(clk);
222 38 pela
    check("Testing incorrect integer = 17", s_i, 18, pltbv, pltbs);
223 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
224
    expected_checks_cnt   <= v_expected_checks_cnt;
225
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
226
    expected_errors_cnt   <= v_expected_errors_cnt;
227
    s_i <= -1;
228
    wait until rising_edge(clk);
229 38 pela
    check("Testing negative integer = -1", s_i, -1, pltbv, pltbs);
230 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
231 99 pela
    expected_checks_cnt   <= v_expected_checks_cnt;
232 2 pela
    print("<Done testing check() integer>");
233
 
234
    print("<Testing check() std_logic>");
235
    s_sl <= '0';
236
    wait until rising_edge(clk);
237 38 pela
    check("Testing correct std_logic = '0'", s_sl, '0', pltbv, pltbs);
238 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
239
    expected_checks_cnt   <= v_expected_checks_cnt;
240
    s_sl <= '1';
241
    wait until rising_edge(clk);
242 38 pela
    check("Testing correct std_logic = '1'", s_sl, '1', pltbv, pltbs);
243 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
244
    expected_checks_cnt   <= v_expected_checks_cnt;
245
    s_sl <= 'X';
246
    wait until rising_edge(clk);
247 38 pela
    check("Testing incorrect std_logic = '1'", s_sl, '1', pltbv, pltbs);
248 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
249
    expected_checks_cnt   <= v_expected_checks_cnt;
250
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
251
    expected_errors_cnt   <= v_expected_errors_cnt;
252
    print("<Done testing check() std_logic>");
253
 
254
    print("<Testing check() std_logic against integer>");
255
    s_sl <= '0';
256
    wait until rising_edge(clk);
257 38 pela
    check("Testing correct std_logic = '0'", s_sl, 0, pltbv, pltbs);
258 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
259
    expected_checks_cnt   <= v_expected_checks_cnt;
260
    s_sl <= '1';
261
    wait until rising_edge(clk);
262 38 pela
    check("Testing correct std_logic = '1'", s_sl, 1, pltbv, pltbs);
263 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
264
    expected_checks_cnt   <= v_expected_checks_cnt;
265
    s_sl <= 'X';
266
    wait until rising_edge(clk);
267 38 pela
    check("Testing incorrect std_logic = '1'", s_sl, 1, pltbv, pltbs);
268 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
269
    expected_checks_cnt   <= v_expected_checks_cnt;
270
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
271
    expected_errors_cnt   <= v_expected_errors_cnt;
272
    s_sl <= '1';
273
    wait until rising_edge(clk);
274 38 pela
    check("Testing std_logic = '1' with incorrect expected", s_sl, 2, pltbv, pltbs);
275 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
276
    expected_checks_cnt   <= v_expected_checks_cnt;
277
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
278
    expected_errors_cnt   <= v_expected_errors_cnt;
279
    print("<Done testing check() std_logic against integer>");
280
 
281
    print("<Testing check() std_logic_vector>");
282
    s_slv <= x"00";
283
    wait until rising_edge(clk);
284 38 pela
    check("Testing correct std_logic_vector = x'00'", s_slv, x"00", pltbv, pltbs);
285 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
286
    expected_checks_cnt   <= v_expected_checks_cnt;
287
    s_slv <= x"47";
288
    wait until rising_edge(clk);
289 38 pela
    check("Testing correct std_logic_vector = x'47'", s_slv, x"47", pltbv, pltbs);
290 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
291
    expected_checks_cnt   <= v_expected_checks_cnt;
292
    s_slv <= x"11";
293
    wait until rising_edge(clk);
294 38 pela
    check("Testing incorrect std_logic_vector = x'11'", s_slv, x"10", pltbv, pltbs);
295 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
296
    expected_checks_cnt   <= v_expected_checks_cnt;
297
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
298
    expected_errors_cnt   <= v_expected_errors_cnt;
299
    print("<Done testing check() std_logic_vector>");
300
 
301
    print("<Testing check() std_logic_vector with mask>");
302
    s_slv <= x"47";
303
    wait until rising_edge(clk);
304 38 pela
    check("Testing std_logic_vector = x'47' with correct nibble mask", s_slv, x"57", x"0F", pltbv, pltbs);
305 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
306
    expected_checks_cnt   <= v_expected_checks_cnt;
307
    s_slv <= x"47";
308
    wait until rising_edge(clk);
309 38 pela
    check("Testing std_logic_vector = x'47' with incorrect nibble mask", s_slv, x"57", x"F0", pltbv, pltbs);
310 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
311
    expected_checks_cnt   <= v_expected_checks_cnt;
312
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
313
    expected_errors_cnt   <= v_expected_errors_cnt;
314
    print("<Done testing check() std_logic_vector with mask>");
315
 
316
    print("<Testing check() std_logic_vector against integer>");
317
    s_slv <= x"00";
318
    wait until rising_edge(clk);
319 38 pela
    check("Testing correct std_logic_vector = x'00'", s_slv, 0, pltbv, pltbs);
320 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
321
    expected_checks_cnt   <= v_expected_checks_cnt;
322
    s_slv <= x"47";
323
    wait until rising_edge(clk);
324 38 pela
    check("Testing correct std_logic_vector = x'47'", s_slv, 16#47#, pltbv, pltbs);
325 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
326
    expected_checks_cnt   <= v_expected_checks_cnt;
327
    s_slv <= x"11";
328
    wait until rising_edge(clk);
329 38 pela
    check("Testing incorrect std_logic_vector = x'11'", s_slv, 16#10#, pltbv, pltbs);
330 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
331
    expected_checks_cnt   <= v_expected_checks_cnt;
332
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
333
    expected_errors_cnt   <= v_expected_errors_cnt;
334
    s_slv <= x"FF";
335
    wait until rising_edge(clk);
336 38 pela
    check("Testing negative std_logic_vector = x'FF'", s_slv, -1, pltbv, pltbs);
337 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
338
    expected_checks_cnt   <= v_expected_checks_cnt;
339
    print("<Done testing check() std_logic_vector against integer>");
340
 
341
    print("<Testing check() std_logic_vector with mask against integer>");
342
    s_slv <= x"47";
343
    wait until rising_edge(clk);
344 38 pela
    check("Testing std_logic_vector = x'47' with correct nibble mask", s_slv, 16#57#, x"0F", pltbv, pltbs);
345 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
346
    expected_checks_cnt   <= v_expected_checks_cnt;
347
    s_slv <= x"47";
348
    wait until rising_edge(clk);
349 38 pela
    check("Testing std_logic_vector = x'47' with incorrect nibble mask", s_slv, 16#57#, x"F0", pltbv, pltbs);
350 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
351
    expected_checks_cnt   <= v_expected_checks_cnt;
352
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
353
    expected_errors_cnt   <= v_expected_errors_cnt;
354
    print("<Done testing check() std_logic_vector with mask against integer>");
355
 
356
    print("<Testing check() unsigned>");
357
    s_u <= x"00";
358
    wait until rising_edge(clk);
359 38 pela
    check("Testing correct unsigned = x'00'", s_u, x"00", pltbv, pltbs);
360 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
361
    expected_checks_cnt   <= v_expected_checks_cnt;
362
    s_u <= x"47";
363
    wait until rising_edge(clk);
364 38 pela
    check("Testing correct unsigned = x'47'", s_u, x"47", pltbv, pltbs);
365 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
366
    expected_checks_cnt   <= v_expected_checks_cnt;
367
    s_u <= x"11";
368
    wait until rising_edge(clk);
369 38 pela
    check("Testing incorrect unsigned = x'11'", s_u, x"10", pltbv, pltbs);
370 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
371
    expected_checks_cnt   <= v_expected_checks_cnt;
372
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
373
    expected_errors_cnt   <= v_expected_errors_cnt;
374
    print("<Done testing check() unsigned>");
375
 
376
    print("<Testing check() unsigned against integer>");
377
    s_u <= x"00";
378
    wait until rising_edge(clk);
379 38 pela
    check("Testing correct unsigned = x'00'", s_u, 0, pltbv, pltbs);
380 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
381
    expected_checks_cnt   <= v_expected_checks_cnt;
382
    s_u <= x"47";
383
    wait until rising_edge(clk);
384 38 pela
    check("Testing correct unsigned = x'47'", s_u, 16#47#, pltbv, pltbs);
385 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
386
    expected_checks_cnt   <= v_expected_checks_cnt;
387
    s_u <= x"11";
388
    wait until rising_edge(clk);
389 38 pela
    check("Testing incorrect unsigned = x'11'", s_u, 16#10#, pltbv, pltbs);
390 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
391
    expected_checks_cnt   <= v_expected_checks_cnt;
392
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
393
    expected_errors_cnt   <= v_expected_errors_cnt;
394
    print("<Done testing check() unsigned against integer>");
395
 
396
    print("<Testing check() signed>");
397
    s_s <= x"00";
398
    wait until rising_edge(clk);
399 38 pela
    check("Testing correct signed = x'00'", s_s, x"00", pltbv, pltbs);
400 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
401
    expected_checks_cnt   <= v_expected_checks_cnt;
402
    s_s <= x"47";
403
    wait until rising_edge(clk);
404 38 pela
    check("Testing correct signed = x'47'", s_s, x"47", pltbv, pltbs);
405 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
406
    expected_checks_cnt   <= v_expected_checks_cnt;
407
    s_s <= x"11";
408
    wait until rising_edge(clk);
409 38 pela
    check("Testing incorrect signed = x'11'", s_s, x"10", pltbv, pltbs);
410 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
411
    expected_checks_cnt   <= v_expected_checks_cnt;
412
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
413
    expected_errors_cnt   <= v_expected_errors_cnt;
414
    s_s <= x"FF";
415
    wait until rising_edge(clk);
416 38 pela
    check("Testing negative signed = x'FF'", s_s, x"FF", pltbv, pltbs);
417 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
418
    expected_checks_cnt   <= v_expected_checks_cnt;
419
    print("<Done testing check() signed>");
420
 
421
    print("<Testing check() signed against integer>");
422
    s_s <= x"00";
423
    wait until rising_edge(clk);
424 38 pela
    check("Testing correct signed = x'00'", s_s, 0, pltbv, pltbs);
425 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
426
    expected_checks_cnt   <= v_expected_checks_cnt;
427
    s_s <= x"47";
428
    wait until rising_edge(clk);
429 38 pela
    check("Testing correct signed = x'47'", s_s, 16#47#, pltbv, pltbs);
430 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
431
    expected_checks_cnt   <= v_expected_checks_cnt;
432
    s_s <= x"11";
433
    wait until rising_edge(clk);
434 38 pela
    check("Testing incorrect signed = x'11'", s_s, 16#10#, pltbv, pltbs);
435 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
436
    expected_checks_cnt   <= v_expected_checks_cnt;
437
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
438
    expected_errors_cnt   <= v_expected_errors_cnt;
439
    s_s <= x"FF";
440
    wait until rising_edge(clk);
441 99 pela
    print("NOTE: Skipping test with negative signed. There seem to be a bug in ModelSim.");
442 97 pela
    --print("The following check fails in ModelSim for unknown reason." &
443
    --      " It causes mismatch between expected number of errors" &
444
    --      " and the number presented by endsim()");
445
    --check("Testing negative signed = x'FF'", s_s, -1, pltbv, pltbs);
446
    --v_expected_checks_cnt := v_expected_checks_cnt + 1;    
447
    --expected_checks_cnt   <= v_expected_checks_cnt;
448 99 pela
    print("<Done testing check() signed against integer>");
449 2 pela
 
450 99 pela
    print("<Testing check() boolean>");
451
    s_b <= false;
452
    wait until rising_edge(clk);
453
    check("Testing correct boolean = false", s_b, false, pltbv, pltbs);
454
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
455
    expected_checks_cnt   <= v_expected_checks_cnt;
456
    s_b <= true;
457
    wait until rising_edge(clk);
458
    check("Testing correct boolean = true", s_b, true, pltbv, pltbs);
459
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
460
    expected_checks_cnt   <= v_expected_checks_cnt;
461
    s_b <= false;
462
    wait until rising_edge(clk);
463
    check("Testing incorrect boolean = true", s_b, true, pltbv, pltbs);
464
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
465
    expected_checks_cnt   <= v_expected_checks_cnt;
466
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
467
    expected_errors_cnt   <= v_expected_errors_cnt;
468
    print("<Done testing check() boolean>");
469
 
470
    print("<Testing check() boolean against integer>");
471
    s_b <= false;
472
    wait until rising_edge(clk);
473
    check("Testing correct boolean = false", s_b, 0, pltbv, pltbs);
474
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
475
    expected_checks_cnt   <= v_expected_checks_cnt;
476
    s_b <= true;
477
    wait until rising_edge(clk);
478
    check("Testing correct boolean = true", s_b, 1, pltbv, pltbs);
479
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
480
    expected_checks_cnt   <= v_expected_checks_cnt;
481
    s_b <= false;
482
    wait until rising_edge(clk);
483
    check("Testing incorrect boolean = true", s_b, 1, pltbv, pltbs);
484
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
485
    expected_checks_cnt   <= v_expected_checks_cnt;
486
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
487
    expected_errors_cnt   <= v_expected_errors_cnt;
488
    s_b <= true;
489
    wait until rising_edge(clk);
490
    check("Testing boolean = true with incorrect expected", s_b, 2, pltbv, pltbs);
491
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
492
    expected_checks_cnt   <= v_expected_checks_cnt;
493
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
494
    expected_errors_cnt   <= v_expected_errors_cnt;
495
    print("<Done testing check() boolean against integer>");
496
 
497
    print("<Testing check() time>");
498
    s_time <= 0 sec;
499
    wait until rising_edge(clk);
500
    check("Testing correct time = 0 sec", s_time, 0 sec, pltbv, pltbs);
501
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
502
    expected_checks_cnt   <= v_expected_checks_cnt;
503
    s_time <= 47 ns;
504
    wait until rising_edge(clk);
505
    check("Testing correct time = 47 ns", s_time, 47 ns, pltbv, pltbs);
506
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
507
    expected_checks_cnt   <= v_expected_checks_cnt;
508
    s_time <= 11 us;
509
    wait until rising_edge(clk);
510
    check("Testing incorrect time = 10 us", s_time, 10 us, 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
    print("<Done testing check() time>");
516
 
517
    print("<Testing check() time with tolerance>");
518
    s_time <= 0 sec;
519
    wait until rising_edge(clk);
520
    check("Testing correct unsigned = 0 sec +/- 0 sec", s_time, 0 sec, 0 sec, pltbv, pltbs);
521
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
522
    expected_checks_cnt   <= v_expected_checks_cnt;
523
    s_time <= 47 ns - 3 ns;
524
    wait until rising_edge(clk);
525
    check("Testing correct time = 47 ns +/- 5 ns", s_time, 47 ns, 5 ns, pltbv, pltbs);
526
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
527
    expected_checks_cnt   <= v_expected_checks_cnt;
528
    s_time <= 10 us + 7 us;
529
    wait until rising_edge(clk);
530
    check("Testing incorrect time = 10 us +/- 5 us", s_time, 10 us, 5 us, pltbv, pltbs);
531
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
532
    expected_checks_cnt   <= v_expected_checks_cnt;
533
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
534
    expected_errors_cnt   <= v_expected_errors_cnt;
535
    print("<Done testing check() time with tolerance>");
536
 
537 89 pela
    print("<Testing check() string>");
538
    s_str_exp   <= string'("The quick brown fox jumps over the lazy dog.");
539
    s_str1      <= string'("The quick brown fox jumps over the lazy dog.");
540
    s_str2      <= string'("The quick brown dog jumps over the lazy fox.");
541
    s_str3      <= string'("The quick brown fox jumps over the lazy dog");
542
    s_str4      <= string'("The quick brown fox jumps over the lazy dog..");
543
    wait until rising_edge(clk);
544
    check("Testing correct string", s_str1, s_str_exp, pltbv, pltbs);
545
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
546
    expected_checks_cnt   <= v_expected_checks_cnt;
547
    s_s <= x"47";
548
    wait until rising_edge(clk);
549
    check("Testing incorrect string with correct length", s_str2, s_str_exp, pltbv, pltbs);
550
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
551
    expected_checks_cnt   <= v_expected_checks_cnt;
552
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
553
    expected_errors_cnt   <= v_expected_errors_cnt;
554
    s_s <= x"11";
555
    wait until rising_edge(clk);
556
    check("Testing too short string", s_str3, s_str_exp, pltbv, pltbs);
557
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
558
    expected_checks_cnt   <= v_expected_checks_cnt;
559
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
560
    expected_errors_cnt   <= v_expected_errors_cnt;
561
    wait until rising_edge(clk);
562
    check("Testing too long string", s_str4, s_str_exp, pltbv, pltbs);
563
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
564
    expected_checks_cnt   <= v_expected_checks_cnt;
565
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
566
    expected_errors_cnt   <= v_expected_errors_cnt;
567
    print("<Done testing check() string>");
568
 
569 2 pela
    print("<Testing check() boolean expression>");
570
    s_i <= 0;
571
    wait until rising_edge(clk);
572 38 pela
    check("Testing correct boolean expression 0 = 16#00#", s_i = 16#00#, pltbv, pltbs);
573 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
574
    expected_checks_cnt   <= v_expected_checks_cnt;
575
    s_i <= 47;
576
    wait until rising_edge(clk);
577 38 pela
    check("Testing incorrect boolean expression 47 < 16#10#", s_i < 16#10#, pltbv, pltbs);
578 2 pela
    v_expected_checks_cnt := v_expected_checks_cnt + 1;
579
    expected_checks_cnt   <= v_expected_checks_cnt;
580
    v_expected_errors_cnt := v_expected_errors_cnt + 1;
581
    expected_errors_cnt   <= v_expected_errors_cnt;
582
    print("<Done testing check() boolean expresson>");
583 25 pela
 
584
    print("<Testing endtest()>");
585 38 pela
    endtest(pltbv, pltbs);
586 25 pela
    print("<Done testing endtest()>");
587 2 pela
 
588
    wait until rising_edge(clk);
589
    print("<Testing endsim()>");
590 99 pela
    print("");
591 101 pela
    print("Expected number of tests:         " & str(v_expected_tests_cnt));
592
    print("Expected number of skipped tests: " & str(v_expected_skiptests_cnt));
593
    print("Expected number of checks:        " & str(v_expected_checks_cnt));
594
    print("Expected number of errors:        " & str(v_expected_errors_cnt));
595 99 pela
    if v_expected_errors_cnt = 0 then
596
      print("Expected result:           SUCCESS");
597
    else
598
      print("Expected result:           FAIL");
599
    end if;
600 2 pela
    wait until rising_edge(clk);
601 38 pela
    endsim(pltbv, pltbs, true);
602 2 pela
    wait until rising_edge(clk);
603
    print("<Done testing endsim()>");
604
    wait;
605
  end process p_tc1;
606
end architecture bhv;

powered by: WebSVN 2.1.0

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