forked from clydepp/Lab4-Reduced-RISC-V
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.cpp
More file actions
67 lines (56 loc) · 1.21 KB
/
verify.cpp
File metadata and controls
67 lines (56 loc) · 1.21 KB
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
#include "testbench.h"
#include <cstdlib>
Vdut *top;
VerilatedVcdC *tfp;
unsigned int ticks = 0;
class CpuTestbench : public Testbench
{
protected:
void initializeInputs() override
{
top->clk = 1;
top->rst = 0;
}
};
TEST_F(CpuTestbench, BaseProgramTest)
{
bool success = false;
system("./compile.sh asm/program.S");
for (int i = 0; i < 1000; i++)
{
runSimulation(1);
if (top->a0 == 254)
{
SUCCEED();
success = true;
break;
}
}
if (!success)
{
FAIL() << "Counter did not reach 254";
}
}
// Note this is how we are going to test your CPU. Do not worry about this for
// now, as it requires a lot more instructions to function
TEST_F(CpuTestbench, Return5Test)
{
system("./compile.sh c/return_5.c");
runSimulation(100);
EXPECT_EQ(top->a0, 5);
}
int main(int argc, char **argv)
{
top = new Vdut;
tfp = new VerilatedVcdC;
Verilated::traceEverOn(true);
top->trace(tfp, 99);
tfp->open("waveform.vcd");
testing::InitGoogleTest(&argc, argv);
auto res = RUN_ALL_TESTS();
top->final();
tfp->close();
delete top;
delete tfp;
return res;
}