summaryrefslogtreecommitdiff
path: root/verilog/tbdatapath.cpp
diff options
context:
space:
mode:
authorJoshua Yun <jjyun4@illinois.edu>2023-08-28 14:42:23 -0500
committerJoshua Yun <jjyun4@illinois.edu>2023-08-28 14:42:23 -0500
commitc1fa3c36da28e9e947f6279329c47777f31fe7a2 (patch)
treebd321c8e33200427b23bffe96c7c1bae90d8a044 /verilog/tbdatapath.cpp
parentd069ea63cce08c0f5c8d7da7f8ab05115bd8d856 (diff)
downloadriscv-processor-inorder-master.tar.gz
Added new riscv processor design into git repoHEADmaster
Diffstat (limited to 'verilog/tbdatapath.cpp')
-rw-r--r--verilog/tbdatapath.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/verilog/tbdatapath.cpp b/verilog/tbdatapath.cpp
new file mode 100644
index 0000000..ff7d3b8
--- /dev/null
+++ b/verilog/tbdatapath.cpp
@@ -0,0 +1,73 @@
+#include<memory>
+
+#include<iostream>
+#include<iomanip>
+#include<bitset>
+
+#include <verilated.h>
+
+#include "svdpi.h"
+
+#include "Vdatapath.h"
+#include "Vdatapath__Dpi.h"
+
+#include "tbdatapath.h"
+
+int main(int argc, char** argv, char** env) {
+
+ if (false && argc && argv && env) {}
+
+ Verilated::mkdir("log_datapath");
+
+ const std::unique_ptr<VerilatedContext> contextp {new VerilatedContext};
+ contextp->commandArgs(argc, argv);
+ contextp->debug(0);
+ contextp->traceEverOn(true);
+ contextp->randReset(2);
+ contextp->randReset(2);
+
+ const std::unique_ptr<Vdatapath> top{new Vdatapath{contextp.get(), "TOP"}};
+
+ contextp->timeInc(1);
+ top->clk = 0;
+ top->rst = 1;
+
+ top->eval();
+
+ contextp->timeInc(1);
+ top->clk = 1;
+ top->rst = 1;
+
+ top->eval();
+
+ contextp->timeInc(1);
+ top->clk = 0;
+ top->rst = 0;
+
+ top->eval();
+
+ for (int i = 0; i < 75; i++) {
+ contextp->timeInc(1);
+ top->clk = !top->clk;
+ top->eval();
+ }
+
+ const svScope scope = svGetScopeFromName("TOP.datapath.reg0");
+ assert(scope);
+ svSetScope(scope);
+
+ uint32_t reg_addr;
+ uint32_t reg_val;
+ for (int i = 1; i < 6; i++) {
+ reg_addr = i;
+ reg_val = 0;
+ top->get_reg_value(&reg_addr, &reg_val);
+ std::cout << "Register: " << i << " Value: " << std::hex << reg_val << std::endl;
+ }
+
+ top->final();
+
+ return 0;
+
+
+}