from soc.alu.maskgen import MaskGen
from soc.alu.rotl import ROTL
+from soc.decoder.power_fields import DecodeFields
+from soc.decoder.power_fieldsn import SignalBitRange
+
class ALUMainStage(PipeModBase):
def __init__(self, pspec):
super().__init__(pspec, "main")
+ self.fields = DecodeFields(SignalBitRange, [self.i.ctx.op.insn])
+ self.fields.create_specs()
def ispec(self):
return ALUInputData(self.pspec)
m = Module()
comb = m.d.comb
+
+ fields = self.fields.instrs['M']
+ mb = Signal(fields['MB'][0:-1].shape())
+ comb += mb.eq(fields['MB'][0:-1])
+ me = Signal(fields['ME'][0:-1].shape())
+ comb += me.eq(fields['ME'][0:-1])
+
# check if op is 32-bit, and get sign bit from operand a
is_32bit = Signal(reset_less=True)
sign_bit = Signal(reset_less=True)
with m.Else():
comb += self.o.o.eq(rotl_out & mask)
+ with m.Case(InternalOp.OP_RLC):
+ 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)
+ comb += self.o.o.eq(rotl_out & mask)
+
+
###### sticky overflow and context, both pass-through #####
comb += self.o.so.eq(self.i.so)
vld = yield alu.n.valid_o
yield
alu_out = yield alu.n.data_o.o
+ print(f"expected {simulator.gpr(3).value:x}, actual: {alu_out:x}")
self.assertEqual(simulator.gpr(3).value, alu_out)
sim.add_sync_process(process)
with Program(lst) as program:
sim = self.run_tst_program(program, initial_regs)
+ def test_rlwinm(self):
+ for i in range(10):
+ mb = random.randint(0,31)
+ me = random.randint(0,31)
+ sh = random.randint(0,31)
+ lst = [f"rlwinm 3, 1, {mb}, {me}, {sh}"]
+ initial_regs = [0] * 32
+ initial_regs[1] = 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()