with m.Switch(rec.insn_type):
with m.Case(InternalOp.OP_ADD):
comb += Assert(Cat(o, carry_out) == (a + b + carry_in))
- with m.Case(InternalOp.OP_AND):
- comb += Assert(dut.o.o == a & b)
- with m.Case(InternalOp.OP_OR):
- comb += Assert(dut.o.o == a | b)
- with m.Case(InternalOp.OP_XOR):
- comb += Assert(dut.o.o == a ^ b)
return m
comb += self.o.o.eq(add_output[1:-1])
comb += self.o.carry_out.eq(add_output[-1])
- #### and ####
- with m.Case(InternalOp.OP_AND):
- comb += self.o.o.eq(self.i.a & self.i.b)
-
- #### or ####
- with m.Case(InternalOp.OP_OR):
- comb += self.o.o.eq(self.i.a | self.i.b)
-
- #### xor ####
- with m.Case(InternalOp.OP_XOR):
- comb += self.o.o.eq(self.i.a ^ self.i.b)
-
#### exts (sign-extend) ####
with m.Case(InternalOp.OP_EXTS):
with m.If(self.i.ctx.op.data_len == 1):
test_data.append(tc)
def test_rand(self):
- insns = ["add", "add.", "and", "or", "xor", "subf"]
+ insns = ["add", "add.", "subf"]
for i in range(40):
choice = random.choice(insns)
lst = [f"{choice} 3, 1, 2"]
initial_regs[1] = random.randint(0, (1<<64)-1)
self.run_tst_program(Program(lst), initial_regs)
- def test_rand_imm_logical(self):
- insns = ["andi.", "andis.", "ori", "oris", "xori", "xoris"]
- for i in range(10):
- choice = random.choice(insns)
- imm = random.randint(0, (1<<16)-1)
- lst = [f"{choice} 3, 1, {imm}"]
- print(lst)
- initial_regs = [0] * 32
- initial_regs[1] = random.randint(0, (1<<64)-1)
- self.run_tst_program(Program(lst), initial_regs)
-
def test_adde(self):
lst = ["adde. 5, 6, 7"]
initial_regs = [0] * 32