alu_tb cleanup
This commit is contained in:
parent
e8f3e33271
commit
5e3b7d307f
32
alu_tb.vhdl
32
alu_tb.vhdl
|
@ -82,7 +82,7 @@ begin
|
||||||
-- SUM
|
-- SUM
|
||||||
cmd <= "00";
|
cmd <= "00";
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
report "[test_01] addition of 32 random numbers, range between (0 to 536870911)";
|
report "addition of 32 random numbers, range between (0 to 536870911)";
|
||||||
|
|
||||||
la : for va in 0 to 31 loop
|
la : for va in 0 to 31 loop
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ begin
|
||||||
vz := '0';
|
vz := '0';
|
||||||
end if;
|
end if;
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
assert (res = vres) report "[error] resultat of sum. vres = " & integer'image(to_integer(unsigned(vres))) & " versus res = " & integer'image(to_integer(unsigned(res)))
|
assert (res = vres) report "[error] vres = " & integer'image(to_integer(unsigned(vres))) & " versus res = " & integer'image(to_integer(unsigned(res)))
|
||||||
severity error;
|
severity error;
|
||||||
assert (bit_to_integer(n) = bit_to_integer(vtemp(31))) report "[error] negative. n = " & integer'image(bit_to_integer(n)) & " versus vn = " & integer'image(bit_to_integer(vtemp(31)))
|
assert (bit_to_integer(n) = bit_to_integer(vtemp(31))) report "[error] negative. n = " & integer'image(bit_to_integer(n)) & " versus vn = " & integer'image(bit_to_integer(vtemp(31)))
|
||||||
severity error;
|
severity error;
|
||||||
|
@ -116,24 +116,21 @@ begin
|
||||||
severity error;
|
severity error;
|
||||||
end loop la;
|
end loop la;
|
||||||
|
|
||||||
report "[test_01] finished";
|
|
||||||
|
|
||||||
|
|
||||||
cin <= '0';
|
cin <= '0';
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
report "[test_02] addition of (7fff ffff) + (7fff ffff)";
|
report "addition of (7fff ffff) + (7fff ffff)";
|
||||||
op1 <= x"7fffffff"; --(+)2147483647
|
op1 <= x"7fffffff"; --(+)2147483647
|
||||||
op2 <= x"7fffffff"; --(+)2147483647
|
op2 <= x"7fffffff"; --(+)2147483647
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
assert (res = x"fffffffe") report "[error] res = " & integer'image(to_integer(unsigned(res))) severity error;
|
assert (res = x"fffffffe") report "[error] res = " & integer'image(to_integer(unsigned(res))) severity error;
|
||||||
assert (bit_to_integer(cout) = 0) report "cout = " & integer'image(bit_to_integer(cout)) severity error;
|
assert (bit_to_integer(cout) = 0) report "cout = " & integer'image(bit_to_integer(cout)) severity error;
|
||||||
assert (bit_to_integer(v) = 1) report "[error] v = " & integer'image(bit_to_integer(v)) severity error;
|
assert (bit_to_integer(v) = 1) report "[error] v = " & integer'image(bit_to_integer(v)) severity error;
|
||||||
|
|
||||||
report "[test_02] finished";
|
|
||||||
|
|
||||||
|
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
report "[test_03] test overflow, zero and carry in addition (ffff ffff) + (0000 0001)";
|
report "overflow, zero and carry in addition (ffff ffff) + (0000 0001)";
|
||||||
op1 <= x"ffffffff";
|
op1 <= x"ffffffff";
|
||||||
op2 <= x"00000001";
|
op2 <= x"00000001";
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
|
@ -142,11 +139,9 @@ begin
|
||||||
assert (bit_to_integer(cout) = 1) report "[error] cout = " & integer'image(bit_to_integer(cout)) severity error;
|
assert (bit_to_integer(cout) = 1) report "[error] cout = " & integer'image(bit_to_integer(cout)) severity error;
|
||||||
assert (bit_to_integer(v) = 1) report "[error] v = " & integer'image(bit_to_integer(v)) severity error;
|
assert (bit_to_integer(v) = 1) report "[error] v = " & integer'image(bit_to_integer(v)) severity error;
|
||||||
|
|
||||||
report "[test_03] finished";
|
|
||||||
|
|
||||||
|
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
report "[test_04] test addition negative number with negative result";
|
report "test addition negative number with negative result";
|
||||||
op1 <= x"0000002a"; -- 42
|
op1 <= x"0000002a"; -- 42
|
||||||
op2 <= x"ffffffd3"; -- -45
|
op2 <= x"ffffffd3"; -- -45
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
|
@ -156,13 +151,11 @@ begin
|
||||||
assert (bit_to_integer(z) = 0) report "[error] z = " & integer'image(bit_to_integer(z)) severity error;
|
assert (bit_to_integer(z) = 0) report "[error] z = " & integer'image(bit_to_integer(z)) severity error;
|
||||||
assert (bit_to_integer(cout) = 0) report "[error] cout = " & integer'image(bit_to_integer(cout)) severity error;
|
assert (bit_to_integer(cout) = 0) report "[error] cout = " & integer'image(bit_to_integer(cout)) severity error;
|
||||||
assert (bit_to_integer(v) = 1) report "[error] v = " & integer'image(bit_to_integer(v)) severity error;
|
assert (bit_to_integer(v) = 1) report "[error] v = " & integer'image(bit_to_integer(v)) severity error;
|
||||||
|
|
||||||
report "[test_04] finished";
|
|
||||||
|
|
||||||
|
|
||||||
-- AND
|
-- AND
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
report "[test_05] and of 32 random numbers in a range between (0 to 536870911)";
|
report "and of 32 random numbers in a range between (0 to 536870911)";
|
||||||
cmd <= "01";
|
cmd <= "01";
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
lb : for vb in 0 to 31 loop
|
lb : for vb in 0 to 31 loop
|
||||||
|
@ -195,13 +188,11 @@ begin
|
||||||
assert (bit_to_integer(z) = bit_to_integer(vz)) report "[error] z flag. z = " & integer'image(bit_to_integer(z)) & " versus vz = " & integer'image(bit_to_integer(vz))
|
assert (bit_to_integer(z) = bit_to_integer(vz)) report "[error] z flag. z = " & integer'image(bit_to_integer(z)) & " versus vz = " & integer'image(bit_to_integer(vz))
|
||||||
severity error;
|
severity error;
|
||||||
end loop lb;
|
end loop lb;
|
||||||
|
|
||||||
report "[test_05] finished";
|
|
||||||
|
|
||||||
|
|
||||||
-- OR
|
-- OR
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
report "[test_06] or of 32 random numbers in a range between (0 to 536870911)";
|
report "or of 32 random numbers in a range between (0 to 536870911)";
|
||||||
cmd <= "10";
|
cmd <= "10";
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
lc : for vc in 0 to 31 loop
|
lc : for vc in 0 to 31 loop
|
||||||
|
@ -235,13 +226,11 @@ begin
|
||||||
assert (bit_to_integer(z) = bit_to_integer(vz)) report "[error] z flag. z = " & integer'image(bit_to_integer(z)) & " versus vz = " & integer'image(bit_to_integer(vz))
|
assert (bit_to_integer(z) = bit_to_integer(vz)) report "[error] z flag. z = " & integer'image(bit_to_integer(z)) & " versus vz = " & integer'image(bit_to_integer(vz))
|
||||||
severity error;
|
severity error;
|
||||||
end loop lc;
|
end loop lc;
|
||||||
|
|
||||||
report "[test_06] finished";
|
|
||||||
|
|
||||||
|
|
||||||
-- XOR
|
-- XOR
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
report "[test_07] xor of 32 random numbers in a range between (0 to 536870911)";
|
report "xor of 32 random numbers in a range between (0 to 536870911)";
|
||||||
cmd <= "11";
|
cmd <= "11";
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
ld : for vd in 0 to 31 loop
|
ld : for vd in 0 to 31 loop
|
||||||
|
@ -275,8 +264,7 @@ begin
|
||||||
assert (bit_to_integer(z) = bit_to_integer(vz)) report "[error] z flag. z = " & integer'image(bit_to_integer(z)) & " versus vz = " & integer'image(bit_to_integer(vz))
|
assert (bit_to_integer(z) = bit_to_integer(vz)) report "[error] z flag. z = " & integer'image(bit_to_integer(z)) & " versus vz = " & integer'image(bit_to_integer(vz))
|
||||||
severity error;
|
severity error;
|
||||||
end loop ld;
|
end loop ld;
|
||||||
|
|
||||||
report "[test_07] finished";
|
|
||||||
|
|
||||||
|
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
|
|
Loading…
Reference in New Issue