Line 59... |
Line 59... |
use work.pltbutils_func_pkg.all;
|
use work.pltbutils_func_pkg.all;
|
use work.pltbutils_comp_pkg.all;
|
use work.pltbutils_comp_pkg.all;
|
|
|
entity tb_pltbutils is
|
entity tb_pltbutils is
|
generic (
|
generic (
|
|
G_SKIPTESTS : std_logic_vector := (
|
|
'0', -- Dummy
|
|
'0', -- Test 1
|
|
'0', -- Test 2
|
|
'0', -- Test 3
|
|
'0', -- Test 4: NonSkipTest
|
|
'1' -- Test 5: SkipTest
|
|
);
|
G_CLK_PERIOD : time := 10 ns
|
G_CLK_PERIOD : time := 10 ns
|
);
|
);
|
end entity tb_pltbutils;
|
end entity tb_pltbutils;
|
|
|
architecture bhv of tb_pltbutils is
|
architecture bhv of tb_pltbutils is
|
Line 119... |
Line 127... |
|
|
-- Testcase
|
-- Testcase
|
p_tc1 : process
|
p_tc1 : process
|
variable pltbv : pltbv_t := C_PLTBV_INIT;
|
variable pltbv : pltbv_t := C_PLTBV_INIT;
|
variable v_expected_tests_cnt : integer := 0;
|
variable v_expected_tests_cnt : integer := 0;
|
|
variable v_expected_skiptests_cnt : integer := 0;
|
variable v_expected_checks_cnt : integer := 0;
|
variable v_expected_checks_cnt : integer := 0;
|
variable v_expected_errors_cnt : integer := 0;
|
variable v_expected_errors_cnt : integer := 0;
|
begin
|
begin
|
|
|
print("<Testing startsim()>");
|
print("<Testing startsim()>");
|
startsim("tc1", pltbv, pltbs);
|
startsim("tc1", G_SKIPTESTS, pltbv, pltbs);
|
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
assert (pltbv.test_num = 0) and (pltbs.test_num = 0)
|
assert (pltbv.test_num = 0) and (pltbs.test_num = 0)
|
report "test_num after startsim() incorrect"
|
report "test_num after startsim() incorrect"
|
severity error;
|
severity error;
|
print("<Done testing startsim()>");
|
print("<Done testing startsim()>");
|
|
|
print("<Testing starttest() with auto-incrementing test_num>");
|
print("<Testing starttest() with auto-incrementing test_num>");
|
starttest("TestName1", pltbv, pltbs);
|
starttest("StartTest1", pltbv, pltbs);
|
v_expected_tests_cnt := v_expected_tests_cnt + 1;
|
v_expected_tests_cnt := v_expected_tests_cnt + 1;
|
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
assert (pltbv.test_num = 1) and (pltbs.test_num = 1)
|
assert (pltbv.test_num = 1) and (pltbs.test_num = 1)
|
report "test_num after starttest() incorrect"
|
report "test_num after starttest() incorrect"
|
severity error;
|
severity error;
|
Line 145... |
Line 154... |
print("<Testing endtest()>");
|
print("<Testing endtest()>");
|
endtest(pltbv, pltbs);
|
endtest(pltbv, pltbs);
|
print("<Done testing endtest()>");
|
print("<Done testing endtest()>");
|
|
|
print("<Testing starttest() with explicit test_num>");
|
print("<Testing starttest() with explicit test_num>");
|
starttest(3, "TestName2", pltbv, pltbs);
|
starttest(3, "StartTest2", pltbv, pltbs);
|
v_expected_tests_cnt := v_expected_tests_cnt + 1;
|
v_expected_tests_cnt := v_expected_tests_cnt + 1;
|
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
assert (pltbv.test_num = 3) and (pltbs.test_num = 3)
|
assert (pltbv.test_num = 3) and (pltbs.test_num = 3)
|
report "test_num after startsim() incorrect"
|
report "test_num after startsim() incorrect"
|
severity error;
|
severity error;
|
print("<Done testing starttest() with explicit test_num>");
|
print("<Done testing starttest() with explicit test_num>");
|
|
|
|
print("<Testing starttest() and is_test_active() for non-skipped test>");
|
|
starttest(4, "NoSkipTest", pltbv, pltbs);
|
|
if is_test_active(pltbv) then
|
|
v_expected_tests_cnt := v_expected_tests_cnt + 1;
|
|
wait until rising_edge(clk);
|
|
else
|
|
v_expected_skiptests_cnt := v_expected_skiptests_cnt + 1;
|
|
wait until rising_edge(clk);
|
|
assert false
|
|
report "Executing test that should have been skipped"
|
|
severity error;
|
|
end if;
|
|
endtest(pltbv, pltbs);
|
|
print("<Done testing starttest() and is_test_active() for non-skipped test>");
|
|
|
|
print("<Testing starttest() and is_test_active() for skipped test>");
|
|
starttest(5, "SkipTest", pltbv, pltbs);
|
|
if is_test_active(pltbv) then
|
|
v_expected_tests_cnt := v_expected_tests_cnt + 1;
|
|
wait until rising_edge(clk);
|
|
assert false
|
|
report "Executing test that should have been skipped"
|
|
severity error;
|
|
else
|
|
--check("Checking if check() detects that it should not be called in skipped test", false, pltbv, pltbs);
|
|
v_expected_skiptests_cnt := v_expected_skiptests_cnt + 1;
|
|
end if;
|
|
endtest(pltbv, pltbs);
|
|
print("<Done testing starttest() and is_test_active() for skipped test>");
|
|
|
print("<Testing waitclks()>");
|
print("<Testing waitclks()>");
|
clk_cnt_clr <= true;
|
clk_cnt_clr <= true;
|
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
clk_cnt_clr <= false;
|
clk_cnt_clr <= false;
|
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
Line 548... |
Line 587... |
|
|
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
print("<Testing endsim()>");
|
print("<Testing endsim()>");
|
print("");
|
print("");
|
print("Expected number of tests: " & str(v_expected_tests_cnt));
|
print("Expected number of tests: " & str(v_expected_tests_cnt));
|
|
print("Expected number of skipped tests: " & str(v_expected_skiptests_cnt));
|
print("Expected number of checks: " & str(v_expected_checks_cnt));
|
print("Expected number of checks: " & str(v_expected_checks_cnt));
|
print("Expected number of errors: " & str(v_expected_errors_cnt));
|
print("Expected number of errors: " & str(v_expected_errors_cnt));
|
if v_expected_errors_cnt = 0 then
|
if v_expected_errors_cnt = 0 then
|
print("Expected result: SUCCESS");
|
print("Expected result: SUCCESS");
|
else
|
else
|