from nmigen import (Module, Signal, Cat, Const, Mux, Repl, signed,
unsigned)
from nmutil.pipemodbase import PipeModBase
+from soc.decoder.power_enums import InternalOp
from soc.alu.pipe_data import ALUInputData
from soc.decoder.power_enums import CryIn
##### operand B #####
# If there's an immediate, set the B operand to that
- with m.If(self.i.ctx.op.imm_data.imm_ok):
+ with m.If(self.i.ctx.op.imm_data.imm_ok &
+ ~(self.i.ctx.op.insn_type == InternalOp.OP_RLC)):
comb += self.o.b.eq(self.i.ctx.op.imm_data.imm)
with m.Else():
comb += self.o.b.eq(self.i.b)
comb += self.o.o.eq(rotl_out & mask)
with m.Case(InternalOp.OP_RLC):
- comb += rotate_amt.eq(self.i.b[0:5])
+ with m.If(self.i.ctx.op.imm_data.imm_ok):
+ comb += rotate_amt.eq(self.i.ctx.op.imm_data.imm[0:5])
+ with m.Else():
+ comb += rotate_amt.eq(self.i.b[0:5])
comb += maskgen.mb.eq(mb+32)
comb += maskgen.me.eq(me+32)
comb += mask.eq(maskgen.o)
with Program(lst) as program:
sim = self.run_tst_program(program, initial_regs)
+ def test_rlwimi(self):
+ lst = ["rlwinm 3, 1, 5, 20, 6",
+ "rlwimi 3, 1, 5, 20, 6"]
+ initial_regs = [0] * 32
+ initial_regs[1] = random.randint(0, (1<<64)-1)
+ initial_regs[3] = random.randint(0, (1<<64)-1)
+ with Program(lst) as program:
+ sim = self.run_tst_program(program, initial_regs)
+
def test_ilang(self):
rec = CompALUOpSubset()
--- fixedshift.py.orig 2020-05-09 09:56:10.393656481 -0400
-+++ fixedshift.py 2020-05-10 16:03:17.449405581 -0400
-@@ -12,8 +12,8 @@
++++ fixedshift.py 2020-05-10 18:51:24.725396454 -0400
+@@ -12,48 +12,48 @@
@inject()
def op_rlwinm(self, RS):
n = SH
RA = r & m
return (RA,)
-@@ -21,7 +21,7 @@
+ @inject()
def op_rlwinm_(self, RS):
n = SH
- r = ROTL32(RS[32:64], n)
+- r = ROTL32(RS[32:64], n)
- m = MASK(MB + 32, ME + 32)
++ r = ROTL32(EXTZ64(RS[32:64]), n)
+ m = MASK(MB.value + 32, ME.value + 32)
RA = r & m
return (RA,)
-@@ -29,7 +29,7 @@
+ @inject()
def op_rlwnm(self, RB, RS):
n = RB[59:64]
- r = ROTL32(RS[32:64], n)
+- r = ROTL32(RS[32:64], n)
- m = MASK(MB + 32, ME + 32)
++ r = ROTL32(EXTZ64(RS[32:64]), n)
+ m = MASK(MB.value + 32, ME.value + 32)
RA = r & m
return (RA,)
-@@ -37,7 +37,7 @@
+ @inject()
def op_rlwnm_(self, RB, RS):
n = RB[59:64]
- r = ROTL32(RS[32:64], n)
+- r = ROTL32(RS[32:64], n)
- m = MASK(MB + 32, ME + 32)
++ r = ROTL32(EXTZ64(RS[32:64]), n)
+ m = MASK(MB.value + 32, ME.value + 32)
RA = r & m
return (RA,)
-@@ -45,7 +45,7 @@
+ @inject()
def op_rlwimi(self, RS, RA):
n = SH
- r = ROTL32(RS[32:64], n)
+- r = ROTL32(RS[32:64], n)
- m = MASK(MB + 32, ME + 32)
++ r = ROTL32(EXTZ64(RS[32:64]), n)
+ m = MASK(MB.value + 32, ME.value + 32)
RA = r & m | RA & ~m
return (RA,)
-@@ -53,7 +53,7 @@
+ @inject()
def op_rlwimi_(self, RS, RA):
n = SH
- r = ROTL32(RS[32:64], n)
+- r = ROTL32(RS[32:64], n)
- m = MASK(MB + 32, ME + 32)
++ r = ROTL32(EXTZ64(RS[32:64]), n)
+ m = MASK(MB.value + 32, ME.value + 32)
RA = r & m | RA & ~m
return (RA,)