Add IRQ test

This commit is contained in:
2026-04-30 22:59:21 -07:00
parent d519943385
commit 79ce91669b
2 changed files with 44 additions and 1 deletions

View File

@@ -534,7 +534,6 @@ async def test_jsr(dut):
(0x1234567c, False, None), # Updating PC before jump
(0x00000208, False, None), # WAI
(0x00000209, False, None), # second wai
(0x0000020a, False, None), # third wai
]
await check_instruction_sequence(dut, expected_cpu_outputs)
@@ -604,6 +603,48 @@ async def test_rti(dut):
await check_instruction_sequence(dut, expected_cpu_outputs)
@cocotb.test
async def test_irq(dut):
cocotb.start_soon(Clock(dut.clk, CLK_PERIOD, unit="ns").start())
cocotb.start_soon(handle_memory(dut))
write_dword(0xfffffff4, 0x200)
write_dword(0xfffffffc, 0x300)
# @0x200
# cli
# wai
# wai
# 0x300
# rti
write_bytes(0x200, [0x58, 0xcb, 0xcb])
write_bytes(0x300, [0x40])
dut.RDY.value = Immediate(1)
dut.reset.value = Immediate(1)
for _ in range(10):
await RisingEdge(dut.clk)
dut.reset.value = 0
await FallingEdge(dut.RDY_O)
await RisingEdge(dut.clk)
await RisingEdge(dut.clk)
dut.IRQ.value = 1
while True:
await RisingEdge(dut.clk)
if int(dut.state.value) == 0x08:
break
dut.IRQ.value = 0
await Timer(300, "ns")
assert int(dut.RDY_O.value) == 0
@cocotb.test
async def test_adc(dut):

View File

@@ -434,6 +434,8 @@ always @*
case( state )
DECODE: if( (~I & IRQ) | NMI_edge ) begin
PC_inc = 0;
end else if (IR == 8'b1100_1011) begin
PC_inc = 0;
end else begin
PC_inc = 1;
end