# operand a to be as-is or inverted
a = Signal.like(self.i.a)
- if hasattr(op, "invert_a"):
+ op_to_invert = 'ra'
+ if hasattr(self, "invert_op"):
+ op_to_invert = self.invert_op
+
+ if hasattr(op, "invert_a") and op_to_invert == 'ra':
with m.If(op.invert_a):
comb += a.eq(~self.i.a)
with m.Else():
comb += self.o.a.eq(a)
+ ##### operand B #####
+
+ # operand b to be as-is or inverted
+ b = Signal.like(self.i.b)
+
+ if hasattr(op, "invert_a") and op_to_invert == 'rb':
+ with m.If(op.invert_a):
+ comb += b.eq(~self.i.b)
+ with m.Else():
+ comb += b.eq(self.i.b)
+ else:
+ comb += b.eq(self.i.b)
+
+ comb += self.o.b.eq(b)
+
##### carry-in #####
# either copy incoming carry or set to 1/0 as defined by op
class LogicalInputStage(CommonInputStage):
def __init__(self, pspec):
super().__init__(pspec, "input")
+ self.invert_op = "rb" # inversion is on register b
def ispec(self):
return LogicalInputData(self.pspec)
return LogicalInputData(self.pspec)
def elaborate(self, platform):
- m = super().elaborate(platform) # covers A-invert, carry, excludes SO
+ m = super().elaborate(platform) # covers B-invert, carry, excludes SO
comb = m.d.comb
ctx = self.i.ctx
- # operand b
- comb += self.o.b.eq(self.i.b)
-
return m
m = super().elaborate(platform) # handles A, carry and sticky overflow
comb = m.d.comb
- # operands ra and rb
- comb += self.o.rb.eq(self.i.rb)
+ # operand rs
comb += self.o.rs.eq(self.i.rs)
return m
def __init__(self, pspec):
super().__init__(pspec, False)
# convenience
- self.a, self.rs = self.ra, self.rc
+ self.a, self.b, self.rs = self.ra, self.rb, self.rc
+
class ShiftRotPipeSpec(CommonPipeSpec):