From 8b71fb7db5d8ba9ae0192f3acb9d5a3f6f29e592 Mon Sep 17 00:00:00 2001
From: tracer-ysyx <tracer@ysyx.org>
Date: Sat, 23 Dec 2023 19:57:04 +0800
Subject: [PATCH] =?UTF-8?q?>=20sim=20RTL=20ysyx=5F22040000=20=E6=9D=8E?=
 =?UTF-8?q?=E5=BF=83=E6=9D=A8=20Linux=20calcite=206.1.65=20#1-NixOS=20SMP?=
 =?UTF-8?q?=20PREEMPT=5FDYNAMIC=20Sun=20Dec=20=203=2006:32:13=20UTC=202023?=
 =?UTF-8?q?=20x86=5F64=20GNU/Linux=20=2019:57:04=20=20up=20=2022:55,=20=20?=
 =?UTF-8?q?2=20users,=20=20load=20average:=200.71,=200.62,=200.53?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 npc/csrc/main.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/npc/csrc/main.cpp b/npc/csrc/main.cpp
index 9f178e3..0374c7e 100644
--- a/npc/csrc/main.cpp
+++ b/npc/csrc/main.cpp
@@ -1,13 +1,17 @@
 #include <cstdlib>
 #include <cassert>
 #include <cstdlib>
+#include <verilated.h>
+#include <verilated_vcd_c.h>
 #include "Vexample.h"
-#include "verilated.h"
 
 int main(int argc, char **argv, char **env) {
+    int round = 100;
     Verilated::commandArgs(argc, argv);
     Vexample *top = new Vexample;
-    int round = 100;
+    VerilatedVcdC *m_trace = new VerilatedVcdC; 
+    top->trace(m_trace, 5);
+    m_trace->open("waveform.vcd");
     while (round--) {
         int a = rand() & 1;
         int b = rand() & 1;
@@ -17,5 +21,7 @@ int main(int argc, char **argv, char **env) {
         printf("a = %d, b = %d, f = %d\n", a, b, top->f);
         assert(top->f == (a ^ b));
     }
-    exit(0);
+    m_trace->close();
+    delete top;
+    exit(EXIT_SUCCESS);
 }