summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorruki <[email protected]>2023-01-14 11:22:42 +0800
committerruki <[email protected]>2023-01-14 11:22:53 +0800
commit74f739212453135284fcc3fe2a9b0363356e3086 (patch)
tree0b3ae3a2c6714fe8cbb10bac25597b1956135b54 /tests
parent6ebcc5c4bc3df9459904c777f5c3d4ceb0b6b261 (diff)
improve hello tests
Diffstat (limited to 'tests')
-rw-r--r--tests/projects/embed/verilator/hello/src/main.v1
-rw-r--r--tests/projects/embed/verilator/hello/src/sim_main.cpp40
2 files changed, 26 insertions, 15 deletions
diff --git a/tests/projects/embed/verilator/hello/src/main.v b/tests/projects/embed/verilator/hello/src/main.v
index 9661c433e..9bd2c43b5 100644
--- a/tests/projects/embed/verilator/hello/src/main.v
+++ b/tests/projects/embed/verilator/hello/src/main.v
@@ -1,7 +1,6 @@
module hello;
initial begin
$display("hello world!");
- $dumpfile("hello.vcd");
$dumpvars(0, hello);
$finish ;
end
diff --git a/tests/projects/embed/verilator/hello/src/sim_main.cpp b/tests/projects/embed/verilator/hello/src/sim_main.cpp
index 95660029b..0aa763a0a 100644
--- a/tests/projects/embed/verilator/hello/src/sim_main.cpp
+++ b/tests/projects/embed/verilator/hello/src/sim_main.cpp
@@ -1,16 +1,28 @@
- #include "hello.h"
- #include "verilated.h"
+#include "hello.h"
+#include "verilated.h"
+#include "verilated_vcd_c.h"
- double sc_time_stamp() {
- return 0;
- }
+double sc_time_stamp() {
+ return 0;
+}
- int main(int argc, char** argv) {
- VerilatedContext* contextp = new VerilatedContext;
- contextp->commandArgs(argc, argv);
- hello* top = new hello{contextp};
- while (!contextp->gotFinish()) { top->eval(); }
- delete top;
- delete contextp;
- return 0;
- }
+int main(int argc, char** argv) {
+ char const* vcdfile = NULL;
+ if (argc == 2) {
+ vcdfile = argv[1];
+ } else {
+ printf("xmake run hello [vcdfile]\n");
+ return -1;
+ }
+ VerilatedContext* contextp = new VerilatedContext;
+ contextp->commandArgs(argc, argv);
+ hello* top = new hello{contextp};
+ VerilatedVcdC* tfp = new VerilatedVcdC;
+ top->trace(tfp, 99);
+ Verilated::traceEverOn(true);
+ tfp->open(vcdfile);
+ while (!contextp->gotFinish()) { top->eval(); }
+ delete top;
+ delete contextp;
+ return 0;
+}