summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-08-03 19:56:24 -0400
committerIan Moffett <ian@osmora.org>2024-08-03 19:56:24 -0400
commit9bb02c687f45f529c2cb016151db7b1fd1ee35e8 (patch)
tree5323acc762a81f006aa29ad8a561336f1f2e60ab
parentca5484e280296b28870186e13236e0033b9f1b27 (diff)
tb/soc: pimc: Test IRQ line 3 and masking
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--tb/soc/irq/tb_pimc.cpp46
1 files changed, 37 insertions, 9 deletions
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);
}