+ b.eq(AnyConst(64)),
+ cr_a_in.eq(AnyConst(4)),
+ full_cr_in.eq(AnyConst(32))]
+
+ a_fields = dut.fields.FormA
+ xl_fields = dut.fields.FormXL
+ xfx_fields = dut.fields.FormXFX
+
+ # I'd like to be able to prove this module using the proof
+ # written before I made the change to use 4 bit cr inputs for
+ # OP_MCRF and OP_CROP. So I'm going to set up the machinery to
+ # let me do that here
+
+ cr_input_arr = Array([full_cr_in[(7-i)*4:(7-i)*4+4] for i in range(8)])
+ cr_output_arr = Array([cr_o[(7-i)*4:(7-i)*4+4] for i in range(8)])
+
+ bf = Signal(xl_fields.BF[0:-1].shape())
+ bfa = Signal(xl_fields.BFA[0:-1].shape())
+ comb += bf.eq(xl_fields.BF[0:-1])
+ comb += bfa.eq(xl_fields.BFA[0:-1])
+
+ with m.Switch(rec.insn_type):
+ # CR_ISEL takes cr_a
+ with m.Case(MicrOp.OP_ISEL):
+ # grab the MSBs of the cr bit selector
+ bc = Signal(3, reset_less=True)
+ comb += bc.eq(a_fields.BC[2:5])
+
+ # Use the MSBs to select which CR register to feed
+ # into cr_a
+ comb += dut.i.cr_a.eq(cr_input_arr[bc])
+
+ # For OP_CROP, we need to input the corresponding CR
+ # registers for BA, BB, and BT
+ with m.Case(MicrOp.OP_CROP):
+ # grab the MSBs of the 3 bit selectors
+ bt = Signal(3, reset_less=True)
+ ba = Signal(3, reset_less=True)
+ bb = Signal(3, reset_less=True)
+ comb += bt.eq(xl_fields.BT[2:5])
+ comb += ba.eq(xl_fields.BA[2:5])
+ comb += bb.eq(xl_fields.BB[2:5])
+
+ # Grab the cr register containing the bit from BA, BB,
+ # and BT, and feed it to the cr inputs
+ comb += dut.i.cr_a.eq(cr_input_arr[ba])
+ comb += dut.i.cr_b.eq(cr_input_arr[bb])
+ comb += dut.i.cr_c.eq(cr_input_arr[bt])
+
+ # Insert the output into the output CR register so the
+ # proof below can use it
+ for i in range(8):
+ with m.If(i != bt):
+ comb += cr_output_arr[i].eq(cr_input_arr[i])
+ with m.Else():
+ comb += cr_output_arr[i].eq(dut.o.cr.data)
+
+ with m.Case(MicrOp.OP_MCRF):
+ # This does a similar thing to OP_CROP above, with
+ # less inputs. The CR selection fields are already 3
+ # bits so there's no need to grab only the MSBs
+
+ # set cr_a to the CR selected by BFA
+ comb += dut.i.cr_a.eq(cr_input_arr[bfa])
+ for i in range(8):
+ # Similar to above, insert the result cr back into
+ # the full cr register so the proof below can use
+ # it
+ with m.If(i != bf):
+ comb += cr_output_arr[i].eq(cr_input_arr[i])
+ with m.Else():
+ comb += cr_output_arr[i].eq(dut.o.cr.data)
+
+ # Set the input similar to OP_MCRF
+ with m.Case(MicrOp.OP_SETB):
+ comb += dut.i.cr_a.eq(cr_input_arr[bfa])
+
+ # For the other two, they take the full CR as input, and
+ # output a full CR. This handles that
+ with m.Default():
+ comb += dut.i.full_cr.eq(full_cr_in)
+ comb += cr_o.eq(full_cr_out)