summaryrefslogtreecommitdiff
path: root/tb/soc/irq/tb_pimc.cpp
blob: 4fbc822509ac8da84e217875a1e15ebe3ef6c994 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdlib.h>
#include <iostream>
#include <verilated.h>
#include <verilated_vcd_c.h>
#include "Vpimc.h"
#include "Vpimc___024root.h"

#define MAX_SIM_ITER 100

int main(int argc, char** argv, char** env) {
    Vpimc *pimc = new Vpimc;

    Verilated::traceEverOn(true);
    VerilatedVcdC *m_trace = new VerilatedVcdC;
    pimc->trace(m_trace, 5);
    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;
        }

        if (i == 10) {
            pimc->irqack = 0;
        }

        pimc->clk ^= 1;
        pimc->eval();
        m_trace->dump(i);
    }

    m_trace->close();
    delete pimc;
    exit(EXIT_SUCCESS);
}