1 |
2 |
pela |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- PlTbUtils Fuctions and Procedures Package ----
|
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 file defines fuctions and procedures for controlling ----
|
14 |
|
|
---- stimuli to a DUT and checking response. ----
|
15 |
|
|
---- ----
|
16 |
|
|
---- To Do: ----
|
17 |
|
|
---- - ----
|
18 |
|
|
---- ----
|
19 |
|
|
---- Author(s): ----
|
20 |
|
|
---- - Per Larsson, pela@opencores.org ----
|
21 |
|
|
---- ----
|
22 |
|
|
----------------------------------------------------------------------
|
23 |
|
|
---- ----
|
24 |
|
|
---- Copyright (C) 2013 Authors and OPENCORES.ORG ----
|
25 |
|
|
---- ----
|
26 |
|
|
---- This source file may be used and distributed without ----
|
27 |
|
|
---- restriction provided that this copyright statement is not ----
|
28 |
|
|
---- removed from the file and that any derivative work contains ----
|
29 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
30 |
|
|
---- ----
|
31 |
|
|
---- This source file is free software; you can redistribute it ----
|
32 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
33 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
34 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
35 |
|
|
---- later version. ----
|
36 |
|
|
---- ----
|
37 |
|
|
---- This source is distributed in the hope that it will be ----
|
38 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
39 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
40 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
41 |
|
|
---- details. ----
|
42 |
|
|
---- ----
|
43 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
44 |
|
|
---- Public License along with this source; if not, download it ----
|
45 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
46 |
|
|
---- ----
|
47 |
|
|
----------------------------------------------------------------------
|
48 |
|
|
library ieee;
|
49 |
|
|
use ieee.std_logic_1164.all;
|
50 |
|
|
use ieee.numeric_std.all;
|
51 |
|
|
use std.textio.all;
|
52 |
|
|
use std.env.all; -- VHDL-2008
|
53 |
|
|
use work.txt_util.all;
|
54 |
|
|
use work.pltbutils_type_pkg.all; -- Use for VHDL-2002, comment out for VHDL-93
|
55 |
|
|
|
56 |
|
|
package pltbutils_func_pkg is
|
57 |
|
|
|
58 |
|
|
-- See the package body for a description of the functions and procedures.
|
59 |
|
|
constant C_PLTBUTILS_STRLEN : natural := 80;
|
60 |
|
|
constant C_PLTBUTILS_TIMEOUT : time := 10 sec;
|
61 |
|
|
constant C_WAIT_BEFORE_STOP_TIME : time := 1 us;
|
62 |
|
|
|
63 |
|
|
-- Counters for number of checks and number of errors
|
64 |
|
|
-- VHDL-2002:
|
65 |
|
|
shared variable v_pltbutils_test_num : pltbutils_p_integer_t;
|
66 |
|
|
shared variable v_pltbutils_test_name : pltbutils_p_string_t;
|
67 |
|
|
shared variable v_pltbutils_info : pltbutils_p_string_t;
|
68 |
|
|
shared variable v_pltbutils_chk_cnt : pltbutils_p_integer_t;
|
69 |
|
|
shared variable v_pltbutils_err_cnt : pltbutils_p_integer_t;
|
70 |
|
|
shared variable v_pltbutils_stop_sim : pltbutils_p_std_logic_t;
|
71 |
|
|
-- VHDL-1993:
|
72 |
|
|
--shared variable v_pltbutils_test_num : natural := 0;
|
73 |
|
|
--shared variable v_pltbutils_test_name : string(1 to C_PLTBUTILS_STRLEN) := (others => ' ');
|
74 |
|
|
--shared variable v_pltbutils_info : string(1 to C_PLTBUTILS_STRLEN) := (others => ' ');
|
75 |
|
|
--shared variable v_pltbutils_chk_cnt : natural := 0;
|
76 |
|
|
--shared variable v_pltbutils_err_cnt : natural := 0;
|
77 |
|
|
--shared variable v_pltbutils_stop_sim : std_logic := '0';
|
78 |
|
|
|
79 |
|
|
-- Global status- and control signal
|
80 |
|
|
type pltbutils_sc_t is
|
81 |
|
|
record
|
82 |
|
|
test_num : natural;
|
83 |
|
|
test_name : string(1 to C_PLTBUTILS_STRLEN);
|
84 |
|
|
info : string(1 to C_PLTBUTILS_STRLEN);
|
85 |
|
|
chk_cnt : natural;
|
86 |
|
|
err_cnt : natural;
|
87 |
|
|
stop_sim : std_logic;
|
88 |
|
|
end record;
|
89 |
|
|
signal pltbutils_sc : pltbutils_sc_t;
|
90 |
|
|
|
91 |
|
|
-- startsim
|
92 |
|
|
procedure startsim(
|
93 |
|
|
constant testcase_name : in string;
|
94 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
95 |
|
|
);
|
96 |
|
|
|
97 |
|
|
-- endsim
|
98 |
|
|
procedure endsim(
|
99 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
100 |
|
|
constant show_success_fail : in boolean := false;
|
101 |
|
|
constant force : in boolean := false
|
102 |
|
|
);
|
103 |
|
|
|
104 |
|
|
-- testname
|
105 |
|
|
procedure testname(
|
106 |
|
|
constant num : in integer := -1;
|
107 |
|
|
constant name : in string;
|
108 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
109 |
|
|
);
|
110 |
|
|
procedure testname(
|
111 |
|
|
constant name : in string;
|
112 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
113 |
|
|
);
|
114 |
|
|
|
115 |
|
|
-- print, printv, print2
|
116 |
|
|
procedure print(
|
117 |
6 |
pela |
constant active : in boolean;
|
118 |
2 |
pela |
signal s : out string;
|
119 |
|
|
constant txt : in string
|
120 |
|
|
);
|
121 |
6 |
pela |
procedure print(
|
122 |
|
|
signal s : out string;
|
123 |
|
|
constant txt : in string
|
124 |
|
|
);
|
125 |
2 |
pela |
procedure printv(
|
126 |
6 |
pela |
constant active : in boolean;
|
127 |
2 |
pela |
variable s : out string;
|
128 |
|
|
constant txt : in string
|
129 |
|
|
);
|
130 |
|
|
procedure printv(
|
131 |
6 |
pela |
variable s : out string;
|
132 |
|
|
constant txt : in string
|
133 |
|
|
);
|
134 |
|
|
procedure printv(
|
135 |
|
|
constant active : in boolean;
|
136 |
2 |
pela |
variable s : inout pltbutils_p_string_t;
|
137 |
|
|
constant txt : in string
|
138 |
|
|
);
|
139 |
6 |
pela |
procedure printv(
|
140 |
|
|
variable s : inout pltbutils_p_string_t;
|
141 |
|
|
constant txt : in string
|
142 |
|
|
);
|
143 |
2 |
pela |
procedure print(
|
144 |
6 |
pela |
constant active : in boolean;
|
145 |
2 |
pela |
signal pltbutils_sc : out pltbutils_sc_t;
|
146 |
|
|
constant txt : in string
|
147 |
|
|
);
|
148 |
6 |
pela |
procedure print(
|
149 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
150 |
|
|
constant txt : in string
|
151 |
|
|
);
|
152 |
2 |
pela |
procedure print2(
|
153 |
6 |
pela |
constant active : in boolean;
|
154 |
2 |
pela |
signal s : out string;
|
155 |
|
|
constant txt : in string
|
156 |
|
|
);
|
157 |
|
|
procedure print2(
|
158 |
6 |
pela |
signal s : out string;
|
159 |
|
|
constant txt : in string
|
160 |
|
|
);
|
161 |
|
|
procedure print2(
|
162 |
|
|
constant active : in boolean;
|
163 |
2 |
pela |
signal pltbutils_sc : out pltbutils_sc_t;
|
164 |
|
|
constant txt : in string
|
165 |
|
|
);
|
166 |
6 |
pela |
procedure print2(
|
167 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
168 |
|
|
constant txt : in string
|
169 |
|
|
);
|
170 |
2 |
pela |
|
171 |
|
|
-- waitclks
|
172 |
|
|
procedure waitclks(
|
173 |
|
|
constant N : in natural;
|
174 |
|
|
signal clk : in std_logic;
|
175 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
176 |
|
|
constant falling : in boolean := false;
|
177 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
178 |
|
|
);
|
179 |
|
|
|
180 |
6 |
pela |
-- waitsig
|
181 |
|
|
procedure waitsig(
|
182 |
|
|
signal s : in integer;
|
183 |
|
|
constant value : in integer;
|
184 |
|
|
signal clk : in std_logic;
|
185 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
186 |
|
|
constant falling : in boolean := false;
|
187 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
188 |
|
|
);
|
189 |
|
|
procedure waitsig(
|
190 |
|
|
signal s : in std_logic;
|
191 |
|
|
constant value : in std_logic;
|
192 |
|
|
signal clk : in std_logic;
|
193 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
194 |
|
|
constant falling : in boolean := false;
|
195 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
196 |
|
|
);
|
197 |
|
|
procedure waitsig(
|
198 |
|
|
signal s : in std_logic;
|
199 |
|
|
constant value : in integer;
|
200 |
|
|
signal clk : in std_logic;
|
201 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
202 |
|
|
constant falling : in boolean := false;
|
203 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
204 |
|
|
);
|
205 |
|
|
procedure waitsig(
|
206 |
|
|
signal s : in std_logic_vector;
|
207 |
|
|
constant value : in std_logic_vector;
|
208 |
|
|
signal clk : in std_logic;
|
209 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
210 |
|
|
constant falling : in boolean := false;
|
211 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
212 |
|
|
);
|
213 |
|
|
procedure waitsig(
|
214 |
|
|
signal s : in std_logic_vector;
|
215 |
|
|
constant value : in integer;
|
216 |
|
|
signal clk : in std_logic;
|
217 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
218 |
|
|
constant falling : in boolean := false;
|
219 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
220 |
|
|
);
|
221 |
|
|
procedure waitsig(
|
222 |
|
|
signal s : in unsigned;
|
223 |
|
|
constant value : in unsigned;
|
224 |
|
|
signal clk : in std_logic;
|
225 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
226 |
|
|
constant falling : in boolean := false;
|
227 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
228 |
|
|
);
|
229 |
|
|
procedure waitsig(
|
230 |
|
|
signal s : in unsigned;
|
231 |
|
|
constant value : in integer;
|
232 |
|
|
signal clk : in std_logic;
|
233 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
234 |
|
|
constant falling : in boolean := false;
|
235 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
236 |
|
|
);
|
237 |
|
|
procedure waitsig(
|
238 |
|
|
signal s : in signed;
|
239 |
|
|
constant value : in signed;
|
240 |
|
|
signal clk : in std_logic;
|
241 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
242 |
|
|
constant falling : in boolean := false;
|
243 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
244 |
|
|
);
|
245 |
|
|
procedure waitsig(
|
246 |
|
|
signal s : in signed;
|
247 |
|
|
constant value : in integer;
|
248 |
|
|
signal clk : in std_logic;
|
249 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
250 |
|
|
constant falling : in boolean := false;
|
251 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
252 |
|
|
);
|
253 |
|
|
|
254 |
2 |
pela |
-- check
|
255 |
|
|
procedure check(
|
256 |
|
|
constant rpt : in string;
|
257 |
|
|
constant data : in integer;
|
258 |
|
|
constant expected : in integer;
|
259 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
260 |
|
|
);
|
261 |
|
|
procedure check(
|
262 |
|
|
constant rpt : in string;
|
263 |
|
|
constant data : in std_logic;
|
264 |
|
|
constant expected : in std_logic;
|
265 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
266 |
|
|
);
|
267 |
|
|
procedure check(
|
268 |
|
|
constant rpt : in string;
|
269 |
|
|
constant data : in std_logic;
|
270 |
|
|
constant expected : in integer;
|
271 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
272 |
|
|
);
|
273 |
|
|
procedure check(
|
274 |
|
|
constant rpt : in string;
|
275 |
|
|
constant data : in std_logic_vector;
|
276 |
|
|
constant expected : in std_logic_vector;
|
277 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
278 |
|
|
);
|
279 |
|
|
procedure check(
|
280 |
|
|
constant rpt : in string;
|
281 |
|
|
constant data : in std_logic_vector;
|
282 |
|
|
constant expected : in std_logic_vector;
|
283 |
|
|
constant mask : in std_logic_vector;
|
284 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
285 |
|
|
);
|
286 |
|
|
procedure check(
|
287 |
|
|
constant rpt : in string;
|
288 |
|
|
constant data : in std_logic_vector;
|
289 |
|
|
constant expected : in integer;
|
290 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
291 |
|
|
);
|
292 |
|
|
procedure check(
|
293 |
|
|
constant rpt : in string;
|
294 |
|
|
constant data : in std_logic_vector;
|
295 |
|
|
constant expected : in integer;
|
296 |
|
|
constant mask : in std_logic_vector;
|
297 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
298 |
|
|
);
|
299 |
|
|
procedure check(
|
300 |
|
|
constant rpt : in string;
|
301 |
|
|
constant data : in unsigned;
|
302 |
|
|
constant expected : in unsigned;
|
303 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
304 |
|
|
);
|
305 |
|
|
procedure check(
|
306 |
|
|
constant rpt : in string;
|
307 |
|
|
constant data : in unsigned;
|
308 |
|
|
constant expected : in integer;
|
309 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
310 |
|
|
);
|
311 |
|
|
procedure check(
|
312 |
|
|
constant rpt : in string;
|
313 |
|
|
constant data : in signed;
|
314 |
|
|
constant expected : in signed;
|
315 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
316 |
|
|
);
|
317 |
|
|
procedure check(
|
318 |
|
|
constant rpt : in string;
|
319 |
|
|
constant data : in signed;
|
320 |
|
|
constant expected : in integer;
|
321 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
322 |
|
|
);
|
323 |
|
|
procedure check(
|
324 |
|
|
constant rpt : in string;
|
325 |
|
|
constant expr : in boolean;
|
326 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
327 |
|
|
);
|
328 |
14 |
pela |
|
329 |
|
|
-- to_ascending
|
330 |
|
|
function to_ascending(
|
331 |
|
|
constant s : std_logic_vector
|
332 |
|
|
) return std_logic_vector;
|
333 |
|
|
function to_ascending(
|
334 |
|
|
constant s : unsigned
|
335 |
|
|
) return unsigned;
|
336 |
|
|
function to_ascending(
|
337 |
|
|
constant s : signed
|
338 |
|
|
) return signed;
|
339 |
2 |
pela |
|
340 |
14 |
pela |
-- to_descending
|
341 |
|
|
function to_descending(
|
342 |
|
|
constant s : std_logic_vector
|
343 |
|
|
) return std_logic_vector;
|
344 |
|
|
function to_descending(
|
345 |
|
|
constant s : unsigned
|
346 |
|
|
) return unsigned;
|
347 |
|
|
function to_descending(
|
348 |
|
|
constant s : signed
|
349 |
|
|
) return signed;
|
350 |
|
|
|
351 |
|
|
-- hxstr
|
352 |
|
|
function hxstr(
|
353 |
|
|
constant s : std_logic_vector;
|
354 |
|
|
constant prefix : string := ""
|
355 |
|
|
) return string;
|
356 |
|
|
function hxstr(
|
357 |
|
|
constant s : unsigned;
|
358 |
|
|
constant prefix : string := ""
|
359 |
|
|
) return string;
|
360 |
|
|
function hxstr(
|
361 |
|
|
constant s : signed;
|
362 |
|
|
constant prefix : string := ""
|
363 |
|
|
) return string;
|
364 |
|
|
|
365 |
2 |
pela |
-- pltbutils internal procedure(s), do not call from user's code
|
366 |
|
|
procedure pltbutils_sc_update(
|
367 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
368 |
|
|
);
|
369 |
|
|
|
370 |
|
|
end package pltbutils_func_pkg;
|
371 |
|
|
|
372 |
|
|
package body pltbutils_func_pkg is
|
373 |
|
|
|
374 |
|
|
----------------------------------------------------------------------------
|
375 |
|
|
-- startsim
|
376 |
|
|
--
|
377 |
|
|
-- procedure startsim(
|
378 |
|
|
-- constant testcase_name : in string;
|
379 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t
|
380 |
|
|
-- )
|
381 |
|
|
--
|
382 |
|
|
-- Displays a message at start of simulation message, and initializes
|
383 |
|
|
-- PlTbUtils' global status and control signal.
|
384 |
|
|
-- Call startsim() only once.
|
385 |
|
|
--
|
386 |
|
|
-- Arguments:
|
387 |
|
|
-- testcase_name Name of the test case, e.g. "tc1".
|
388 |
|
|
--
|
389 |
|
|
-- pltbutils_sc PlTbUtils' global status- and control signal.
|
390 |
|
|
-- Must be set to pltbutils_sc.
|
391 |
|
|
--
|
392 |
|
|
-- NOTE:
|
393 |
|
|
-- The start-of-simulation message is not only intended to be informative
|
394 |
|
|
-- for humans. It is also intended to be searched for by scripts,
|
395 |
|
|
-- e.g. for collecting results from a large number of regression tests.
|
396 |
|
|
-- For this reason, the message must be consistent and unique.
|
397 |
|
|
--
|
398 |
|
|
-- DO NOT MODIFY the message "--- START OF SIMULATION ---".
|
399 |
|
|
-- DO NOT OUTPUT AN IDENTICAL MESSAGE anywhere else.
|
400 |
|
|
--
|
401 |
|
|
-- Example:
|
402 |
|
|
-- startsim("tc1", pltbutils_sc);
|
403 |
|
|
----------------------------------------------------------------------------
|
404 |
|
|
procedure startsim(
|
405 |
|
|
constant testcase_name : in string;
|
406 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
407 |
|
|
) is
|
408 |
|
|
variable dummy : integer;
|
409 |
|
|
begin
|
410 |
|
|
printv(v_pltbutils_info, testcase_name);
|
411 |
|
|
print(lf & "--- START OF SIMULATION ---");
|
412 |
|
|
print("Testcase: " & testcase_name);
|
413 |
|
|
print(time'image(now));
|
414 |
|
|
-- VHDL-2002:
|
415 |
|
|
v_pltbutils_stop_sim.clr;
|
416 |
|
|
v_pltbutils_test_num.clr;
|
417 |
|
|
v_pltbutils_test_name.set("START OF SIMULATION");
|
418 |
|
|
v_pltbutils_chk_cnt.clr;
|
419 |
|
|
v_pltbutils_err_cnt.clr;
|
420 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
421 |
|
|
-- VHDL-1993:
|
422 |
|
|
--v_pltbutils_stop_sim := '0';
|
423 |
|
|
--v_pltbutils_test_num := 0;
|
424 |
|
|
--printv(v_pltbutils_test_name, "START OF SIMULATION");
|
425 |
|
|
--v_pltbutils_chk_cnt := 0;
|
426 |
|
|
--v_pltbutils_err_cnt := 0;
|
427 |
|
|
--pltbutils_sc_update(pltbutils_sc);
|
428 |
|
|
end procedure startsim;
|
429 |
|
|
|
430 |
|
|
----------------------------------------------------------------------------
|
431 |
|
|
-- endsim
|
432 |
|
|
--
|
433 |
|
|
-- procedure endsim(
|
434 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t;
|
435 |
|
|
-- constant show_success_fail : in boolean := false;
|
436 |
|
|
-- constant force : in boolean := false
|
437 |
|
|
-- )
|
438 |
|
|
--
|
439 |
|
|
-- Displays a message at end of simulation message, presents the simulation
|
440 |
|
|
-- results, and stops the simulation.
|
441 |
|
|
-- Call endsim() it only once.
|
442 |
|
|
--
|
443 |
|
|
-- Arguments:
|
444 |
|
|
-- pltbutils_sc PlTbUtils' global status- and control signal.
|
445 |
|
|
-- Must be set to pltbutils_sc.
|
446 |
|
|
--
|
447 |
|
|
-- show_success_fail If true, endsim() shows "*** SUCCESS ***",
|
448 |
|
|
-- "*** FAIL ***", or "*** NO CHECKS ***".
|
449 |
|
|
-- Optional, default is false.
|
450 |
|
|
--
|
451 |
|
|
-- force If true, forces the simulation to stop using an
|
452 |
|
|
-- assert failure statement. Use this option only
|
453 |
|
|
-- if the normal way of stopping the simulation
|
454 |
|
|
-- doesn't work (see below).
|
455 |
|
|
-- Optional, default is false.
|
456 |
|
|
--
|
457 |
|
|
-- The testbench should be designed so that all clocks stop when endsim()
|
458 |
|
|
-- sets the signal stop_sim to '1'. This should stop the simulator.
|
459 |
|
|
-- In some cases, that doesn't work, then set the force argument to true, which
|
460 |
|
|
-- causes a false assert failure, which should stop the simulator.
|
461 |
|
|
-- Scripts searching transcript logs for errors and failures, should ignore
|
462 |
|
|
-- the failure with "--- FORCE END OF SIMULATION ---" as part of the report.
|
463 |
|
|
--
|
464 |
|
|
-- NOTE:
|
465 |
|
|
-- The end-of-simulation messages and success/fail messages are not only
|
466 |
|
|
-- intended to be informative for humans. They are also intended to be
|
467 |
|
|
-- searched for by scripts, e.g. for collecting results from a large number
|
468 |
|
|
-- of regression tests.
|
469 |
|
|
-- For this reason, the message must be consistent and unique.
|
470 |
|
|
--
|
471 |
|
|
-- DO NOT MODIFY the messages "--- END OF SIMULATION ---",
|
472 |
|
|
-- "*** SUCCESS ***", "*** FAIL ***", "*** NO CHECKS ***".
|
473 |
|
|
-- DO NOT OUTPUT IDENTICAL MESSAGES anywhere else.
|
474 |
|
|
--
|
475 |
|
|
-- Examples:
|
476 |
|
|
-- endsim(pltbutils_sc);
|
477 |
|
|
-- endsim(pltbutils_sc, true);
|
478 |
|
|
-- endsim(pltbutils_sc, true, true);
|
479 |
|
|
----------------------------------------------------------------------------
|
480 |
|
|
procedure endsim(
|
481 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
482 |
|
|
constant show_success_fail : in boolean := false;
|
483 |
|
|
constant force : in boolean := false
|
484 |
|
|
) is
|
485 |
|
|
variable l : line;
|
486 |
|
|
begin
|
487 |
|
|
printv(v_pltbutils_info, "");
|
488 |
|
|
print(lf & "--- END OF SIMULATION ---");
|
489 |
|
|
print("Note: the results presented below are based on the PlTbUtil's check() procedure calls.");
|
490 |
|
|
print(" The design may contain more errors, for which there are no check() calls.");
|
491 |
|
|
write(l, now, right, 14);
|
492 |
|
|
writeline(output, l);
|
493 |
|
|
write(l, v_pltbutils_chk_cnt.value, right, 11); -- VHDL-2002
|
494 |
|
|
--write(l, v_pltbutils_chk_cnt, right, 11); -- VHDL-1993
|
495 |
|
|
write(l, string'(" Checks"));
|
496 |
|
|
writeline(output, l);
|
497 |
|
|
write(l, v_pltbutils_err_cnt.value, right, 11); -- VHDL-2002
|
498 |
|
|
--write(l, v_pltbutils_chk_cnt, right, 11); -- VHDL-1993
|
499 |
|
|
write(l, string'(" Errors"));
|
500 |
|
|
writeline(output, l);
|
501 |
|
|
|
502 |
|
|
if show_success_fail then
|
503 |
|
|
if v_pltbutils_err_cnt.value = 0 and v_pltbutils_chk_cnt.value > 0 then -- VHDL-2002
|
504 |
|
|
--if v_pltbutils_err_cnt = 0 and v_pltbutils_chk_cnt > 0 then -- VHDL-1993
|
505 |
|
|
print("*** SUCCESS ***");
|
506 |
|
|
elsif v_pltbutils_chk_cnt.value > 0 then -- VHDL-2002
|
507 |
|
|
--elsif v_pltbutils_chk_cnt > 0 then -- VHDL-1993
|
508 |
|
|
print("*** FAIL ***");
|
509 |
|
|
else
|
510 |
|
|
print("*** NO CHECKS ***");
|
511 |
|
|
end if;
|
512 |
|
|
end if;
|
513 |
|
|
-- VHDL-2002:
|
514 |
|
|
v_pltbutils_stop_sim.set('1');
|
515 |
|
|
v_pltbutils_test_num.clr;
|
516 |
|
|
v_pltbutils_test_name.set("END OF SIMULATION");
|
517 |
|
|
-- VHDL-1993:
|
518 |
|
|
--v_pltbutils_stop_sim := '1';
|
519 |
|
|
--v_pltbutils_test_num := 0;
|
520 |
|
|
--printv(v_pltbutils_test_name, "END OF SIMULATION");
|
521 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
522 |
|
|
wait for C_WAIT_BEFORE_STOP_TIME;
|
523 |
|
|
stop(0); -- VHDL-2008
|
524 |
|
|
assert not force
|
525 |
|
|
report "--- FORCE END OF SIMULATION ---" &
|
526 |
|
|
" (ignore this false failure message, it's not a real failure)"
|
527 |
|
|
severity failure;
|
528 |
|
|
wait;
|
529 |
|
|
end procedure endsim;
|
530 |
|
|
|
531 |
|
|
----------------------------------------------------------------------------
|
532 |
|
|
-- testname
|
533 |
|
|
--
|
534 |
|
|
-- procedure testname(
|
535 |
|
|
-- constant num : in integer := -1;
|
536 |
|
|
-- constant name : in string;
|
537 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t
|
538 |
|
|
-- )
|
539 |
|
|
--
|
540 |
|
|
-- Sets a number (optional) and a name for a test. The number and name will
|
541 |
|
|
-- be printed to the screen, and displayed in the simulator's waveform
|
542 |
|
|
-- window.
|
543 |
|
|
-- The test number and name is also included if there errors reported by the
|
544 |
|
|
-- check() procedure calls.
|
545 |
|
|
--
|
546 |
|
|
-- Arguments:
|
547 |
|
|
-- num Test number. Optional, default is to increment
|
548 |
|
|
-- the current test number.
|
549 |
|
|
--
|
550 |
|
|
-- name Test name.
|
551 |
|
|
--
|
552 |
|
|
-- pltbutils_sc PlTbUtils' global status- and control signal.
|
553 |
|
|
-- Must be set to pltbutils_sc.
|
554 |
|
|
--
|
555 |
|
|
-- If the test number is omitted, a new test number is automatically
|
556 |
|
|
-- computed by incrementing the current test number.
|
557 |
|
|
-- Manually setting the test number may make it easier to find the test code
|
558 |
|
|
-- in the testbench code, though.
|
559 |
|
|
--
|
560 |
|
|
-- Examples:
|
561 |
|
|
-- testname("Reset test", pltbutils_sc);
|
562 |
|
|
-- testname(1, "Reset test", pltbutils_sc);
|
563 |
|
|
----------------------------------------------------------------------------
|
564 |
|
|
procedure testname(
|
565 |
|
|
constant num : in integer := -1;
|
566 |
|
|
constant name : in string;
|
567 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
568 |
|
|
) is
|
569 |
|
|
begin
|
570 |
|
|
-- VHDL-2002:
|
571 |
|
|
if num = -1 then
|
572 |
|
|
v_pltbutils_test_num.inc;
|
573 |
|
|
else
|
574 |
|
|
v_pltbutils_test_num.set(num);
|
575 |
|
|
end if;
|
576 |
|
|
v_pltbutils_test_name.set(name);
|
577 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
578 |
14 |
pela |
print(lf & "Test " & str(v_pltbutils_test_num.value) & ": " & name);
|
579 |
2 |
pela |
-- VHDL-1993:
|
580 |
|
|
--if num = -1 then
|
581 |
|
|
-- b_pltbutils_test_num := v_pltbutils_test_num + 1;
|
582 |
|
|
--else
|
583 |
|
|
-- v_pltbutils_test_num := num;
|
584 |
|
|
--end if;
|
585 |
|
|
--printv(v_pltbutils_test_name, name);
|
586 |
|
|
--pltbutils_sc_update(pltbutils_sc);
|
587 |
|
|
--print("Test " & str(v_pltbutils_test_num) & ": " & name);
|
588 |
|
|
end procedure testname;
|
589 |
|
|
|
590 |
|
|
procedure testname(
|
591 |
|
|
constant name : in string;
|
592 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
593 |
|
|
) is
|
594 |
|
|
begin
|
595 |
|
|
testname(-1, name, pltbutils_sc);
|
596 |
|
|
end procedure testname;
|
597 |
|
|
|
598 |
|
|
----------------------------------------------------------------------------
|
599 |
|
|
-- print printv print2
|
600 |
|
|
--
|
601 |
|
|
-- procedure print(
|
602 |
|
|
-- signal s : out string;
|
603 |
|
|
-- constant txt : in string
|
604 |
|
|
-- )
|
605 |
|
|
--
|
606 |
6 |
pela |
-- procedure print(
|
607 |
|
|
-- constant active : in boolean;
|
608 |
|
|
-- signal s : out string;
|
609 |
|
|
-- constant txt : in string
|
610 |
|
|
-- )
|
611 |
|
|
--
|
612 |
2 |
pela |
-- procedure print(
|
613 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t;
|
614 |
|
|
-- constant txt : in string
|
615 |
|
|
-- )
|
616 |
|
|
--
|
617 |
6 |
pela |
-- procedure print(
|
618 |
|
|
-- constant active : in boolean;
|
619 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t;
|
620 |
|
|
-- constant txt : in string
|
621 |
|
|
-- )
|
622 |
|
|
--
|
623 |
2 |
pela |
-- procedure printv(
|
624 |
|
|
-- variable s : out string;
|
625 |
|
|
-- constant txt : in string
|
626 |
|
|
-- )
|
627 |
|
|
--
|
628 |
6 |
pela |
-- procedure printv(
|
629 |
|
|
-- constant active : in boolean;
|
630 |
|
|
-- variable s : out string;
|
631 |
|
|
-- constant txt : in string
|
632 |
|
|
-- )
|
633 |
|
|
--
|
634 |
2 |
pela |
-- procedure print2(
|
635 |
|
|
-- signal s : out string;
|
636 |
|
|
-- constant txt : in string
|
637 |
|
|
-- )
|
638 |
|
|
--
|
639 |
|
|
-- procedure print2(
|
640 |
6 |
pela |
-- constant active : in boolean;
|
641 |
|
|
-- signal s : out string;
|
642 |
|
|
-- constant txt : in string
|
643 |
|
|
-- )
|
644 |
|
|
--
|
645 |
|
|
-- procedure print2(
|
646 |
2 |
pela |
-- signal pltbutils : out pltbutils_sc_t;
|
647 |
|
|
-- constant txt : in string
|
648 |
|
|
-- )
|
649 |
|
|
--
|
650 |
6 |
pela |
-- procedure print2(
|
651 |
|
|
-- constant active : in boolean;
|
652 |
|
|
-- signal pltbutils : out pltbutils_sc_t;
|
653 |
|
|
-- constant txt : in string
|
654 |
|
|
-- )
|
655 |
|
|
--
|
656 |
2 |
pela |
-- print() prints text messages to a signal for viewing in the simulator's
|
657 |
|
|
-- waveform window. printv() does the same thing, but to a variable instead.
|
658 |
|
|
-- print2() prints both to a signal and to the transcript window.
|
659 |
|
|
-- The type of the output can be string or pltbutils_sc_t.
|
660 |
|
|
-- If the type is pltbutils_sc_t, the name can be no other than pltbutils_sc.
|
661 |
|
|
--
|
662 |
|
|
-- Arguments:
|
663 |
|
|
-- s Signal or variable of type string to be
|
664 |
|
|
-- printed to.
|
665 |
|
|
--
|
666 |
|
|
-- txt The text.
|
667 |
|
|
--
|
668 |
6 |
pela |
-- active The text is only printed if active is true.
|
669 |
|
|
-- Useful for debug switches, etc.
|
670 |
|
|
--
|
671 |
2 |
pela |
-- pltbutils_sc PlTbUtils' global status- and control signal
|
672 |
|
|
-- of type pltbutils_sc_t.
|
673 |
|
|
-- The name must be no other than pltbutils_sc.
|
674 |
|
|
--
|
675 |
|
|
-- If the string txt is longer than the signal s, the text will be truncated.
|
676 |
|
|
-- If txt is shorter, s will be padded with spaces.
|
677 |
|
|
--
|
678 |
|
|
-- Examples:
|
679 |
|
|
-- print(msg, "Hello, world"); -- Prints to signal msg
|
680 |
6 |
pela |
-- print(G_DEBUG, msg, "Hello, world"); -- Prints to signal msg if
|
681 |
|
|
-- -- generic G_DEBUG is true
|
682 |
2 |
pela |
-- printv(v_msg, "Hello, world"); -- Prints to variable msg
|
683 |
|
|
-- print(pltbutils_sc, "Hello, world"); -- Prints to "info" in waveform window
|
684 |
|
|
-- print2(msg, "Hello, world"); -- Prints to signal and transcript window
|
685 |
|
|
-- print(pltbutils_sc, "Hello, world"); -- Prints to "info" in waveform and
|
686 |
|
|
-- -- transcript windows
|
687 |
|
|
----------------------------------------------------------------------------
|
688 |
|
|
procedure print(
|
689 |
6 |
pela |
constant active : in boolean;
|
690 |
2 |
pela |
signal s : out string;
|
691 |
|
|
constant txt : in string
|
692 |
|
|
) is
|
693 |
|
|
variable j : positive := txt 'low;
|
694 |
|
|
begin
|
695 |
6 |
pela |
if active then
|
696 |
|
|
for i in s'range loop
|
697 |
|
|
if j <= txt 'high then
|
698 |
|
|
s(i) <= txt (j);
|
699 |
|
|
else
|
700 |
|
|
s(i) <= ' ';
|
701 |
|
|
end if;
|
702 |
|
|
j := j + 1;
|
703 |
|
|
end loop;
|
704 |
|
|
end if;
|
705 |
2 |
pela |
end procedure print;
|
706 |
|
|
|
707 |
6 |
pela |
procedure print(
|
708 |
|
|
signal s : out string;
|
709 |
|
|
constant txt : in string
|
710 |
|
|
) is
|
711 |
|
|
begin
|
712 |
|
|
print(true, s, txt);
|
713 |
|
|
end procedure print;
|
714 |
|
|
|
715 |
2 |
pela |
procedure printv(
|
716 |
6 |
pela |
constant active : in boolean;
|
717 |
2 |
pela |
variable s : out string;
|
718 |
|
|
constant txt : in string
|
719 |
|
|
) is
|
720 |
|
|
variable j : positive := txt 'low;
|
721 |
|
|
begin
|
722 |
6 |
pela |
if active then
|
723 |
|
|
for i in s'range loop
|
724 |
|
|
if j <= txt 'high then
|
725 |
|
|
s(i) := txt (j);
|
726 |
|
|
else
|
727 |
|
|
s(i) := ' ';
|
728 |
|
|
end if;
|
729 |
|
|
j := j + 1;
|
730 |
|
|
end loop;
|
731 |
|
|
end if;
|
732 |
2 |
pela |
end procedure printv;
|
733 |
|
|
|
734 |
6 |
pela |
procedure printv(
|
735 |
|
|
variable s : out string;
|
736 |
|
|
constant txt : in string
|
737 |
|
|
) is
|
738 |
|
|
begin
|
739 |
|
|
printv(true, s, txt);
|
740 |
|
|
end procedure printv;
|
741 |
|
|
|
742 |
2 |
pela |
-- VHDL-2002:
|
743 |
|
|
procedure printv(
|
744 |
6 |
pela |
constant active : in boolean;
|
745 |
2 |
pela |
variable s : inout pltbutils_p_string_t;
|
746 |
|
|
constant txt : in string
|
747 |
|
|
) is
|
748 |
|
|
variable j : positive := txt 'low;
|
749 |
|
|
begin
|
750 |
6 |
pela |
if active then
|
751 |
|
|
s.set(txt);
|
752 |
|
|
end if;
|
753 |
2 |
pela |
end procedure printv;
|
754 |
6 |
pela |
|
755 |
|
|
procedure printv(
|
756 |
|
|
variable s : inout pltbutils_p_string_t;
|
757 |
|
|
constant txt : in string
|
758 |
|
|
) is
|
759 |
|
|
begin
|
760 |
|
|
printv(true, s, txt);
|
761 |
|
|
end procedure printv;
|
762 |
2 |
pela |
|
763 |
|
|
-- Print to info element in pltbutils_sc, which shows up in waveform window
|
764 |
|
|
procedure print(
|
765 |
6 |
pela |
constant active : in boolean;
|
766 |
2 |
pela |
signal pltbutils_sc : out pltbutils_sc_t;
|
767 |
|
|
constant txt : in string
|
768 |
|
|
) is
|
769 |
|
|
variable j : positive := txt 'low;
|
770 |
|
|
begin
|
771 |
6 |
pela |
if active then
|
772 |
|
|
printv(v_pltbutils_info, txt );
|
773 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
774 |
|
|
end if;
|
775 |
2 |
pela |
end procedure print;
|
776 |
6 |
pela |
|
777 |
|
|
procedure print(
|
778 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
779 |
|
|
constant txt : in string
|
780 |
|
|
) is
|
781 |
|
|
begin
|
782 |
|
|
print(true, pltbutils_sc, txt);
|
783 |
|
|
end procedure print;
|
784 |
2 |
pela |
|
785 |
|
|
procedure print2(
|
786 |
6 |
pela |
constant active : in boolean;
|
787 |
2 |
pela |
signal s : out string;
|
788 |
|
|
constant txt : in string
|
789 |
|
|
) is
|
790 |
|
|
begin
|
791 |
6 |
pela |
if active then
|
792 |
|
|
print(s, txt );
|
793 |
|
|
print(txt);
|
794 |
|
|
end if;
|
795 |
2 |
pela |
end procedure print2;
|
796 |
|
|
|
797 |
|
|
procedure print2(
|
798 |
6 |
pela |
signal s : out string;
|
799 |
|
|
constant txt : in string
|
800 |
|
|
) is
|
801 |
|
|
begin
|
802 |
|
|
print(true, s, txt);
|
803 |
|
|
end procedure print2;
|
804 |
|
|
|
805 |
|
|
procedure print2(
|
806 |
|
|
constant active : in boolean;
|
807 |
2 |
pela |
signal pltbutils_sc : out pltbutils_sc_t;
|
808 |
|
|
constant txt : in string
|
809 |
|
|
) is
|
810 |
|
|
begin
|
811 |
|
|
print(pltbutils_sc, txt );
|
812 |
6 |
pela |
print(txt);
|
813 |
2 |
pela |
end procedure print2;
|
814 |
|
|
|
815 |
6 |
pela |
procedure print2(
|
816 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
817 |
|
|
constant txt : in string
|
818 |
|
|
) is
|
819 |
|
|
begin
|
820 |
|
|
print(true, pltbutils_sc, txt);
|
821 |
|
|
end procedure print2;
|
822 |
|
|
|
823 |
2 |
pela |
----------------------------------------------------------------------------
|
824 |
|
|
-- waitclks
|
825 |
|
|
--
|
826 |
|
|
-- procedure waitclks(
|
827 |
|
|
-- constant n : in natural;
|
828 |
|
|
-- signal clk : in std_logic;
|
829 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t;
|
830 |
|
|
-- constant falling : in boolean := false;
|
831 |
|
|
-- constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
832 |
|
|
-- )
|
833 |
|
|
--
|
834 |
|
|
-- Waits specified amount of clock cycles of the specified clock.
|
835 |
|
|
-- Or, to be more precise, a specified number of specified clock edges of
|
836 |
|
|
-- the specified clock.
|
837 |
|
|
--
|
838 |
|
|
-- Arguments:
|
839 |
|
|
-- n Number of rising or falling clock edges to wait.
|
840 |
|
|
--
|
841 |
|
|
-- clk The clock to wait for.
|
842 |
|
|
--
|
843 |
|
|
-- pltbutils_sc PlTbUtils' global status- and control signal.
|
844 |
|
|
-- Must be set to pltbutils_sc.
|
845 |
|
|
--
|
846 |
|
|
-- falling If true, waits for falling edges, otherwise
|
847 |
|
|
-- rising edges. Optional, default is false.
|
848 |
|
|
--
|
849 |
|
|
-- timeout Timeout time, in case the clock is not working.
|
850 |
|
|
-- Optional, default is C_PLTBUTILS_TIMEOUT.
|
851 |
|
|
--
|
852 |
|
|
-- Examples:
|
853 |
|
|
-- waitclks(5, sys_clk, pltbutils_sc);
|
854 |
|
|
-- waitclks(5, sys_clk, pltbutils_sc, true);
|
855 |
|
|
-- waitclks(5, sys_clk, pltbutils_sc, true, 1 ms);
|
856 |
|
|
----------------------------------------------------------------------------
|
857 |
|
|
procedure waitclks(
|
858 |
|
|
constant n : in natural;
|
859 |
|
|
signal clk : in std_logic;
|
860 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
861 |
|
|
constant falling : in boolean := false;
|
862 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
863 |
|
|
) is
|
864 |
|
|
variable i : natural := n;
|
865 |
|
|
variable v_timeout_time : time;
|
866 |
|
|
begin
|
867 |
|
|
v_timeout_time := now + timeout;
|
868 |
|
|
while i > 0 loop
|
869 |
6 |
pela |
if falling then
|
870 |
2 |
pela |
wait until falling_edge(clk) for timeout / n;
|
871 |
|
|
else
|
872 |
|
|
wait until rising_edge(clk) for timeout / n;
|
873 |
|
|
end if;
|
874 |
|
|
i := i - 1;
|
875 |
|
|
end loop;
|
876 |
|
|
if now >= v_timeout_time then
|
877 |
|
|
assert false
|
878 |
|
|
report "waitclks() timeout"
|
879 |
|
|
severity error;
|
880 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
881 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
882 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
883 |
|
|
end if;
|
884 |
|
|
end procedure waitclks;
|
885 |
6 |
pela |
|
886 |
|
|
----------------------------------------------------------------------------
|
887 |
|
|
-- waitsig
|
888 |
|
|
--
|
889 |
|
|
-- procedure waitsig(
|
890 |
|
|
-- signal s : in integer|std_logic|std_logic_vector|unsigned|signed;
|
891 |
|
|
-- constant value : in integer|std_logic|std_logic_vector|unsigned|signed;
|
892 |
|
|
-- signal clk : in std_logic;
|
893 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t;
|
894 |
|
|
-- constant falling : in boolean := false;
|
895 |
|
|
-- constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
896 |
|
|
-- )
|
897 |
|
|
--
|
898 |
|
|
-- Waits until a signal has reached a specified value after specified clock
|
899 |
|
|
-- edge.
|
900 |
|
|
--
|
901 |
|
|
-- Arguments:
|
902 |
|
|
-- s The signal to test.
|
903 |
|
|
-- Supported types: integer, std_logic,
|
904 |
|
|
-- std_logic_vector, unsigned, signed.
|
905 |
|
|
--
|
906 |
|
|
-- value Value to wait for.
|
907 |
|
|
-- Same type as data or integer.
|
908 |
|
|
--
|
909 |
|
|
-- clk The clock.
|
910 |
|
|
--
|
911 |
|
|
-- pltbutils_sc PlTbUtils' global status- and control signal.
|
912 |
|
|
-- Must be set to pltbutils_sc.
|
913 |
|
|
--
|
914 |
|
|
-- falling If true, waits for falling edges, otherwise
|
915 |
|
|
-- rising edges. Optional, default is false.
|
916 |
|
|
--
|
917 |
|
|
-- timeout Timeout time, in case the clock is not working.
|
918 |
|
|
-- Optional, default is C_PLTBUTILS_TIMEOUT.
|
919 |
|
|
--
|
920 |
|
|
-- Examples:
|
921 |
|
|
-- waitsig(wr_en, '1', sys_clk, pltbutils_sc);
|
922 |
|
|
-- waitsig(rd_en, 1, sys_clk, pltbutils_sc, true);
|
923 |
|
|
-- waitclks(full, '1', sys_clk, pltbutils_sc, true, 1 ms);
|
924 |
|
|
----------------------------------------------------------------------------
|
925 |
|
|
procedure waitsig(
|
926 |
|
|
signal s : in integer;
|
927 |
|
|
constant value : in integer;
|
928 |
|
|
signal clk : in std_logic;
|
929 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
930 |
|
|
constant falling : in boolean := false;
|
931 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
932 |
|
|
) is
|
933 |
|
|
variable v_timeout_time : time;
|
934 |
|
|
begin
|
935 |
|
|
v_timeout_time := now + timeout;
|
936 |
|
|
l1 : loop
|
937 |
|
|
waitclks(1, clk, pltbutils_sc, falling, timeout);
|
938 |
|
|
exit l1 when s = value or now >= v_timeout_time;
|
939 |
|
|
end loop;
|
940 |
|
|
if now >= v_timeout_time then
|
941 |
|
|
assert false
|
942 |
|
|
report "waitsig() timeout"
|
943 |
|
|
severity error;
|
944 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
945 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
946 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
947 |
|
|
end if;
|
948 |
|
|
end procedure waitsig;
|
949 |
|
|
|
950 |
|
|
procedure waitsig(
|
951 |
|
|
signal s : in std_logic;
|
952 |
|
|
constant value : in std_logic;
|
953 |
|
|
signal clk : in std_logic;
|
954 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
955 |
|
|
constant falling : in boolean := false;
|
956 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
957 |
|
|
) is
|
958 |
|
|
variable v_timeout_time : time;
|
959 |
|
|
begin
|
960 |
|
|
v_timeout_time := now + timeout;
|
961 |
|
|
l1 : loop
|
962 |
|
|
waitclks(1, clk, pltbutils_sc, falling, timeout);
|
963 |
|
|
exit l1 when s = value or now >= v_timeout_time;
|
964 |
|
|
end loop;
|
965 |
|
|
if now >= v_timeout_time then
|
966 |
|
|
assert false
|
967 |
|
|
report "waitsig() timeout"
|
968 |
|
|
severity error;
|
969 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
970 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
971 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
972 |
|
|
end if;
|
973 |
|
|
end procedure waitsig;
|
974 |
2 |
pela |
|
975 |
6 |
pela |
procedure waitsig(
|
976 |
|
|
signal s : in std_logic;
|
977 |
|
|
constant value : in integer;
|
978 |
|
|
signal clk : in std_logic;
|
979 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
980 |
|
|
constant falling : in boolean := false;
|
981 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
982 |
|
|
) is
|
983 |
|
|
variable v_value : std_logic;
|
984 |
|
|
variable v_timeout_time : time;
|
985 |
|
|
begin
|
986 |
|
|
case value is
|
987 |
|
|
when 0 => v_value := '0';
|
988 |
|
|
when 1 => v_value := '1';
|
989 |
|
|
when others => v_value := 'X';
|
990 |
|
|
end case;
|
991 |
|
|
if v_value /= 'X' then
|
992 |
|
|
waitsig(s, v_value, clk,
|
993 |
|
|
pltbutils_sc, falling, timeout);
|
994 |
|
|
else
|
995 |
|
|
assert false
|
996 |
|
|
report "waitsig() illegal value to wait for: " & integer'image(value)
|
997 |
|
|
severity error;
|
998 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
999 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1000 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1001 |
|
|
end if;
|
1002 |
|
|
end procedure waitsig;
|
1003 |
|
|
|
1004 |
|
|
procedure waitsig(
|
1005 |
|
|
signal s : in std_logic_vector;
|
1006 |
|
|
constant value : in std_logic_vector;
|
1007 |
|
|
signal clk : in std_logic;
|
1008 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
1009 |
|
|
constant falling : in boolean := false;
|
1010 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
1011 |
|
|
) is
|
1012 |
|
|
variable v_timeout_time : time;
|
1013 |
|
|
begin
|
1014 |
|
|
v_timeout_time := now + timeout;
|
1015 |
|
|
l1 : loop
|
1016 |
|
|
waitclks(1, clk, pltbutils_sc, falling, timeout);
|
1017 |
|
|
exit l1 when s = value or now >= v_timeout_time;
|
1018 |
|
|
end loop;
|
1019 |
|
|
if now >= v_timeout_time then
|
1020 |
|
|
assert false
|
1021 |
|
|
report "waitsig() timeout"
|
1022 |
|
|
severity error;
|
1023 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
1024 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1025 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1026 |
|
|
end if;
|
1027 |
|
|
end procedure waitsig;
|
1028 |
|
|
|
1029 |
|
|
procedure waitsig(
|
1030 |
|
|
signal s : in std_logic_vector;
|
1031 |
|
|
constant value : in integer;
|
1032 |
|
|
signal clk : in std_logic;
|
1033 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
1034 |
|
|
constant falling : in boolean := false;
|
1035 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
1036 |
|
|
) is
|
1037 |
|
|
variable v_timeout_time : time;
|
1038 |
|
|
begin
|
1039 |
|
|
waitsig(s, std_logic_vector(to_unsigned(value, s'length)), clk,
|
1040 |
|
|
pltbutils_sc, falling, timeout);
|
1041 |
|
|
end procedure waitsig;
|
1042 |
|
|
|
1043 |
|
|
procedure waitsig(
|
1044 |
|
|
signal s : in unsigned;
|
1045 |
|
|
constant value : in unsigned;
|
1046 |
|
|
signal clk : in std_logic;
|
1047 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
1048 |
|
|
constant falling : in boolean := false;
|
1049 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
1050 |
|
|
) is
|
1051 |
|
|
variable v_timeout_time : time;
|
1052 |
|
|
begin
|
1053 |
|
|
v_timeout_time := now + timeout;
|
1054 |
|
|
l1 : loop
|
1055 |
|
|
waitclks(1, clk, pltbutils_sc, falling, timeout);
|
1056 |
|
|
exit l1 when s = value or now >= v_timeout_time;
|
1057 |
|
|
end loop;
|
1058 |
|
|
if now >= v_timeout_time then
|
1059 |
|
|
assert false
|
1060 |
|
|
report "waitsig() timeout"
|
1061 |
|
|
severity error;
|
1062 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
1063 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1064 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1065 |
|
|
end if;
|
1066 |
|
|
end procedure waitsig;
|
1067 |
|
|
|
1068 |
|
|
procedure waitsig(
|
1069 |
|
|
signal s : in unsigned;
|
1070 |
|
|
constant value : in integer;
|
1071 |
|
|
signal clk : in std_logic;
|
1072 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
1073 |
|
|
constant falling : in boolean := false;
|
1074 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
1075 |
|
|
) is
|
1076 |
|
|
variable v_timeout_time : time;
|
1077 |
|
|
begin
|
1078 |
|
|
waitsig(s, to_unsigned(value, s'length), clk,
|
1079 |
|
|
pltbutils_sc, falling, timeout);
|
1080 |
|
|
end procedure waitsig;
|
1081 |
|
|
|
1082 |
|
|
procedure waitsig(
|
1083 |
|
|
signal s : in signed;
|
1084 |
|
|
constant value : in signed;
|
1085 |
|
|
signal clk : in std_logic;
|
1086 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
1087 |
|
|
constant falling : in boolean := false;
|
1088 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
1089 |
|
|
) is
|
1090 |
|
|
variable v_timeout_time : time;
|
1091 |
|
|
begin
|
1092 |
|
|
v_timeout_time := now + timeout;
|
1093 |
|
|
l1 : loop
|
1094 |
|
|
waitclks(1, clk, pltbutils_sc, falling, timeout);
|
1095 |
|
|
exit l1 when s = value or now >= v_timeout_time;
|
1096 |
|
|
end loop;
|
1097 |
|
|
if now >= v_timeout_time then
|
1098 |
|
|
assert false
|
1099 |
|
|
report "waitsig() timeout"
|
1100 |
|
|
severity error;
|
1101 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
1102 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1103 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1104 |
|
|
end if;
|
1105 |
|
|
end procedure waitsig;
|
1106 |
|
|
|
1107 |
|
|
procedure waitsig(
|
1108 |
|
|
signal s : in signed;
|
1109 |
|
|
constant value : in integer;
|
1110 |
|
|
signal clk : in std_logic;
|
1111 |
|
|
signal pltbutils_sc : out pltbutils_sc_t;
|
1112 |
|
|
constant falling : in boolean := false;
|
1113 |
|
|
constant timeout : in time := C_PLTBUTILS_TIMEOUT
|
1114 |
|
|
) is
|
1115 |
|
|
variable v_timeout_time : time;
|
1116 |
|
|
begin
|
1117 |
|
|
waitsig(s, to_signed(value, s'length), clk,
|
1118 |
|
|
pltbutils_sc, falling, timeout);
|
1119 |
|
|
end procedure waitsig;
|
1120 |
|
|
|
1121 |
2 |
pela |
----------------------------------------------------------------------------
|
1122 |
|
|
-- check
|
1123 |
|
|
--
|
1124 |
|
|
-- procedure check(
|
1125 |
|
|
-- constant rpt : in string;
|
1126 |
|
|
-- constant data : in integer|std_logic|std_logic_vector|unsigned|signed;
|
1127 |
|
|
-- constant expected : in integer|std_logic|std_logic_vector|unsigned|signed;
|
1128 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t
|
1129 |
|
|
-- )
|
1130 |
|
|
--
|
1131 |
|
|
-- procedure check(
|
1132 |
|
|
-- constant rpt : in string;
|
1133 |
|
|
-- constant data : in std_logic_vector;
|
1134 |
|
|
-- constant expected : in std_logic_vector;
|
1135 |
|
|
-- constant mask : in std_logic_vector;
|
1136 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t
|
1137 |
|
|
-- )
|
1138 |
|
|
--
|
1139 |
|
|
-- procedure check(
|
1140 |
|
|
-- constant rpt : in string;
|
1141 |
|
|
-- constant expr : in boolean;
|
1142 |
|
|
-- signal pltbutils_sc : out pltbutils_sc_t
|
1143 |
|
|
-- )
|
1144 |
|
|
--
|
1145 |
|
|
-- Checks that the value of a signal or variable is equal to expected.
|
1146 |
|
|
-- If not equal, displays an error message and increments the error counter.
|
1147 |
|
|
--
|
1148 |
|
|
-- Arguments:
|
1149 |
|
|
-- rpt Report message to be displayed in case of
|
1150 |
|
|
-- mismatch.
|
1151 |
|
|
-- It is recommended that the message is unique
|
1152 |
|
|
-- and that it contains the name of the signal
|
1153 |
|
|
-- or variable being checked.
|
1154 |
|
|
-- The message should NOT contain the expected
|
1155 |
|
|
-- value, becase check() prints that
|
1156 |
|
|
-- automatically.
|
1157 |
|
|
--
|
1158 |
|
|
-- data The signal or variable to be checked.
|
1159 |
|
|
-- Supported types: integer, std_logic,
|
1160 |
|
|
-- std_logic_vector, unsigned, signed.
|
1161 |
|
|
--
|
1162 |
|
|
-- expected Expected value.
|
1163 |
|
|
-- Same type as data or integer.
|
1164 |
|
|
--
|
1165 |
|
|
-- mask Bit mask and:ed to data and expected
|
1166 |
|
|
-- before comparison.
|
1167 |
|
|
-- Optional if data is std_logic_vector.
|
1168 |
|
|
-- Not allowed for other types.
|
1169 |
|
|
--
|
1170 |
|
|
-- expr boolean expression for checking.
|
1171 |
|
|
-- This makes it possible to check any kind of
|
1172 |
|
|
-- expresion, not just equality.
|
1173 |
|
|
--
|
1174 |
|
|
-- pltbutils_sc PlTbUtils' global status- and control signal.
|
1175 |
|
|
-- Must be set to the name pltbutils_sc.
|
1176 |
|
|
--
|
1177 |
|
|
-- Examples:
|
1178 |
|
|
-- check("dat_o after reset", dat_o, 0, pltbutils_sc);
|
1179 |
|
|
-- -- With mask:
|
1180 |
|
|
-- check("Status field in reg_o after start", reg_o, x"01", x"03", pltbutils_sc);
|
1181 |
|
|
-- -- Boolean expression:
|
1182 |
|
|
-- check("Counter after data burst", cnt_o > 10, pltbutils_sc);
|
1183 |
|
|
----------------------------------------------------------------------------
|
1184 |
|
|
-- check integer
|
1185 |
|
|
procedure check(
|
1186 |
|
|
constant rpt : in string;
|
1187 |
|
|
constant data : in integer;
|
1188 |
|
|
constant expected : in integer;
|
1189 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1190 |
|
|
) is
|
1191 |
|
|
begin
|
1192 |
|
|
v_pltbutils_chk_cnt.inc; -- VHDL-2002
|
1193 |
|
|
--v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
|
1194 |
|
|
if data /= expected then
|
1195 |
|
|
assert false
|
1196 |
|
|
report "Check " &
|
1197 |
|
|
str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
|
1198 |
|
|
--str(v_pltbutils_chk_cnt) & -- VHDL-1993
|
1199 |
|
|
"; " & rpt &
|
1200 |
|
|
"; Data=" & str(data) &
|
1201 |
|
|
" Expected=" & str(expected) &
|
1202 |
|
|
" " & --str(character'(lf)) &
|
1203 |
|
|
" in test " &
|
1204 |
|
|
str(v_pltbutils_test_num.value) & -- VHDL-2002
|
1205 |
|
|
--str(v_pltbutils_test_num) & -- VHDL-1993
|
1206 |
|
|
" " &
|
1207 |
|
|
v_pltbutils_test_name.value -- VHDL-2002
|
1208 |
|
|
--v_pltbutils_test_name -- VHDL-1993
|
1209 |
|
|
severity error;
|
1210 |
|
|
v_pltbutils_err_cnt.inc; -- VHLD-2002
|
1211 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1212 |
|
|
end if;
|
1213 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1214 |
|
|
end procedure check;
|
1215 |
|
|
|
1216 |
|
|
-- check std_logic
|
1217 |
|
|
procedure check(
|
1218 |
|
|
constant rpt : in string;
|
1219 |
|
|
constant data : in std_logic;
|
1220 |
|
|
constant expected : in std_logic;
|
1221 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1222 |
|
|
) is
|
1223 |
|
|
begin
|
1224 |
|
|
v_pltbutils_chk_cnt.inc; -- VHDL-2002
|
1225 |
|
|
--v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
|
1226 |
|
|
if data /= expected then
|
1227 |
|
|
assert false
|
1228 |
|
|
report "Check " &
|
1229 |
|
|
str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
|
1230 |
|
|
--str(v_pltbutils_chk_cnt) & -- VHDL-1993
|
1231 |
|
|
"; " & rpt &
|
1232 |
|
|
"; Data=" & str(data) &
|
1233 |
|
|
" Expected=" & str(expected) &
|
1234 |
|
|
" " & --str(character'(lf)) &
|
1235 |
|
|
" in test " &
|
1236 |
|
|
str(v_pltbutils_test_num.value) & -- VHDL-2002
|
1237 |
|
|
--str(v_pltbutils_test_num) & -- VHDL-1993
|
1238 |
|
|
" " &
|
1239 |
|
|
v_pltbutils_test_name.value -- VHDL-2002
|
1240 |
|
|
--v_pltbutils_test_name -- VHDL-1993
|
1241 |
|
|
severity error;
|
1242 |
|
|
v_pltbutils_err_cnt.inc; -- VHLD-2002
|
1243 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1244 |
|
|
end if;
|
1245 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1246 |
|
|
end procedure check;
|
1247 |
|
|
|
1248 |
|
|
-- check std_logic against integer
|
1249 |
|
|
procedure check(
|
1250 |
|
|
constant rpt : in string;
|
1251 |
|
|
constant data : in std_logic;
|
1252 |
|
|
constant expected : in integer;
|
1253 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1254 |
|
|
) is
|
1255 |
|
|
variable v_expected : std_logic;
|
1256 |
|
|
begin
|
1257 |
|
|
if expected = 0 then
|
1258 |
|
|
check(rpt , data, std_logic'('0'), pltbutils_sc);
|
1259 |
|
|
elsif expected = 1 then
|
1260 |
|
|
check(rpt , data, std_logic'('1'), pltbutils_sc);
|
1261 |
|
|
else
|
1262 |
|
|
v_pltbutils_chk_cnt.inc; -- VHDL-2002
|
1263 |
|
|
--v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
|
1264 |
|
|
assert false
|
1265 |
|
|
report "Check " &
|
1266 |
|
|
str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
|
1267 |
|
|
--str(v_pltbutils_chk_cnt) & -- VHDL-1993
|
1268 |
|
|
"; " & rpt &
|
1269 |
|
|
"; Data=" & str(data) &
|
1270 |
|
|
" Expected=" & str(expected) &
|
1271 |
|
|
" " & --str(character'(lf)) &
|
1272 |
|
|
" in test " &
|
1273 |
|
|
str(v_pltbutils_test_num.value) & -- VHDL-2002
|
1274 |
|
|
--str(v_pltbutils_test_num) & -- VHDL-1993
|
1275 |
|
|
" " &
|
1276 |
|
|
v_pltbutils_test_name.value -- VHDL-2002
|
1277 |
|
|
--v_pltbutils_test_name -- VHDL-1993
|
1278 |
|
|
severity error;
|
1279 |
|
|
v_pltbutils_err_cnt.inc; -- VHLD-2002
|
1280 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1281 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1282 |
|
|
end if;
|
1283 |
|
|
end procedure check;
|
1284 |
|
|
|
1285 |
|
|
-- check std_logic_vector
|
1286 |
|
|
procedure check(
|
1287 |
|
|
constant rpt : in string;
|
1288 |
|
|
constant data : in std_logic_vector;
|
1289 |
|
|
constant expected : in std_logic_vector;
|
1290 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1291 |
|
|
) is
|
1292 |
|
|
begin
|
1293 |
|
|
v_pltbutils_chk_cnt.inc; -- VHDL-2002
|
1294 |
|
|
--v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
|
1295 |
|
|
if data /= expected then
|
1296 |
|
|
assert false
|
1297 |
|
|
report "Check " &
|
1298 |
|
|
str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
|
1299 |
|
|
--str(v_pltbutils_chk_cnt) & -- VHDL-1993
|
1300 |
|
|
"; " & rpt &
|
1301 |
14 |
pela |
"; Data=" & hxstr(data, "0x") &
|
1302 |
|
|
" Expected=" & hxstr(expected, "0x") &
|
1303 |
2 |
pela |
" " & --str('lf') &
|
1304 |
|
|
" in test " &
|
1305 |
|
|
str(v_pltbutils_test_num.value) & -- VHDL-2002
|
1306 |
|
|
--str(v_pltbutils_test_num) & -- VHDL-1993
|
1307 |
|
|
" " &
|
1308 |
|
|
v_pltbutils_test_name.value -- VHDL-2002
|
1309 |
|
|
--v_pltbutils_test_name -- VHDL-1993
|
1310 |
|
|
severity error;
|
1311 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
1312 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1313 |
|
|
end if;
|
1314 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1315 |
|
|
end procedure check;
|
1316 |
|
|
|
1317 |
|
|
-- check std_logic_vector with mask
|
1318 |
|
|
procedure check(
|
1319 |
|
|
constant rpt : in string;
|
1320 |
|
|
constant data : in std_logic_vector;
|
1321 |
|
|
constant expected : in std_logic_vector;
|
1322 |
|
|
constant mask : in std_logic_vector;
|
1323 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1324 |
|
|
) is
|
1325 |
|
|
begin
|
1326 |
|
|
v_pltbutils_chk_cnt.inc; -- VHDL-2002
|
1327 |
|
|
--v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
|
1328 |
|
|
if (data and mask) /= (expected and mask) then
|
1329 |
|
|
assert false
|
1330 |
|
|
report "Check " &
|
1331 |
|
|
str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
|
1332 |
|
|
--str(v_pltbutils_chk_cnt) & -- VHDL-1993
|
1333 |
|
|
"; " & rpt &
|
1334 |
14 |
pela |
"; Data=" & hxstr(data, "0x") &
|
1335 |
|
|
" Expected=" & hxstr(expected, "0x") &
|
1336 |
|
|
" Mask=" & hxstr(mask, "0x") &
|
1337 |
2 |
pela |
" " & --str('lf') &
|
1338 |
|
|
" in test " &
|
1339 |
|
|
str(v_pltbutils_test_num.value) & -- VHDL-2002
|
1340 |
|
|
--str(v_pltbutils_test_num) & -- VHDL-1993
|
1341 |
|
|
" " &
|
1342 |
|
|
v_pltbutils_test_name.value -- VHDL-2002
|
1343 |
|
|
--v_pltbutils_test_name -- VHDL-1993
|
1344 |
|
|
severity error;
|
1345 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
1346 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1347 |
|
|
end if;
|
1348 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1349 |
|
|
end procedure check;
|
1350 |
|
|
|
1351 |
|
|
-- check std_logic_vector against integer
|
1352 |
|
|
procedure check(
|
1353 |
|
|
constant rpt : in string;
|
1354 |
|
|
constant data : in std_logic_vector;
|
1355 |
|
|
constant expected : in integer;
|
1356 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1357 |
|
|
) is
|
1358 |
|
|
begin
|
1359 |
|
|
check(rpt, data, std_logic_vector(to_signed(expected, data'length)), pltbutils_sc);
|
1360 |
|
|
end procedure check;
|
1361 |
|
|
|
1362 |
|
|
-- check std_logic_vector with mask against integer
|
1363 |
|
|
procedure check(
|
1364 |
|
|
constant rpt : in string;
|
1365 |
|
|
constant data : in std_logic_vector;
|
1366 |
|
|
constant expected : in integer;
|
1367 |
|
|
constant mask : in std_logic_vector;
|
1368 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1369 |
|
|
) is
|
1370 |
|
|
begin
|
1371 |
|
|
check(rpt, data, std_logic_vector(to_signed(expected, data'length)), mask, pltbutils_sc);
|
1372 |
|
|
end procedure check;
|
1373 |
|
|
|
1374 |
|
|
-- check unsigned
|
1375 |
|
|
procedure check(
|
1376 |
|
|
constant rpt : in string;
|
1377 |
|
|
constant data : in unsigned;
|
1378 |
|
|
constant expected : in unsigned;
|
1379 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1380 |
|
|
) is
|
1381 |
|
|
begin
|
1382 |
|
|
v_pltbutils_chk_cnt.inc; -- VHDL-2002
|
1383 |
|
|
--v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
|
1384 |
|
|
if data /= expected then
|
1385 |
|
|
assert false
|
1386 |
|
|
report "Check " &
|
1387 |
|
|
str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
|
1388 |
|
|
--str(v_pltbutils_chk_cnt) & -- VHDL-1993
|
1389 |
|
|
"; " & rpt &
|
1390 |
14 |
pela |
"; Data=" & hxstr(data, "0x") &
|
1391 |
|
|
" Expected=" & hxstr(expected, "0x") &
|
1392 |
2 |
pela |
" " & --str('lf') &
|
1393 |
|
|
" in test " &
|
1394 |
|
|
str(v_pltbutils_test_num.value) & -- VHDL-2002
|
1395 |
|
|
--str(v_pltbutils_test_num) & -- VHDL-1993
|
1396 |
|
|
" " &
|
1397 |
|
|
v_pltbutils_test_name.value -- VHDL-2002
|
1398 |
|
|
--v_pltbutils_test_name -- VHDL-1993
|
1399 |
|
|
severity error;
|
1400 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
1401 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1402 |
|
|
end if;
|
1403 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1404 |
|
|
end procedure check;
|
1405 |
|
|
|
1406 |
|
|
-- check unsigned against integer
|
1407 |
|
|
procedure check(
|
1408 |
|
|
constant rpt : in string;
|
1409 |
|
|
constant data : in unsigned;
|
1410 |
|
|
constant expected : in integer;
|
1411 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1412 |
|
|
) is
|
1413 |
|
|
begin
|
1414 |
|
|
check(rpt, data, to_unsigned(expected, data'length), pltbutils_sc);
|
1415 |
|
|
end procedure check;
|
1416 |
|
|
|
1417 |
|
|
-- check signed
|
1418 |
|
|
procedure check(
|
1419 |
|
|
constant rpt : in string;
|
1420 |
|
|
constant data : in signed;
|
1421 |
|
|
constant expected : in signed;
|
1422 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1423 |
|
|
) is
|
1424 |
|
|
begin
|
1425 |
|
|
v_pltbutils_chk_cnt.inc; -- VHDL-2002
|
1426 |
|
|
--v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
|
1427 |
|
|
if data /= expected then
|
1428 |
|
|
assert false
|
1429 |
|
|
report "Check " &
|
1430 |
|
|
str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
|
1431 |
|
|
--str(v_pltbutils_chk_cnt) & -- VHDL-1993
|
1432 |
|
|
"; " & rpt &
|
1433 |
14 |
pela |
"; Data=" & hxstr(data, "0x") &
|
1434 |
|
|
" Expected=" & hxstr(expected, "0x") &
|
1435 |
2 |
pela |
" " & --str('lf') &
|
1436 |
|
|
" in test " &
|
1437 |
|
|
str(v_pltbutils_test_num.value) & -- VHDL-2002
|
1438 |
|
|
--str(v_pltbutils_test_num) & -- VHDL-1993
|
1439 |
|
|
" " &
|
1440 |
|
|
v_pltbutils_test_name.value -- VHDL-2002
|
1441 |
|
|
--v_pltbutils_test_name -- VHDL-1993
|
1442 |
|
|
severity error;
|
1443 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
1444 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1445 |
|
|
end if;
|
1446 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1447 |
|
|
end procedure check;
|
1448 |
|
|
|
1449 |
|
|
-- check signed against integer
|
1450 |
|
|
-- TODO: find the bug reported by tb_pltbutils when expected is negative (-1):
|
1451 |
|
|
-- ** Error: (vsim-86) numstd_conv_unsigned_nu: NATURAL arg value is negative (-1)
|
1452 |
|
|
procedure check(
|
1453 |
|
|
constant rpt : in string;
|
1454 |
|
|
constant data : in signed;
|
1455 |
|
|
constant expected : in integer;
|
1456 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1457 |
|
|
) is
|
1458 |
|
|
begin
|
1459 |
|
|
check(rpt, data, to_signed(expected, data'length), pltbutils_sc);
|
1460 |
|
|
end procedure check;
|
1461 |
|
|
|
1462 |
|
|
-- check with boolean expression
|
1463 |
|
|
-- Check signal or variable with a boolean expression as argument C_EXPR.
|
1464 |
|
|
-- This allowes any kind of check.
|
1465 |
|
|
procedure check(
|
1466 |
|
|
constant rpt : in string;
|
1467 |
|
|
constant expr : in boolean;
|
1468 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1469 |
|
|
) is
|
1470 |
|
|
begin
|
1471 |
|
|
v_pltbutils_chk_cnt.inc; -- VHDL-2002
|
1472 |
|
|
--v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
|
1473 |
|
|
if not expr then
|
1474 |
|
|
assert false
|
1475 |
|
|
report "Check " &
|
1476 |
|
|
str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
|
1477 |
|
|
--str(v_pltbutils_chk_cnt) & -- VHDL-1993
|
1478 |
|
|
"; " & rpt &
|
1479 |
|
|
" " & --str('lf') &
|
1480 |
|
|
" in test " &
|
1481 |
|
|
str(v_pltbutils_test_num.value) & -- VHDL-2002
|
1482 |
|
|
--str(v_pltbutils_test_num) & -- VHDL-1993
|
1483 |
|
|
" " &
|
1484 |
|
|
v_pltbutils_test_name.value -- VHDL-2002
|
1485 |
|
|
--v_pltbutils_test_name -- VHDL-1993
|
1486 |
|
|
severity error;
|
1487 |
|
|
v_pltbutils_err_cnt.inc; -- VHDL-2002
|
1488 |
|
|
--v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
|
1489 |
|
|
end if;
|
1490 |
|
|
pltbutils_sc_update(pltbutils_sc);
|
1491 |
|
|
end procedure check;
|
1492 |
|
|
|
1493 |
|
|
----------------------------------------------------------------------------
|
1494 |
14 |
pela |
-- to_ascending
|
1495 |
|
|
--
|
1496 |
|
|
-- function to_ascending(
|
1497 |
|
|
-- constant s : std_logic_vector
|
1498 |
|
|
-- ) return std_logic_vector;
|
1499 |
|
|
--
|
1500 |
|
|
-- function to_ascending(
|
1501 |
|
|
-- constant s : unsigned
|
1502 |
|
|
-- ) return unsigned
|
1503 |
|
|
--
|
1504 |
|
|
-- function to_ascending(
|
1505 |
|
|
-- constant s : signed
|
1506 |
|
|
-- ) return signed;
|
1507 |
|
|
--
|
1508 |
|
|
-- Converts a signal to ascending range ( "to"-range ).
|
1509 |
|
|
-- The argument s can have ascending or descending range.
|
1510 |
|
|
----------------------------------------------------------------------------
|
1511 |
|
|
function to_ascending(
|
1512 |
|
|
constant s : std_logic_vector
|
1513 |
|
|
) return std_logic_vector is
|
1514 |
|
|
variable r : std_logic_vector(0 to s'length-1);
|
1515 |
|
|
begin
|
1516 |
|
|
for i in r'range loop
|
1517 |
|
|
r(i) := s(i);
|
1518 |
|
|
end loop;
|
1519 |
|
|
return r;
|
1520 |
|
|
end function to_ascending;
|
1521 |
|
|
|
1522 |
|
|
function to_ascending(
|
1523 |
|
|
constant s : unsigned
|
1524 |
|
|
) return unsigned is
|
1525 |
|
|
variable r : unsigned(0 to s'length-1);
|
1526 |
|
|
begin
|
1527 |
|
|
for i in r'range loop
|
1528 |
|
|
r(i) := s(i);
|
1529 |
|
|
end loop;
|
1530 |
|
|
return r;
|
1531 |
|
|
end function to_ascending;
|
1532 |
|
|
|
1533 |
|
|
function to_ascending(
|
1534 |
|
|
constant s : signed
|
1535 |
|
|
) return signed is
|
1536 |
|
|
variable r : signed(0 to s'length-1);
|
1537 |
|
|
begin
|
1538 |
|
|
for i in r'range loop
|
1539 |
|
|
r(i) := s(i);
|
1540 |
|
|
end loop;
|
1541 |
|
|
return r;
|
1542 |
|
|
end function to_ascending;
|
1543 |
|
|
|
1544 |
|
|
----------------------------------------------------------------------------
|
1545 |
|
|
-- to_descending
|
1546 |
|
|
--
|
1547 |
|
|
-- function to_descending(
|
1548 |
|
|
-- constant s : std_logic_vector
|
1549 |
|
|
-- ) return std_logic_vector;
|
1550 |
|
|
--
|
1551 |
|
|
-- function to_descending(
|
1552 |
|
|
-- constant s : unsigned
|
1553 |
|
|
-- ) return unsigned
|
1554 |
|
|
--
|
1555 |
|
|
-- function to_descending(
|
1556 |
|
|
-- constant s : signed
|
1557 |
|
|
-- ) return signed;
|
1558 |
|
|
--
|
1559 |
|
|
-- Converts a signal to descending range ( "downto"-range ).
|
1560 |
|
|
-- The argument s can have ascending or descending range.
|
1561 |
|
|
----------------------------------------------------------------------------
|
1562 |
|
|
function to_descending(
|
1563 |
|
|
constant s : std_logic_vector
|
1564 |
|
|
) return std_logic_vector is
|
1565 |
|
|
variable r : std_logic_vector(s'length-1 downto 0);
|
1566 |
|
|
begin
|
1567 |
|
|
for i in r'range loop
|
1568 |
|
|
r(i) := s(i);
|
1569 |
|
|
end loop;
|
1570 |
|
|
return r;
|
1571 |
|
|
end function to_descending;
|
1572 |
|
|
|
1573 |
|
|
function to_descending(
|
1574 |
|
|
constant s : unsigned
|
1575 |
|
|
) return unsigned is
|
1576 |
|
|
variable r : unsigned(s'length-1 downto 0);
|
1577 |
|
|
begin
|
1578 |
|
|
for i in r'range loop
|
1579 |
|
|
r(i) := s(i);
|
1580 |
|
|
end loop;
|
1581 |
|
|
return r;
|
1582 |
|
|
end function to_descending;
|
1583 |
|
|
|
1584 |
|
|
function to_descending(
|
1585 |
|
|
constant s : signed
|
1586 |
|
|
) return signed is
|
1587 |
|
|
variable r : signed(s'length-1 downto 0);
|
1588 |
|
|
begin
|
1589 |
|
|
for i in r'range loop
|
1590 |
|
|
r(i) := s(i);
|
1591 |
|
|
end loop;
|
1592 |
|
|
return r;
|
1593 |
|
|
end function to_descending;
|
1594 |
|
|
|
1595 |
|
|
----------------------------------------------------------------------------
|
1596 |
|
|
-- hxstr
|
1597 |
|
|
-- function hxstr(
|
1598 |
|
|
-- constant s : std_logic_vector;
|
1599 |
|
|
-- constant prefix : string := ""
|
1600 |
|
|
-- ) return string;
|
1601 |
|
|
--
|
1602 |
|
|
-- function hxstr(
|
1603 |
|
|
-- constant s : unsigned;
|
1604 |
|
|
-- constant prefix : string := ""
|
1605 |
|
|
-- ) return string;
|
1606 |
|
|
--
|
1607 |
|
|
-- function hxstr(
|
1608 |
|
|
-- constant s : signed;
|
1609 |
|
|
-- constant prefix : string := ""
|
1610 |
|
|
-- ) return string;
|
1611 |
|
|
--
|
1612 |
|
|
-- Converts a signal to a string in hexadecimal format.
|
1613 |
|
|
-- An optional prefix can be specified, e.g. "0x".
|
1614 |
|
|
--
|
1615 |
|
|
-- The signal can have ascending range ( "to-range" ) or descending range
|
1616 |
|
|
-- ("downto-range").
|
1617 |
|
|
--
|
1618 |
|
|
-- hxstr is a wrapper function for hstr in txt_util.
|
1619 |
|
|
-- hstr only support std_logic_vector with descending range.
|
1620 |
|
|
--
|
1621 |
|
|
-- Examples:
|
1622 |
|
|
-- print("value=" & hxstr(s));
|
1623 |
|
|
-- print("value=" & hxstr(s, "0x"));
|
1624 |
|
|
----------------------------------------------------------------------------
|
1625 |
|
|
function hxstr(
|
1626 |
|
|
constant s : std_logic_vector;
|
1627 |
|
|
constant prefix : string := ""
|
1628 |
|
|
) return string is
|
1629 |
|
|
begin
|
1630 |
|
|
return prefix & hstr(to_descending(s));
|
1631 |
|
|
end function hxstr;
|
1632 |
|
|
|
1633 |
|
|
function hxstr(
|
1634 |
|
|
constant s : unsigned;
|
1635 |
|
|
constant prefix : string := ""
|
1636 |
|
|
) return string is
|
1637 |
|
|
begin
|
1638 |
|
|
return prefix & hstr(to_descending(std_logic_vector(s)));
|
1639 |
|
|
end function hxstr;
|
1640 |
|
|
|
1641 |
|
|
function hxstr(
|
1642 |
|
|
constant s : signed;
|
1643 |
|
|
constant prefix : string := ""
|
1644 |
|
|
) return string is
|
1645 |
|
|
begin
|
1646 |
|
|
return prefix & hstr(to_descending(std_logic_vector(s)));
|
1647 |
|
|
end function hxstr;
|
1648 |
|
|
|
1649 |
|
|
----------------------------------------------------------------------------
|
1650 |
2 |
pela |
-- pltbutils internal procedure(s), called from other pltbutils procedures.
|
1651 |
|
|
-- Do not to call this/these from user's code.
|
1652 |
|
|
-- This/these procedures are undocumented in the specification on purpose.
|
1653 |
|
|
----------------------------------------------------------------------------
|
1654 |
|
|
procedure pltbutils_sc_update(
|
1655 |
|
|
signal pltbutils_sc : out pltbutils_sc_t
|
1656 |
|
|
) is
|
1657 |
|
|
begin
|
1658 |
|
|
-- VHDL-2002:
|
1659 |
|
|
pltbutils_sc.test_num <= v_pltbutils_test_num.value;
|
1660 |
|
|
print(pltbutils_sc.test_name, v_pltbutils_test_name.value);
|
1661 |
|
|
print(pltbutils_sc.info, v_pltbutils_info.value);
|
1662 |
|
|
pltbutils_sc.chk_cnt <= v_pltbutils_chk_cnt.value;
|
1663 |
|
|
pltbutils_sc.err_cnt <= v_pltbutils_err_cnt.value;
|
1664 |
|
|
pltbutils_sc.stop_sim <= v_pltbutils_stop_sim.value;
|
1665 |
|
|
-- VHDL-1993:
|
1666 |
|
|
--pltbutils_sc.test_num <= v_pltbutils_test_num;
|
1667 |
|
|
--print(pltbutils_sc.test_name, v_pltbutils_test_name);
|
1668 |
|
|
--print(pltbutils_sc.info, v_pltbutils_info);
|
1669 |
|
|
--pltbutils_sc.chk_cnt <= v_pltbutils_chk_cnt;
|
1670 |
|
|
--pltbutils_sc.err_cnt <= v_pltbutils_err_cnt;
|
1671 |
|
|
--pltbutils_sc.stop_sim <= v_pltbutils_stop_sim;
|
1672 |
|
|
end procedure pltbutils_sc_update;
|
1673 |
|
|
|
1674 |
|
|
end package body pltbutils_func_pkg;
|