-
Notifications
You must be signed in to change notification settings - Fork 0
/
negator.cpp
43 lines (33 loc) · 915 Bytes
/
negator.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
#include <cassert>
#include <iostream>
#include "Vnegator.h"
#include "verilated.h"
#include "common.hpp"
class NegatorTestCase : public TestCase<Vnegator> {
public:
NegatorTestCase() : TestCase("negator.cpp.vcd") {}
virtual void step(bool& finish) {
this->dut->in = this->clock;
finish = (time == 7);
}
};
int main(int argc, char **argv) {
Verilated::commandArgs(argc, argv);
/*
Sample fully explicit test case.
Since this is a sequential circuit, we only need to test
each input once, history does not matter.
*/
{
Vnegator *dut = new Vnegator;
dut->in = 0;
dut->eval();
assert(dut->out == 1);
dut->in = 1;
dut->eval();
assert(dut->out == 0);
delete dut;
}
/* Factored out test case using our little library. */
assert(NegatorTestCase().run());
}