Пример #1
0
 def test_init(self):
     """
     Validates good working of the __init__ method for InstructionFetchUnit
     """
     self.assertRaises(
         RuntimeError,
         InstructionFetchUnit)  # IFU needs a memory array to work with
     ma = MemoryArray()
     ifu = InstructionFetchUnit(ma)
     self.assertEqual(ifu._memoryArray, ma)
Пример #2
0
    def __init__(self, ma=None, mioc=None, name="System"):
        """
        Preparing the whole execution environment for this Capua instance. Note that a single memory
        array can be shared between multiple Capua environment.
        """

        # Two execution units CAN share a single memory array and MIOC
        if ma is None:
            self.ma = MemoryArray()
        else:
            self.ma = ma

        if mioc is None:
            self.mioc = MemoryIOController(self.ma, testOnly=False)
        else:
            self.mioc = mioc

        self.ifu = InstructionFetchUnit(self.ma)
        self.eu = ExecutionUnit(self.mioc, self.ifu, name)
Пример #3
0
class TestInstructionFetchUnit(unittest.TestCase):

    ma = MemoryArray()
    ifu = InstructionFetchUnit(ma)

    def test_init(self):
        """
        Validates good working of the __init__ method for InstructionFetchUnit
        """
        self.assertRaises(
            RuntimeError,
            InstructionFetchUnit)  # IFU needs a memory array to work with
        ma = MemoryArray()
        ifu = InstructionFetchUnit(ma)
        self.assertEqual(ifu._memoryArray, ma)

    def test_fetchInstructionAtAddress(self):
        """
        Validates good working of the fetchInstructionAtAddress method for InstructionFetchUnit
        """
        self.ifu._memoryArray.writeMemory(
            MEMORY_START_AT, [0xFF])  # Insert nop instruction in memory
        instruction, nextInstructionAddress = self.ifu.fetchInstructionAtAddress(
            MEMORY_START_AT)
        self.assertIsNotNone(instruction.instructionCode)
        self.assertIsNone(instruction.sourceRegister)
        self.assertIsNone(instruction.destinationRegister)
        self.assertIsNone(instruction.sourceImmediate)
        self.assertIsNone(instruction.destinationImmediate)
        self.assertIsNone(instruction.width)
        self.assertIsNone(instruction.flags)
        self.assertEqual(nextInstructionAddress, MEMORY_START_AT + 1)

        self.ifu._memoryArray.writeMemory(
            MEMORY_START_AT,
            [0b00010000])  # Insert InsWidthRegReg instruction type in memory
        instruction, nextInstructionAddress = self.ifu.fetchInstructionAtAddress(
            MEMORY_START_AT)
        self.assertIsNotNone(instruction.instructionCode)
        self.assertIsNotNone(instruction.sourceRegister)
        self.assertIsNotNone(instruction.destinationRegister)
        self.assertIsNone(instruction.sourceImmediate)
        self.assertIsNone(instruction.destinationImmediate)
        self.assertIsNotNone(instruction.width)
        self.assertIsNone(instruction.flags)
        self.assertEqual(nextInstructionAddress, MEMORY_START_AT + 3)

    def test_fetchInstructionFormAtAddress(self):
        """
        Validates good working of the fetchInstructionFormAtAddress method for InstructionFetchUnit
        """
        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0xFF])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["Ins"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b01110000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsReg"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b10000000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsImm"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b01100000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsImmReg"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b00000000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsWidthImmReg"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b00010000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsWidthRegReg"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b00100000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsWidthRegImm"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b00110000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsWidthImmImm"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b01000000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsFlagImm"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b01010000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsFlagReg"], form)

        self.ifu._memoryArray.writeMemory(MEMORY_START_AT, [0b10010000])
        form = self.ifu._fetchInstructionFormAtAddress(MEMORY_START_AT)
        self.assertEqual(formDescription["InsRegReg"], form)

    def test_fetchInstructionAtAddressUsingForm(self):
        """
        Validates good working of the fetchInstructionAtAddressUsingForm method for InstructionFetchUnit
        """

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["Ins"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNone(ins.sourceRegister)
        self.assertIsNone(ins.destinationRegister)
        self.assertIsNone(ins.sourceImmediate)
        self.assertIsNone(ins.destinationImmediate)
        self.assertIsNone(ins.width)
        self.assertIsNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsReg"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNotNone(ins.sourceRegister)
        self.assertIsNone(ins.destinationRegister)
        self.assertIsNone(ins.sourceImmediate)
        self.assertIsNone(ins.destinationImmediate)
        self.assertIsNone(ins.width)
        self.assertIsNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsImm"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNone(ins.sourceRegister)
        self.assertIsNone(ins.destinationRegister)
        self.assertIsNotNone(ins.sourceImmediate)
        self.assertIsNone(ins.destinationImmediate)
        self.assertIsNone(ins.width)
        self.assertIsNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsImmReg"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNone(ins.sourceRegister)
        self.assertIsNotNone(ins.destinationRegister)
        self.assertIsNotNone(ins.sourceImmediate)
        self.assertIsNone(ins.destinationImmediate)
        self.assertIsNone(ins.width)
        self.assertIsNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsWidthImmReg"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNone(ins.sourceRegister)
        self.assertIsNotNone(ins.destinationRegister)
        self.assertIsNotNone(ins.sourceImmediate)
        self.assertIsNone(ins.destinationImmediate)
        self.assertIsNotNone(ins.width)
        self.assertIsNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsWidthRegReg"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNotNone(ins.sourceRegister)
        self.assertIsNotNone(ins.destinationRegister)
        self.assertIsNone(ins.sourceImmediate)
        self.assertIsNone(ins.destinationImmediate)
        self.assertIsNotNone(ins.width)
        self.assertIsNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsWidthRegImm"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNotNone(ins.sourceRegister)
        self.assertIsNone(ins.destinationRegister)
        self.assertIsNone(ins.sourceImmediate)
        self.assertIsNotNone(ins.destinationImmediate)
        self.assertIsNotNone(ins.width)
        self.assertIsNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsWidthImmImm"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNone(ins.sourceRegister)
        self.assertIsNone(ins.destinationRegister)
        self.assertIsNotNone(ins.sourceImmediate)
        self.assertIsNotNone(ins.destinationImmediate)
        self.assertIsNotNone(ins.width)
        self.assertIsNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsFlagImm"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNone(ins.sourceRegister)
        self.assertIsNone(ins.destinationRegister)
        self.assertIsNotNone(ins.sourceImmediate)
        self.assertIsNone(ins.destinationImmediate)
        self.assertIsNone(ins.width)
        self.assertIsNotNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsFlagReg"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNotNone(ins.sourceRegister)
        self.assertIsNone(ins.destinationRegister)
        self.assertIsNone(ins.sourceImmediate)
        self.assertIsNone(ins.destinationImmediate)
        self.assertIsNone(ins.width)
        self.assertIsNotNone(ins.flags)

        ins = self.ifu._fetchInstructionAtAddressUsingForm(
            MEMORY_START_AT, formDescription["InsRegReg"])
        self.assertIsNotNone(ins.instructionCode)
        self.assertIsNotNone(ins.sourceRegister)
        self.assertIsNotNone(ins.destinationRegister)
        self.assertIsNone(ins.sourceImmediate)
        self.assertIsNone(ins.destinationImmediate)
        self.assertIsNone(ins.width)
        self.assertIsNone(ins.flags)
Пример #4
0
class TestExecutionUnit(unittest.TestCase):

    ma = MemoryArray()
    mioc = MemoryIOController(ma)
    ifu = InstructionFetchUnit(ma)
    eu = ExecutionUnit(mioc, ifu, "System")

    def test_init(self):
        """
        Validates good working of the __init__ method for ExecutionUnit
        def __init__(self, mioc: MemoryIOController=None, ifu: InstructionFetchUnit=None, name: str="System"):
        """
        self.assertRaises(RuntimeError, ExecutionUnit, None, None, None)
        self.assertRaises(RuntimeError, ExecutionUnit, self.mioc, self.ifu,
                          None)
        self.assertRaises(RuntimeError, ExecutionUnit, self.mioc, None,
                          "System")
        self.assertRaises(RuntimeError, ExecutionUnit, None, self.ifu,
                          "System")
        self.assertRaises(RuntimeError, ExecutionUnit, "test", self.ifu,
                          "System")
        self.assertRaises(RuntimeError, ExecutionUnit, self.mioc, "test",
                          "System")
        self.assertRaises(RuntimeError, ExecutionUnit, self.mioc, self.ifu,
                          0x41414141)

        eu = ExecutionUnit(self.mioc, self.ifu, "System")
        self.assertEqual(self.mioc, eu.mioc)
        self.assertEqual(self.ifu, eu.ifu)
        self.assertEqual("System", eu.name)

    def test_setupCore(self):
        """
        Validates good working of the setupCore method for ExecutionUnit
        def setupCore(self, I: int=MEMORY_START_AT):
        """
        self.assertRaises(RuntimeError, self.eu.setupCore,
                          (MEMORY_START_AT - 1))
        self.assertRaises(RuntimeError, self.eu.setupCore, (MEMORY_END_AT + 1))

        self.eu.setupCore(MEMORY_START_AT)
        self.assertEqual(MEMORY_START_AT, self.eu.I)

    def test_execute(self):
        """
        Validates good working of the execute method for ExecutionUnit
        def execute(self):
        """
        # NOP
        self.eu.setupCore(MEMORY_START_AT)
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT + 1, self.eu.I)
        self.assertEqual(0, self.eu.A)
        self.assertEqual(0, self.eu.B)
        self.assertEqual(0, self.eu.C)
        self.assertEqual(0, self.eu.S)
        self.assertEqual(0, self.eu.FLAGS)
        self.eu.execute()
        # NOP
        self.assertEqual(MEMORY_START_AT + 2, self.eu.I)
        self.assertEqual(0, self.eu.A)
        self.assertEqual(0, self.eu.B)
        self.assertEqual(0, self.eu.C)
        self.assertEqual(0, self.eu.S)
        self.assertEqual(0, self.eu.FLAGS)
        # MOV
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 2, 1,
                                                0b01100000)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 3, 1, 0b00)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 4, 1, 0b00)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 5, 1, 0b00)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 6, 1, 0b01)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 7, 1, 0b00)
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT + 8, self.eu.I)
        self.assertEqual(1, self.eu.A)
        self.assertEqual(0, self.eu.B)
        self.assertEqual(0, self.eu.C)
        self.assertEqual(0, self.eu.S)
        self.assertEqual(0, self.eu.FLAGS)
        # JMP
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 8, 1,
                                                0b01000001)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 9, 1, 0b00)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 10, 4,
                                                MEMORY_START_AT)
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT, self.eu.I)
        self.assertEqual(1, self.eu.A)
        self.assertEqual(0, self.eu.B)
        self.assertEqual(0, self.eu.C)
        self.assertEqual(0, self.eu.S)
        self.assertEqual(0, self.eu.FLAGS)
        # NOP
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT + 1, self.eu.I)
        self.assertEqual(1, self.eu.A)
        self.assertEqual(0, self.eu.B)
        self.assertEqual(0, self.eu.C)
        self.assertEqual(0, self.eu.S)
        self.assertEqual(0, self.eu.FLAGS)
        # NOP
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT + 2, self.eu.I)
        self.assertEqual(1, self.eu.A)
        self.assertEqual(0, self.eu.B)
        self.assertEqual(0, self.eu.C)
        self.assertEqual(0, self.eu.S)
        self.assertEqual(0, self.eu.FLAGS)

        # Beware, ACTI and DACTI tests are dependent one on anoter
        self.eu.setupCore(MEMORY_START_AT)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1,
                                                0b11110001)  # ACTI 1
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 1, 1,
                                                0b11110001)  # ACTI 2
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 2, 1,
                                                0b11110010)  # DACTI 1
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 3, 1,
                                                0b11110010)  # DACTI 2
        # ACTI
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT + 1, self.eu.I)
        self.assertEqual(
            0b1, self.eu.IS)  # Interrupt State should be = 1 after ACTI
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT + 2, self.eu.I)
        self.assertEqual(
            0b1, self.eu.IS
        )  # Interrupt State should not change if ACTI is run when IS = 1
        # DACTI
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT + 3, self.eu.I)
        self.assertEqual(
            0b0, self.eu.IS)  # Interrupt State should be = 0 after DACTI
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT + 4, self.eu.I)
        self.assertEqual(
            0b0, self.eu.IS
        )  # Interrupt State should not change if DACTI is run when IS = 0

        # SFSTOR - Data will be written
        self.eu.setupCore(MEMORY_START_AT)
        self.eu.A = MEMORY_START_AT + 20
        self.eu.B = 0xCCCCCCCC
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b01010010)
        self.mioc.memoryWriteAtAddressForLength(
            MEMORY_START_AT + 1, 1,
            0b00110001)  # Instruction goes: SFSTOR [LH] $B
        self.eu.FLAGS = 0b00
        self.eu.execute()
        dataWritten = self.mioc.memoryReadAtAddressForLength(MEMORY_START_AT +
                                                             20,
                                                             length=4)
        self.assertEqual(MEMORY_START_AT + 2, self.eu.I)
        self.assertEqual(0xCCCCCCCC, dataWritten)
        self.assertEqual(0b10, self.eu.FLAGS)

        # SFSTOR - Data will NOT be written
        self.eu.setupCore(MEMORY_START_AT)
        self.eu.A = MEMORY_START_AT + 20
        self.eu.B = 0xBBBBBBBB
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b01010010)
        self.mioc.memoryWriteAtAddressForLength(
            MEMORY_START_AT + 1, 1,
            0b01000001)  # Instruction goes: SFSTOR [E] $B
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 20, 4,
                                                0xAAAAAAAA)
        self.eu.FLAGS = 0b00
        self.eu.execute()
        dataWritten = self.mioc.memoryReadAtAddressForLength(MEMORY_START_AT +
                                                             20,
                                                             length=4)
        self.assertEqual(MEMORY_START_AT + 2, self.eu.I)
        self.assertNotEqual(0xBBBBBBBB, dataWritten)
        self.assertEqual(0b1, self.eu.FLAGS)

        # SIVR
        self.eu.setupCore(MEMORY_START_AT)
        self.eu.A = 0xAAAAAAAA
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b01110101)
        self.mioc.memoryWriteAtAddressForLength(
            MEMORY_START_AT + 1, 1, 0b00000000)  # Instruction goes: SIVR $A
        self.eu.execute()
        self.assertEqual(MEMORY_START_AT + 2, self.eu.I)
        self.assertEqual(0xAAAAAAAA, self.eu.IVR)
        self.assertEqual(0xAAAAAAAA, self.eu.A)

        # HIRET - Deactivated Interrupts
        self.eu.setupCore(MEMORY_START_AT)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b11110011)
        self.mioc.memoryWriteAtAddressForLength(
            0x40000100, 4, 0x40000200)  # This is the return address
        self.mioc.memoryWriteAtAddressForLength(
            0x400000FC, 4, 0x1)  # This is the flag to be restored
        self.eu.A = 0xFF
        self.eu.IS = 0b0
        self.eu.S = 0x40000100
        self.eu.FLAGS = 0x0
        sMarker = self.eu.S
        self.eu.execute()
        self.assertEqual(0xFF, self.eu.A,
                         "HIRET broken - bad A register value")
        self.assertEqual(0x01, self.eu.FLAGS,
                         "HIRET broken - bad flag restoration")
        self.assertEqual(0b1, self.eu.IS, "HIRET broken - IS should not be 0")
        self.assertEqual(0x40000200, self.eu.I, "HIRET broken - Bad I address")
        self.assertEqual(sMarker, self.eu.S + 8, "HIRET broken - Bad stack")

        # INT register - Deactivated Interrupts
        self.eu.setupCore(MEMORY_START_AT)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b01110110)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 1, 1,
                                                0b00000000)
        self.eu.A = 0x0  # Holds the interrupt number
        self.eu.IS = 0b0
        self.eu.S = 0x40000100
        self.eu.IVR = 0x40000050
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR, 4, 0xAAAAAAAA)
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR + 4, 4, 0xBBBBBBBB)
        sMarker = self.eu.S
        self.eu.execute()
        self.assertEqual(self.eu.I, MEMORY_START_AT + 2,
                         "INT when IS is 0 broken - Bad I address")
        self.assertEqual(self.eu.S, sMarker,
                         "INT when IS is 0 broken - Bad stack")

        # INT register - Activated Interrupts
        self.eu.setupCore(MEMORY_START_AT)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b01110110)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 1, 1,
                                                0b00000000)
        self.eu.A = 0x0  # Holds the interrupt number
        self.eu.IS = 0b1
        self.eu.S = 0x40000100
        self.eu.IVR = 0x40000050
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR, 4, 0xAAAAAAAA)
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR + 4, 4, 0xBBBBBBBB)
        sMarker = self.eu.S
        iMarker = self.eu.I
        self.eu.execute()
        self.assertEqual(self.eu.I, 0xAAAAAAAA,
                         "INT when IS is 1 broken - Bad I address")
        self.assertEqual(self.eu.S, sMarker + 4,
                         "INT when IS is 1 broken - Bad stack")
        topStack = self.mioc.memoryReadAtAddressForLength(self.eu.S, 4)
        self.assertEqual(iMarker + 2, topStack,
                         "INT when IS is 1 broken - Bad return address")
        # Testing the second vector entry
        self.eu.setupCore(MEMORY_START_AT)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b01110110)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT + 1, 1,
                                                0b00000000)
        self.eu.A = 0x1  # Holds the interrupt number
        self.eu.IS = 0b1
        self.eu.S = 0x40000100
        self.eu.IVR = 0x40000050
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR, 4, 0xAAAAAAAA)
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR + 4, 4, 0xBBBBBBBB)
        sMarker = self.eu.S
        iMarker = self.eu.I
        self.eu.execute()
        self.assertEqual(self.eu.I, 0xBBBBBBBB,
                         "INT when IS is 1 broken - Bad I address")
        self.assertEqual(self.eu.S, sMarker + 4,
                         "INT when IS is 1 broken - Bad stack")
        topStack = self.mioc.memoryReadAtAddressForLength(self.eu.S, 4)
        self.assertEqual(iMarker + 2, topStack,
                         "INT when IS is 1 broken - Bad return address")

        # INT immediate - Deactivated Interrupts
        self.eu.setupCore(MEMORY_START_AT)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b10000011)
        self.mioc.memoryWriteAtAddressForLength(
            MEMORY_START_AT + 1, 1, 0b00000000)  # Interrupt number is here
        self.eu.IS = 0b0
        self.eu.S = 0x40000100
        self.eu.IVR = 0x40000050
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR, 4, 0xAAAAAAAA)
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR + 4, 4, 0xBBBBBBBB)
        sMarker = self.eu.S
        self.eu.execute()
        self.assertEqual(self.eu.I, MEMORY_START_AT + 5,
                         "INT when IS is 0 broken - Bad I address")
        self.assertEqual(self.eu.S, sMarker,
                         "INT when IS is 0 broken - Bad stack")

        # INT immediate - Activated Interrupts
        self.eu.setupCore(MEMORY_START_AT)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b10000011)
        self.mioc.memoryWriteAtAddressForLength(
            MEMORY_START_AT + 1, 4, 0b00000000)  # Interrupt number is here
        self.eu.IS = 0b1
        self.eu.S = 0x40000100
        self.eu.IVR = 0x40000050
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR, 4, 0xAAAAAAAA)
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR + 4, 4, 0xBBBBBBBB)
        sMarker = self.eu.S
        iMarker = self.eu.I
        self.eu.execute()
        self.assertEqual(self.eu.I, 0xAAAAAAAA,
                         "INT when IS is 1 broken - Bad I address")
        self.assertEqual(self.eu.S, sMarker + 4,
                         "INT when IS is 1 broken - Bad stack")
        topStack = self.mioc.memoryReadAtAddressForLength(self.eu.S, 4)
        self.assertEqual(iMarker + 5, topStack,
                         "INT when IS is 1 broken - Bad return address")
        # testing the second vector entry
        self.eu.setupCore(MEMORY_START_AT)
        self.mioc.memoryWriteAtAddressForLength(MEMORY_START_AT, 1, 0b10000011)
        self.mioc.memoryWriteAtAddressForLength(
            MEMORY_START_AT + 1, 4, 0b00000001)  # Interrupt number is here
        self.eu.IS = 0b1
        self.eu.S = 0x40000100
        self.eu.IVR = 0x40000050
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR, 4, 0xAAAAAAAA)
        self.mioc.memoryWriteAtAddressForLength(self.eu.IVR + 4, 4, 0xBBBBBBBB)
        sMarker = self.eu.S
        iMarker = self.eu.I
        self.eu.execute()
        self.assertEqual(self.eu.I, 0xBBBBBBBB,
                         "INT when IS is 1 broken - Bad I address")
        self.assertEqual(self.eu.S, sMarker + 4,
                         "INT when IS is 1 broken - Bad stack")
        topStack = self.mioc.memoryReadAtAddressForLength(self.eu.S, 4)
        self.assertEqual(iMarker + 5, topStack,
                         "INT when IS is 1 broken - Bad return address")

    def test_reset(self):
        self.eu.setupCore(MEMORY_START_AT)
        self.eu.A = 1
        self.eu.B = 1
        self.eu.C = 1
        self.eu.D = 1
        self.eu.E = 1
        self.eu.F = 1
        self.eu.G = 1
        self.eu.A2 = 1
        self.eu.B2 = 1
        self.eu.C2 = 1
        self.eu.D2 = 1
        self.eu.E2 = 1
        self.eu.F2 = 1
        self.eu.G2 = 1
        self.eu.S = 1
        self.eu.S2 = 1
        self.eu.IS = 1
        self.eu.IVR = 1
        self.eu.FLAGS = 1
        self.eu.reset(0)  # Making sure we can set I to value requested
        count = self.eu.A + self.eu.B + self.eu.C + self.eu.D + self.eu.E + self.eu.F + self.eu.G + \
                self.eu.A2 + self.eu.B2 + self.eu.C2 + self.eu.D2 + self.eu.E2 + self.eu.F2 + self.eu.G2 + \
                self.eu.S + self.eu.S2 + self.eu.IS +self.eu.IVR + self.eu.I + self.eu.FLAGS
        self.assertEqual(count, 0)
        self.eu.setupCore(MEMORY_START_AT)
        self.eu.A = 1
        self.eu.B = 1
        self.eu.C = 1
        self.eu.D = 1
        self.eu.E = 1
        self.eu.F = 1
        self.eu.G = 1
        self.eu.A2 = 1
        self.eu.B2 = 1
        self.eu.C2 = 1
        self.eu.D2 = 1
        self.eu.E2 = 1
        self.eu.F2 = 1
        self.eu.G2 = 1
        self.eu.S = 1
        self.eu.S2 = 1
        self.eu.IS = 1
        self.eu.IVR = 1
        self.eu.FLAGS = 1
        self.eu.reset(
        )  # Making sure we can rely on the default value for I after reset
        count = self.eu.A + self.eu.B + self.eu.C + self.eu.D + self.eu.E + self.eu.F + self.eu.G + \
                self.eu.A2 + self.eu.B2 + self.eu.C2 + self.eu.D2 + self.eu.E2 + self.eu.F2 + self.eu.G2 + \
                self.eu.S + self.eu.S2 + self.eu.IS + self.eu.IVR + self.eu.I + self.eu.FLAGS
        self.assertEqual(count, MEMORY_START_AT)