From d278cae6073e544a426f7f348510b80d6a82b12a Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Mon, 1 Jan 2024 11:09:46 +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.69=20#1-NixOS=20SMP?= =?UTF-8?q?=20PREEMPT=5FDYNAMIC=20Wed=20Dec=2020=2016:00:29=20UTC=202023?= =?UTF-8?q?=20x86=5F64=20GNU/Linux=20=2011:09:46=20=20up=20=2019:48,=20=20?= =?UTF-8?q?2=20users,=20=20load=20average:=200.84,=200.64,=200.85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + npc/Makefile | 12 +++++++++++- npc/flake.nix | 7 +++++++ npc/trace/main.cpp | 32 -------------------------------- 4 files changed, 19 insertions(+), 33 deletions(-) delete mode 100644 npc/trace/main.cpp diff --git a/.gitignore b/.gitignore index 0481b99..285397f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ !.gitignore !init.sh /fceux-am +/nvboard diff --git a/npc/Makefile b/npc/Makefile index 4910019..a5b768d 100644 --- a/npc/Makefile +++ b/npc/Makefile @@ -1,9 +1,13 @@ VSRC := $(wildcard vsrc/*.v) CPPSRC := $(addprefix $(PWD)/,$(wildcard csrc/*.cpp)) +CPPSRC += $(SRC_AUTO_BIND) +NXDC_FILES = $(abspath constr/top.nxdc) + PREFIX ?= build OBJDIR := $(PREFIX)/obj SUBMAKE := $(OBJDIR)/Vexample.mk VERILATOR_FLAGS := --cc --exe +NVBOARD_HOME ?= $(abspath ../nvboard) all: sim @@ -18,11 +22,17 @@ $(OBJDIR)/Vexample: $(SUBMAKE) $(MAKE) -C $(OBJDIR) -f $(notdir $(SUBMAKE)) Vexample $(SUBMAKE): $(VSRC) $(CPPSRC) $(OBJDIR) - verilator $(VERILATOR_FLAGS) --Mdir $(PWD)/$(OBJDIR) $(VSRC) $(CPPSRC) + verilator $(VERILATOR_FLAGS) \ + --Mdir $(abspath $(OBJDIR)) $(VSRC) $(CPPSRC) +# $(addprefix -CFLAGS , $(CXXFLAGS)) $(addprefix -LDFLAGS , $(LDFLAGS)) \ $(OBJDIR): mkdir -p $(OBJDIR) +SRC_AUTO_BIND = $(abspath $(PREFIX)/auto_bind.cpp) +$(SRC_AUTO_BIND): $(NXDC_FILES) + python3 $(NVBOARD_HOME)/scripts/auto_pin_bind.py $^ $@ + include ../Makefile .PHONY: clean diff --git a/npc/flake.nix b/npc/flake.nix index 3c5c8af..f938820 100644 --- a/npc/flake.nix +++ b/npc/flake.nix @@ -14,7 +14,14 @@ gtkwave gcc bear + clang-tools + rnix-lsp ]; + + nativeBuildInputs = with pkgs; [ + python3 + ]; + shellHook = '' export NEMU_HOME=/home/xin/repo/ysyx-workbench/nemu ''; diff --git a/npc/trace/main.cpp b/npc/trace/main.cpp deleted file mode 100644 index a62b9be..0000000 --- a/npc/trace/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#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