m = Module()
comb = m.d.comb
+ ##### operand A #####
+ # operand a to be as-is or inverted
a = Signal.like(self.i.a)
with m.If(self.i.ctx.op.invert_a):
comb += self.o.a.eq(a)
- # TODO: remove this because it's handled by the Computational Unit?
+ ##### 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.Else():
comb += self.o.b.eq(self.i.b)
+ ##### carry-in #####
+
+ # either copy incoming carry or set to 1/0 as defined by op
with m.Switch(self.i.ctx.op.input_carry):
with m.Case(CryIn.ZERO):
comb += self.o.carry_in.eq(0)
with m.Case(CryIn.CA):
comb += self.o.carry_in.eq(self.i.carry_in)
+ ##### context #####
+
comb += self.o.ctx.eq(self.i.ctx)
return m