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