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