comb += self.o.o.eq(self.i.a | self.i.b)
with m.Case(InternalOp.OP_XOR):
comb += self.o.o.eq(self.i.a ^ self.i.b)
+ ###### cmpb #######
+ with m.Case(InternalOp.OP_CMPB):
+ for i in range(8):
+ slc = slice(i*8, (i+1)*8)
+ with m.If(self.i.a[slc] == self.i.b[slc]):
+ comb += self.o.o[slc].eq(Repl(1, 8))
+ with m.Else():
+ comb += self.o.o[slc].eq(Repl(0, 8))
+
###### popcount #######
# TODO with m.Case(InternalOp.OP_POPCNT):
###### parity #######
# TODO with m.Case(InternalOp.OP_PRTY):
- ###### cmpb #######
- # TODO with m.Case(InternalOp.OP_CMPB):
###### cntlz #######
# TODO with m.Case(InternalOp.OP_CNTZ):
###### bpermd #######
initial_regs = [0] * 32
initial_regs[1] = random.randint(0, (1<<64)-1)
self.run_tst_program(Program(lst), initial_regs)
-
+
+ def test_cmpb(self):
+ lst = ["cmpb 3, 1, 2"]
+ initial_regs = [0] * 32
+ initial_regs[1] = 0xdeadbeefcafec0de
+ initial_regs[2] = 0xd0adb0000afec1de
+ self.run_tst_program(Program(lst), initial_regs)
+
def test_ilang(self):
rec = CompALUOpSubset()