From 9bb02c687f45f529c2cb016151db7b1fd1ee35e8 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 3 Aug 2024 19:56:24 -0400 Subject: tb/soc: pimc: Test IRQ line 3 and masking Signed-off-by: Ian Moffett --- tb/soc/irq/tb_pimc.cpp | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'tb/soc/irq/tb_pimc.cpp') diff --git a/tb/soc/irq/tb_pimc.cpp b/tb/soc/irq/tb_pimc.cpp index d04998c..b315fc7 100644 --- a/tb/soc/irq/tb_pimc.cpp +++ b/tb/soc/irq/tb_pimc.cpp @@ -35,9 +35,11 @@ #include "Vpimc___024root.h" #define MAX_SIM_ITER 100 +#define IRQ_WAIT_CLOCKS 5 int main(int argc, char** argv, char** env) { Vpimc *pimc = new Vpimc; + vluint64_t posedge_cnt = 0; Verilated::traceEverOn(true); VerilatedVcdC *m_trace = new VerilatedVcdC; @@ -45,20 +47,46 @@ int main(int argc, char** argv, char** env) { m_trace->open("waveform.vcd"); pimc->notify = 1; - pimc->irq_in = 0b00000010; /* Pulse IRQ line high */ for (int i = 0; i < MAX_SIM_ITER; ++i) { - if (i == 5) { - pimc->irq_in = 0b00000000; - pimc->irqack = 1; - } + pimc->clk ^= 1; + pimc->eval(); + + if (pimc->clk == 1) { + ++posedge_cnt; + + /* Pulse IRQ line 3 high some cycles */ + if (posedge_cnt == 5) { + pimc->irq_in |= (1 << 3); + } else if (posedge_cnt == 9) { + pimc->irq_in &= ~(1 << 3); + } - if (i == 10) { - pimc->irqack = 0; + /* ACK IRQ */ + if (posedge_cnt == 13) { + pimc->irqack = 1; + } else if (posedge_cnt == 17) { + pimc->irqack = 0; + } + + /* Mask IRQ line 0 */ + if (posedge_cnt == 15) { + pimc->mmio_addr = 0x1000; + pimc->mmio_wdata |= (1 << 8); + pimc->mmio_we = 1; + pimc->mmio_re = 0; + } else if (posedge_cnt == 18) { + pimc->mmio_we = 0; + } + + /* Pulse IRQ line 0 high some cycles */ + if (posedge_cnt == 19) { + pimc->irq_in |= (1 << 0); + } else if (posedge_cnt == 23) { + pimc->irq_in &= ~(1 << 0); + } } - pimc->clk ^= 1; - pimc->eval(); m_trace->dump(i); } -- cgit v1.2.3