From 3b0310ef472ad45a82561b9e198315b914ac5184 Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Sat, 23 Dec 2023 19:50:34 +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:50:34=20=20up=20=2022:48,=20=20?= =?UTF-8?q?2=20users,=20=20load=20average:=200.25,=200.38,=200.46?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- npc/Makefile | 4 ++-- npc/trace/main.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 npc/trace/main.cpp diff --git a/npc/Makefile b/npc/Makefile index c1b395e..c97a404 100644 --- a/npc/Makefile +++ b/npc/Makefile @@ -10,12 +10,12 @@ sim: all $(call git_commit, "sim RTL") # DO NOT REMOVE THIS LINE!!! @echo "Running" $(OBJDIR)/Vexample "..." @echo "================================" - $(OBJDIR)/Vexample + @$(OBJDIR)/Vexample $(OBJDIR): $(VSRC) $(CPPSRC) mkdir -p $(OBJDIR) - verilator --cc --exe --Mdir $(PWD)/$(OBJDIR) $(VSRC) $(CPPSRC) + verilator --trace --cc --exe --Mdir $(PWD)/$(OBJDIR) $(VSRC) $(CPPSRC) include ../Makefile diff --git a/npc/trace/main.cpp b/npc/trace/main.cpp new file mode 100644 index 0000000..a62b9be --- /dev/null +++ b/npc/trace/main.cpp @@ -0,0 +1,32 @@ +#include "verilated_vcd_c.h" +#include "Vexample.h" +#include "verilated.h" + +int main(int argc, char **argv, char **env) { +} + +int main(int argc, char **argv, char **env) { + Verilated::commandArgs(argc, argv); + Verilated::traceEverOn(true); + VerilatedVcdC* tfp = new VerilatedVcdC; + Vexample *top = new Vexample; + int round = 100; + while (round--) { + int a = rand() & 1; + int b = rand() & 1; + top->a = a; + top->b = b; + top->eval(); + printf("a = %d, b = %d, f = %d\n", a, b, top->f); + assert(top->f == (a ^ b)); + } + exit(0); + topp->trace (tfp, 99); + tfp->open ("obj_dir/t_trace_ena_cc/simx.vcd"); + ... + while (sc_time_stamp() < sim_time && !Verilated::gotFinish()) { + main_time += #; + tfp->dump (main_time); + } + tfp->close(); +} \ No newline at end of file