m = Module()
comb = m.d.comb
- pspec = ALUPipeSpec(id_wid=2, op_wid=1)
+ rec = CompALUOpSubset()
+ recwidth = 0
+ # Setup random inputs for dut.op
+ for p in rec.ports():
+ width = p.width
+ recwidth += width
+ comb += p.eq(AnyConst(width))
+
+ pspec = ALUPipeSpec(id_wid=2, op_wid=recwidth)
m.submodules.dut = dut = ALUInputStage(pspec)
a = Signal(64)
a.eq(AnyConst(64)),
b.eq(AnyConst(64))]
- # Setup random inputs for dut.op
- rec = CompALUOpSubset()
- for p in rec.ports():
- width = p.width
- comb += p.eq(AnyConst(width))
- comb += dut.i.op.eq(rec)
+ comb += dut.i.ctx.op.eq(rec)
# Assert that op gets copied from the input to output
for p in rec.ports():
name = p.name
rec_sig = p
- dut_sig = getattr(dut.o.op, name)
+ dut_sig = getattr(dut.o.ctx.op, name)
comb += Assert(dut_sig == rec_sig)
with m.If(rec.invert_a):
return m
class GTCombinerTestCase(FHDLTestCase):
- def test_gt_combiner(self):
+ def test_formal(self):
module = Driver()
self.assertFormal(module, mode="bmc", depth=4)
self.assertFormal(module, mode="cover", depth=4)
m = Module()
comb = m.d.comb
- comb += self.o.op.eq(self.i.op)
a = Signal.like(self.i.a)
- with m.If(self.i.op.invert_a):
+ with m.If(self.i.ctx.op.invert_a):
comb += a.eq(~self.i.a)
with m.Else():
comb += a.eq(self.i.a)
comb += self.o.b.eq(self.i.b)
+ comb += self.o.ctx.eq(self.i.ctx)
+
return m
class IntegerData:
def __init__(self, pspec):
- self.op = CompALUOpSubset()
self.ctx = FPPipeContext(pspec)
self.muxid = self.ctx.muxid
def __init__(self, id_wid=2, op_wid=1):
self.id_wid = id_wid
self.op_wid = op_wid
- self.opkls = CompALUOpSubset
+ self.opkls = lambda _: CompALUOpSubset(name="op")
class ALUPipeSpec(IntPipeSpec):
def __init__(self, id_wid, op_wid):