38 use ieee.std_logic_1164.
all;
39 use ieee.numeric_std.
all;
74 testcase_name_len : integer;
77 test_name_len : integer;
79 test_active : boolean;
83 skiptest_cnt : integer;
86 chk_cnt_in_test : integer;
87 err_cnt_in_test : integer;
93 testcase_name_len => 1,
97 skiptests => (others => '0'),
105 chk_cnt_in_test => 0,
106 err_cnt_in_test => 0,
124 stop_sim : std_logic;
176 constant testcase_name :
in string;
177 constant skiptests :
in std_logic_vector;
178 variable pltbv :
inout pltbv_t;
230 variable pltbv :
inout pltbv_t;
232 constant show_success_fail :
in boolean := false;
233 constant force_stop :
in boolean := false
253 constant name :
in string;
254 variable pltbv :
inout pltbv_t;
277 constant num :
in integer :=
1;
278 constant name :
in string;
279 variable pltbv :
inout pltbv_t;
309 variable pltbv :
inout pltbv_t;
336 constant active :
in boolean;
337 variable pltbv :
inout pltbv_t;
339 constant txt :
in string
350 constant active :
in boolean;
351 signal s :
out string;
352 constant txt :
in string
361 signal s :
out string;
362 constant txt :
in string
378 constant active :
in boolean;
379 variable s :
out string;
380 constant txt :
in string
389 variable s :
out string;
390 constant txt :
in string
398 variable pltbv :
inout pltbv_t;
400 constant txt :
in string
413 constant active :
in boolean;
414 variable pltbv :
inout pltbv_t;
416 constant txt :
in string
421 constant active :
in boolean;
422 signal s :
out string;
423 constant txt :
in string
428 signal s :
out string;
429 constant txt :
in string
434 variable pltbv :
inout pltbv_t;
436 constant txt :
in string
464 constant N :
in natural;
465 signal clk :
in std_logic;
466 variable pltbv :
inout pltbv_t;
468 constant falling :
in boolean := false;
500 signal s :
in integer;
501 constant value :
in integer;
502 signal clk :
in std_logic;
503 variable pltbv :
inout pltbv_t;
505 constant falling :
in boolean := false;
511 signal s :
in std_logic;
512 constant value :
in std_logic;
513 signal clk :
in std_logic;
514 variable pltbv :
inout pltbv_t;
516 constant falling :
in boolean := false;
522 signal s :
in std_logic;
523 constant value :
in integer;
524 signal clk :
in std_logic;
525 variable pltbv :
inout pltbv_t;
527 constant falling :
in boolean := false;
533 signal s :
in std_logic_vector;
534 constant value :
in std_logic_vector;
535 signal clk :
in std_logic;
536 variable pltbv :
inout pltbv_t;
538 constant falling :
in boolean := false;
544 signal s :
in std_logic_vector;
545 constant value :
in integer;
546 signal clk :
in std_logic;
547 variable pltbv :
inout pltbv_t;
549 constant falling :
in boolean := false;
555 signal s :
in unsigned;
556 constant value :
in unsigned;
557 signal clk :
in std_logic;
558 variable pltbv :
inout pltbv_t;
560 constant falling :
in boolean := false;
566 signal s :
in unsigned;
567 constant value :
in integer;
568 signal clk :
in std_logic;
569 variable pltbv :
inout pltbv_t;
571 constant falling :
in boolean := false;
577 signal s :
in signed;
578 constant value :
in signed;
579 signal clk :
in std_logic;
580 variable pltbv :
inout pltbv_t;
582 constant falling :
in boolean := false;
588 signal s :
in signed;
589 constant value :
in integer;
590 signal clk :
in std_logic;
591 variable pltbv :
inout pltbv_t;
593 constant falling :
in boolean := false;
599 signal s :
in std_logic;
600 constant value :
in std_logic;
601 variable pltbv :
inout pltbv_t;
610 signal s :
in std_logic;
611 variable pltbv :
inout pltbv_t;
613 constant falling :
in boolean := false;
655 constant rpt :
in string;
656 constant actual :
in std_logic_vector;
657 constant expected :
in std_logic_vector;
658 constant mask :
in std_logic_vector;
659 variable pltbv :
inout pltbv_t;
665 constant rpt :
in string;
666 constant actual :
in integer;
667 constant expected :
in integer;
668 variable pltbv :
inout pltbv_t;
674 constant rpt :
in string;
675 constant actual :
in std_logic;
676 constant expected :
in std_logic;
677 variable pltbv :
inout pltbv_t;
683 constant rpt :
in string;
684 constant actual :
in std_logic;
685 constant expected :
in integer;
686 variable pltbv :
inout pltbv_t;
692 constant rpt :
in string;
693 constant actual :
in std_logic_vector;
694 constant expected :
in std_logic_vector;
695 variable pltbv :
inout pltbv_t;
701 constant rpt :
in string;
702 constant actual :
in std_logic_vector;
703 constant expected :
in integer;
704 variable pltbv :
inout pltbv_t;
710 constant rpt :
in string;
711 constant actual :
in std_logic_vector;
712 constant expected :
in integer;
713 constant mask :
in std_logic_vector;
714 variable pltbv :
inout pltbv_t;
720 constant rpt :
in string;
721 constant actual :
in unsigned;
722 constant expected :
in unsigned;
723 variable pltbv :
inout pltbv_t;
729 constant rpt :
in string;
730 constant actual :
in unsigned;
731 constant expected :
in integer;
732 variable pltbv :
inout pltbv_t;
738 constant rpt :
in string;
739 constant actual :
in signed;
740 constant expected :
in signed;
741 variable pltbv :
inout pltbv_t;
747 constant rpt :
in string;
748 constant actual :
in signed;
749 constant expected :
in integer;
750 variable pltbv :
inout pltbv_t;
756 constant rpt :
in string;
757 constant actual :
in boolean;
758 constant expected :
in boolean;
759 variable pltbv :
inout pltbv_t;
765 constant rpt :
in string;
766 constant actual :
in boolean;
767 constant expected :
in integer;
768 variable pltbv :
inout pltbv_t;
774 constant rpt :
in string;
775 constant actual :
in time;
776 constant expected :
in time;
777 variable pltbv :
inout pltbv_t;
806 constant rpt :
in string;
807 constant actual :
in time;
808 constant expected :
in time;
809 constant tolerance :
in time;
810 variable pltbv :
inout pltbv_t;
816 constant rpt :
in string;
817 constant actual :
in string;
818 constant expected :
in string;
819 variable pltbv :
inout pltbv_t;
825 constant rpt :
in string;
826 constant expr :
in boolean;
827 variable pltbv :
inout pltbv_t;
870 constant rpt :
in string;
871 constant expr :
in boolean;
872 constant actual :
in string;
873 constant expected :
in string;
874 constant mask :
in string;
875 variable pltbv :
inout pltbv_t;
925 constant rpt :
in string;
926 constant filename1 :
in string;
927 constant filename2 :
in string;
928 constant verbosity :
in integer;
929 variable pltbv :
inout pltbv_t;
969 constant rpt :
in string;
970 constant filename1 :
in string;
971 constant filename2 :
in string;
972 constant verbosity :
in integer;
973 variable pltbv :
inout pltbv_t;
1024 constant rpt :
in string;
1025 constant filename1 :
in string;
1026 constant filename2 :
in string;
1027 constant verbosity :
in integer;
1028 variable pltbv :
inout pltbv_t;
1030 constant skip_init_items :
in integer :=
0
1049 constant s :
std_logic_vector
1050 )
return std_logic_vector;
1054 constant s :
unsigned
1078 constant s :
std_logic_vector
1079 )
return std_logic_vector;
1083 constant s :
unsigned
1111 constant s :
std_logic_vector;
1112 constant prefix :
string := ;
1113 constant postfix :
string :=
1120 constant s :
unsigned;
1121 constant prefix :
string := ;
1122 constant postfix :
string :=
1129 constant s :
signed;
1130 constant prefix :
string := ;
1131 constant postfix :
string :=
1136 variable pltbv :
inout pltbv_t;
1143 constant n :
integer;
1144 constant len :
integer;
1145 constant fillchar :
character := ' '
1153 constant s1 :
STRING;
1154 constant s2 :
STRING
1161 procedure starttest_msg(
1162 constant test_num :
in integer;
1163 constant test_name :
in string;
1164 constant timestamp :
in time
1167 print
(lf &
"Test " & str
(test_num
) &
": " & test_name &
" (" &
time'
image(timestamp
) &
")");
1168 end procedure starttest_msg;
1170 procedure skiptest_msg
(
1171 constant test_num :
in integer;
1172 constant test_name :
in string;
1173 constant timestamp :
in time
1176 print
(lf &
"Skipping Test " & str
(test_num
) &
": " & test_name &
" (" &
time'
image(timestamp
) &
")");
1177 end procedure skiptest_msg;
1179 procedure endtest_msg
(
1180 constant test_num :
in integer;
1181 constant test_name :
in string;
1182 constant timestamp :
in time;
1183 constant test_active :
in boolean;
1184 constant num_checks_in_test :
in integer;
1185 constant num_errors_in_test :
in integer
1189 print
("Done with test " & str
(test_num
) &
": " & test_name &
" (" &
time'
image(timestamp
) &
")");
1191 end procedure endtest_msg;
1193 procedure check_msg
(
1194 constant rpt :
in string;
1195 constant timestamp :
in time;
1196 constant expr :
in boolean;
1197 constant actual :
in string;
1198 constant expected :
in string;
1199 constant mask :
in string;
1200 constant test_num :
in integer;
1201 constant test_name :
in string;
1202 constant check_num :
in integer;
1203 constant err_cnt_in_test :
in integer
1205 variable actual_str_len :
integer :=
1;
1206 variable actual_str :
string(1 to actual'
length+
8) :=
(others => ' '
);
1207 variable expected_str :
string(1 to expected'
length+
10) :=
(others => ' '
);
1208 variable expected_str_len :
integer :=
1;
1209 variable mask_str :
string(1 to mask'
length+
6) :=
(others => ' '
);
1210 variable mask_str_len :
integer :=
1;
1211 constant C_ACTUAL_PREFIX :
string :=
" Actual=";
1212 constant C_ACTUAL_POSTFIX :
string :=
"";
1213 constant C_EXPECTED_PREFIX :
string :=
" Expected=";
1214 constant C_EXPECTED_POSTFIX :
string :=
"";
1215 constant C_MASK_PREFIX :
string :=
" Mask=";
1216 constant C_MASK_POSTFIX :
string :=
"";
1218 if not expr
then -- Output message only if the check fails
1219 if str_equal
(mask,
"!NO_TAGS!") then
1221 actual_str_len := actual'
length;
1222 actual_str
(1 to actual_str_len
) := actual;
1223 expected_str_len := expected'
length;
1224 expected_str
(1 to expected_str_len
) := expected;
1228 if actual /=
"" then
1231 actual_str_len := C_ACTUAL_PREFIX'
length + actual'
length + C_ACTUAL_POSTFIX'
length;
1232 actual_str
(1 to actual_str_len
) := C_ACTUAL_PREFIX & tcfilter
(actual
) & C_ACTUAL_POSTFIX;
1234 if expected /=
"" then
1237 expected_str_len := C_EXPECTED_PREFIX'
length + expected'
length + C_EXPECTED_POSTFIX'
length;
1238 expected_str
(1 to expected_str_len
) := C_EXPECTED_PREFIX & tcfilter
(expected
) & C_EXPECTED_POSTFIX;
1243 mask_str_len := C_MASK_PREFIX'
length + mask'
length + C_MASK_POSTFIX'
length;
1244 mask_str
(1 to mask_str_len
) := C_MASK_PREFIX & tcfilter
(mask
) & C_MASK_POSTFIX;
1248 report "Check " & str
(check_num
) &
"; " & rpt &
"; " &
1249 actual_str
(1 to actual_str_len
) &
1250 expected_str
(1 to expected_str_len
) &
1251 mask_str
(1 to mask_str_len
) &
1252 " in test " & str
(test_num
) &
" " & test_name
1255 end procedure check_msg;
1257 procedure error_msg
(
1258 constant rpt :
in string;
1259 constant timestamp :
in time;
1260 constant test_num :
in integer;
1261 constant test_name :
in string;
1262 constant err_cnt_in_test :
in integer
1266 report rpt &
" in test " & str
(test_num
) &
": " & test_name
1268 end procedure error_msg;
1271 constant timestamp :
in time
1275 report "--- FORCE END OF SIMULATION ---" &
1276 " (ignore this false failure message, it's not a real failure)"
1278 end procedure stopsim;
1280 procedure startsim_msg
(
1281 constant testcase_name :
in string;
1282 constant timestamp :
in time
1285 print
(lf &
"--- START OF SIMULATION ---");
1286 print
("Testcase: " & testcase_name
);
1287 print
(time'
image(timestamp
));
1288 end procedure startsim_msg;
1290 procedure endsim_msg
(
1291 constant testcase_name :
in string;
1292 constant timestamp :
in time;
1293 constant num_tests :
in integer;
1294 constant num_skiptests :
in integer;
1295 constant num_checks :
in integer;
1296 constant num_errors :
in integer;
1297 constant show_success_fail :
in boolean
1301 print
(lf &
"--- END OF SIMULATION ---");
1302 print
("Note: the results presented below are based on the PlTbUtil's check() procedure calls.");
1303 print
(" The design may contain more errors, for which there are no check() calls.");
1304 write
(l, timestamp,
right,
14);
1305 writeline
(output, l
);
1306 write
(l, num_tests,
right,
11);
1307 write
(l,
string'
(" Tests"));
1308 writeline
(output, l
);
1309 write
(l, num_skiptests,
right,
11);
1310 write
(l,
string'
(" Skipped tests"));
1311 writeline
(output, l
);
1312 write
(l, num_checks,
right,
11);
1313 write
(l,
string'
(" Checks"));
1314 writeline
(output, l
);
1315 write
(l, num_errors,
right,
11);
1316 write
(l,
string'
(" Errors"));
1317 writeline
(output, l
);
1318 if show_success_fail
then
1319 if num_errors =
0 and num_checks >
0 then
1320 print
("*** SUCCESS ***");
1321 elsif num_checks >
0 then
1322 print
("*** FAIL ***");
1324 print
("*** NO CHECKS ***");
1327 end procedure endsim_msg;
1332 procedure get_file_item
(
1334 variable l :
inout line;
1335 variable item :
out string;
1336 variable item_len :
out integer;
1337 variable line_num :
inout integer;
1338 variable item_num :
inout integer
1340 variable c :
character := ' ';
1341 variable c_good :
boolean := true;
1342 variable i :
integer :=
0;
1344 item :=
(item'
low to item'
high => ' '
);
1349 exit when endfile
(f
);
1351 line_num := line_num +
1;
1352 elsif l'
length =
0 then
1353 exit when endfile
(f
);
1355 line_num := line_num +
1;
1361 while c_good
and (c = ' '
or c = ht
or c = cr
or c = lf
) loop
1365 while c_good
and c /= ' '
and c /= ht
and c /= cr
and c /= lf
and c /= '#'
loop
1369 item
(item'
low + i
) := c;
1375 if c_good
and c = '#'
then
1376 while l'
length >
0 loop
1383 item_num := item_num +
1;
1386 end procedure get_file_item;
1388 procedure pltbutils_error
(
1389 constant rpt :
in string;
1390 variable pltbv :
inout pltbv_t;
1394 pltbv.err_cnt := pltbv.err_cnt +
1;
1395 pltbv.err_cnt_in_test := pltbv.err_cnt_in_test +
1;
1396 pltbs_update
(pltbv, pltbs
);
1398 if (C_PLTBUTILS_USE_STD_ERROR_MSG
) then
1399 error_msg
(rpt, now, pltbv.test_num,
1400 pltbv.test_name
(1 to pltbv.test_name_len
), pltbv.err_cnt_in_test
);
1403 if (C_PLTBUTILS_USE_CUSTOM_ERROR_MSG
) then
1404 custom_error_msg
(rpt, now, pltbv.test_num,
1405 pltbv.test_name
(1 to pltbv.test_name_len
), pltbv.err_cnt_in_test
);
1408 end procedure pltbutils_error;
1418 constant testcase_name :
in string;
1419 constant skiptests :
in std_logic_vector;
1420 variable pltbv :
inout pltbv_t;
1423 variable timestamp :
time;
1424 variable v_ignored_skiptest :
boolean := false;
1428 printv
(pltbv.testcase_name, testcase_name
);
1429 pltbv.testcase_name_len := testcase_name'
length;
1430 printv
(pltbv.test_name,
"START OF SIMULATION");
1431 pltbv.test_name_len :=
19;
1432 printv
(pltbv.info, testcase_name
);
1434 if (skiptests'
length >
0) then
1435 for i
in skiptests'
low to skiptests'
high loop
1436 if (i >= pltbv.skiptests'
low and i <= pltbv.skiptests'
high) then
1437 pltbv.skiptests
(i
) := skiptests
(i
);
1439 if (pltbv.skiptests
(i
) = '
1'
) then
1440 v_ignored_skiptest := true;
1444 if (v_ignored_skiptest
) then
1446 report "Some SKIPTESTS flags ignored. Max " &
1447 integer'
image(pltbv.skiptests'
length) &
" flag bits supported."
1452 pltbv.info_len := testcase_name'
length;
1453 pltbs_update
(pltbv, pltbs
);
1455 if (C_PLTBUTILS_USE_STD_STARTSIM_MSG
) then
1456 startsim_msg
(testcase_name, timestamp
);
1459 if (C_PLTBUTILS_USE_CUSTOM_STARTSIM_MSG
) then
1460 custom_startsim_msg
(testcase_name, timestamp
);
1463 end procedure startsim;
1467 variable pltbv :
inout pltbv_t;
1469 constant show_success_fail :
in boolean := false;
1470 constant force_stop :
in boolean := false
1472 variable timestamp :
time;
1476 if (C_PLTBUTILS_USE_STD_ENDSIM_MSG
) then
1477 endsim_msg
(pltbv.testcase_name
(1 to pltbv.testcase_name_len
), timestamp,
1478 pltbv.test_cnt, pltbv.skiptest_cnt, pltbv.chk_cnt, pltbv.err_cnt,
1482 if (C_PLTBUTILS_USE_CUSTOM_ENDSIM_MSG
) then
1483 custom_endsim_msg
(pltbv.testcase_name
(1 to pltbv.testcase_name_len
), timestamp,
1484 pltbv.test_cnt, pltbv.skiptest_cnt, pltbv.chk_cnt, pltbv.err_cnt,
1488 pltbv.test_num :=
0;
1489 printv
(pltbv.test_name,
"END OF SIMULATION");
1490 pltbv.test_name_len :=
17;
1491 pltbv.stop_sim := '
1';
1492 pltbs_update
(pltbv, pltbs
);
1495 if (force_stop
) then
1496 if (C_PLTBUTILS_USE_STD_STOPSIM
) then
1499 if (C_PLTBUTILS_USE_CUSTOM_STOPSIM
) then
1500 custom_stopsim
(now
);
1505 end procedure endsim;
1507 procedure starttest
(
1508 constant num :
in integer := -
1;
1509 constant name :
in string;
1510 variable pltbv :
inout pltbv_t;
1513 variable timestamp :
time;
1518 pltbv.test_num := pltbv.test_num +
1;
1520 pltbv.test_num := num;
1523 printv
(pltbv.test_name, name
);
1524 pltbv.test_name_len := name'
length;
1525 pltbv.chk_cnt_in_test :=
0;
1526 pltbv.err_cnt_in_test :=
0;
1527 pltbv.test_active := true;
1529 if (pltbv.test_num >= pltbv.skiptests'
low and pltbv.test_num <= pltbv.skiptests'
high) then
1530 if (pltbv.skiptests
(pltbv.test_num
) = '
1'
) then
1531 pltbv.test_active := false;
1535 if (pltbv.test_active
) then
1536 pltbv.test_cnt := pltbv.test_cnt +
1;
1537 pltbs_update
(pltbv, pltbs
);
1538 if (C_PLTBUTILS_USE_STD_STARTTEST_MSG
) then
1539 starttest_msg
(pltbv.test_num, name, timestamp
);
1541 if (C_PLTBUTILS_USE_CUSTOM_STARTTEST_MSG
) then
1542 custom_starttest_msg
(pltbv.test_num, name, timestamp
);
1545 pltbv.skiptest_cnt := pltbv.skiptest_cnt +
1;
1546 pltbs_update
(pltbv, pltbs
);
1547 if (C_PLTBUTILS_USE_STD_SKIPTEST_MSG
) then
1548 skiptest_msg
(pltbv.test_num, name, timestamp
);
1550 if (C_PLTBUTILS_USE_CUSTOM_SKIPTEST_MSG
) then
1551 custom_skiptest_msg
(pltbv.test_num, name, timestamp
);
1555 end procedure starttest;
1557 procedure starttest
(
1558 constant name :
in string;
1559 variable pltbv :
inout pltbv_t;
1563 starttest
(-
1, name, pltbv, pltbs
);
1564 end procedure starttest;
1566 function is_test_active
(
1570 return pltbv.test_active;
1571 end function is_test_active;
1575 variable pltbv :
inout pltbv_t;
1578 variable timestamp :
time;
1582 if (C_PLTBUTILS_USE_STD_ENDTEST_MSG
) then
1583 endtest_msg
(pltbv.test_num, pltbv.test_name
(1 to pltbv.test_name_len
),
1584 timestamp, pltbv.test_active, pltbv.chk_cnt_in_test, pltbv.err_cnt_in_test
);
1587 if (C_PLTBUTILS_USE_CUSTOM_ENDTEST_MSG
) then
1588 custom_endtest_msg
(pltbv.test_num, pltbv.test_name
(1 to pltbv.test_name_len
),
1589 timestamp, pltbv.test_active, pltbv.chk_cnt_in_test, pltbv.err_cnt_in_test
);
1592 pltbv.test_active := true;
1593 printv
(pltbv.test_name,
" ");
1594 pltbv.test_name_len :=
1;
1595 pltbs_update
(pltbv, pltbs
);
1596 end procedure endtest;
1599 constant active :
in boolean;
1600 signal s :
out string;
1601 constant txt :
in string
1603 variable j :
positive := txt '
low;
1607 for i
in s'
range loop
1608 if (j <= txt '
high) then
1617 end procedure print;
1620 signal s :
out string;
1621 constant txt :
in string
1624 print
(true, s, txt
);
1625 end procedure print;
1628 constant active :
in boolean;
1629 variable s :
out string;
1630 constant txt :
in string
1632 variable j :
positive := txt '
low;
1636 for i
in s'
range loop
1637 if (j <= txt '
high) then
1646 end procedure printv;
1649 variable s :
out string;
1650 constant txt :
in string
1653 printv
(true, s, txt
);
1654 end procedure printv;
1658 constant active :
in boolean;
1659 variable pltbv :
inout pltbv_t;
1661 constant txt :
in string
1663 variable j :
positive := txt '
low;
1667 printv
(pltbv.info, txt
);
1668 pltbv.info_len := txt'
length;
1669 pltbs_update
(pltbv, pltbs
);
1672 end procedure print;
1675 variable pltbv :
inout pltbv_t;
1677 constant txt :
in string
1680 print
(true, pltbv, pltbs, txt
);
1681 end procedure print;
1684 constant active :
in boolean;
1685 signal s :
out string;
1686 constant txt :
in string
1695 end procedure print2;
1698 signal s :
out string;
1699 constant txt :
in string
1702 print2
(true, s, txt
);
1703 end procedure print2;
1706 constant active :
in boolean;
1707 variable pltbv :
inout pltbv_t;
1709 constant txt :
in string
1712 print
(active, pltbv, pltbs, txt
);
1714 end procedure print2;
1717 variable pltbv :
inout pltbv_t;
1719 constant txt :
in string
1722 print2
(true, pltbv, pltbs, txt
);
1723 end procedure print2;
1727 constant n :
in natural;
1728 signal clk :
in std_logic;
1729 variable pltbv :
inout pltbv_t;
1731 constant falling :
in boolean := false;
1734 variable i :
natural := n;
1735 variable v_timeout_time :
time;
1737 v_timeout_time := now + timeout;
1741 wait until falling_edge
(clk
) for timeout / n;
1743 wait until rising_edge
(clk
) for timeout / n;
1749 if (now >= v_timeout_time
) then
1750 pltbutils_error
("waitclks() timeout", pltbv, pltbs
);
1753 end procedure waitclks;
1757 signal s :
in integer;
1758 constant value :
in integer;
1759 signal clk :
in std_logic;
1760 variable pltbv :
inout pltbv_t;
1762 constant falling :
in boolean := false;
1765 variable v_timeout_time :
time;
1767 v_timeout_time := now + timeout;
1769 waitclks
(1, clk, pltbv, pltbs, falling, timeout
);
1770 exit l1
when s =
value or now >= v_timeout_time;
1773 if (now >= v_timeout_time
) then
1774 pltbutils_error
("waitsig() timeout", pltbv, pltbs
);
1777 end procedure waitsig;
1781 signal s :
in std_logic;
1782 constant value :
in std_logic;
1783 signal clk :
in std_logic;
1784 variable pltbv :
inout pltbv_t;
1786 constant falling :
in boolean := false;
1789 variable v_timeout_time :
time;
1791 v_timeout_time := now + timeout;
1793 waitclks
(1, clk, pltbv, pltbs, falling, timeout
);
1794 exit l1
when s =
value or now >= v_timeout_time;
1797 if (now >= v_timeout_time
) then
1798 pltbutils_error
("waitsig() timeout", pltbv, pltbs
);
1801 end procedure waitsig;
1805 signal s :
in std_logic;
1806 constant value :
in integer;
1807 signal clk :
in std_logic;
1808 variable pltbv :
inout pltbv_t;
1810 constant falling :
in boolean := false;
1813 variable v_value :
std_logic;
1814 variable v_timeout_time :
time;
1828 if (v_value /= 'X'
) then
1829 waitsig
(s, v_value, clk, pltbv, pltbs, falling, timeout
);
1831 pltbutils_error
("waitsig() timeout", pltbv, pltbs
);
1834 end procedure waitsig;
1838 signal s :
in std_logic_vector;
1839 constant value :
in std_logic_vector;
1840 signal clk :
in std_logic;
1841 variable pltbv :
inout pltbv_t;
1843 constant falling :
in boolean := false;
1846 variable v_timeout_time :
time;
1848 v_timeout_time := now + timeout;
1850 waitclks
(1, clk, pltbv, pltbs, falling, timeout
);
1851 exit l1
when s =
value or now >= v_timeout_time;
1854 if (now >= v_timeout_time
) then
1855 pltbutils_error
("waitsig() timeout", pltbv, pltbs
);
1858 end procedure waitsig;
1862 signal s :
in std_logic_vector;
1863 constant value :
in integer;
1864 signal clk :
in std_logic;
1865 variable pltbv :
inout pltbv_t;
1867 constant falling :
in boolean := false;
1870 variable v_timeout_time :
time;
1872 waitsig
(s,
std_logic_vector(to_unsigned
(value, s'
length)), clk,
1873 pltbv, pltbs, falling, timeout
);
1874 end procedure waitsig;
1878 signal s :
in unsigned;
1879 constant value :
in unsigned;
1880 signal clk :
in std_logic;
1881 variable pltbv :
inout pltbv_t;
1883 constant falling :
in boolean := false;
1886 variable v_timeout_time :
time;
1888 v_timeout_time := now + timeout;
1890 waitclks
(1, clk, pltbv, pltbs, falling, timeout
);
1891 exit l1
when s =
value or now >= v_timeout_time;
1894 if (now >= v_timeout_time
) then
1895 pltbutils_error
("waitsig() timeout", pltbv, pltbs
);
1898 end procedure waitsig;
1902 signal s :
in unsigned;
1903 constant value :
in integer;
1904 signal clk :
in std_logic;
1905 variable pltbv :
inout pltbv_t;
1907 constant falling :
in boolean := false;
1910 variable v_timeout_time :
time;
1912 waitsig
(s, to_unsigned
(value, s'
length), clk,
1913 pltbv, pltbs, falling, timeout
);
1914 end procedure waitsig;
1918 signal s :
in signed;
1919 constant value :
in signed;
1920 signal clk :
in std_logic;
1921 variable pltbv :
inout pltbv_t;
1923 constant falling :
in boolean := false;
1926 variable v_timeout_time :
time;
1928 v_timeout_time := now + timeout;
1930 waitclks
(1, clk, pltbv, pltbs, falling, timeout
);
1931 exit l1
when s =
value or now >= v_timeout_time;
1934 if (now >= v_timeout_time
) then
1935 pltbutils_error
("waitsig() timeout", pltbv, pltbs
);
1938 end procedure waitsig;
1942 signal s :
in signed;
1943 constant value :
in integer;
1944 signal clk :
in std_logic;
1945 variable pltbv :
inout pltbv_t;
1947 constant falling :
in boolean := false;
1950 variable v_timeout_time :
time;
1952 waitsig
(s, to_signed
(value, s'
length), clk,
1953 pltbv, pltbs, falling, timeout
);
1954 end procedure waitsig;
1958 signal s :
in std_logic;
1959 constant value :
in std_logic;
1960 variable pltbv :
inout pltbv_t;
1966 if (s /=
value) then
1967 wait until s =
value for timeout;
1968 if (s /=
value) then
1969 pltbutils_error
("waitsig() timeout", pltbv, pltbs
);
1973 end procedure waitsig;
1977 signal s :
in std_logic;
1978 variable pltbv :
inout pltbv_t;
1980 constant falling :
in boolean := false;
1983 variable v_timeout_time :
time;
1986 wait until falling_edge
(s
) for timeout;
1988 wait until rising_edge
(s
) for timeout;
1990 if (not ((falling
and (s = '
0'
or s = 'L'
)) or ((not falling
) and (s = '
1'
or s = 'H'
)))) then
1991 pltbutils_error
("waitsig() timeout", pltbv, pltbs
);
1993 end procedure waitsig;
1997 constant rpt :
in string;
1998 constant actual :
in integer;
1999 constant expected :
in integer;
2000 variable pltbv :
inout pltbv_t;
2004 check
(rpt, actual = expected, str
(actual
), str
(expected
),
"", pltbv, pltbs
);
2005 end procedure check;
2009 constant rpt :
in string;
2010 constant actual :
in std_logic;
2011 constant expected :
in std_logic;
2012 variable pltbv :
inout pltbv_t;
2016 check
(rpt, actual = expected, str
(actual
), str
(expected
),
"", pltbv, pltbs
);
2017 end procedure check;
2021 constant rpt :
in string;
2022 constant actual :
in std_logic;
2023 constant expected :
in integer;
2024 variable pltbv :
inout pltbv_t;
2028 check
(rpt,
((actual = '
0'
and expected =
0) or (actual = '
1'
and expected =
1)),
2029 str
(actual
), str
(expected
),
"", pltbv, pltbs
);
2030 end procedure check;
2034 constant rpt :
in string;
2035 constant actual :
in std_logic_vector;
2036 constant expected :
in std_logic_vector;
2037 variable pltbv :
inout pltbv_t;
2041 check
(rpt, actual = expected, hxstr
(actual,
"0x"), hxstr
(expected,
"0x"),
"", pltbv, pltbs
);
2042 end procedure check;
2046 constant rpt :
in string;
2047 constant actual :
in std_logic_vector;
2048 constant expected :
in std_logic_vector;
2049 constant mask :
in std_logic_vector;
2050 variable pltbv :
inout pltbv_t;
2054 check
(rpt,
(actual
and mask
) =
(expected
and mask
),
2055 hxstr
(actual,
"0x"), hxstr
(expected,
"0x"), hxstr
(mask,
"0x"), pltbv, pltbs
);
2056 end procedure check;
2060 constant rpt :
in string;
2061 constant actual :
in std_logic_vector;
2062 constant expected :
in integer;
2063 variable pltbv :
inout pltbv_t;
2067 check
(rpt, actual,
std_logic_vector(to_signed
(expected, actual'
length)), pltbv, pltbs
);
2068 end procedure check;
2072 constant rpt :
in string;
2073 constant actual :
in std_logic_vector;
2074 constant expected :
in integer;
2075 constant mask :
in std_logic_vector;
2076 variable pltbv :
inout pltbv_t;
2080 check
(rpt, actual,
std_logic_vector(to_signed
(expected, actual'
length)), mask, pltbv, pltbs
);
2081 end procedure check;
2085 constant rpt :
in string;
2086 constant actual :
in unsigned;
2087 constant expected :
in unsigned;
2088 variable pltbv :
inout pltbv_t;
2092 check
(rpt, actual = expected, hxstr
(actual,
"0x"), hxstr
(expected,
"0x"),
"", pltbv, pltbs
);
2093 end procedure check;
2097 constant rpt :
in string;
2098 constant actual :
in unsigned;
2099 constant expected :
in integer;
2100 variable pltbv :
inout pltbv_t;
2104 check
(rpt, actual, to_unsigned
(expected, actual'
length), pltbv, pltbs
);
2105 end procedure check;
2109 constant rpt :
in string;
2110 constant actual :
in signed;
2111 constant expected :
in signed;
2112 variable pltbv :
inout pltbv_t;
2116 check
(rpt, actual = expected, hxstr
(actual,
"0x"), hxstr
(expected,
"0x"),
"", pltbv, pltbs
);
2117 end procedure check;
2123 constant rpt :
in string;
2124 constant actual :
in signed;
2125 constant expected :
in integer;
2126 variable pltbv :
inout pltbv_t;
2130 check
(rpt, actual, to_signed
(expected, actual'
length), pltbv, pltbs
);
2131 end procedure check;
2135 constant rpt :
in string;
2136 constant actual :
in boolean;
2137 constant expected :
in boolean;
2138 variable pltbv :
inout pltbv_t;
2142 check
(rpt, actual = expected, str
(actual
), str
(expected
),
"", pltbv, pltbs
);
2143 end procedure check;
2147 constant rpt :
in string;
2148 constant actual :
in boolean;
2149 constant expected :
in integer;
2150 variable pltbv :
inout pltbv_t;
2154 check
(rpt,
((actual = false
and expected =
0) or (actual = true
and expected =
1)),
2155 str
(actual
), str
(expected
),
"", pltbv, pltbs
);
2156 end procedure check;
2160 constant rpt :
in string;
2161 constant actual :
in time;
2162 constant expected :
in time;
2163 variable pltbv :
inout pltbv_t;
2167 check
(rpt, actual = expected,
time'
image(actual
),
time'
image(expected
),
"", pltbv, pltbs
);
2168 end procedure check;
2172 constant rpt :
in string;
2173 constant actual :
in time;
2174 constant expected :
in time;
2175 constant tolerance :
in time;
2176 variable pltbv :
inout pltbv_t;
2182 ((actual >= expected-tolerance
) and (actual <= expected+tolerance
)),
2184 time'
image(expected
) &
" +/- " &
time'
image(tolerance
),
2189 end procedure check;
2193 constant rpt :
in string;
2194 constant actual :
in string;
2195 constant expected :
in string;
2196 variable pltbv :
inout pltbv_t;
2199 variable mismatch :
boolean := false;
2202 if (actual'
length /= expected'
length) then
2205 for i
in 0 to actual'
length-
1 loop
2206 if (actual
(i+actual'
low) /= expected
(i+expected'
low)) then
2213 check
(rpt,
not mismatch, actual, expected,
"", pltbv, pltbs
);
2214 end procedure check;
2221 constant rpt :
in string;
2222 constant expr :
in boolean;
2223 variable pltbv :
inout pltbv_t;
2227 check
(rpt, expr,
"",
"",
"", pltbv, pltbs
);
2228 end procedure check;
2232 procedure check_binfile
(
2233 constant rpt :
in string;
2234 constant filename1 :
in string;
2235 constant filename2 :
in string;
2236 constant verbosity :
in integer;
2237 variable pltbv :
inout pltbv_t;
2240 variable v_file_errors :
integer :=
0;
2241 type charfile
is file of character;
2244 variable f1_status : file_open_status;
2245 variable f2_status : file_open_status;
2246 variable c1 :
character;
2247 variable c2 :
character;
2248 variable offset1 :
integer :=
0;
2249 variable offset2 :
integer :=
0;
2250 variable error_line : line;
2252 file_open
(f1_status, f1, filename1, read_mode
);
2253 if f1_status /= open_ok
then
2254 v_file_errors := v_file_errors +
1;
2255 write
(error_line,
" Could not open file " & filename1 &
" for reading.");
2257 file_open
(f2_status, f2, filename2, read_mode
);
2258 if f2_status /= open_ok
then
2259 v_file_errors := v_file_errors +
1;
2260 write
(error_line,
" Could not open file " & filename2 &
" for reading. ");
2264 if f1_status = open_ok
and f2_status = open_ok
then
2265 while not endfile
(f1
) and not endfile
(f2
) loop
2269 v_file_errors := v_file_errors +
1;
2270 if ((verbosity >=
2) or (verbosity =
1 and v_file_errors <=
10)) then
2271 write
(error_line,
" Diff offset " &
integer'
image(offset1
) &
": " &
2272 integer'
image(character'
pos(c1
)) &
" /= " &
integer'
image(character'
pos(c2
)) &
".");
2274 if verbosity =
1 and v_file_errors =
11 then
2275 write
(error_line,
string'
(" Further diffs suppressed."));
2278 offset1 := offset1 +
1;
2279 offset2 := offset2 +
1;
2281 if v_file_errors >
0 then
2282 write
(error_line,
" " &
integer'
image(v_file_errors
) &
" bytes differ.");
2287 while not endfile
(f1
) loop
2289 offset1 := offset1 +
1;
2291 while not endfile
(f2
) loop
2293 offset2 := offset2 +
1;
2295 if offset1 /= offset2
then
2296 v_file_errors := v_file_errors +
1;
2297 write
(error_line,
" File sizes differ: " &
integer'
image(offset1
) &
2298 " /= " &
integer'
image(offset2
) &
" bytes.");
2300 write
(error_line,
" (" & filename1 &
", " & filename2 &
")");
2301 end if;
-- f1_status, f2_status
2303 if f1_status = open_ok
then
2306 if f2_status = open_ok
then
2310 check
(rpt, v_file_errors =
0, error_line.
all,
"",
"!NO_TAGS!", pltbv, pltbs
);
2312 if error_line /=
null then
2313 deallocate
(error_line
);
2315 end procedure check_binfile;
2319 procedure check_txtfile
(
2320 constant rpt :
in string;
2321 constant filename1 :
in string;
2322 constant filename2 :
in string;
2323 constant verbosity :
in integer;
2324 variable pltbv :
inout pltbv_t;
2327 variable v_file_errors :
integer :=
0;
2330 variable f1_status : file_open_status;
2331 variable f2_status : file_open_status;
2334 variable line_num1 :
integer :=
0;
2335 variable line_num2 :
integer :=
0;
2336 variable error_line : line;
2338 file_open
(f1_status, f1, filename1, read_mode
);
2339 if f1_status /= open_ok
then
2340 v_file_errors := v_file_errors +
1;
2341 write
(error_line,
" Could not open file " & filename1 &
" for reading.");
2343 file_open
(f2_status, f2, filename2, read_mode
);
2344 if f2_status /= open_ok
then
2345 v_file_errors := v_file_errors +
1;
2346 write
(error_line,
" Could not open file " & filename2 &
" for reading. ");
2350 if f1_status = open_ok
and f2_status = open_ok
then
2351 while not endfile
(f1
) and not endfile
(f2
) loop
2354 line_num1 := line_num1 +
1;
2355 line_num2 := line_num2 +
1;
2356 if l1.
all /= l2.
all then
2357 v_file_errors := v_file_errors +
1;
2358 if ((verbosity >=
2) or (verbosity =
1 and v_file_errors <=
10)) then
2359 write
(error_line,
" Diff line " &
integer'
image(line_num1
) &
": '" &
2360 l1.
all &
"'' /= '" & l2.
all &
"'.");
2362 if verbosity =
1 and v_file_errors =
11 then
2363 write
(error_line,
string'
(" Further diffs suppressed."));
2367 if v_file_errors >
0 then
2368 write
(error_line,
" " &
integer'
image(v_file_errors
) &
" lines differ.");
2373 while not endfile
(f1
) loop
2375 line_num1 := line_num1 +
1;
2377 while not endfile
(f2
) loop
2379 line_num2 := line_num2 +
1;
2381 if line_num1 /= line_num2
then
2382 v_file_errors := v_file_errors +
1;
2383 write
(error_line,
" File sizes differ: " &
integer'
image(line_num1
) &
2384 " /= " &
integer'
image(line_num2
) &
" lines.");
2386 write
(error_line,
" (" & filename1 &
", " & filename2 &
")");
2387 end if;
-- f1_status, f2_status
2389 if f1_status = open_ok
then
2392 if f2_status = open_ok
then
2396 check
(rpt, v_file_errors =
0, error_line.
all,
"",
"!NO_TAGS!", pltbv, pltbs
);
2398 if error_line /=
null then
2399 deallocate
(error_line
);
2401 end procedure check_txtfile;
2404 procedure check_datfile
(
2405 constant rpt :
in string;
2406 constant filename1 :
in string;
2407 constant filename2 :
in string;
2408 constant verbosity :
in integer;
2409 variable pltbv :
inout pltbv_t;
2411 constant skip_init_items :
in integer :=
0
2413 variable v_file_errors :
integer :=
0;
2416 variable f1_status : file_open_status;
2417 variable f2_status : file_open_status;
2420 variable line_num1 :
integer :=
0;
2421 variable line_num2 :
integer :=
0;
2422 variable item1 :
string(1 to 256);
2423 variable item2 :
string(1 to 256);
2424 variable item_len1 :
integer := -
1;
2425 variable item_len2 :
integer := -
1;
2426 variable item_num1 :
integer :=
0;
2427 variable item_num2 :
integer :=
0;
2428 variable item_cnt :
integer :=
0;
2429 variable error_line : line;
2431 file_open
(f1_status, f1, filename1, read_mode
);
2432 if f1_status /= open_ok
then
2433 v_file_errors := v_file_errors +
1;
2434 write
(error_line,
" Could not open file " & filename1 &
" for reading: " & file_open_status'
image(f1_status
));
2436 file_open
(f2_status, f2, filename2, read_mode
);
2437 if f2_status /= open_ok
then
2438 v_file_errors := v_file_errors +
1;
2439 write
(error_line,
" Could not open file " & filename2 &
" for reading: " & file_open_status'
image(f2_status
));
2443 if f1_status = open_ok
and f2_status = open_ok
then
2444 while item_len1 /=
0 or item_len2 /=
0 loop
2445 get_file_item
(f1, l1, item1, item_len1, line_num1, item_num1
);
2446 get_file_item
(f2, l2, item2, item_len2, line_num2, item_num2
);
2447 item_cnt := item_cnt +
1;
2448 if item_len1 >
0 and item_len2 >
0 and item_cnt > skip_init_items
then
2449 if item1 /= item2
then
2450 v_file_errors := v_file_errors +
1;
2451 if ((verbosity >=
2) or (verbosity =
1 and v_file_errors <=
10)) then
2452 write
(error_line,
" Diff item " &
integer'
image(item_num1
) &
": '" &
2453 item1
(1 to item_len1
) &
"' /= '" & item2
(1 to item_len2
) &
"'.");
2455 if verbosity =
1 and v_file_errors =
11 then
2456 write
(error_line,
string'
(" Further diffs suppressed."));
2462 if v_file_errors >
0 then
2463 write
(error_line,
" " &
integer'
image(v_file_errors
) &
" items differ.");
2468 while not endfile
(f1
) loop
2469 get_file_item
(f1, l1, item1, item_len1, line_num1, item_num1
);
2471 while not endfile
(f2
) loop
2472 get_file_item
(f2, l2, item2, item_len2, line_num2, item_num2
);
2474 if item_num1 /= item_num2
then
2475 v_file_errors := v_file_errors +
1;
2476 write
(error_line,
" File sizes differ: " &
integer'
image(item_num1
) &
2477 " /= " &
integer'
image(item_num2
) &
" items.");
2479 write
(error_line,
" (" & filename1 &
", " & filename2 &
")");
2482 if f1_status = open_ok
then
2485 if f2_status = open_ok
then
2489 check
(rpt, v_file_errors =
0, error_line.
all,
"",
"!NO_TAGS!", pltbv, pltbs
);
2491 if error_line /=
null then
2492 deallocate
(error_line
);
2494 end procedure check_datfile;
2503 constant rpt :
in string;
2504 constant expr :
in boolean;
2505 constant actual :
in string;
2506 constant expected :
in string;
2507 constant mask :
in string;
2508 variable pltbv :
inout pltbv_t;
2511 variable timestamp :
time;
2514 pltbv.chk_cnt := pltbv.chk_cnt +
1;
2515 pltbv.chk_cnt_in_test := pltbv.chk_cnt_in_test +
1;
2517 if (not is_test_active
(pltbv
)) then
2518 pltbv.err_cnt := pltbv.err_cnt +
1;
2519 pltbv.err_cnt_in_test := pltbv.err_cnt_in_test +
1;
2520 if (C_PLTBUTILS_USE_STD_CHECK_MSG
) then
2521 check_msg
("check() executed in skipped test, missing if clause?", timestamp, false,
"",
"",
"", pltbv.test_num,
2522 pltbv.test_name
(1 to pltbv.test_name_len
), pltbv.chk_cnt, pltbv.err_cnt_in_test
);
2524 if (C_PLTBUTILS_USE_CUSTOM_CHECK_MSG
) then
2525 custom_check_msg
("check() executed in skipped test, missing if clause?", timestamp, false,
"",
"",
"", pltbv.test_num,
2526 pltbv.test_name
(1 to pltbv.test_name_len
), pltbv.chk_cnt, pltbv.err_cnt_in_test
);
2531 pltbv.err_cnt := pltbv.err_cnt +
1;
2532 pltbv.err_cnt_in_test := pltbv.err_cnt_in_test +
1;
2535 pltbs_update
(pltbv, pltbs
);
2537 if (C_PLTBUTILS_USE_STD_CHECK_MSG
) then
2538 check_msg
(rpt, timestamp, expr, actual, expected, mask, pltbv.test_num,
2539 pltbv.test_name
(1 to pltbv.test_name_len
), pltbv.chk_cnt, pltbv.err_cnt_in_test
);
2542 if (C_PLTBUTILS_USE_CUSTOM_CHECK_MSG
) then
2543 custom_check_msg
(rpt, timestamp, expr, actual, expected, mask, pltbv.test_num,
2544 pltbv.test_name
(1 to pltbv.test_name_len
), pltbv.chk_cnt, pltbv.err_cnt_in_test
);
2547 pltbs_update
(pltbv, pltbs
);
2548 end procedure check;
2551 function to_ascending
(
2552 constant s :
std_logic_vector
2553 ) return std_logic_vector is
2554 variable r :
std_logic_vector(s'
low to s'
high);
2556 for i
in r'
range loop
2560 end function to_ascending;
2563 constant s :
unsigned
2564 )
return unsigned is
2565 variable r :
unsigned(s'
low to s'
high);
2567 for i
in r'
range loop
2571 end function to_ascending;
2576 variable r :
signed(s'
low to s'
high);
2578 for i
in r'
range loop
2582 end function to_ascending;
2587 constant s :
std_logic_vector
2588 )
return std_logic_vector is
2589 variable r :
std_logic_vector(s'
high downto s'
low);
2591 for i
in r'
range loop
2595 end function to_descending;
2598 constant s :
unsigned
2599 )
return unsigned is
2600 variable r :
unsigned(s'
high downto s'
low);
2602 for i
in r'
range loop
2606 end function to_descending;
2611 variable r :
signed(s'
high downto s'
low);
2613 for i
in r'
range loop
2617 end function to_descending;
2620 constant s :
std_logic_vector;
2621 constant prefix :
string := ;
2622 constant postfix :
string :=
2624 variable hexstr :
string(1 to (s'
length+
3)/
4);
2625 variable nibble_aligned_s :
std_logic_vector(((s'
length+
3)/
4)*
4-
1 downto 0) :=
(others => '
0'
);
2626 variable nibble :
std_logic_vector(3 downto 0);
2628 nibble_aligned_s
(s'
length-
1 downto 0) := to_descending
(s
);
2629 for i
in 0 to nibble_aligned_s'
high/
4 loop
2630 nibble := nibble_aligned_s
(4*i +
3 downto 4*i
);
2635 hexstr
(hexstr'
high-i
) := '
0';
2637 hexstr
(hexstr'
high-i
) := '
1';
2639 hexstr
(hexstr'
high-i
) := '
2';
2641 hexstr
(hexstr'
high-i
) := '
3';
2643 hexstr
(hexstr'
high-i
) := '
4';
2645 hexstr
(hexstr'
high-i
) := '
5';
2647 hexstr
(hexstr'
high-i
) := '
6';
2649 hexstr
(hexstr'
high-i
) := '
7';
2651 hexstr
(hexstr'
high-i
) := '
8';
2653 hexstr
(hexstr'
high-i
) := '
9';
2655 hexstr
(hexstr'
high-i
) := 'A';
2657 hexstr
(hexstr'
high-i
) := 'B';
2659 hexstr
(hexstr'
high-i
) := 'C';
2661 hexstr
(hexstr'
high-i
) := 'D';
2663 hexstr
(hexstr'
high-i
) := 'E';
2665 hexstr
(hexstr'
high-i
) := 'F';
2667 hexstr
(hexstr'
high-i
) := 'U';
2669 hexstr
(hexstr'
high-i
) := 'X';
2671 hexstr
(hexstr'
high-i
) := 'Z';
2673 hexstr
(hexstr'
high-i
) := 'W';
2675 hexstr
(hexstr'
high-i
) := 'L';
2677 hexstr
(hexstr'
high-i
) := 'H';
2679 hexstr
(hexstr'
high-i
) := '-';
2681 hexstr
(hexstr'
high-i
) := '?';
2687 return prefix & hexstr & postfix;
2691 constant s :
unsigned;
2692 constant prefix :
string := ;
2693 constant postfix :
string :=
2696 return hxstr
(std_logic_vector(s
), prefix, postfix
);
2700 constant s :
signed;
2701 constant prefix :
string := ;
2702 constant postfix :
string :=
2705 return hxstr
(std_logic_vector(s
), prefix, postfix
);
2712 variable pltbv :
inout pltbv_t;
2716 pltbs.test_num <= pltbv.test_num;
2717 print
(pltbs.test_name, pltbv.test_name
);
2718 print
(pltbs.info, pltbv.info
);
2719 pltbs.chk_cnt <= pltbv.chk_cnt;
2720 pltbs.err_cnt <= pltbv.err_cnt;
2721 pltbs.stop_sim <= pltbv.stop_sim;
2722 end procedure pltbs_update;
2726 constant n :
integer;
2727 constant len :
integer;
2728 constant fillchar :
character := ' '
2730 variable s :
string(1 to len
) :=
(others => fillchar
);
2731 variable val :
integer := n;
2732 variable digit :
integer;
2734 for i
in 0 to len-
1 loop
2736 digit :=
val mod 10;
2738 s
(len - i
) :=
character'
val(character'
pos('
0'
) + digit
);
2742 report "str: value " &
integer'
image(n
) &
" does not fit in string with length " &
integer'
image(len
)
2749 constant s1 :
STRING;
2750 constant s2 :
STRING
2753 if s1'
length /= s2'
length then
2758 end function str_equal;
This package defines fuctions and procedures for controlling stimuli to a DUT and checking response.
pltbv_t
Type for status- and control variable.
pltbs_updatepltbv,pltbs,
pltbutils internal procedure(s), do not call from user's code
checkrpt,actual,expected,mask,pltbv,pltbs,
Checks that the value of a signal or variable is equal to expected.
natural := 512 C_PLTBUTILS_SKIPTESTLEN
endsimpltbv,pltbs,show_success_fail,force_stop,
Displays a message at end of simulation message, presents the simulation results, and stops the simul...
time := 1 us C_WAIT_BEFORE_STOP_TIME
endtestpltbv,pltbs,
Prints an end-of-test message to the screen.
waitclksN,clk,pltbv,pltbs,falling,timeout,
Waits specified amount of clock cycles of the specified clock.
boolean str_equals1,s2,
Function str_equal returns true if strings s1 and s2 are equal, otherwise false.
check_txtfilerpt,filename1,filename2,verbosity,pltbv,pltbs,
check_txtfile compares two text files.
natural := 80 C_PLTBUTILS_STRLEN
string hxstrs,prefix,postfix,
Converts a vector to a string in hexadecimal format.
character := ' ' EMPTY_CHR
check_binfilerpt,filename1,filename2,verbosity,pltbv,pltbs,
Checks that the contents of a file is equal to expected contents, by comparing with a reference file.
string strn,len,fillchar,
pltbs_t :=( test_num=> 0, test_name=>( others => EMPTY_CHR), info=>( others => EMPTY_CHR), chk_cnt=> 0, err_cnt=> 0, stop_sim=> '0') C_PLTBS_INIT
pltbv_t :=( testcase_name=>( others => EMPTY_CHR), testcase_name_len=> 1, test_num=> 0, test_name=>( others => EMPTY_CHR), test_name_len=> 1, skiptests=>( others => '0'), test_active=> true, info=>( others => EMPTY_CHR), info_len=> 1, test_cnt=> 0, skiptest_cnt=> 0, chk_cnt=> 0, err_cnt=> 0, chk_cnt_in_test=> 0, err_cnt_in_test=> 0, stop_sim=> '0') C_PLTBV_INIT
waitsigs,value,clk,pltbv,pltbs,falling,timeout,
Waits until a signal has reached a specified value after specified clock edge.
boolean is_test_activepltbv,
Returns true if a test is active (not skipped), otherwise false.
std_logic_vector to_ascendings,
Converts a vector to ascending range ("to-range").
printactive,pltbv,pltbs,txt,
Prints text messages to a signal for viewing in the simulator's waveform window.
starttestname,pltbv,pltbs,
Sets a number (optional) and a name for a test. The number and name will be printed to the screen,...
pltbs_t
Status- and control signal (subset of pltbv_t)
startsimtestcase_name,skiptests,pltbv,pltbs,
Displays a message at start of simulation message, and initializes PlTbUtils' status and control vari...
check_datfilerpt,filename1,filename2,verbosity,pltbv,pltbs,skip_init_items,
check_datfile compares two files with data formatted as follows. The files contain a sequence of data...
std_logic_vector to_descendings,
Converts a vector to descending range ("downto-range").
time := 10 sec C_PLTBUTILS_TIMEOUT
print2active,pltbv,pltbs,txt,
PlTbUtils User Configuration Package: User's function and procedure declarations.
Defines useful functions an procedures for text handling text in VHDL.