op = self.i.ctx.op
a, full_cr = self.i.a, self.i.full_cr
cr_a, cr_b, cr_c = self.i.cr_a, self.i.cr_b, self.i.cr_c
+ cr_o, full_cr_o, rt_o = self.o.cr_o, self.o.full_cr, self.o.o
+
xl_fields = self.fields.FormXL
xfx_fields = self.fields.FormXFX
- cr_o = self.o.cr_o
-
# Generate the mask for mtcrf, mtocrf, and mfocrf
# replicate every fxm field in the insn to 4-bit, as a mask
FXM = xfx_fields.FXM[0:-1]
cr_b_arr = Array([cr_b[i] for i in range(4)])
cr_o_arr = Array([cr_o[i] for i in range(4)])
- # this may have one bit be modified by OP_CROP
- comb += cr_o.eq(cr_c)
-
with m.Switch(op.insn_type):
##### mcrf #####
with m.Case(InternalOp.OP_MCRF):
# Since it takes in a 4 bit cr, and outputs a 4 bit
# cr, we don't have to do anything special
comb += cr_o.eq(cr_a)
+ comb += cr_o.ok.eq(1) # indicate "this CR has changed"
# ##### crand, cror, crnor etc. #####
with m.Case(InternalOp.OP_CROP):
Mux(bit_a, lut[3], lut[1]),
Mux(bit_a, lut[2], lut[0])))
- # insert the output bit into the 4-bit CR output
+ # may have one bit modified by OP_CROP. copy the other 3
+ comb += cr_o.data.eq(cr_c)
+ # insert the (index-targetted) output bit into 4-bit CR output
comb += cr_o_arr[bt].eq(bit_o)
+ comb += cr_o.ok.eq(1) # indicate "this CR has changed"
##### mtcrf #####
with m.Case(InternalOp.OP_MTCRF):
# mtocrf and mtcrf are essentially identical
# put input (RA) - mask-selected - into output CR, leave
# rest of CR alone.
- comb += self.o.full_cr.eq((a[0:32] & mask) | (full_cr & ~mask))
+ comb += full_cr_o.data.eq((a[0:32] & mask) | (full_cr & ~mask))
+ comb += full_cr_o.ok.eq(1) # indicate "this CR has changed"
# ##### mfcr #####
with m.Case(InternalOp.OP_MFCR):
# mfocrf
with m.If(move_one):
# output register RT
- comb += self.o.o.eq(full_cr & mask)
+ comb += rt_o.eq(full_cr & mask)
# mfcrf
with m.Else():
# output register RT
- comb += self.o.o.eq(full_cr)
+ comb += rt_o.eq(full_cr)
comb += self.o.ctx.eq(self.i.ctx)
from ieee754.fpcommon.getop import FPPipeContext
from soc.fu.pipe_data import IntegerData, CommonPipeSpec
from soc.fu.alu.alu_input_record import CompALUOpSubset # TODO: replace
+from soc.decoder.power_decoder2 import Data
class CRInputData(IntegerData):
def __init__(self, pspec):
super().__init__(pspec)
self.o = Signal(64, reset_less=True) # RA
- self.full_cr = Signal(32, reset_less=True, name="cr_out") # CR in
- self.cr_o = Signal(4, reset_less=True)
+ self.full_cr = Data(32, name="cr_out") # CR in
+ self.cr_o = Data(4, name="cr_o")
def __iter__(self):
yield from super().__iter__()
whole_reg = yield dec2.e.write_cr_whole
cr_en = yield dec2.e.write_cr.ok
if whole_reg:
- full_cr = yield alu.n.data_o.full_cr
+ full_cr = yield alu.n.data_o.full_cr.data
expected_cr = simulator.cr.get_range().value
self.assertEqual(expected_cr, full_cr)
elif cr_en:
cr_sel = yield dec2.e.write_cr.data
expected_cr = simulator.crl[cr_sel].get_range().value
- real_cr = yield alu.n.data_o.cr_o
+ real_cr = yield alu.n.data_o.cr_o.data
self.assertEqual(expected_cr, real_cr)