@ -23,7 +23,7 @@ architecture behave of rotator_tb is
signal shift: std_ulogic_vector(6 downto 0) := (others => '0');
signal shift: std_ulogic_vector(6 downto 0) := (others => '0');
signal insn: std_ulogic_vector(31 downto 0) := (others => '0');
signal insn: std_ulogic_vector(31 downto 0) := (others => '0');
signal is_32bit, right_shift, arith, clear_left, clear_right: std_ulogic := '0';
signal is_32bit, right_shift, arith, clear_left, clear_right: std_ulogic := '0';
signal result: std_ulogic_vector(63 downto 0);
signal res: std_ulogic_vector(63 downto 0);
signal carry_out: std_ulogic;
signal carry_out: std_ulogic;
signal extsw: std_ulogic;
signal extsw: std_ulogic;
@ -40,7 +40,7 @@ begin
clear_left => clear_left,
clear_left => clear_left,
clear_right => clear_right,
clear_right => clear_right,
sign_ext_rs => extsw,
sign_ext_rs => extsw,
result => result,
result => res,
carry_out => carry_out
carry_out => carry_out
);
);
@ -51,6 +51,10 @@ begin
begin
begin
rnd.InitSeed(stim_process'path_name);
rnd.InitSeed(stim_process'path_name);
-- TODO: Consider making debug messages visible with a command line option
-- rather than uncommenting this line:
-- show(display_handler, debug);
test_runner_setup(runner, runner_cfg);
test_runner_setup(runner, runner_cfg);
while test_suite loop
while test_suite loop
@ -68,8 +72,7 @@ begin
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
wait for clk_period;
wait for clk_period;
behave_ra := ppc_rlwinm(rs, shift(4 downto 0), insn_mb32(insn), insn_me32(insn));
behave_ra := ppc_rlwinm(rs, shift(4 downto 0), insn_mb32(insn), insn_me32(insn));
assert behave_ra = result
check_equal(res, behave_ra, result("for rlwnm"));
report "bad rlwnm expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test rlwimi") then
elsif run("Test rlwimi") then
@ -85,8 +88,7 @@ begin
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
wait for clk_period;
wait for clk_period;
behave_ra := ppc_rlwimi(ra, rs, shift(4 downto 0), insn_mb32(insn), insn_me32(insn));
behave_ra := ppc_rlwimi(ra, rs, shift(4 downto 0), insn_mb32(insn), insn_me32(insn));
assert behave_ra = result
check_equal(res, behave_ra, result("for rlwnimi"));
report "bad rlwimi expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test rld[i]cl") then
elsif run("Test rld[i]cl") then
@ -102,8 +104,7 @@ begin
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
wait for clk_period;
wait for clk_period;
behave_ra := ppc_rldicl(rs, shift(5 downto 0), insn_mb(insn));
behave_ra := ppc_rldicl(rs, shift(5 downto 0), insn_mb(insn));
assert behave_ra = result
check_equal(res, behave_ra, result("for rldicl"));
report "bad rldicl expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test rld[i]cr") then
elsif run("Test rld[i]cr") then
@ -119,13 +120,12 @@ begin
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
wait for clk_period;
wait for clk_period;
behave_ra := ppc_rldicr(rs, shift(5 downto 0), insn_me(insn));
behave_ra := ppc_rldicr(rs, shift(5 downto 0), insn_me(insn));
--report "rs = " & to_hstring(rs);
debug("rs = " & to_hstring(rs));
--report "ra = " & to_hstring(ra);
debug("ra = " & to_hstring(ra));
--report "shift = " & to_hstring(shift);
debug("shift = " & to_hstring(shift));
--report "insn me = " & to_hstring(insn_me(insn));
debug("insn me = " & to_hstring(insn_me(insn)));
--report "result = " & to_hstring(result);
debug("result = " & to_hstring(res));
assert behave_ra = result
check_equal(res, behave_ra, result("for rldicr"));
report "bad rldicr expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test rldic") then
elsif run("Test rldic") then
@ -141,8 +141,7 @@ begin
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
wait for clk_period;
wait for clk_period;
behave_ra := ppc_rldic(rs, shift(5 downto 0), insn_mb(insn));
behave_ra := ppc_rldic(rs, shift(5 downto 0), insn_mb(insn));
assert behave_ra = result
check_equal(res, behave_ra, result("for rldic"));
report "bad rldic expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test rldimi") then
elsif run("Test rldimi") then
@ -158,8 +157,7 @@ begin
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
insn <= x"00000" & '0' & rnd.RandSlv(10) & '0';
wait for clk_period;
wait for clk_period;
behave_ra := ppc_rldimi(ra, rs, shift(5 downto 0), insn_mb(insn));
behave_ra := ppc_rldimi(ra, rs, shift(5 downto 0), insn_mb(insn));
assert behave_ra = result
check_equal(res, behave_ra, result("for rldimi"));
report "bad rldimi expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test slw") then
elsif run("Test slw") then
@ -174,8 +172,7 @@ begin
shift <= rnd.RandSlv(7);
shift <= rnd.RandSlv(7);
wait for clk_period;
wait for clk_period;
behave_ra := ppc_slw(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
behave_ra := ppc_slw(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
assert behave_ra = result
check_equal(res, behave_ra, result("for slv"));
report "bad slw expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test sld") then
elsif run("Test sld") then
@ -190,8 +187,7 @@ begin
shift <= rnd.RandSlv(7);
shift <= rnd.RandSlv(7);
wait for clk_period;
wait for clk_period;
behave_ra := ppc_sld(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
behave_ra := ppc_sld(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
assert behave_ra = result
check_equal(res, behave_ra, result("for sld"));
report "bad sld expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test srw") then
elsif run("Test srw") then
@ -206,8 +202,7 @@ begin
shift <= rnd.RandSlv(7);
shift <= rnd.RandSlv(7);
wait for clk_period;
wait for clk_period;
behave_ra := ppc_srw(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
behave_ra := ppc_srw(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
assert behave_ra = result
check_equal(res, behave_ra, result("for srw"));
report "bad srw expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test srd") then
elsif run("Test srd") then
@ -222,8 +217,7 @@ begin
shift <= rnd.RandSlv(7);
shift <= rnd.RandSlv(7);
wait for clk_period;
wait for clk_period;
behave_ra := ppc_srd(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
behave_ra := ppc_srd(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
assert behave_ra = result
check_equal(res, behave_ra, result("for srd"));
report "bad srd expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
elsif run("Test sraw[i]") then
elsif run("Test sraw[i]") then
@ -238,12 +232,12 @@ begin
shift <= '0' & rnd.RandSlv(6);
shift <= '0' & rnd.RandSlv(6);
wait for clk_period;
wait for clk_period;
behave_ca_ra := ppc_sraw(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
behave_ca_ra := ppc_sraw(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
--report "rs = " & to_hstring(rs);
debug("rs = " & to_hstring(rs));
--report "ra = " & to_hstring(ra);
debug("ra = " & to_hstring(ra));
--report "shift = " & to_hstring(shift);
debug("shift = " & to_hstring(shift));
--report "result = " & to_hstring(carry_out & result);
debug("result = " & to_hstring(carry_out & res));
assert behave_ca_ra(63 downto 0) = result and behave_ca_ra(64) = carry_out
check_equal(res, behave_ca_ra(63 downto 0), result("for sraw"));
report "bad sraw expected " & to_hstring(behave_ca_ra) & " got " & to_hstring(carry_out & result);
check_equal(carry_out, behave_ca_ra(64), result("for sraw carry_out"));
end loop;
end loop;
elsif run("Test srad[i]") then
elsif run("Test srad[i]") then
@ -258,12 +252,12 @@ begin
shift <= rnd.RandSlv(7);
shift <= rnd.RandSlv(7);
wait for clk_period;
wait for clk_period;
behave_ca_ra := ppc_srad(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
behave_ca_ra := ppc_srad(rs, std_ulogic_vector(resize(unsigned(shift), 64)));
--report "rs = " & to_hstring(rs);
debug("rs = " & to_hstring(rs));
--report "ra = " & to_hstring(ra);
debug("ra = " & to_hstring(ra));
--report "shift = " & to_hstring(shift);
debug("shift = " & to_hstring(shift));
--report "result = " & to_hstring(carry_out & result);
debug("result = " & to_hstring(carry_out & res));
assert behave_ca_ra(63 downto 0) = result and behave_ca_ra(64) = carry_out
check_equal(res, behave_ca_ra(63 downto 0), result("for srad"));
report "bad srad expected " & to_hstring(behave_ca_ra) & " got " & to_hstring(carry_out & result);
check_equal(carry_out, behave_ca_ra(64), result("for srad carry_out"));
end loop;
end loop;
elsif run("Test extswsli") then
elsif run("Test extswsli") then
@ -282,12 +276,11 @@ begin
behave_ra(63 downto 32) := (others => rs(31));
behave_ra(63 downto 32) := (others => rs(31));
behave_ra := std_ulogic_vector(shift_left(unsigned(behave_ra),
behave_ra := std_ulogic_vector(shift_left(unsigned(behave_ra),
to_integer(unsigned(shift))));
to_integer(unsigned(shift))));
--report "rs = " & to_hstring(rs);
debug("rs = " & to_hstring(rs));
--report "ra = " & to_hstring(ra);
debug("ra = " & to_hstring(ra));
--report "shift = " & to_hstring(shift);
debug("shift = " & to_hstring(shift));
--report "result = " & to_hstring(carry_out & result);
debug("result = " & to_hstring(carry_out & res));
assert behave_ra = result
check_equal(res, behave_ra, result("for extswsli"));
report "bad extswsli expected " & to_hstring(behave_ra) & " got " & to_hstring(result);
end loop;
end loop;
end if;
end if;
end loop;
end loop;