From 65d6a900c373b33cac27a1cc64d8530d1ddc4fca Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Mon, 20 May 2019 16:15:08 -0700 Subject: [PATCH 1/3] rename output | helper rules to run binaries --- common.mk | 6 ++++++ sims/verisim/Makefile | 6 ++++++ sims/vsim/Makefile | 6 ++++++ variables.mk | 8 +++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/common.mk b/common.mk index b1195ee5..2136080b 100644 --- a/common.mk +++ b/common.mk @@ -67,6 +67,12 @@ $(SMEMS_FILE) $(SMEMS_FIR): $(SMEMS_CONF) .PHONY: verilog verilog: $(sim_vsrcs) +######################################################################################### +# helper rules to run simulator +######################################################################################### +run-binary: $(sim) + $(sim) $(PERMISSIVEON) $(SIM_FLAGS) $(PERMISSIVEOFF) $(BINARY) + ######################################################################################### # run assembly/benchmarks rules ######################################################################################### diff --git a/sims/verisim/Makefile b/sims/verisim/Makefile index 0c5644b8..35a36369 100644 --- a/sims/verisim/Makefile +++ b/sims/verisim/Makefile @@ -80,6 +80,12 @@ $(sim): $(model_mk) $(sim_debug): $(model_mk_debug) $(MAKE) VM_PARALLEL_BUILDS=1 -C $(build_dir)/$(long_name).debug -f V$(VLOG_MODEL).mk +######################################################################################### +# helper rules to run simulator with debug +######################################################################################### +run-binary-debug: $(sim_debug) + $(sim_debug) $(SIM_FLAGS) -v$(long_name).vcd $(BINARY) + ######################################################################################### # create a verisim vpd rule ######################################################################################### diff --git a/sims/vsim/Makefile b/sims/vsim/Makefile index 212c3e6f..9931bc03 100644 --- a/sims/vsim/Makefile +++ b/sims/vsim/Makefile @@ -86,6 +86,12 @@ $(sim_debug) : $(sim_vsrcs) $(sim_dotf) rm -rf csrc && $(VCS) $(VCS_OPTS) -o $@ \ +define+DEBUG -debug_pp +######################################################################################### +# helper rules to run simulator with debug +######################################################################################### +run-binary-debug: $(sim_debug) + $(sim_debug) $(PERMISSIVEON) $(SIM_FLAGS) +vcdplusfile=$(long_name).vpd $(PERMISSIVEOFF) $(BINARY) + ######################################################################################### # create a vcs vpd rule ######################################################################################### diff --git a/variables.mk b/variables.mk index 94709245..22efd535 100644 --- a/variables.mk +++ b/variables.mk @@ -138,7 +138,13 @@ SBT ?= java $(JAVA_ARGS) -jar $(ROCKETCHIP_DIR)/sbt-launch.jar ++$(SCALA_VERSION ######################################################################################### # output directory for tests ######################################################################################### -output_dir=$(sim_dir)/output +output_dir=$(sim_dir)/output/$(long_name) + +######################################################################################### +# helper variables to run binaries +######################################################################################### +BINARY ?= none +SIM_FLAGS ?= +verbose ######################################################################################### # build output directory for compilation From 30d54a6851b511b017070619f67141e0fb927e22 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Mon, 20 May 2019 17:12:22 -0700 Subject: [PATCH 2/3] readme addition | pipe out output | renamed output files --- README.md | 10 ++++++++++ common.mk | 2 +- sims/verisim/Makefile | 2 +- sims/vsim/Makefile | 2 +- variables.mk | 3 ++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9e2b31fa..a4ef1c81 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,16 @@ build an alternate configuration. make PROJECT=yourproject CONFIG=YourConfig ./simulator-yourproject-YourConfig ... +Additionally, you can use a helper make rule to run your simulation binary. The output will be in the "verisim" +directory under the file names: `..*` + + # first make your verisim rtl simulator binary + make SUB_PROJECT=example + # then run the binary (with no vcd generation) + make SUB_PROJECT=example BINARY= run-binary + # then run the binary (with vcd generation) + make SUB_PROJECT=example BINARY= run-binary-debug + ## Submodules and Subdirectories The submodules and subdirectories for the project template are organized as diff --git a/common.mk b/common.mk index 2136080b..b6519df0 100644 --- a/common.mk +++ b/common.mk @@ -71,7 +71,7 @@ verilog: $(sim_vsrcs) # helper rules to run simulator ######################################################################################### run-binary: $(sim) - $(sim) $(PERMISSIVEON) $(SIM_FLAGS) $(PERMISSIVEOFF) $(BINARY) + $(sim) $(PERMISSIVEON) $(SIM_FLAGS) $(PERMISSIVEOFF) $(BINARY) 3>&1 1>&2 2>&3 | spike-dasm > $(sim_out_name).out ######################################################################################### # run assembly/benchmarks rules diff --git a/sims/verisim/Makefile b/sims/verisim/Makefile index 35a36369..9264b43f 100644 --- a/sims/verisim/Makefile +++ b/sims/verisim/Makefile @@ -84,7 +84,7 @@ $(sim_debug): $(model_mk_debug) # helper rules to run simulator with debug ######################################################################################### run-binary-debug: $(sim_debug) - $(sim_debug) $(SIM_FLAGS) -v$(long_name).vcd $(BINARY) + $(sim_debug) $(SIM_FLAGS) -v$(sim_out_name).vcd $(BINARY) 3>&1 1>&2 2>&3 | spike-dasm > $(sim_out_name).out ######################################################################################### # create a verisim vpd rule diff --git a/sims/vsim/Makefile b/sims/vsim/Makefile index 9931bc03..a9edcdc5 100644 --- a/sims/vsim/Makefile +++ b/sims/vsim/Makefile @@ -90,7 +90,7 @@ $(sim_debug) : $(sim_vsrcs) $(sim_dotf) # helper rules to run simulator with debug ######################################################################################### run-binary-debug: $(sim_debug) - $(sim_debug) $(PERMISSIVEON) $(SIM_FLAGS) +vcdplusfile=$(long_name).vpd $(PERMISSIVEOFF) $(BINARY) + $(sim_debug) $(PERMISSIVEON) $(SIM_FLAGS) +vcdplusfile=$(sim_out_name).vpd $(PERMISSIVEOFF) $(BINARY) 3>&1 1>&2 2>&3 | spike-dasm > $(sim_out_name).out ######################################################################################### # create a vcs vpd rule diff --git a/variables.mk b/variables.mk index 22efd535..dfc9d9fa 100644 --- a/variables.mk +++ b/variables.mk @@ -143,8 +143,9 @@ output_dir=$(sim_dir)/output/$(long_name) ######################################################################################### # helper variables to run binaries ######################################################################################### -BINARY ?= none +BINARY ?= SIM_FLAGS ?= +verbose +sim_out_name = $(notdir $(basename $(BINARY))).$(long_name) ######################################################################################### # build output directory for compilation From cc0d33ee4dcb6cc2519df2571f52408c6f08578c Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Mon, 20 May 2019 17:19:46 -0700 Subject: [PATCH 3/3] updated permissive naming | small bugfix for vcd/vpd dumping --- common.mk | 6 +++--- sims/verisim/Makefile | 4 ++-- sims/vsim/Makefile | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common.mk b/common.mk index b6519df0..ce5f845c 100644 --- a/common.mk +++ b/common.mk @@ -71,7 +71,7 @@ verilog: $(sim_vsrcs) # helper rules to run simulator ######################################################################################### run-binary: $(sim) - $(sim) $(PERMISSIVEON) $(SIM_FLAGS) $(PERMISSIVEOFF) $(BINARY) 3>&1 1>&2 2>&3 | spike-dasm > $(sim_out_name).out + $(sim) $(PERMISSIVE_ON) $(SIM_FLAGS) $(PERMISSIVE_OFF) $(BINARY) 3>&1 1>&2 2>&3 | spike-dasm > $(sim_out_name).out ######################################################################################### # run assembly/benchmarks rules @@ -81,10 +81,10 @@ $(output_dir)/%: $(RISCV)/riscv64-unknown-elf/share/riscv-tests/isa/% ln -sf $< $@ $(output_dir)/%.run: $(output_dir)/% $(sim) - $(sim) +max-cycles=$(timeout_cycles) $< && touch $@ + $(sim) $(PERMISSIVE_ON) +max-cycles=$(timeout_cycles) $(PERMISSIVE_OFF) $< && touch $@ $(output_dir)/%.out: $(output_dir)/% $(sim) - $(sim) $(PERMISSIVEON) +verbose +max-cycles=$(timeout_cycles) $(PERMISSIVEOFF) $< 3>&1 1>&2 2>&3 | spike-dasm > $@ + $(sim) $(PERMISSIVE_ON) +verbose +max-cycles=$(timeout_cycles) $(PERMISSIVE_OFF) $< 3>&1 1>&2 2>&3 | spike-dasm > $@ ######################################################################################### # include build/project specific makefrags made from the generator diff --git a/sims/verisim/Makefile b/sims/verisim/Makefile index 9264b43f..655d67cc 100644 --- a/sims/verisim/Makefile +++ b/sims/verisim/Makefile @@ -25,8 +25,8 @@ sim_prefix = simulator sim = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG) sim_debug = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG)-debug -PERMISSIVEON= -PERMISSIVEOFF= +PERMISSIVE_ON= +PERMISSIVE_OFF= .PHONY: default debug default: $(sim) diff --git a/sims/vsim/Makefile b/sims/vsim/Makefile index a9edcdc5..d34fb5eb 100644 --- a/sims/vsim/Makefile +++ b/sims/vsim/Makefile @@ -25,8 +25,8 @@ sim_prefix = simv sim = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG) sim_debug = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG)-debug -PERMISSIVEON=+permissive -PERMISSIVEOFF=+permissive-off +PERMISSIVE_ON=+permissive +PERMISSIVE_OFF=+permissive-off .PHONY: default debug default: $(sim) @@ -90,13 +90,13 @@ $(sim_debug) : $(sim_vsrcs) $(sim_dotf) # helper rules to run simulator with debug ######################################################################################### run-binary-debug: $(sim_debug) - $(sim_debug) $(PERMISSIVEON) $(SIM_FLAGS) +vcdplusfile=$(sim_out_name).vpd $(PERMISSIVEOFF) $(BINARY) 3>&1 1>&2 2>&3 | spike-dasm > $(sim_out_name).out + $(sim_debug) $(PERMISSIVE_ON) $(SIM_FLAGS) +vcdplusfile=$(sim_out_name).vpd $(PERMISSIVE_OFF) $(BINARY) 3>&1 1>&2 2>&3 | spike-dasm > $(sim_out_name).out ######################################################################################### # create a vcs vpd rule ######################################################################################### $(output_dir)/%.vpd: $(output_dir)/% $(sim_debug) - $(sim_debug) +vcdplusfile=$@ +max-cycles=$(timeout_cycles) $< + $(sim_debug) $(PERMISSIVE_ON) +vcdplusfile=$@ +max-cycles=$(timeout_cycles) $(PERMISSIVE_OFF) $< ######################################################################################### # general cleanup rule