forked from HITSZ-NSCSCC22/mycpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestbench.cpp
More file actions
36 lines (30 loc) · 764 Bytes
/
testbench.cpp
File metadata and controls
36 lines (30 loc) · 764 Bytes
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
#include "VSimTop.h"
#include <memory>
#include <iostream>
// Work around
double sc_time_stamp() { return 0; }
int main(int argc, char const *argv[])
{
// Enable tracing aka waveform
const std::unique_ptr<VerilatedContext> context{new VerilatedContext};
context->debug(0);
context->traceEverOn(true);
context->commandArgs(argc, argv);
Verilated::mkdir("logs");
std::unique_ptr<VSimTop> sopc(new VSimTop{context.get()});
sopc->clock = 1;
sopc->reset = 1;
// Simulation loop
for (size_t i = 0; i < 10000; i++)
{
if (i == 10)
{
sopc->reset = 0;
}
sopc->clock = 1 - sopc->clock;
sopc->eval();
context->timeInc(1);
}
sopc->final();
return 0;
}