summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorJulian Blake Kongslie2021-03-23 12:22:38 -0700
committerJulian Blake Kongslie2021-03-23 12:22:38 -0700
commit5d95607192380be5cc62592efac52814a0e090df (patch)
tree656bc3ec79180a89f355681e454808ebce6eb6d9 /main.cpp
downloadtoycpu-5d95607192380be5cc62592efac52814a0e090df.tar.xz
Initial commit.
Diffstat (limited to '')
-rw-r--r--main.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..3f49cb6
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,56 @@
1#include <cstdint>
2#include <iostream>
3#include <verilated.h>
4#include <verilated_vcd_c.h>
5
6#include "Vtop.h"
7
8int main(int argc, const char *argv[])
9{
10 Verilated::commandArgs(argc, argv);
11
12 Verilated::traceEverOn(true);
13 VerilatedVcdC vcd;
14
15 Vtop top;
16 top.trace(&vcd, 100 /* levels of hierarchy */);
17
18 vcd.set_time_unit("ns");
19 vcd.set_time_resolution("ns");
20 vcd.open("build/out.vcd");
21
22 std::cout << "*** RESET SEQUENCE ***\n";
23
24 std::uint64_t time = 0;
25
26 top.clk = 0;
27 top.reset_n = 0;
28 top.eval();
29 vcd.dump(++time);
30
31 top.clk = 1;
32 top.eval();
33 vcd.dump(++time);
34
35 top.clk = 0;
36 top.reset_n = 1;
37 top.eval();
38 vcd.dump(++time);
39
40 std::cout << "*** MAIN LOOP ***\n";
41
42 for (unsigned int i = 0; i < 500 && !Verilated::gotFinish(); ++i) {
43 top.clk = 1;
44 top.eval();
45 vcd.dump(++time);
46 top.clk = 0;
47 top.eval();
48 vcd.dump(++time);
49 }
50
51 std::cout << "\n";
52
53 vcd.close();
54
55 return 0;
56}