variable result_with_carry : std_ulogic_vector(64 downto 0);
variable result_en : integer;
variable crnum : integer;
+ variable lo, hi : integer;
begin
result := (others => '0');
result_with_carry := (others => '0');
e_out.write_cr_enable <= '1';
crnum := to_integer(unsigned(e.const1(2 downto 0)));
e_out.write_cr_mask <= num_to_fxm(crnum);
- e_out.write_cr_data <= (others => '0');
- e_out.write_cr_data((4*(7-crnum)+3) downto (4*(7-crnum))) <= ppc_cmp(e.const2(0), e.read_data1, e.read_data2);
+ for i in 0 to 7 loop
+ lo := i*4;
+ hi := lo + 3;
+ e_out.write_cr_data(hi downto lo) <= ppc_cmp(e.const2(0), e.read_data1, e.read_data2);
+ end loop;
when OP_CMPL =>
e_out.write_cr_enable <= '1';
crnum := to_integer(unsigned(e.const1(2 downto 0)));
e_out.write_cr_mask <= num_to_fxm(crnum);
- e_out.write_cr_data <= (others => '0');
- e_out.write_cr_data((4*(7-crnum)+3) downto (4*(7-crnum))) <= ppc_cmpl(e.const2(0), e.read_data1, e.read_data2);
+ for i in 0 to 7 loop
+ lo := i*4;
+ hi := lo + 3;
+ e_out.write_cr_data(hi downto lo) <= ppc_cmpl(e.const2(0), e.read_data1, e.read_data2);
+ end loop;
when OP_CNTLZW =>
result := ppc_cntlzw(e.read_data1);
result_en := 1;
when OP_MFOCRF =>
crnum := fxm_to_num(e.const1(7 downto 0));
result := (others => '0');
- result((4*(7-crnum)+3) downto (4*(7-crnum))) := e.cr((4*(7-crnum)+3) downto (4*(7-crnum)));
+-- result((4*(7-crnum)+3) downto (4*(7-crnum))) := e.cr((4*(7-crnum)+3) downto (4*(7-crnum))); FIXME
+ for i in 0 to 7 loop
+ lo := (7-i)*4;
+ hi := lo + 3;
+ if crnum = i then
+ result(hi downto lo) := e.cr(hi downto lo);
+ end if;
+ end loop;
result_en := 1;
when OP_MTCRF =>
e_out.write_cr_enable <= '1';
tmp2 := (others => '0');
if hi < lo then
-- Mask wraps around
- tmp2(63 downto lo) := tmp1(63 downto lo);
- tmp2(hi downto 0) := tmp1(hi downto 0);
+ for i in 0 to 63 loop
+ if i <= hi or i >= lo then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
else
- tmp2(hi downto lo) := tmp1(hi downto lo);
+ for i in 0 to 63 loop
+ if i >= lo and i <= hi then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
end if;
return tmp2;
end;
tmp2 := (others => '0');
if hi < lo then
-- Mask wraps around
- tmp2(63 downto lo) := tmp1(63 downto lo);
- tmp2(hi downto 0) := tmp1(hi downto 0);
+ for i in 0 to 63 loop
+ if i <= hi or i >= lo then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
else
- tmp2(hi downto lo) := tmp1(hi downto lo);
+ for i in 0 to 63 loop
+ if i >= lo and i <= hi then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
end if;
return tmp2;
end;
tmp2 := ra;
if hi < lo then
-- Mask wraps around
- tmp2(63 downto lo) := tmp1(63 downto lo);
- tmp2(hi downto 0) := tmp1(hi downto 0);
+ for i in 0 to 63 loop
+ if i <= hi or i >= lo then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
else
- tmp2(hi downto lo) := tmp1(hi downto lo);
+ for i in 0 to 63 loop
+ if i >= lo and i <= hi then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
end if;
return tmp2;
end;
hi := 63-to_integer(unsigned(mb));
tmp1 := std_ulogic_vector(rotate_left(unsigned(rs), to_integer(unsigned(sh))));
tmp2 := (others => '0');
- tmp2(hi downto 0) := tmp1(hi downto 0);
+ for i in 0 to 63 loop
+ if i <= hi then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
return tmp2;
end;
lo := 63-to_integer(unsigned(me));
tmp1 := std_ulogic_vector(rotate_left(unsigned(rs), to_integer(unsigned(sh))));
tmp2 := (others => '0');
- tmp2(63 downto lo) := tmp1(63 downto lo);
+ for i in 0 to 63 loop
+ if i >= lo then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
return tmp2;
end;
tmp2 := (others => '0');
if hi < lo then
-- Mask wraps around
- tmp2(63 downto lo) := tmp1(63 downto lo);
- tmp2(hi downto 0) := tmp1(hi downto 0);
+ for i in 0 to 63 loop
+ if i <= hi or i >= lo then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
else
- tmp2(hi downto lo) := tmp1(hi downto lo);
+ for i in 0 to 63 loop
+ if i >= lo and i <= hi then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
end if;
return tmp2;
end;
hi := 63-to_integer(unsigned(mb));
tmp1 := std_ulogic_vector(rotate_left(unsigned(rs), to_integer(unsigned(rb(5 downto 0)))));
tmp2 := (others => '0');
- tmp2(hi downto 0) := tmp1(hi downto 0);
+ for i in 0 to 63 loop
+ if i <= hi then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
return tmp2;
end;
lo := 63-to_integer(unsigned(me));
tmp1 := std_ulogic_vector(rotate_left(unsigned(rs), to_integer(unsigned(rb(5 downto 0)))));
tmp2 := (others => '0');
- tmp2(63 downto lo) := tmp1(63 downto lo);
+ for i in 0 to 63 loop
+ if i >= lo then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
return tmp2;
end;
tmp2 := ra;
if hi < lo then
-- Mask wraps around
- tmp2(63 downto lo) := tmp1(63 downto lo);
- tmp2(hi downto 0) := tmp1(hi downto 0);
+ for i in 0 to 63 loop
+ if i <= hi or i >= lo then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
else
- tmp2(hi downto lo) := tmp1(hi downto lo);
+ for i in 0 to 63 loop
+ if i >= lo and i <= hi then
+ tmp2(i) := tmp1(i);
+ end if;
+ end loop;
end if;
return tmp2;
end;
function ppc_srawi (rs : std_ulogic_vector(63 downto 0); sh: std_ulogic_vector(5 downto 0)) return std_ulogic_vector is
variable n : integer;
variable tmp : signed(31 downto 0);
+ variable mask : std_ulogic_vector(63 downto 0);
variable carry: std_ulogic;
begin
n := to_integer(unsigned(sh));
tmp := shift_right(signed(rs(31 downto 0)), n);
-- what about n = 0?
- carry := or rs(n-1 downto 0) and rs(31);
+ mask := (others => '0');
+ for i in 0 to 63 loop
+ if i < n then
+ mask(i) := '1';
+ end if;
+ end loop;
+ carry := '0' when (rs and mask) = (63 downto 0 => '0') else rs(31);
return carry & std_ulogic_vector(resize(tmp, rs'length));
end;
function ppc_sraw (rs, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector is
variable n : natural;
variable tmp : signed(31 downto 0);
+ variable mask : std_ulogic_vector(63 downto 0);
variable carry: std_ulogic;
begin
n := to_integer(unsigned(rb(5 downto 0)));
tmp := shift_right(signed(rs(31 downto 0)), n);
-- what about n = 0?
- carry := or rs(n-1 downto 0) and rs(31);
-
+ mask := (others => '0');
+ for i in 0 to 63 loop
+ if i < n then
+ mask(i) := '1';
+ end if;
+ end loop;
+ carry := or (rs and mask) and rs(31);
return carry & std_ulogic_vector(resize(tmp, rs'length));
end;
function ppc_sradi (rs: std_ulogic_vector(63 downto 0); sh: std_ulogic_vector(5 downto 0)) return std_ulogic_vector is
variable n : integer;
variable carry: std_ulogic;
+ variable mask : std_ulogic_vector(63 downto 0);
begin
n := to_integer(unsigned(sh));
-- what about n = 0?
- carry := or rs(n-1 downto 0) and rs(63);
+ mask := (others => '0');
+ for i in 0 to 63 loop
+ if i < n then
+ mask(i) := '1';
+ end if;
+ end loop;
+ carry := '0' when (rs and mask) = (63 downto 0 => '0') else rs(63);
return carry & std_ulogic_vector(shift_right(signed(rs), n));
end;
function ppc_srad (rs, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector is
variable n : integer;
variable carry: std_ulogic;
+ variable mask : std_ulogic_vector(63 downto 0);
begin
n := to_integer(unsigned(rb(6 downto 0)));
-- what about n = 0?
- carry := or rs(n-1 downto 0) and rs(63);
+ mask := (others => '0');
+ for i in 0 to 63 loop
+ if i < n then
+ mask(i) := '1';
+ end if;
+ end loop;
+ carry := '0' when (rs and mask) = (63 downto 0 => '0') else rs(63);
return carry & std_ulogic_vector(shift_right(signed(rs), n));
end;