-
Notifications
You must be signed in to change notification settings - Fork 3
/
Sim_PC.cpp
48 lines (40 loc) · 904 Bytes
/
Sim_PC.cpp
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
#include <verilated.h>
#include <verilated_vcd_c.h>
#include "VPC.h"
using namespace std;
VPC* top;
VerilatedVcdC* tfp;
vluint64_t main_time = 0;
const vluint64_t sim_time = 1024;
int input_index = 0;
int pc[20] = {0, 4, 8, 12, 64, 68, 1024, 1028, 4, 8};
int main(int argc, char **argv)
{
Verilated::commandArgs(argc, argv);
Verilated::traceEverOn(true);
top = new VPC;
tfp = new VerilatedVcdC;
top->trace(tfp, 99);
tfp->open("PC.vcd");
while(!Verilated::gotFinish() && main_time < sim_time)
{
if(main_time % 2)
{
top->clock = 1;
}
else
{
top->clock = 0;
input_index++;
}
top->io_next_pc = pc[input_index];
top->eval();
tfp->dump(main_time);
main_time++;
}
tfp->close();
delete top;
delete tfp;
exit(0);
return 0;
}