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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#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");
// sim/control_flow.c
uint32_t rom[] =
{
0xea000032,
0xea000034,
0xea000000,
0xeafffffe,
0xeafffffe,
0xeafffffe,
0xeafffffe,
0xe3500000,
0xda000001,
0xe3a00001,
0xe1a0f00e,
0x13e00000,
0x03a00000,
0xe1a0f00e,
0xe1a02000,
0xe92d4010,
0xe1a00002,
0xebfffff4,
0xe1a03000,
0xe1a00001,
0xebfffff1,
0xe0933000,
0x0a00000c,
0xe3730001,
0x0a00000e,
0xe3530001,
0x0a00000a,
0xe1a038a1,
0xe1a00502,
0xe1833601,
0xe02023c2,
0xe0831001,
0xe1520001,
0xcaffffed,
0xe0820001,
0xe8bd8010,
0xe1a02822,
0xe1822801,
0xe1a00f62,
0xe8bd8010,
0xe3500000,
0xda000002,
0xe1a02001,
0xe2611001,
0xeafffff2,
0xe1e02001,
0xe1a00002,
0xebffffd6,
0xe3500000,
0xdaffffed,
0xe1a01002,
0xeafffff5,
0xe59fd008,
0xebffffd7,
0xeafffffe,
0xeafffffe,
0x20000000,
};
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(rom)/sizeof(rom[0]); ++i)
{
top.insn = rom[i];
top.eval();
trace.dump(time++);
std::printf("insn=0x%08x, ctrl=0x%08x\n",
rom[i], top.ctrl);
}
trace.close();
top.final(); // Done simulating
}
|