示例#1
0
    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)
示例#2
0
    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))
示例#3
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)
示例#4
0
 def valid(self, instr: Value) -> Value:
     return instr.matches(TAB, TBA)
示例#5
0
 def valid(self, instr: Value) -> Value:
     return instr.matches("01111110")
示例#6
0
 def valid(self, instr: Value) -> Value:
     return instr.matches(INX, DEX)
示例#7
0
 def valid(self, instr: Value) -> Value:
     return instr.matches("1---10-1")
示例#8
0
 def valid(self, instr: Value) -> Value:
     return instr.matches(ROL, ROR, ASL, ASR, LSR)
示例#9
0
 def valid(self, instr: Value) -> Value:
     return instr.matches("10001101")
示例#10
0
 def valid(self, instr: Value) -> Value:
     return instr.matches("1--10111", "1-100111")
示例#11
0
 def valid(self, instr: Value) -> Value:
     return instr.matches("0010----")
示例#12
0
 def valid(self, instr: Value) -> Value:
     return instr.matches(CLV, SEV, CLC, SEC, CLI, SEI)
示例#13
0
 def valid(self, instr: Value) -> Value:
     return instr.matches("1-1100-0")
示例#14
0
 def valid(self, instr: Value) -> Value:
     return instr.matches(JSR_IND, JSR_EXT)
示例#15
0
 def valid(self, instr: Value) -> Value:
     return instr.matches(SBA, CBA)