Line 54... |
Line 54... |
|
|
package pltbutils_func_pkg is
|
package pltbutils_func_pkg is
|
|
|
-- See the package body for a description of the functions and procedures.
|
-- See the package body for a description of the functions and procedures.
|
constant C_PLTBUTILS_STRLEN : natural := 80;
|
constant C_PLTBUTILS_STRLEN : natural := 80;
|
|
constant C_PLTBUTILS_SKIPTESTLEN : natural := 512;
|
constant C_PLTBUTILS_TIMEOUT : time := 10 sec;
|
constant C_PLTBUTILS_TIMEOUT : time := 10 sec;
|
constant C_WAIT_BEFORE_STOP_TIME : time := 1 us;
|
constant C_WAIT_BEFORE_STOP_TIME : time := 1 us;
|
|
|
-- Type for status- and control variable
|
-- Type for status- and control variable
|
type pltbv_t is
|
type pltbv_t is
|
Line 65... |
Line 66... |
testcase_name : string(1 to C_PLTBUTILS_STRLEN);
|
testcase_name : string(1 to C_PLTBUTILS_STRLEN);
|
testcase_name_len: integer;
|
testcase_name_len: integer;
|
test_num : integer;
|
test_num : integer;
|
test_name : string(1 to C_PLTBUTILS_STRLEN);
|
test_name : string(1 to C_PLTBUTILS_STRLEN);
|
test_name_len : integer;
|
test_name_len : integer;
|
|
skiptests : std_logic_vector(0 to C_PLTBUTILS_SKIPTESTLEN-1);
|
|
test_active : boolean;
|
info : string(1 to C_PLTBUTILS_STRLEN);
|
info : string(1 to C_PLTBUTILS_STRLEN);
|
info_len : integer;
|
info_len : integer;
|
test_cnt : integer;
|
test_cnt : integer;
|
|
skiptest_cnt : integer;
|
chk_cnt : integer;
|
chk_cnt : integer;
|
err_cnt : integer;
|
err_cnt : integer;
|
chk_cnt_in_test : integer;
|
chk_cnt_in_test : integer;
|
err_cnt_in_test : integer;
|
err_cnt_in_test : integer;
|
stop_sim : std_logic;
|
stop_sim : std_logic;
|
Line 81... |
Line 85... |
(others => ' '), -- testcase_name
|
(others => ' '), -- testcase_name
|
1, -- testcase_name_len
|
1, -- testcase_name_len
|
0, -- test_num
|
0, -- test_num
|
(others => ' '), -- test_name
|
(others => ' '), -- test_name
|
1, -- test_name_len
|
1, -- test_name_len
|
|
(others => '0'), -- skiptest
|
|
true, -- test_active
|
(others => ' '), -- info
|
(others => ' '), -- info
|
1, -- info_len
|
1, -- info_len
|
0, -- test_cnt
|
0, -- test_cnt
|
|
0, -- skiptest_cnt
|
0, -- chk_cnt
|
0, -- chk_cnt
|
0, -- err_cnt
|
0, -- err_cnt
|
0, -- chk_cnt_in_test
|
0, -- chk_cnt_in_test
|
0, -- err_cnt_in_test
|
0, -- err_cnt_in_test
|
'0' -- stop_sim
|
'0' -- stop_sim
|
Line 114... |
Line 121... |
);
|
);
|
|
|
-- startsim
|
-- startsim
|
procedure startsim(
|
procedure startsim(
|
constant testcase_name : in string;
|
constant testcase_name : in string;
|
|
constant skiptests : in std_logic_vector;
|
variable pltbv : inout pltbv_t;
|
variable pltbv : inout pltbv_t;
|
signal pltbs : out pltbs_t
|
signal pltbs : out pltbs_t
|
);
|
);
|
|
|
-- endsim
|
-- endsim
|
Line 139... |
Line 147... |
constant name : in string;
|
constant name : in string;
|
variable pltbv : inout pltbv_t;
|
variable pltbv : inout pltbv_t;
|
signal pltbs : out pltbs_t
|
signal pltbs : out pltbs_t
|
);
|
);
|
|
|
|
-- is_test_active
|
|
function is_test_active(
|
|
constant pltbv : in pltbv_t
|
|
) return boolean;
|
|
|
-- endtest
|
-- endtest
|
procedure endtest(
|
procedure endtest(
|
variable pltbv : inout pltbv_t;
|
variable pltbv : inout pltbv_t;
|
signal pltbs : out pltbs_t
|
signal pltbs : out pltbs_t
|
);
|
);
|
Line 492... |
Line 505... |
|
|
procedure endsim_msg(
|
procedure endsim_msg(
|
constant testcase_name : in string;
|
constant testcase_name : in string;
|
constant timestamp : in time;
|
constant timestamp : in time;
|
constant num_tests : in integer;
|
constant num_tests : in integer;
|
|
constant num_skiptests : in integer;
|
constant num_checks : in integer;
|
constant num_checks : in integer;
|
constant num_errors : in integer;
|
constant num_errors : in integer;
|
constant show_success_fail : in boolean
|
constant show_success_fail : in boolean
|
);
|
);
|
|
|
Line 503... |
Line 517... |
constant test_num : in integer;
|
constant test_num : in integer;
|
constant test_name : in string;
|
constant test_name : in string;
|
constant timestamp : in time
|
constant timestamp : in time
|
);
|
);
|
|
|
|
procedure skiptest_msg(
|
|
constant test_num : in integer;
|
|
constant test_name : in string;
|
|
constant timestamp : in time
|
|
);
|
|
|
procedure endtest_msg(
|
procedure endtest_msg(
|
constant test_num : in integer;
|
constant test_num : in integer;
|
constant test_name : in string;
|
constant test_name : in string;
|
constant timestamp : in time;
|
constant timestamp : in time;
|
|
constant test_active : in boolean;
|
constant num_checks_in_test : in integer;
|
constant num_checks_in_test : in integer;
|
constant num_errors_in_test : in integer
|
constant num_errors_in_test : in integer
|
);
|
);
|
|
|
procedure check_msg(
|
procedure check_msg(
|
Line 541... |
Line 562... |
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
-- startsim
|
-- startsim
|
--
|
--
|
-- procedure startsim(
|
-- procedure startsim(
|
-- constant testcase_name : in string;
|
-- constant testcase_name : in string;
|
|
-- constant skiptests : in std_logic_vector;
|
-- variable pltbv : inout pltbv_t;
|
-- variable pltbv : inout pltbv_t;
|
-- signal pltbs : out pltbs_t
|
-- signal pltbs : out pltbs_t
|
-- )
|
-- )
|
--
|
--
|
-- Displays a message at start of simulation message, and initializes
|
-- Displays a message at start of simulation message, and initializes
|
Line 552... |
Line 574... |
-- Call startsim() only once.
|
-- Call startsim() only once.
|
--
|
--
|
-- Arguments:
|
-- Arguments:
|
-- testcase_name Name of the test case, e.g. "tc1".
|
-- testcase_name Name of the test case, e.g. "tc1".
|
--
|
--
|
|
-- skiptests std_logic_vector for marking tests that should
|
|
-- be skipped. The leftmost bit has position 0,
|
|
-- and position numbers increment to the right.
|
|
-- A '1' indicates that the test with the same
|
|
-- number as the position should be skipped.
|
|
-- Note that there is usually no test which has
|
|
-- number 0, so bit zero in the vector is usually
|
|
-- ignored.
|
|
-- This argument is normally fed by a generic.
|
|
-- If no tests should be skipped, a zero-length
|
|
-- vector is allowed, ("").
|
|
--
|
-- pltbv, pltbs PlTbUtils' status- and control variable and
|
-- pltbv, pltbs PlTbUtils' status- and control variable and
|
-- -signal.
|
-- -signal.
|
--
|
--
|
-- NOTE:
|
-- NOTE:
|
-- The start-of-simulation message is not only intended to be informative
|
-- The start-of-simulation message is not only intended to be informative
|
Line 564... |
Line 598... |
-- For this reason, the message must be consistent and unique.
|
-- For this reason, the message must be consistent and unique.
|
--
|
--
|
-- DO NOT MODIFY the message "--- START OF SIMULATION ---".
|
-- DO NOT MODIFY the message "--- START OF SIMULATION ---".
|
-- DO NOT OUTPUT AN IDENTICAL MESSAGE anywhere else.
|
-- DO NOT OUTPUT AN IDENTICAL MESSAGE anywhere else.
|
--
|
--
|
-- Example:
|
-- Examples:
|
-- startsim("tc1", pltbv, pltbs);
|
-- startsim("tc1", "", pltbv, pltbs);
|
|
-- startsim("tc2", G_SKIPTESTS, pltbv, pltbs); -- G_SKIPTESTS is a generic
|
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
procedure startsim(
|
procedure startsim(
|
constant testcase_name : in string;
|
constant testcase_name : in string;
|
|
constant skiptests : in std_logic_vector;
|
variable pltbv : inout pltbv_t;
|
variable pltbv : inout pltbv_t;
|
signal pltbs : out pltbs_t
|
signal pltbs : out pltbs_t
|
) is
|
) is
|
variable timestamp : time;
|
variable timestamp : time;
|
|
variable v_ignored_skiptest : boolean := false;
|
begin
|
begin
|
timestamp := now;
|
timestamp := now;
|
pltbv := C_PLTBV_INIT;
|
pltbv := C_PLTBV_INIT;
|
printv(pltbv.testcase_name, testcase_name);
|
printv(pltbv.testcase_name, testcase_name);
|
pltbv.testcase_name_len := testcase_name'length;
|
pltbv.testcase_name_len := testcase_name'length;
|
printv(pltbv.test_name, "START OF SIMULATION");
|
printv(pltbv.test_name, "START OF SIMULATION");
|
pltbv.test_name_len := 19;
|
pltbv.test_name_len := 19;
|
printv(pltbv.info, testcase_name);
|
printv(pltbv.info, testcase_name);
|
|
if skiptests'length > 0 then
|
|
for i in skiptests'low to skiptests'high loop
|
|
if i >= pltbv.skiptests'low and i <= pltbv.skiptests'high then
|
|
pltbv.skiptests(i) := skiptests(i);
|
|
else
|
|
if pltbv.skiptests(i) = '1' then
|
|
v_ignored_skiptest := true;
|
|
end if;
|
|
end if;
|
|
end loop;
|
|
if v_ignored_skiptest then
|
|
assert false
|
|
report "Some SKIPTESTS flags ignored. Max " &
|
|
integer'image(pltbv.skiptests'length) & " flag bits supported."
|
|
severity warning;
|
|
end if;
|
|
end if;
|
pltbv.info_len := testcase_name'length;
|
pltbv.info_len := testcase_name'length;
|
pltbs_update(pltbv, pltbs);
|
pltbs_update(pltbv, pltbs);
|
if C_PLTBUTILS_USE_STD_STARTSIM_MSG then
|
if C_PLTBUTILS_USE_STD_STARTSIM_MSG then
|
startsim_msg(testcase_name, timestamp);
|
startsim_msg(testcase_name, timestamp);
|
end if;
|
end if;
|
Line 653... |
Line 707... |
variable timestamp : time;
|
variable timestamp : time;
|
begin
|
begin
|
timestamp := now;
|
timestamp := now;
|
if C_PLTBUTILS_USE_STD_ENDSIM_MSG then
|
if C_PLTBUTILS_USE_STD_ENDSIM_MSG then
|
endsim_msg(pltbv.testcase_name(1 to pltbv.testcase_name_len), timestamp,
|
endsim_msg(pltbv.testcase_name(1 to pltbv.testcase_name_len), timestamp,
|
pltbv.test_cnt, pltbv.chk_cnt, pltbv.err_cnt, show_success_fail);
|
pltbv.test_cnt, pltbv.skiptest_cnt, pltbv.chk_cnt, pltbv.err_cnt,
|
|
show_success_fail);
|
end if;
|
end if;
|
if C_PLTBUTILS_USE_CUSTOM_ENDSIM_MSG then
|
if C_PLTBUTILS_USE_CUSTOM_ENDSIM_MSG then
|
custom_endsim_msg(pltbv.testcase_name(1 to pltbv.testcase_name_len), timestamp,
|
custom_endsim_msg(pltbv.testcase_name(1 to pltbv.testcase_name_len), timestamp,
|
pltbv.test_cnt, pltbv.chk_cnt, pltbv.err_cnt, show_success_fail);
|
pltbv.test_cnt, pltbv.skiptest_cnt, pltbv.chk_cnt, pltbv.err_cnt,
|
|
show_success_fail);
|
end if;
|
end if;
|
pltbv.test_num := 0;
|
pltbv.test_num := 0;
|
printv(pltbv.test_name, "END OF SIMULATION");
|
printv(pltbv.test_name, "END OF SIMULATION");
|
pltbv.test_name_len := 17;
|
pltbv.test_name_len := 17;
|
pltbv.stop_sim := '1';
|
pltbv.stop_sim := '1';
|
Line 726... |
Line 782... |
else
|
else
|
pltbv.test_num := num;
|
pltbv.test_num := num;
|
end if;
|
end if;
|
printv(pltbv.test_name, name);
|
printv(pltbv.test_name, name);
|
pltbv.test_name_len := name'length;
|
pltbv.test_name_len := name'length;
|
pltbv.test_cnt := pltbv.test_cnt + 1;
|
|
pltbv.chk_cnt_in_test := 0;
|
pltbv.chk_cnt_in_test := 0;
|
pltbv.err_cnt_in_test := 0;
|
pltbv.err_cnt_in_test := 0;
|
|
pltbv.test_active := true;
|
|
if num >= pltbv.skiptests'low and num <= pltbv.skiptests'high then
|
|
if pltbv.skiptests(num) = '1' then
|
|
pltbv.test_active := false;
|
|
end if;
|
|
end if;
|
|
if pltbv.test_active then
|
|
pltbv.test_cnt := pltbv.test_cnt + 1;
|
pltbs_update(pltbv, pltbs);
|
pltbs_update(pltbv, pltbs);
|
if C_PLTBUTILS_USE_STD_STARTTEST_MSG then
|
if C_PLTBUTILS_USE_STD_STARTTEST_MSG then
|
starttest_msg(pltbv.test_num, name, timestamp);
|
starttest_msg(pltbv.test_num, name, timestamp);
|
end if;
|
end if;
|
if C_PLTBUTILS_USE_CUSTOM_STARTTEST_MSG then
|
if C_PLTBUTILS_USE_CUSTOM_STARTTEST_MSG then
|
custom_starttest_msg(pltbv.test_num, name, timestamp);
|
custom_starttest_msg(pltbv.test_num, name, timestamp);
|
end if;
|
end if;
|
|
else
|
|
pltbv.skiptest_cnt := pltbv.skiptest_cnt + 1;
|
|
pltbs_update(pltbv, pltbs);
|
|
if C_PLTBUTILS_USE_STD_SKIPTEST_MSG then
|
|
skiptest_msg(pltbv.test_num, name, timestamp);
|
|
end if;
|
|
if C_PLTBUTILS_USE_CUSTOM_SKIPTEST_MSG then
|
|
custom_skiptest_msg(pltbv.test_num, name, timestamp);
|
|
end if;
|
|
end if;
|
end procedure starttest;
|
end procedure starttest;
|
|
|
procedure starttest(
|
procedure starttest(
|
constant name : in string;
|
constant name : in string;
|
variable pltbv : inout pltbv_t;
|
variable pltbv : inout pltbv_t;
|
Line 748... |
Line 821... |
begin
|
begin
|
starttest(-1, name, pltbv, pltbs);
|
starttest(-1, name, pltbv, pltbs);
|
end procedure starttest;
|
end procedure starttest;
|
|
|
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
|
-- is_test_active
|
|
--
|
|
-- function is_test_active(
|
|
-- constant pltbv : in pltbv_t
|
|
-- ) return boolean
|
|
--
|
|
-- Returns true if a test is active (not skipped), otherwise false.
|
|
--
|
|
-- Arguments:
|
|
-- pltbv PlTbUtils' status- and control variable.
|
|
--
|
|
-- Example:
|
|
-- starttest(3, "Example test", pltbv, pltbs);
|
|
-- if is_test_active(pltbv) then
|
|
-- ... test code ...
|
|
-- end if;
|
|
-- endtest(pltbv, pltbs);
|
|
----------------------------------------------------------------------------
|
|
function is_test_active(
|
|
constant pltbv : in pltbv_t
|
|
) return boolean is
|
|
begin
|
|
return pltbv.test_active;
|
|
end function is_test_active;
|
|
|
|
----------------------------------------------------------------------------
|
-- endtest
|
-- endtest
|
--
|
--
|
-- procedure endtest(
|
-- procedure endtest(
|
-- variable pltbv : inout pltbv_t;
|
-- variable pltbv : inout pltbv_t;
|
-- signal pltbs : out pltbs_t
|
-- signal pltbs : out pltbs_t
|
Line 773... |
Line 872... |
variable timestamp : time;
|
variable timestamp : time;
|
begin
|
begin
|
timestamp := now;
|
timestamp := now;
|
if C_PLTBUTILS_USE_STD_ENDTEST_MSG then
|
if C_PLTBUTILS_USE_STD_ENDTEST_MSG then
|
endtest_msg(pltbv.test_num, pltbv.test_name(1 to pltbv.test_name_len),
|
endtest_msg(pltbv.test_num, pltbv.test_name(1 to pltbv.test_name_len),
|
timestamp, pltbv.chk_cnt_in_test, pltbv.err_cnt_in_test);
|
timestamp, pltbv.test_active, pltbv.chk_cnt_in_test, pltbv.err_cnt_in_test);
|
end if;
|
end if;
|
if C_PLTBUTILS_USE_CUSTOM_ENDTEST_MSG then
|
if C_PLTBUTILS_USE_CUSTOM_ENDTEST_MSG then
|
custom_endtest_msg(pltbv.test_num, pltbv.test_name(1 to pltbv.test_name_len),
|
custom_endtest_msg(pltbv.test_num, pltbv.test_name(1 to pltbv.test_name_len),
|
timestamp, pltbv.chk_cnt_in_test, pltbv.err_cnt_in_test);
|
timestamp, pltbv.test_active, pltbv.chk_cnt_in_test, pltbv.err_cnt_in_test);
|
end if;
|
end if;
|
|
pltbv.test_active := true;
|
printv(pltbv.test_name, " ");
|
printv(pltbv.test_name, " ");
|
pltbv.test_name_len := 1;
|
pltbv.test_name_len := 1;
|
pltbs_update(pltbv, pltbs);
|
pltbs_update(pltbv, pltbs);
|
end procedure endtest;
|
end procedure endtest;
|
|
|
Line 1621... |
Line 1721... |
variable timestamp : time;
|
variable timestamp : time;
|
begin
|
begin
|
timestamp := now;
|
timestamp := now;
|
pltbv.chk_cnt := pltbv.chk_cnt + 1;
|
pltbv.chk_cnt := pltbv.chk_cnt + 1;
|
pltbv.chk_cnt_in_test := pltbv.chk_cnt_in_test + 1;
|
pltbv.chk_cnt_in_test := pltbv.chk_cnt_in_test + 1;
|
|
if not is_test_active(pltbv) then
|
|
pltbv.err_cnt := pltbv.err_cnt + 1;
|
|
pltbv.err_cnt_in_test := pltbv.err_cnt_in_test + 1;
|
|
if C_PLTBUTILS_USE_STD_CHECK_MSG then
|
|
check_msg("check() executed in skipped test, missing if clause?", timestamp, false, "", "", "", pltbv.test_num,
|
|
pltbv.test_name(1 to pltbv.test_name_len), pltbv.chk_cnt, pltbv.err_cnt_in_test);
|
|
end if;
|
|
if C_PLTBUTILS_USE_CUSTOM_CHECK_MSG then
|
|
custom_check_msg("check() executed in skipped test, missing if clause?", timestamp, false, "", "", "", pltbv.test_num,
|
|
pltbv.test_name(1 to pltbv.test_name_len), pltbv.chk_cnt, pltbv.err_cnt_in_test);
|
|
end if;
|
|
end if;
|
if not expr then
|
if not expr then
|
pltbv.err_cnt := pltbv.err_cnt + 1;
|
pltbv.err_cnt := pltbv.err_cnt + 1;
|
pltbv.err_cnt_in_test := pltbv.err_cnt_in_test + 1;
|
pltbv.err_cnt_in_test := pltbv.err_cnt_in_test + 1;
|
end if;
|
end if;
|
pltbs_update(pltbv, pltbs);
|
pltbs_update(pltbv, pltbs);
|
Line 1919... |
Line 2031... |
|
|
procedure endsim_msg(
|
procedure endsim_msg(
|
constant testcase_name : in string;
|
constant testcase_name : in string;
|
constant timestamp : in time;
|
constant timestamp : in time;
|
constant num_tests : in integer;
|
constant num_tests : in integer;
|
|
constant num_skiptests : in integer;
|
constant num_checks : in integer;
|
constant num_checks : in integer;
|
constant num_errors : in integer;
|
constant num_errors : in integer;
|
constant show_success_fail : in boolean
|
constant show_success_fail : in boolean
|
) is
|
) is
|
variable l : line;
|
variable l : line;
|
Line 1933... |
Line 2046... |
write(l, timestamp, right, 14);
|
write(l, timestamp, right, 14);
|
writeline(output, l);
|
writeline(output, l);
|
write(l, num_tests, right, 11);
|
write(l, num_tests, right, 11);
|
write(l, string'(" Tests"));
|
write(l, string'(" Tests"));
|
writeline(output, l);
|
writeline(output, l);
|
|
write(l, num_skiptests, right, 11);
|
|
write(l, string'(" Skipped tests"));
|
|
writeline(output, l);
|
write(l, num_checks, right, 11);
|
write(l, num_checks, right, 11);
|
write(l, string'(" Checks"));
|
write(l, string'(" Checks"));
|
writeline(output, l);
|
writeline(output, l);
|
write(l, num_errors, right, 11);
|
write(l, num_errors, right, 11);
|
write(l, string'(" Errors"));
|
write(l, string'(" Errors"));
|
Line 1959... |
Line 2075... |
) is
|
) is
|
begin
|
begin
|
print(lf & "Test " & str(test_num) & ": " & test_name & " (" & time'image(timestamp) & ")");
|
print(lf & "Test " & str(test_num) & ": " & test_name & " (" & time'image(timestamp) & ")");
|
end procedure starttest_msg;
|
end procedure starttest_msg;
|
|
|
|
procedure skiptest_msg(
|
|
constant test_num : in integer;
|
|
constant test_name : in string;
|
|
constant timestamp : in time
|
|
) is
|
|
begin
|
|
print(lf & "Skipping Test " & str(test_num) & ": " & test_name & " (" & time'image(timestamp) & ")");
|
|
end procedure skiptest_msg;
|
|
|
procedure endtest_msg(
|
procedure endtest_msg(
|
constant test_num : in integer;
|
constant test_num : in integer;
|
constant test_name : in string;
|
constant test_name : in string;
|
constant timestamp : in time;
|
constant timestamp : in time;
|
|
constant test_active : in boolean;
|
constant num_checks_in_test : in integer;
|
constant num_checks_in_test : in integer;
|
constant num_errors_in_test : in integer
|
constant num_errors_in_test : in integer
|
) is
|
) is
|
begin
|
begin
|
|
if test_active then
|
print("Done with test " & str(test_num) & ": " & test_name & " (" & time'image(timestamp) & ")");
|
print("Done with test " & str(test_num) & ": " & test_name & " (" & time'image(timestamp) & ")");
|
|
end if;
|
end procedure endtest_msg;
|
end procedure endtest_msg;
|
|
|
procedure check_msg(
|
procedure check_msg(
|
constant rpt : in string;
|
constant rpt : in string;
|
constant timestamp : in time;
|
constant timestamp : in time;
|