def check(self, m: Module, instr: Value, data: FormalData): input, actual_output = self.common_check(m, instr, data) expected_output = Signal(8) pre_c = data.pre_ccs[Flags.C] c = Signal() with m.If(instr.matches(ROL)): # input[7..0], c -> # c, output[7..0] m.d.comb += [ c.eq(input[7]), expected_output[0].eq(pre_c), Downto(expected_output, 7, 1).eq(Downto(input, 6, 0)), ] with m.Elif(instr.matches(ROR)): # c, input[7..0] -> # output[7..0], c m.d.comb += [ c.eq(input[0]), expected_output[7].eq(pre_c), Downto(expected_output, 6, 0).eq(Downto(input, 7, 1)), ] with m.Elif(instr.matches(ASL)): # input[7..0], 0 -> # c, output[7..0] m.d.comb += [ c.eq(input[7]), expected_output[0].eq(0), Downto(expected_output, 7, 1).eq(Downto(input, 6, 0)), ] with m.Elif(instr.matches(ASR)): # input[7], input[7..0] -> # output[7..0], c m.d.comb += [ c.eq(input[0]), expected_output[7].eq(input[7]), Downto(expected_output, 6, 0).eq(Downto(input, 7, 1)), ] with m.Elif(instr.matches(LSR)): # 0, input[7..0] -> # output[7..0], c m.d.comb += [ c.eq(input[0]), expected_output[7].eq(0), Downto(expected_output, 6, 0).eq(Downto(input, 7, 1)), ] m.d.comb += Assert(expected_output == actual_output) n = expected_output[7] z = (expected_output == 0) v = n ^ c self.assertFlags(m, data.post_ccs, data.pre_ccs, Z=z, N=n, V=v, C=c)
def check(self, m: Module, instr: Value, data: FormalData): m.d.comb += [ Assert(data.post_a == data.pre_a), Assert(data.post_b == data.pre_b), Assert(data.post_sp == data.pre_sp), Assert(data.addresses_written == 0), Assert(data.addresses_read == 0), ] m.d.comb += Assert(data.post_pc == data.plus16(data.pre_pc, 1)) with m.If(instr.matches(INX)): m.d.comb += Assert(data.post_x == (data.pre_x + 1)[:16]) with m.If(instr.matches(DEX)): m.d.comb += Assert(data.post_x == (data.pre_x - 1)[:16]) self.assertFlags(m, data.post_ccs, data.pre_ccs, Z=(data.post_x == 0))
def check(self, m: Module, instr: Value, data: FormalData): input, actual_output = self.common_check(m, instr, data) expected_output = Signal(8) with m.If(instr.matches(INC)): m.d.comb += expected_output.eq((input + 1)[:8]) with m.If(instr.matches(DEC)): m.d.comb += expected_output.eq((input - 1)[:8]) m.d.comb += Assert(expected_output == actual_output) z = (expected_output == 0) n = expected_output[7] v = Mux(instr.matches(INC), expected_output == 0x80, expected_output == 0x7F) self.assertFlags(m, data.post_ccs, data.pre_ccs, Z=z, N=n, V=v)
def valid(self, instr: Value) -> Value: return instr.matches(TAB, TBA)
def valid(self, instr: Value) -> Value: return instr.matches("01111110")
def valid(self, instr: Value) -> Value: return instr.matches(INX, DEX)
def valid(self, instr: Value) -> Value: return instr.matches("1---10-1")
def valid(self, instr: Value) -> Value: return instr.matches(ROL, ROR, ASL, ASR, LSR)
def valid(self, instr: Value) -> Value: return instr.matches("10001101")
def valid(self, instr: Value) -> Value: return instr.matches("1--10111", "1-100111")
def valid(self, instr: Value) -> Value: return instr.matches("0010----")
def valid(self, instr: Value) -> Value: return instr.matches(CLV, SEV, CLC, SEC, CLI, SEI)
def valid(self, instr: Value) -> Value: return instr.matches("1-1100-0")
def valid(self, instr: Value) -> Value: return instr.matches(JSR_IND, JSR_EXT)
def valid(self, instr: Value) -> Value: return instr.matches(SBA, CBA)