execute: Copy XER[SO] to CR for cmp[i] and cmpl[i] instructions

We were copying in XER[SO] for the dot-form instructions but not the
explicit compare instructions.  Fix this.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
jtag-port
Paul Mackerras 5 years ago
parent 501b6daf9b
commit ec9b27660f

@ -291,7 +291,7 @@ begin
for i in 0 to 7 loop for i in 0 to 7 loop
lo := i*4; lo := i*4;
hi := lo + 3; hi := lo + 3;
v.e.write_cr_data(hi downto lo) := ppc_cmp(l, e_in.read_data1, e_in.read_data2); v.e.write_cr_data(hi downto lo) := ppc_cmp(l, e_in.read_data1, e_in.read_data2, v.e.xerc.so);
end loop; end loop;
when OP_CMPL => when OP_CMPL =>
bf := insn_bf(e_in.insn); bf := insn_bf(e_in.insn);
@ -302,7 +302,7 @@ begin
for i in 0 to 7 loop for i in 0 to 7 loop
lo := i*4; lo := i*4;
hi := lo + 3; hi := lo + 3;
v.e.write_cr_data(hi downto lo) := ppc_cmpl(l, e_in.read_data1, e_in.read_data2); v.e.write_cr_data(hi downto lo) := ppc_cmpl(l, e_in.read_data1, e_in.read_data2, v.e.xerc.so);
end loop; end loop;
when OP_CNTZ => when OP_CNTZ =>
result := countzero_result; result := countzero_result;

@ -17,8 +17,8 @@ package helpers is


function cmp_one_byte(a, b: std_ulogic_vector(7 downto 0)) return std_ulogic_vector; function cmp_one_byte(a, b: std_ulogic_vector(7 downto 0)) return std_ulogic_vector;


function ppc_signed_compare(a, b: signed(63 downto 0)) return std_ulogic_vector; function ppc_signed_compare(a, b: signed(63 downto 0); so: std_ulogic) return std_ulogic_vector;
function ppc_unsigned_compare(a, b: unsigned(63 downto 0)) return std_ulogic_vector; function ppc_unsigned_compare(a, b: unsigned(63 downto 0); so: std_ulogic) return std_ulogic_vector;


function ra_or_zero(ra: std_ulogic_vector(63 downto 0); reg: std_ulogic_vector(4 downto 0)) return std_ulogic_vector; function ra_or_zero(ra: std_ulogic_vector(63 downto 0); reg: std_ulogic_vector(4 downto 0)) return std_ulogic_vector;


@ -126,32 +126,32 @@ package body helpers is
return ret; return ret;
end; end;


function ppc_signed_compare(a, b: signed(63 downto 0)) return std_ulogic_vector is function ppc_signed_compare(a, b: signed(63 downto 0); so: std_ulogic) return std_ulogic_vector is
variable ret: std_ulogic_vector(3 downto 0); variable ret: std_ulogic_vector(2 downto 0);
begin begin
if a < b then if a < b then
ret := "1000"; ret := "100";
elsif a > b then elsif a > b then
ret := "0100"; ret := "010";
else else
ret := "0010"; ret := "001";
end if; end if;


return ret; return ret & so;
end; end;


function ppc_unsigned_compare(a, b: unsigned(63 downto 0)) return std_ulogic_vector is function ppc_unsigned_compare(a, b: unsigned(63 downto 0); so: std_ulogic) return std_ulogic_vector is
variable ret: std_ulogic_vector(3 downto 0); variable ret: std_ulogic_vector(2 downto 0);
begin begin
if a < b then if a < b then
ret := "1000"; ret := "100";
elsif a > b then elsif a > b then
ret := "0100"; ret := "010";
else else
ret := "0010"; ret := "001";
end if; end if;


return ret; return ret & so;
end; end;


function ra_or_zero(ra: std_ulogic_vector(63 downto 0); reg: std_ulogic_vector(4 downto 0)) return std_ulogic_vector is function ra_or_zero(ra: std_ulogic_vector(63 downto 0); reg: std_ulogic_vector(4 downto 0)) return std_ulogic_vector is

@ -77,10 +77,14 @@ package ppc_fx_insns is
function ppc_mulhw (ra, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector; function ppc_mulhw (ra, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector;
function ppc_mulhwu (ra, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector; function ppc_mulhwu (ra, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector;


function ppc_cmpi (l: std_ulogic; ra: std_ulogic_vector(63 downto 0); si: std_ulogic_vector(15 downto 0)) return std_ulogic_vector; function ppc_cmpi (l: std_ulogic; ra: std_ulogic_vector(63 downto 0); si: std_ulogic_vector(15 downto 0);
function ppc_cmp (l: std_ulogic; ra, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector; so: std_ulogic) return std_ulogic_vector;
function ppc_cmpli (l: std_ulogic; ra: std_ulogic_vector(63 downto 0); si: std_ulogic_vector(15 downto 0)) return std_ulogic_vector; function ppc_cmp (l: std_ulogic; ra, rb: std_ulogic_vector(63 downto 0);
function ppc_cmpl (l: std_ulogic; ra, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector; so: std_ulogic) return std_ulogic_vector;
function ppc_cmpli (l: std_ulogic; ra: std_ulogic_vector(63 downto 0); si: std_ulogic_vector(15 downto 0);
so: std_ulogic) return std_ulogic_vector;
function ppc_cmpl (l: std_ulogic; ra, rb: std_ulogic_vector(63 downto 0);
so: std_ulogic) return std_ulogic_vector;


function ppc_cmpb (rs, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector; function ppc_cmpb (rs, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector;


@ -677,7 +681,8 @@ package body ppc_fx_insns is
return std_ulogic_vector(tmp(63 downto 32)) & std_ulogic_vector(tmp(63 downto 32)); return std_ulogic_vector(tmp(63 downto 32)) & std_ulogic_vector(tmp(63 downto 32));
end; end;


function ppc_cmpi (l: std_ulogic; ra: std_ulogic_vector(63 downto 0); si: std_ulogic_vector(15 downto 0)) return std_ulogic_vector is function ppc_cmpi (l: std_ulogic; ra: std_ulogic_vector(63 downto 0); si: std_ulogic_vector(15 downto 0);
so: std_ulogic) return std_ulogic_vector is
variable tmp: signed(ra'range); variable tmp: signed(ra'range);
begin begin
tmp := signed(ra); tmp := signed(ra);
@ -685,10 +690,11 @@ package body ppc_fx_insns is
tmp := resize(signed(ra(31 downto 0)), tmp'length); tmp := resize(signed(ra(31 downto 0)), tmp'length);
end if; end if;


return ppc_signed_compare(tmp, resize(signed(si), tmp'length)); return ppc_signed_compare(tmp, resize(signed(si), tmp'length), so);
end; end;


function ppc_cmp (l: std_ulogic; ra, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector is function ppc_cmp (l: std_ulogic; ra, rb: std_ulogic_vector(63 downto 0);
so: std_ulogic) return std_ulogic_vector is
variable tmpa, tmpb: signed(ra'range); variable tmpa, tmpb: signed(ra'range);
begin begin
tmpa := signed(ra); tmpa := signed(ra);
@ -698,10 +704,11 @@ package body ppc_fx_insns is
tmpb := resize(signed(rb(31 downto 0)), ra'length); tmpb := resize(signed(rb(31 downto 0)), ra'length);
end if; end if;


return ppc_signed_compare(tmpa, tmpb); return ppc_signed_compare(tmpa, tmpb, so);
end; end;


function ppc_cmpli (l: std_ulogic; ra: std_ulogic_vector(63 downto 0); si: std_ulogic_vector(15 downto 0)) return std_ulogic_vector is function ppc_cmpli (l: std_ulogic; ra: std_ulogic_vector(63 downto 0); si: std_ulogic_vector(15 downto 0);
so: std_ulogic) return std_ulogic_vector is
variable tmp: unsigned(ra'range); variable tmp: unsigned(ra'range);
begin begin
tmp := unsigned(ra); tmp := unsigned(ra);
@ -709,10 +716,11 @@ package body ppc_fx_insns is
tmp := resize(unsigned(ra(31 downto 0)), tmp'length); tmp := resize(unsigned(ra(31 downto 0)), tmp'length);
end if; end if;


return ppc_unsigned_compare(tmp, resize(unsigned(si), tmp'length)); return ppc_unsigned_compare(tmp, resize(unsigned(si), tmp'length), so);
end; end;


function ppc_cmpl (l: std_ulogic; ra, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector is function ppc_cmpl (l: std_ulogic; ra, rb: std_ulogic_vector(63 downto 0);
so: std_ulogic) return std_ulogic_vector is
variable tmpa, tmpb: unsigned(ra'range); variable tmpa, tmpb: unsigned(ra'range);
begin begin
tmpa := unsigned(ra); tmpa := unsigned(ra);
@ -722,7 +730,7 @@ package body ppc_fx_insns is
tmpb := resize(unsigned(rb(31 downto 0)), ra'length); tmpb := resize(unsigned(rb(31 downto 0)), ra'length);
end if; end if;


return ppc_unsigned_compare(tmpa, tmpb); return ppc_unsigned_compare(tmpa, tmpb, so);
end; end;


function ppc_cmpb (rs, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector is function ppc_cmpb (rs, rb: std_ulogic_vector(63 downto 0)) return std_ulogic_vector is

Loading…
Cancel
Save