From fa97359516670693e2c9c1fb1c339631a2c6bbae Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Fri, 21 Aug 2020 16:14:07 -0700 Subject: [PATCH 1/3] Cleanup VCS's csrc directory | Fix small doc typo --- docs/Simulation/Software-RTL-Simulation.rst | 2 +- sims/vcs/Makefile | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/Simulation/Software-RTL-Simulation.rst b/docs/Simulation/Software-RTL-Simulation.rst index 32164f6d..d952c62c 100644 --- a/docs/Simulation/Software-RTL-Simulation.rst +++ b/docs/Simulation/Software-RTL-Simulation.rst @@ -195,5 +195,5 @@ When building the verilator simulator there are some additional options: The ``VERILATOR_THREADS=`` option enables the compiled Verilator simulator to use ```` parallel threads. On a multi-socket machine, you will want to make sure all threads are on the same socket by using ``NUMACTL=1`` to enable ``numactl``. -By enabling this, you will use CHipyard's ``numa_prefix`` wrapper, which is a simple wrapper around ``numactl`` that runs your verilated simulator like this: ``$(numa_prefix) ./simulator- ``. +By enabling this, you will use Chipyard's ``numa_prefix`` wrapper, which is a simple wrapper around ``numactl`` that runs your verilated simulator like this: ``$(numa_prefix) ./simulator- ``. Note that both these flags are mutually exclusive, you can use either independently (though it makes sense to use ``NUMACTL`` just with ``VERILATOR_THREADS=8`` during a Verilator simulation). diff --git a/sims/vcs/Makefile b/sims/vcs/Makefile index a2896380..2c44ae6e 100644 --- a/sims/vcs/Makefile +++ b/sims/vcs/Makefile @@ -43,14 +43,22 @@ VCS = vcs -full64 VCS_OPTS = $(VCS_CC_OPTS) $(VCS_NONCC_OPTS) $(PREPROC_DEFINES) +######################################################################################### +# vcs build paths +######################################################################################### +model_dir = $(build_dir)/$(long_name) +model_dir_debug = $(build_dir)/$(long_name).debug + ######################################################################################### # vcs simulator rules ######################################################################################### $(sim): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib) $(EXTRA_SIM_REQS) - rm -rf csrc && $(VCS) $(VCS_OPTS) $(EXTRA_SIM_SOURCES) -o $@ + rm -rf $(model_dir) + $(VCS) $(VCS_OPTS) $(EXTRA_SIM_SOURCES) -o $@ -Mdir=$(model_dir) $(sim_debug): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib) $(EXTRA_SIM_REQS) - rm -rf csrc && $(VCS) $(VCS_OPTS) $(EXTRA_SIM_SOURCES) -o $@ \ + rm -rf $(model_dir_debug) + $(VCS) $(VCS_OPTS) $(EXTRA_SIM_SOURCES) -o $@ -Mdir=$(model_dir_debug) \ +define+DEBUG ######################################################################################### @@ -65,10 +73,10 @@ $(output_dir)/%.vpd: $(output_dir)/% $(sim_debug) ######################################################################################### .PHONY: clean clean-sim clean-sim-debug clean: - rm -rf $(gen_dir) csrc $(sim_prefix)-* ucli.key vc_hdrs.h + rm -rf $(gen_dir) $(sim_prefix)-* ucli.key clean-sim: - rm -rf csrc/ $(sim) ucli.key vc_hdrs.h + rm -rf $(model_dir) $(build_dir)/vc_hdrs.h $(sim) $(sim).daidir ucli.key clean-sim-debug: - rm -rf csrc/ $(sim_debug) ucli.key vc_hdrs.h + rm -rf $(model_dir_debug) $(build_dir)/vc_hdrs.h $(sim_debug) $(sim_debug).daidir ucli.key From 06747e6cffa6beec1b573d7da28735041e7def55 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Fri, 21 Aug 2020 17:27:50 -0700 Subject: [PATCH 2/3] Dedup simulation flags --- sims/common-sim-flags.mk | 24 ++++++++++++++++++++++++ sims/verilator/Makefile | 24 ++++-------------------- vcs.mk | 21 +++------------------ 3 files changed, 31 insertions(+), 38 deletions(-) create mode 100644 sims/common-sim-flags.mk diff --git a/sims/common-sim-flags.mk b/sims/common-sim-flags.mk new file mode 100644 index 00000000..1c73a510 --- /dev/null +++ b/sims/common-sim-flags.mk @@ -0,0 +1,24 @@ +#---------------------------------------------------------------------------------------- +# common gcc configuration/optimization +#---------------------------------------------------------------------------------------- +SIM_OPT_CXXFLAGS := -O3 + +SIM_CXXFLAGS = \ + $(CXXFLAGS) \ + $(SIM_OPT_CXXFLAGS) \ + -std=c++11 \ + -I$(RISCV)/include \ + -I$(dramsim_dir) \ + -I$(build_dir) \ + $(EXTRA_SIM_CXXFLAGS) + +SIM_LDFLAGS = \ + $(LDFLAGS) \ + -L$(RISCV)/lib \ + -Wl,-rpath,$(RISCV)/lib \ + -L$(sim_dir) \ + -L$(dramsim_dir) \ + -lfesvr \ + -lpthread \ + -ldramsim \ + $(EXTRA_SIM_LDFLAGS) diff --git a/sims/verilator/Makefile b/sims/verilator/Makefile index 3cc7c18b..211b5676 100644 --- a/sims/verilator/Makefile +++ b/sims/verilator/Makefile @@ -141,35 +141,19 @@ VERILATOR_NONCC_OPTS = \ #---------------------------------------------------------------------------------------- # gcc configuration/optimization #---------------------------------------------------------------------------------------- -# -flto slows down compilation on small-memory and breaks on firesim-manager -CXX_OPT_FLAGS := -O3 +include $(base_dir)/sims/common-sim-flags.mk VERILATOR_CXXFLAGS = \ - $(CXXFLAGS) \ + $(SIM_CXXFLAGS) \ $(RUNTIME_PROFILING_CFLAGS) \ $(TRACING_CFLAGS) \ - $(CXX_OPT_FLAGS) \ - -std=c++11 \ -D__STDC_FORMAT_MACROS \ -DTEST_HARNESS=V$(VLOG_MODEL) \ -DVERILATOR \ - -I$(RISCV)/include \ - -I$(dramsim_dir) \ - -I$(build_dir) \ -include $(build_dir)/$(long_name).plusArgs \ - -include $(build_dir)/verilator.h \ - $(EXTRA_SIM_CXXFLAGS) + -include $(build_dir)/verilator.h -VERILATOR_LDFLAGS = \ - $(LDFLAGS) \ - -L$(RISCV)/lib \ - -Wl,-rpath,$(RISCV)/lib \ - -L$(sim_dir) \ - -L$(dramsim_dir) \ - -lfesvr \ - -lpthread \ - -ldramsim \ - $(EXTRA_SIM_LDFLAGS) +VERILATOR_LDFLAGS = $(SIM_LDFLAGS) VERILATOR_CC_OPTS = \ -CFLAGS "$(VERILATOR_CXXFLAGS)" \ diff --git a/vcs.mk b/vcs.mk index a282aa44..c3ba6da6 100644 --- a/vcs.mk +++ b/vcs.mk @@ -14,25 +14,10 @@ RESET_DELAY ?= 777.7 #---------------------------------------------------------------------------------------- # gcc configuration/optimization #---------------------------------------------------------------------------------------- -CXX_OPT_FLAGS := -O3 +include $(base_dir)/sims/common-sim-flags.mk -VCS_CXXFLAGS = \ - $(CXXFLAGS) \ - $(CXX_OPT_FLAGS) \ - -I$(RISCV)/include \ - -I$(dramsim_dir) \ - -std=c++11 \ - $(EXTRA_SIM_CXXFLAGS) - -VCS_LDFLAGS = \ - $(LDFLAGS) \ - -L$(RISCV)/lib \ - -Wl,-rpath,$(RISCV)/lib \ - -L$(sim_dir) \ - -L$(dramsim_dir) \ - -lfesvr \ - -ldramsim \ - $(EXTRA_SIM_LDFLAGS) +VCS_CXXFLAGS = $(SIM_CXXFLAGS) +VCS_LDFLAGS = $(SIM_LDFLAGS) # vcs requires LDFLAGS to not include library names (i.e. -l needs to be separate) VCS_CC_OPTS = \ From 03457bf9348b6c5a6b423c55e953bf245c4c5d68 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Fri, 21 Aug 2020 17:44:29 -0700 Subject: [PATCH 3/3] Remove unneeded libpthread in simulations --- sims/common-sim-flags.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/sims/common-sim-flags.mk b/sims/common-sim-flags.mk index 1c73a510..766dd0d3 100644 --- a/sims/common-sim-flags.mk +++ b/sims/common-sim-flags.mk @@ -19,6 +19,5 @@ SIM_LDFLAGS = \ -L$(sim_dir) \ -L$(dramsim_dir) \ -lfesvr \ - -lpthread \ -ldramsim \ $(EXTRA_SIM_LDFLAGS)