Organized VUnit testbenches into test cases.

Several of the testbenches have stimuli code divided into sections preceded with a header comment explaining
what is being tested. These sections have been made into VUnit test cases. The default behavior of VUnit is
to run each test case in a separate simulation which comes with a number of benefits:

* A failing test case doesn't prevent other test cases to be executed
* Test cases are independent. A test case cannot fail as a side-effect to a problem with another test case
* Test execution can be more parallelized and the overall test execution time reduced

Signed-off-by: Lars Asplund <lars.anders.asplund@gmail.com>
pull/295/head
Lars Asplund 4 years ago
parent 08c0c4c1b4
commit 0940b8a9d3

@ -49,8 +49,8 @@ begin

test_runner_setup(runner, runner_cfg);

-- test with input = 0
report "test zero input";
while test_suite loop
if run("Test with input = 0") then
rs <= (others => '0');
is_32bit <= '0';
count_right <= '0';
@ -71,7 +71,7 @@ begin
assert result = x"0000000000000020"
report "bad cnttzw 0 = " & to_hstring(result);

report "test cntlzd/w";
elsif run("Test cntlzd/w") then
count_right <= '0';
for j in 0 to 100 loop
r := rnd.RandSlv(64);
@ -96,7 +96,7 @@ begin
end loop;
end loop;

report "test cnttzd/w";
elsif run("Test cnttzd/w") then
count_right <= '1';
for j in 0 to 100 loop
r := rnd.RandSlv(64);
@ -119,6 +119,8 @@ begin
r := r(62 downto 0) & '0';
end loop;
end loop;
end if;
end loop;

test_runner_cleanup(runner);
end process;

@ -49,18 +49,22 @@ begin

test_runner_setup(runner, runner_cfg);

while test_suite loop
rst <= '1';
wait for clk_period;
rst <= '0';

d1.valid <= '1';
d1.dividend <= x"0000000010001000";
d1.divisor <= x"0000000000001111";
d1.is_signed <= '0';
d1.is_32bit <= '0';
d1.neg_result <= '0';
d1.is_extended <= '0';
d1.is_32bit <= '0';
d1.is_modulus <= '0';
d1.neg_result <= '0';
d1.valid <= '0';

if run("Test interface") then
d1.valid <= '1';
d1.dividend <= x"0000000010001000";
d1.divisor <= x"0000000000001111";

wait for clk_period;
assert d2.valid = '0';
@ -100,8 +104,7 @@ begin
wait for clk_period;
assert d2.valid = '0';

-- test divd
report "test divd";
elsif run("Test divd") then
divd_loop : for dlength in 1 to 8 loop
for vlength in 1 to dlength loop
for i in 0 to 100 loop
@ -135,8 +138,7 @@ begin
end loop;
end loop;

-- test divdu
report "test divdu";
elsif run("Test divdu") then
divdu_loop : for dlength in 1 to 8 loop
for vlength in 1 to dlength loop
for i in 0 to 100 loop
@ -145,8 +147,6 @@ begin

d1.dividend <= ra;
d1.divisor <= rb;
d1.is_signed <= '0';
d1.neg_result <= '0';
d1.valid <= '1';

wait for clk_period;
@ -170,8 +170,7 @@ begin
end loop;
end loop;

-- test divde
report "test divde";
elsif run("Test divde") then
divde_loop : for vlength in 1 to 8 loop
for dlength in 1 to vlength loop
for i in 0 to 100 loop
@ -211,8 +210,7 @@ begin
end loop;
end loop;

-- test divdeu
report "test divdeu";
elsif run("Test divdeu") then
divdeu_loop : for vlength in 1 to 8 loop
for dlength in 1 to vlength loop
for i in 0 to 100 loop
@ -221,8 +219,6 @@ begin

d1.dividend <= ra;
d1.divisor <= rb;
d1.is_signed <= '0';
d1.neg_result <= '0';
d1.is_extended <= '1';
d1.valid <= '1';

@ -249,8 +245,7 @@ begin
end loop;
end loop;

-- test divw
report "test divw";
elsif run("Test divw") then
divw_loop : for dlength in 1 to 4 loop
for vlength in 1 to dlength loop
for i in 0 to 100 loop
@ -261,7 +256,6 @@ begin
d1.divisor <= rb when rb(63) = '0' else std_ulogic_vector(- signed(rb));
d1.is_signed <= '1';
d1.neg_result <= ra(63) xor rb(63);
d1.is_extended <= '0';
d1.is_32bit <= '1';
d1.valid <= '1';

@ -286,8 +280,7 @@ begin
end loop;
end loop;

-- test divwu
report "test divwu";
elsif run("Test divwu") then
divwu_loop : for dlength in 1 to 4 loop
for vlength in 1 to dlength loop
for i in 0 to 100 loop
@ -296,9 +289,6 @@ begin

d1.dividend <= ra;
d1.divisor <= rb;
d1.is_signed <= '0';
d1.neg_result <= '0';
d1.is_extended <= '0';
d1.is_32bit <= '1';
d1.valid <= '1';

@ -323,8 +313,7 @@ begin
end loop;
end loop;

-- test divwe
report "test divwe";
elsif run("Test divwe") then
divwe_loop : for vlength in 1 to 4 loop
for dlength in 1 to vlength loop
for i in 0 to 100 loop
@ -335,7 +324,6 @@ begin
d1.divisor <= rb when rb(63) = '0' else std_ulogic_vector(- signed(rb));
d1.is_signed <= '1';
d1.neg_result <= ra(63) xor rb(63);
d1.is_extended <= '0';
d1.is_32bit <= '1';
d1.valid <= '1';

@ -364,8 +352,7 @@ begin
end loop;
end loop;

-- test divweu
report "test divweu";
elsif run("Test divweu") then
divweu_loop : for vlength in 1 to 4 loop
for dlength in 1 to vlength loop
for i in 0 to 100 loop
@ -374,9 +361,6 @@ begin

d1.dividend <= ra;
d1.divisor <= rb;
d1.is_signed <= '0';
d1.neg_result <= '0';
d1.is_extended <= '0';
d1.is_32bit <= '1';
d1.valid <= '1';

@ -401,8 +385,7 @@ begin
end loop;
end loop;

-- test modsd
report "test modsd";
elsif run("Test modsd") then
modsd_loop : for dlength in 1 to 8 loop
for vlength in 1 to dlength loop
for i in 0 to 100 loop
@ -413,8 +396,6 @@ begin
d1.divisor <= rb when rb(63) = '0' else std_ulogic_vector(- signed(rb));
d1.is_signed <= '1';
d1.neg_result <= ra(63);
d1.is_extended <= '0';
d1.is_32bit <= '0';
d1.is_modulus <= '1';
d1.valid <= '1';

@ -439,8 +420,7 @@ begin
end loop;
end loop;

-- test modud
report "test modud";
elsif run("Test modud") then
modud_loop : for dlength in 1 to 8 loop
for vlength in 1 to dlength loop
for i in 0 to 100 loop
@ -449,10 +429,6 @@ begin

d1.dividend <= ra;
d1.divisor <= rb;
d1.is_signed <= '0';
d1.neg_result <= '0';
d1.is_extended <= '0';
d1.is_32bit <= '0';
d1.is_modulus <= '1';
d1.valid <= '1';

@ -477,8 +453,7 @@ begin
end loop;
end loop;

-- test modsw
report "test modsw";
elsif run("Test modsw") then
modsw_loop : for dlength in 1 to 4 loop
for vlength in 1 to dlength loop
for i in 0 to 100 loop
@ -489,7 +464,6 @@ begin
d1.divisor <= rb when rb(63) = '0' else std_ulogic_vector(- signed(rb));
d1.is_signed <= '1';
d1.neg_result <= ra(63);
d1.is_extended <= '0';
d1.is_32bit <= '1';
d1.is_modulus <= '1';
d1.valid <= '1';
@ -520,8 +494,7 @@ begin
end loop;
end loop;

-- test moduw
report "test moduw";
elsif run("Test moduw") then
moduw_loop : for dlength in 1 to 4 loop
for vlength in 1 to dlength loop
for i in 0 to 100 loop
@ -530,9 +503,6 @@ begin

d1.dividend <= ra;
d1.divisor <= rb;
d1.is_signed <= '0';
d1.neg_result <= '0';
d1.is_extended <= '0';
d1.is_32bit <= '1';
d1.is_modulus <= '1';
d1.valid <= '1';
@ -557,6 +527,8 @@ begin
end loop;
end loop;
end loop;
end if;
end loop;

test_runner_cleanup(runner);
end process;

@ -58,6 +58,8 @@ begin

test_runner_setup(runner, runner_cfg);

while test_suite loop
if run("Test interface") then
wait for clk_period;

m1.valid <= '1';
@ -93,7 +95,7 @@ begin
assert m2.valid = '1';
assert m2.result = x"00000000000000000000000001111000";

-- test mulld
elsif run("Test mulld") then
mulld_loop : for i in 0 to 1000 loop
ra := rnd.RandSlv(ra'length);
rb := rnd.RandSlv(rb'length);
@ -119,7 +121,7 @@ begin
report "bad mulld expected " & to_hstring(behave_rt) & " got " & to_hstring(m2.result(63 downto 0));
end loop;

-- test mulhdu
elsif run("Test mulhdu") then
mulhdu_loop : for i in 0 to 1000 loop
ra := rnd.RandSlv(ra'length);
rb := rnd.RandSlv(rb'length);
@ -144,7 +146,7 @@ begin
report "bad mulhdu expected " & to_hstring(behave_rt) & " got " & to_hstring(m2.result(127 downto 64));
end loop;

-- test mulhd
elsif run("Test mulhd") then
mulhd_loop : for i in 0 to 1000 loop
ra := rnd.RandSlv(ra'length);
rb := rnd.RandSlv(rb'length);
@ -170,7 +172,7 @@ begin
report "bad mulhd expected " & to_hstring(behave_rt) & " got " & to_hstring(m2.result(127 downto 64));
end loop;

-- test mullw
elsif run("Test mullw") then
mullw_loop : for i in 0 to 1000 loop
ra := rnd.RandSlv(ra'length);
rb := rnd.RandSlv(rb'length);
@ -198,7 +200,7 @@ begin
report "bad mullw expected " & to_hstring(behave_rt) & " got " & to_hstring(m2.result(63 downto 0));
end loop;

-- test mulhw
elsif run("Test mulhw") then
mulhw_loop : for i in 0 to 1000 loop
ra := rnd.RandSlv(ra'length);
rb := rnd.RandSlv(rb'length);
@ -227,7 +229,7 @@ begin
to_hstring(m2.result(63 downto 32) & m2.result(63 downto 32));
end loop;

-- test mulhwu
elsif run("Test mulhwu") then
mulhwu_loop : for i in 0 to 1000 loop
ra := rnd.RandSlv(ra'length);
rb := rnd.RandSlv(rb'length);
@ -255,7 +257,7 @@ begin
to_hstring(m2.result(63 downto 32) & m2.result(63 downto 32));
end loop;

-- test mulli
elsif run("Test mulli") then
mulli_loop : for i in 0 to 1000 loop
ra := rnd.RandSlv(ra'length);
si := rnd.RandSlv(si'length);
@ -281,6 +283,8 @@ begin
assert to_hstring(behave_rt) = to_hstring(m2.result(63 downto 0))
report "bad mulli expected " & to_hstring(behave_rt) & " got " & to_hstring(m2.result(63 downto 0));
end loop;
end if;
end loop;

test_runner_cleanup(runner);
wait;

@ -53,8 +53,8 @@ begin

test_runner_setup(runner, runner_cfg);

-- rlwinm, rlwnm
report "test rlw[i]nm";
while test_suite loop
if run("Test rlw[i]nm") then
ra <= (others => '0');
is_32bit <= '1';
right_shift <= '0';
@ -72,8 +72,7 @@ begin
report "bad rlwnm expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- rlwimi
report "test rlwimi";
elsif run("Test rlwimi") then
is_32bit <= '1';
right_shift <= '0';
arith <= '0';
@ -90,8 +89,7 @@ begin
report "bad rlwimi expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- rldicl, rldcl
report "test rld[i]cl";
elsif run("Test rld[i]cl") then
ra <= (others => '0');
is_32bit <= '0';
right_shift <= '0';
@ -108,8 +106,7 @@ begin
report "bad rldicl expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- rldicr, rldcr
report "test rld[i]cr";
elsif run("Test rld[i]cr") then
ra <= (others => '0');
is_32bit <= '0';
right_shift <= '0';
@ -131,8 +128,7 @@ begin
report "bad rldicr expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- rldic
report "test rldic";
elsif run("Test rldic") then
ra <= (others => '0');
is_32bit <= '0';
right_shift <= '0';
@ -149,8 +145,7 @@ begin
report "bad rldic expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- rldimi
report "test rldimi";
elsif run("Test rldimi") then
is_32bit <= '0';
right_shift <= '0';
arith <= '0';
@ -167,8 +162,7 @@ begin
report "bad rldimi expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- slw
report "test slw";
elsif run("Test slw") then
ra <= (others => '0');
is_32bit <= '1';
right_shift <= '0';
@ -184,8 +178,7 @@ begin
report "bad slw expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- sld
report "test sld";
elsif run("Test sld") then
ra <= (others => '0');
is_32bit <= '0';
right_shift <= '0';
@ -201,8 +194,7 @@ begin
report "bad sld expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- srw
report "test srw";
elsif run("Test srw") then
ra <= (others => '0');
is_32bit <= '1';
right_shift <= '1';
@ -218,8 +210,7 @@ begin
report "bad srw expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- srd
report "test srd";
elsif run("Test srd") then
ra <= (others => '0');
is_32bit <= '0';
right_shift <= '1';
@ -235,8 +226,7 @@ begin
report "bad srd expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

-- sraw[i]
report "test sraw[i]";
elsif run("Test sraw[i]") then
ra <= (others => '0');
is_32bit <= '1';
right_shift <= '1';
@ -256,8 +246,7 @@ begin
report "bad sraw expected " & to_hstring(behave_ca_ra) & " got " & to_hstring(carry_out & result);
end loop;

-- srad[i]
report "test srad[i]";
elsif run("Test srad[i]") then
ra <= (others => '0');
is_32bit <= '0';
right_shift <= '1';
@ -277,8 +266,7 @@ begin
report "bad srad expected " & to_hstring(behave_ca_ra) & " got " & to_hstring(carry_out & result);
end loop;

-- extswsli
report "test extswsli";
elsif run("Test extswsli") then
ra <= (others => '0');
is_32bit <= '0';
right_shift <= '0';
@ -301,7 +289,8 @@ begin
assert behave_ra = result
report "bad extswsli expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;

end if;
end loop;
test_runner_cleanup(runner);
end process;
end behave;

Loading…
Cancel
Save