blob: 3d8589a6f640b1eb6d7082e68401517e14e8e833 (
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
41
42
43
44
45
46
47
48
49
50
|
#include <cstdio>
#include <verilated.h>
#include <verilated_vcd_c.h>
#include "Vdecode_test.h" // From Verilating "top.v"
int main(int argc, char** argv) {
Verilated::commandArgs(argc, argv); // Remember args
Verilated::traceEverOn(true);
Vdecode_test top;
VerilatedVcdC trace;
top.trace(&trace, 0);
trace.open("decode_test.vcd");
int instructions[4] = {};
top.n = 0;
top.z = 0;
top.c = 0;
top.v = 0;
int clk_tick = 0;
int time = 0;
for(int i = 0; i < sizeof(instructions); ++i)
{
top.insn = instructions[i];
top.n = 0;
top.z = 0;
top.c = 0;
top.v = 0;
top.eval();
trace.dump(time++);
std::printf(" [%c%c%c%c]\n",
top.n ? 'N' : 'n',
top.z ? 'Z' : 'z',
top.c ? 'C' : 'c',
top.v ? 'V' : 'v');
std::printf("insn=%d, ctrl=%d",
instructions[i], top.ctrl);
}
trace.close();
top.final(); // Done simulating
}
|