from soc.fu.alu.alu_input_record import CompALUOpSubset
from soc.decoder.power_enums import MicrOp
import unittest
+from nmutil.extend import exts
# This defines a module to drive the device under test and assert
o = dut.o.o.data
# setup random inputs
- comb += [a.eq(AnyConst(64)),
- b.eq(AnyConst(64)),
- carry_in.eq(AnyConst(1)),
- carry_in32.eq(AnyConst(1)),
- ]
+ comb += a.eq(AnyConst(64))
+ comb += b.eq(AnyConst(64))
+ comb += carry_in.eq(AnyConst(1))
+ comb += carry_in32.eq(AnyConst(1))
comb += dut.i.ctx.op.eq(rec)
with m.Case(MicrOp.OP_RLCL):
pass
with m.Case(MicrOp.OP_EXTSWSLI):
- pass
+ # sign-extend
+ a_s = Signal(64, reset_less=True)
+ comb += a_s.eq(exts(a, 32, 64))
+ # assume b[0:6] is sh
+ comb += Assume(b[7:] == 0)
+ with m.If(b[0:7] == 0):
+ comb += Assert(o[0:32] == a_s[0:32])
+ with m.Else():
+ #b_s = 64-b[0:6]
+ #comb += Assert(o == ((a_s << b_s) & ((1 << 64)-1)))
+ pass
+
with m.Default():
comb += o_ok.eq(0)
self.run_tst_program(Program(lst, bigendian), initial_regs)
def test_regression_extswsli(self):
- sh = random.randint(0, 63)
lst = [f"extswsli 3, 1, 34"]
initial_regs = [0] * 32
initial_regs[1] = 0x5678
self.run_tst_program(Program(lst, bigendian), initial_regs)
+ def test_regression_extswsli_2(self):
+ lst = [f"extswsli 3, 1, 7"]
+ initial_regs = [0] * 32
+ initial_regs[1] = 0x3ffffd7377f19fdd
+ self.run_tst_program(Program(lst, bigendian), initial_regs)
+
+ def test_regression_extswsli_3(self):
+ lst = [f"extswsli 3, 1, 0"]
+ initial_regs = [0] * 32
+ initial_regs[1] = 0x80000000fb4013e2
+ #initial_regs[1] = 0x3ffffd73f7f19fdd
+ self.run_tst_program(Program(lst, bigendian), initial_regs)
+
def test_extswsli(self):
for i in range(40):
sh = random.randint(0, 63)