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 |
|
|
---- - Per Larsson, pela@opencores.org ----
|
27 |
|
|
---- ----
|
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 |
|
|
|
91 |
|
|
begin
|
92 |
|
|
|
93 |
|
|
-- Clock generator
|
94 |
|
|
clkgen0 : pltbutils_clkgen
|
95 |
|
|
generic map(
|
96 |
|
|
G_PERIOD => G_CLK_PERIOD
|
97 |
|
|
)
|
98 |
|
|
port map(
|
99 |
|
|
clk_o => clk,
|
100 |
38 |
pela |
stop_sim_i => pltbs.stop_sim
|
101 |
2 |
pela |
);
|
102 |
|
|
|
103 |
|
|
-- Clock cycle counter
|
104 |
|
|
p_clk_cnt : process (clk_cnt_clr, clk)
|
105 |
|
|
begin
|
106 |
|
|
if clk_cnt_clr then
|
107 |
|
|
clk_cnt <= 0;
|
108 |
|
|
elsif rising_edge(clk) then
|
109 |
|
|
clk_cnt <= clk_cnt + 1;
|
110 |
|
|
end if;
|
111 |
|
|
end process p_clk_cnt;
|
112 |
|
|
|
113 |
|
|
-- Testcase
|
114 |
|
|
p_tc1 : process
|
115 |
38 |
pela |
variable pltbv : pltbv_t := C_PLTBV_INIT;
|
116 |
25 |
pela |
variable v_expected_tests_cnt : integer := 0;
|
117 |
2 |
pela |
variable v_expected_checks_cnt : integer := 0;
|
118 |
|
|
variable v_expected_errors_cnt : integer := 0;
|
119 |
|
|
begin
|
120 |
|
|
|
121 |
|
|
print("<Testing startsim()>");
|
122 |
38 |
pela |
startsim("tc1", pltbv, pltbs);
|
123 |
2 |
pela |
wait until rising_edge(clk);
|
124 |
38 |
pela |
assert (pltbv.test_num = 0) and (pltbs.test_num = 0)
|
125 |
2 |
pela |
report "test_num after startsim() incorrect"
|
126 |
|
|
severity error;
|
127 |
|
|
print("<Done testing startsim()>");
|
128 |
|
|
|
129 |
25 |
pela |
print("<Testing starttest() with auto-incrementing test_num>");
|
130 |
38 |
pela |
starttest("TestName1", pltbv, pltbs);
|
131 |
25 |
pela |
v_expected_tests_cnt := v_expected_tests_cnt + 1;
|
132 |
2 |
pela |
wait until rising_edge(clk);
|
133 |
38 |
pela |
assert (pltbv.test_num = 1) and (pltbs.test_num = 1)
|
134 |
25 |
pela |
report "test_num after starttest() incorrect"
|
135 |
2 |
pela |
severity error;
|
136 |
25 |
pela |
print("<Done testing starttest() with auto-incrementing test_num()>");
|
137 |
2 |
pela |
|
138 |
25 |
pela |
print("<Testing endtest()>");
|
139 |
38 |
pela |
endtest(pltbv, pltbs);
|
140 |
25 |
pela |
print("<Done testing endtest()>");
|
141 |
|
|
|
142 |
|
|
print("<Testing starttest() with explicit test_num>");
|
143 |
38 |
pela |
starttest(3, "TestName2", pltbv, pltbs);
|
144 |
25 |
pela |
v_expected_tests_cnt := v_expected_tests_cnt + 1;
|
145 |
2 |
pela |
wait until rising_edge(clk);
|
146 |
38 |
pela |
assert (pltbv.test_num = 3) and (pltbs.test_num = 3)
|
147 |
2 |
pela |
report "test_num after startsim() incorrect"
|
148 |
|
|
severity error;
|
149 |
25 |
pela |
print("<Done testing starttest() with explicit test_num>");
|
150 |
2 |
pela |
|
151 |
|
|
print("<Testing waitclks()>");
|
152 |
|
|
clk_cnt_clr <= true;
|
153 |
|
|
wait until rising_edge(clk);
|
154 |
|
|
clk_cnt_clr <= false;
|
155 |
|
|
wait until rising_edge(clk);
|
156 |
38 |
pela |
waitclks(10, clk, pltbv, pltbs);
|
157 |
2 |
pela |
assert clk_cnt = 10
|
158 |
|
|
report "clk_cnt after waitclks() incorrect:" & integer'image(clk_cnt) &
|
159 |
|
|
" expected:" & integer'image(10)
|
160 |
|
|
severity error;
|
161 |
|
|
print("<Done testing waitclks()>");
|
162 |
|
|
|
163 |
|
|
print("<Testing check() integer>");
|
164 |
|
|
s_i <= 0;
|
165 |
|
|
wait until rising_edge(clk);
|
166 |
38 |
pela |
check("Testing correct integer = 0", s_i, 0, pltbv, pltbs);
|
167 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
168 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
169 |
|
|
s_i <= 1;
|
170 |
|
|
wait until rising_edge(clk);
|
171 |
38 |
pela |
check("Testing correct integer = 1", s_i, 1, pltbv, pltbs);
|
172 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
173 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
174 |
|
|
s_i <= 17;
|
175 |
|
|
wait until rising_edge(clk);
|
176 |
38 |
pela |
check("Testing incorrect integer = 17", s_i, 18, pltbv, pltbs);
|
177 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
178 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
179 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
180 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
181 |
|
|
s_i <= -1;
|
182 |
|
|
wait until rising_edge(clk);
|
183 |
38 |
pela |
check("Testing negative integer = -1", s_i, -1, pltbv, pltbs);
|
184 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
185 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
186 |
|
|
|
187 |
|
|
print("<Done testing check() integer>");
|
188 |
|
|
|
189 |
|
|
print("<Testing check() std_logic>");
|
190 |
|
|
s_sl <= '0';
|
191 |
|
|
wait until rising_edge(clk);
|
192 |
38 |
pela |
check("Testing correct std_logic = '0'", s_sl, '0', pltbv, pltbs);
|
193 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
194 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
195 |
|
|
s_sl <= '1';
|
196 |
|
|
wait until rising_edge(clk);
|
197 |
38 |
pela |
check("Testing correct std_logic = '1'", s_sl, '1', pltbv, pltbs);
|
198 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
199 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
200 |
|
|
s_sl <= 'X';
|
201 |
|
|
wait until rising_edge(clk);
|
202 |
38 |
pela |
check("Testing incorrect std_logic = '1'", s_sl, '1', pltbv, pltbs);
|
203 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
204 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
205 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
206 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
207 |
|
|
print("<Done testing check() std_logic>");
|
208 |
|
|
|
209 |
|
|
print("<Testing check() std_logic against integer>");
|
210 |
|
|
s_sl <= '0';
|
211 |
|
|
wait until rising_edge(clk);
|
212 |
38 |
pela |
check("Testing correct std_logic = '0'", s_sl, 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_sl <= '1';
|
216 |
|
|
wait until rising_edge(clk);
|
217 |
38 |
pela |
check("Testing correct std_logic = '1'", s_sl, 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_sl <= 'X';
|
221 |
|
|
wait until rising_edge(clk);
|
222 |
38 |
pela |
check("Testing incorrect std_logic = '1'", s_sl, 1, 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_sl <= '1';
|
228 |
|
|
wait until rising_edge(clk);
|
229 |
38 |
pela |
check("Testing std_logic = '1' with incorrect expected", s_sl, 2, pltbv, pltbs);
|
230 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
231 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
232 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
233 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
234 |
|
|
print("<Done testing check() std_logic against integer>");
|
235 |
|
|
|
236 |
|
|
print("<Testing check() std_logic_vector>");
|
237 |
|
|
s_slv <= x"00";
|
238 |
|
|
wait until rising_edge(clk);
|
239 |
38 |
pela |
check("Testing correct std_logic_vector = x'00'", s_slv, x"00", pltbv, pltbs);
|
240 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
241 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
242 |
|
|
s_slv <= x"47";
|
243 |
|
|
wait until rising_edge(clk);
|
244 |
38 |
pela |
check("Testing correct std_logic_vector = x'47'", s_slv, x"47", pltbv, pltbs);
|
245 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
246 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
247 |
|
|
s_slv <= x"11";
|
248 |
|
|
wait until rising_edge(clk);
|
249 |
38 |
pela |
check("Testing incorrect std_logic_vector = x'11'", s_slv, x"10", pltbv, pltbs);
|
250 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
251 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
252 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
253 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
254 |
|
|
print("<Done testing check() std_logic_vector>");
|
255 |
|
|
|
256 |
|
|
print("<Testing check() std_logic_vector with mask>");
|
257 |
|
|
s_slv <= x"47";
|
258 |
|
|
wait until rising_edge(clk);
|
259 |
38 |
pela |
check("Testing std_logic_vector = x'47' with correct nibble mask", s_slv, x"57", x"0F", pltbv, pltbs);
|
260 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
261 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
262 |
|
|
s_slv <= x"47";
|
263 |
|
|
wait until rising_edge(clk);
|
264 |
38 |
pela |
check("Testing std_logic_vector = x'47' with incorrect nibble mask", s_slv, x"57", x"F0", pltbv, pltbs);
|
265 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
266 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
267 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
268 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
269 |
|
|
print("<Done testing check() std_logic_vector with mask>");
|
270 |
|
|
|
271 |
|
|
print("<Testing check() std_logic_vector against integer>");
|
272 |
|
|
s_slv <= x"00";
|
273 |
|
|
wait until rising_edge(clk);
|
274 |
38 |
pela |
check("Testing correct std_logic_vector = x'00'", s_slv, 0, pltbv, pltbs);
|
275 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
276 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
277 |
|
|
s_slv <= x"47";
|
278 |
|
|
wait until rising_edge(clk);
|
279 |
38 |
pela |
check("Testing correct std_logic_vector = x'47'", s_slv, 16#47#, pltbv, pltbs);
|
280 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
281 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
282 |
|
|
s_slv <= x"11";
|
283 |
|
|
wait until rising_edge(clk);
|
284 |
38 |
pela |
check("Testing incorrect std_logic_vector = x'11'", s_slv, 16#10#, pltbv, pltbs);
|
285 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
286 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
287 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
288 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
289 |
|
|
s_slv <= x"FF";
|
290 |
|
|
wait until rising_edge(clk);
|
291 |
38 |
pela |
check("Testing negative std_logic_vector = x'FF'", s_slv, -1, pltbv, pltbs);
|
292 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
293 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
294 |
|
|
print("<Done testing check() std_logic_vector against integer>");
|
295 |
|
|
|
296 |
|
|
print("<Testing check() std_logic_vector with mask against integer>");
|
297 |
|
|
s_slv <= x"47";
|
298 |
|
|
wait until rising_edge(clk);
|
299 |
38 |
pela |
check("Testing std_logic_vector = x'47' with correct nibble mask", s_slv, 16#57#, x"0F", pltbv, pltbs);
|
300 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
301 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
302 |
|
|
s_slv <= x"47";
|
303 |
|
|
wait until rising_edge(clk);
|
304 |
38 |
pela |
check("Testing std_logic_vector = x'47' with incorrect nibble mask", s_slv, 16#57#, x"F0", pltbv, pltbs);
|
305 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
306 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
307 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
308 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
309 |
|
|
print("<Done testing check() std_logic_vector with mask against integer>");
|
310 |
|
|
|
311 |
|
|
print("<Testing check() unsigned>");
|
312 |
|
|
s_u <= x"00";
|
313 |
|
|
wait until rising_edge(clk);
|
314 |
38 |
pela |
check("Testing correct unsigned = x'00'", s_u, x"00", pltbv, pltbs);
|
315 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
316 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
317 |
|
|
s_u <= x"47";
|
318 |
|
|
wait until rising_edge(clk);
|
319 |
38 |
pela |
check("Testing correct unsigned = x'47'", s_u, x"47", pltbv, pltbs);
|
320 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
321 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
322 |
|
|
s_u <= x"11";
|
323 |
|
|
wait until rising_edge(clk);
|
324 |
38 |
pela |
check("Testing incorrect unsigned = x'11'", s_u, x"10", pltbv, pltbs);
|
325 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
326 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
327 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
328 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
329 |
|
|
print("<Done testing check() unsigned>");
|
330 |
|
|
|
331 |
|
|
print("<Testing check() unsigned against integer>");
|
332 |
|
|
s_u <= x"00";
|
333 |
|
|
wait until rising_edge(clk);
|
334 |
38 |
pela |
check("Testing correct unsigned = x'00'", s_u, 0, pltbv, pltbs);
|
335 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
336 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
337 |
|
|
s_u <= x"47";
|
338 |
|
|
wait until rising_edge(clk);
|
339 |
38 |
pela |
check("Testing correct unsigned = x'47'", s_u, 16#47#, pltbv, pltbs);
|
340 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
341 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
342 |
|
|
s_u <= x"11";
|
343 |
|
|
wait until rising_edge(clk);
|
344 |
38 |
pela |
check("Testing incorrect unsigned = x'11'", s_u, 16#10#, pltbv, pltbs);
|
345 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
346 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
347 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
348 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
349 |
|
|
print("<Done testing check() unsigned against integer>");
|
350 |
|
|
|
351 |
|
|
print("<Testing check() signed>");
|
352 |
|
|
s_s <= x"00";
|
353 |
|
|
wait until rising_edge(clk);
|
354 |
38 |
pela |
check("Testing correct signed = x'00'", s_s, x"00", pltbv, pltbs);
|
355 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
356 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
357 |
|
|
s_s <= x"47";
|
358 |
|
|
wait until rising_edge(clk);
|
359 |
38 |
pela |
check("Testing correct signed = x'47'", s_s, x"47", pltbv, pltbs);
|
360 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
361 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
362 |
|
|
s_s <= x"11";
|
363 |
|
|
wait until rising_edge(clk);
|
364 |
38 |
pela |
check("Testing incorrect signed = x'11'", s_s, x"10", pltbv, pltbs);
|
365 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
366 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
367 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
368 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
369 |
|
|
s_s <= x"FF";
|
370 |
|
|
wait until rising_edge(clk);
|
371 |
38 |
pela |
check("Testing negative signed = x'FF'", s_s, x"FF", pltbv, pltbs);
|
372 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
373 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
374 |
|
|
print("<Done testing check() signed>");
|
375 |
|
|
|
376 |
|
|
print("<Testing check() signed against integer>");
|
377 |
|
|
s_s <= x"00";
|
378 |
|
|
wait until rising_edge(clk);
|
379 |
38 |
pela |
check("Testing correct signed = x'00'", s_s, 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_s <= x"47";
|
383 |
|
|
wait until rising_edge(clk);
|
384 |
38 |
pela |
check("Testing correct signed = x'47'", s_s, 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_s <= x"11";
|
388 |
|
|
wait until rising_edge(clk);
|
389 |
38 |
pela |
check("Testing incorrect signed = x'11'", s_s, 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 |
|
|
s_s <= x"FF";
|
395 |
|
|
wait until rising_edge(clk);
|
396 |
|
|
print("The following check fails in ModelSim for unknown reason." &
|
397 |
|
|
" It causes mismatch between expected number of errors" &
|
398 |
|
|
" and the number presented by endsim()");
|
399 |
38 |
pela |
check("Testing negative signed = x'FF'", s_s, -1, pltbv, pltbs);
|
400 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
401 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
402 |
|
|
print("<Done testing check() signed against integer>");
|
403 |
|
|
|
404 |
|
|
print("<Testing check() boolean expression>");
|
405 |
|
|
s_i <= 0;
|
406 |
|
|
wait until rising_edge(clk);
|
407 |
38 |
pela |
check("Testing correct boolean expression 0 = 16#00#", s_i = 16#00#, pltbv, pltbs);
|
408 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
409 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
410 |
|
|
s_i <= 47;
|
411 |
|
|
wait until rising_edge(clk);
|
412 |
38 |
pela |
check("Testing incorrect boolean expression 47 < 16#10#", s_i < 16#10#, pltbv, pltbs);
|
413 |
2 |
pela |
v_expected_checks_cnt := v_expected_checks_cnt + 1;
|
414 |
|
|
expected_checks_cnt <= v_expected_checks_cnt;
|
415 |
|
|
v_expected_errors_cnt := v_expected_errors_cnt + 1;
|
416 |
|
|
expected_errors_cnt <= v_expected_errors_cnt;
|
417 |
|
|
print("<Done testing check() boolean expresson>");
|
418 |
25 |
pela |
|
419 |
|
|
print("<Testing endtest()>");
|
420 |
38 |
pela |
endtest(pltbv, pltbs);
|
421 |
25 |
pela |
print("<Done testing endtest()>");
|
422 |
2 |
pela |
|
423 |
|
|
wait until rising_edge(clk);
|
424 |
|
|
print("<Testing endsim()>");
|
425 |
25 |
pela |
print("Expected number of tests: " & str(v_expected_tests_cnt));
|
426 |
2 |
pela |
print("Expected number of checks: " & str(v_expected_checks_cnt));
|
427 |
|
|
print("Expected number of errors: " & str(v_expected_errors_cnt));
|
428 |
|
|
wait until rising_edge(clk);
|
429 |
38 |
pela |
endsim(pltbv, pltbs, true);
|
430 |
2 |
pela |
wait until rising_edge(clk);
|
431 |
|
|
print("<Done testing endsim()>");
|
432 |
|
|
wait;
|
433 |
|
|
end process p_tc1;
|
434 |
|
|
end architecture bhv;
|