-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmux_tb.cpp
59 lines (44 loc) · 968 Bytes
/
mux_tb.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
49
50
51
52
53
54
55
56
57
58
59
/*
* Verifies the results of the mux, exits with a 0 on success.
* Author: William Huynh <wh1022@ic.ac.uk>
*/
#include "base_testbench.h"
#define NAME "mux"
class MuxTestbench : public BaseTestbench
{
protected:
void initializeInputs() override
{
top->sel = 0;
top->in0 = 0;
top->in1 = 0;
// output: out
}
};
TEST_F(MuxTestbench, Mux0WorksTest)
{
top->sel = 0;
top->in0 = 1;
top->in1 = 0;
top->eval();
EXPECT_EQ(top->out, 1);
}
TEST_F(MuxTestbench, Mux1WorksTest)
{
top->sel = 1;
top->in0 = 0;
top->in1 = 1;
top->eval();
EXPECT_EQ(top->out, 1);
}
int main(int argc, char **argv)
{
Verilated::commandArgs(argc, argv);
testing::InitGoogleTest(&argc, argv);
Verilated::mkdir("logs");
auto res = RUN_ALL_TESTS();
VerilatedCov::write(
("logs/coverage_" + std::string(NAME) + ".dat").c_str()
);
return res;
}