##### 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.xer_ca.eq(0b00)
- with m.Case(CryIn.ONE):
- comb += self.o.xer_ca.eq(0b11) # XER CA/CA32
- with m.Case(CryIn.CA):
- comb += self.o.xer_ca.eq(self.i.xer_ca)
+ if hasattr(self.i, "xer_ca"): # hack (for now - for LogicalInputData)
+ with m.Switch(self.i.ctx.op.input_carry):
+ with m.Case(CryIn.ZERO):
+ comb += self.o.xer_ca.eq(0b00)
+ with m.Case(CryIn.ONE):
+ comb += self.o.xer_ca.eq(0b11) # XER CA/CA32
+ with m.Case(CryIn.CA):
+ comb += self.o.xer_ca.eq(self.i.xer_ca)
##### sticky overflow and context (both pass-through) #####
recwidth += width
comb += p.eq(AnyConst(width))
- pspec = ALUPipeSpec(id_wid=2, op_wid=recwidth)
+ pspec = ALUPipeSpec(id_wid=2)
m.submodules.dut = dut = ALUInputStage(pspec)
a = Signal(64)
a.eq(AnyConst(64)),
b.eq(AnyConst(64))]
-
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
with m.Else():
comb += Assert(dut.o.b == b)
-
-
-
return m
+
class GTCombinerTestCase(FHDLTestCase):
def test_formal(self):
module = Driver()
# convenience variables
a = dut.i.a
b = dut.i.b
- carry_in = dut.i.xer_ca[0]
- carry_in32 = dut.i.xer_ca[1]
+ #carry_in = dut.i.xer_ca[0]
+ #carry_in32 = dut.i.xer_ca[1]
o = dut.o.o.data
# setup random inputs
comb += [a.eq(AnyConst(64)),
b.eq(AnyConst(64)),
- carry_in.eq(AnyConst(0b11)),
+ #carry_in.eq(AnyConst(0b11)),
]
comb += dut.i.ctx.op.eq(rec)
class LogicalInputData(IntegerData):
regspec = [('INT', 'a', '0:63'),
('INT', 'rb', '0:63'),
- ('XER', 'xer_ca', '34,45')]
+ ]
def __init__(self, pspec):
super().__init__(pspec)
self.a = Signal(64, reset_less=True) # RA
self.b = Signal(64, reset_less=True) # RB/immediate
- self.xer_ca = Signal(2, reset_less=True) # XER bit 34/45: CA/CA32
def __iter__(self):
yield from super().__iter__()
yield self.a
yield self.b
- yield self.xer_ca
def eq(self, i):
lst = super().eq(i)
return lst + [self.a.eq(i.a), self.b.eq(i.b),
- self.xer_ca.eq(i.xer_ca) ]
+ ]
class LogicalOutputData(IntegerData):
yield alu.p.data_i.b.eq(data2)
-def set_extra_alu_inputs(alu, dec2, sim):
- carry = 1 if sim.spr['XER'][XER_bits['CA']] else 0
- carry32 = 1 if sim.spr['XER'][XER_bits['CA32']] else 0
- yield alu.p.data_i.xer_ca[0].eq(carry)
- yield alu.p.data_i.xer_ca[1].eq(carry32)
-
-
# This test bench is a bit different than is usual. Initially when I
# was writing it, I had all of the tests call a function to create a
# device under test and simulator, initialize the dut, run the
fn_unit = yield pdecode2.e.fn_unit
self.assertEqual(fn_unit, Function.LOGICAL.value, code)
yield from set_alu_inputs(alu, pdecode2, simulator)
- yield from set_extra_alu_inputs(alu, pdecode2, simulator)
yield
opname = code.split(' ')[0]
yield from simulator.call(opname)