|
|
|
@ -1,3 +1,6 @@
|
|
|
|
|
library vunit_lib;
|
|
|
|
|
context vunit_lib.vunit_context;
|
|
|
|
|
|
|
|
|
|
library ieee;
|
|
|
|
|
use ieee.std_logic_1164.all;
|
|
|
|
|
use ieee.numeric_std.all;
|
|
|
|
@ -5,10 +8,13 @@ use ieee.numeric_std.all;
|
|
|
|
|
library work;
|
|
|
|
|
use work.decode_types.all;
|
|
|
|
|
use work.common.all;
|
|
|
|
|
use work.glibc_random.all;
|
|
|
|
|
use work.ppc_fx_insns.all;
|
|
|
|
|
|
|
|
|
|
library osvvm;
|
|
|
|
|
use osvvm.RandomPkg.all;
|
|
|
|
|
|
|
|
|
|
entity divider_tb is
|
|
|
|
|
generic (runner_cfg : string := runner_cfg_default);
|
|
|
|
|
end divider_tb;
|
|
|
|
|
|
|
|
|
|
architecture behave of divider_tb is
|
|
|
|
@ -37,19 +43,28 @@ begin
|
|
|
|
|
variable q128: std_ulogic_vector(127 downto 0);
|
|
|
|
|
variable q64: std_ulogic_vector(63 downto 0);
|
|
|
|
|
variable rem32: std_ulogic_vector(31 downto 0);
|
|
|
|
|
variable rnd : RandomPType;
|
|
|
|
|
begin
|
|
|
|
|
rnd.InitSeed(stim_process'path_name);
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
@ -89,13 +104,12 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
d1.dividend <= ra when ra(63) = '0' else std_ulogic_vector(- signed(ra));
|
|
|
|
|
d1.divisor <= rb when rb(63) = '0' else std_ulogic_vector(- signed(rb));
|
|
|
|
@ -124,18 +138,15 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
d1.dividend <= ra;
|
|
|
|
|
d1.divisor <= rb;
|
|
|
|
|
d1.is_signed <= '0';
|
|
|
|
|
d1.neg_result <= '0';
|
|
|
|
|
d1.valid <= '1';
|
|
|
|
|
|
|
|
|
|
wait for clk_period;
|
|
|
|
@ -159,13 +170,12 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
d1.dividend <= ra when ra(63) = '0' else std_ulogic_vector(- signed(ra));
|
|
|
|
|
d1.divisor <= rb when rb(63) = '0' else std_ulogic_vector(- signed(rb));
|
|
|
|
@ -200,18 +210,15 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
d1.dividend <= ra;
|
|
|
|
|
d1.divisor <= rb;
|
|
|
|
|
d1.is_signed <= '0';
|
|
|
|
|
d1.neg_result <= '0';
|
|
|
|
|
d1.is_extended <= '1';
|
|
|
|
|
d1.valid <= '1';
|
|
|
|
|
|
|
|
|
@ -238,19 +245,17 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
d1.dividend <= ra when ra(63) = '0' else std_ulogic_vector(- signed(ra));
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
@ -275,19 +280,15 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
@ -312,19 +313,17 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(pseudorand(dlength * 8)), 32)) & x"00000000";
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(rnd.RandSlv(dlength * 8)), 32)) & x"00000000";
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
d1.dividend <= ra when ra(63) = '0' else std_ulogic_vector(- signed(ra));
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
@ -353,19 +352,15 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(pseudorand(dlength * 8)), 32)) & x"00000000";
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(rnd.RandSlv(dlength * 8)), 32)) & x"00000000";
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
@ -390,20 +385,17 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
d1.dividend <= ra when ra(63) = '0' else std_ulogic_vector(- signed(ra));
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
@ -428,20 +420,15 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
@ -466,19 +453,17 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(signed(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(signed(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
d1.dividend <= ra when ra(63) = '0' else std_ulogic_vector(- signed(ra));
|
|
|
|
|
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';
|
|
|
|
@ -509,19 +494,15 @@ 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
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(pseudorand(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(pseudorand(vlength * 8)), 64));
|
|
|
|
|
ra := std_ulogic_vector(resize(unsigned(rnd.RandSlv(dlength * 8)), 64));
|
|
|
|
|
rb := std_ulogic_vector(resize(unsigned(rnd.RandSlv(vlength * 8)), 64));
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
@ -546,7 +527,9 @@ begin
|
|
|
|
|
end loop;
|
|
|
|
|
end loop;
|
|
|
|
|
end loop;
|
|
|
|
|
end if;
|
|
|
|
|
end loop;
|
|
|
|
|
|
|
|
|
|
std.env.finish;
|
|
|
|
|
test_runner_cleanup(runner);
|
|
|
|
|
end process;
|
|
|
|
|
end behave;
|
|
|
|
|