diff --git a/generators/testchipip b/generators/testchipip index 6e8a6842..2d78a045 160000 --- a/generators/testchipip +++ b/generators/testchipip @@ -1 +1 @@ -Subproject commit 6e8a68424216c9a02916af16a15850f40a534a22 +Subproject commit 2d78a045386137de3bfd10d6d970db761a92213a diff --git a/scripts/build-toolchain-extra.sh b/scripts/build-toolchain-extra.sh index 54afe983..0914f23a 100755 --- a/scripts/build-toolchain-extra.sh +++ b/scripts/build-toolchain-extra.sh @@ -111,4 +111,10 @@ if [ $TOOLCHAIN == "riscv-tools" ]; then make -C $RDIR/generators/gemmini/software/libgemmini install fi +echo '==> Installing DRAMSim2 Shared Library' +cd $RDIR +cd tools/DRAMSim2 +make libdramsim.so +cp libdramsim.so $RISCV/lib/ + echo "Extra Toolchain Utilities/Tests Build Complete!" diff --git a/sims/xcelium/Makefile b/sims/xcelium/Makefile new file mode 100644 index 00000000..6604b114 --- /dev/null +++ b/sims/xcelium/Makefile @@ -0,0 +1,141 @@ +######################################################################################### +# xcelium makefile +######################################################################################### + +define CAD_INFO_HEADER +# -------------------------------------------------------------------------------- +# This script was written and developed by Chipyard at UC Berkeley; however, the +# underlying commands and reports are copyrighted by Cadence. We thank Cadence for +# granting permission to share our research to help promote and foster the next +# generation of innovators. +# -------------------------------------------------------------------------------- +endef + +export CAD_INFO_HEADER + +######################################################################################### +# general path variables +######################################################################################### +base_dir=$(abspath ../..) +sim_dir=$(abspath .) + +######################################################################################### +# include shared variables +######################################################################################### +include $(base_dir)/variables.mk + +######################################################################################### +# name of simulator (used to generate *.f arguments file) +######################################################################################### +sim_name = xrun + +######################################################################################### +# vcs simulator types and rules +######################################################################################### +sim_prefix = simx +sim = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG) +sim_debug = $(sim)-debug +sim_workdir = $(sim).xcelium.d +sim_run_tcl = $(sim)_run.tcl +sim_debug_run_tcl = $(sim_debug)_run.tcl + +include $(base_dir)/xcelium.mk + +.PHONY: default debug +default: $(sim) +debug: $(sim_debug) + +######################################################################################### +# simulation requirements +######################################################################################### +SIM_FILE_REQS += \ + $(ROCKETCHIP_RSRCS_DIR)/vsrc/TestDriver.v + +# copy files but ignore *.h files in *.f since xcelium has -Wcxx include +$(sim_files): $(SIM_FILE_REQS) $(ALL_MODS_FILELIST) | $(GEN_COLLATERAL_DIR) + cp -f $(SIM_FILE_REQS) $(GEN_COLLATERAL_DIR) + $(foreach file,\ + $(SIM_FILE_REQS),\ + $(if $(filter %.h,$(file)),\ + ,\ + echo "$(addprefix $(GEN_COLLATERAL_DIR)/, $(notdir $(file)))" >> $@;)) + +######################################################################################### +# import other necessary rules and variables +######################################################################################### +include $(base_dir)/common.mk + +######################################################################################### +# vcs binary and arguments +######################################################################################### +VCS = xrun -64bit -elaborate +#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_workdir): $(sim_common_files) $(dramsim_lib) $(EXTRA_SIM_REQS) + rm -rf $(model_dir) + $(VCS) $(VCS_OPTS) $(EXTRA_SIM_SOURCES) -xmlibdirname $@ + +$(sim_run_tcl): $(sim_workdir) + echo "$$CAD_INFO_HEADER" > $(sim_run_tcl) + echo "run" >> $(sim_run_tcl) + echo "exit" >> $(sim_run_tcl) + +$(sim): $(sim_workdir) $(sim_run_tcl) + echo "#!/usr/bin/env bash" > $(sim) + echo "$$CAD_INFO_HEADER" >> $(sim) + echo "LD_PRELOAD=$(base_dir)/.conda-env/lib/libstdc++.so.6 xrun +verbose +binary=super-awesome-program +permissive -R -xmlibdirname $(sim_workdir) -input $(sim_run_tcl)" >> $(sim) + chmod +x $(sim) + +$(sim_debug_run_tcl): $(sim_workdir) + echo "$$CAD_INFO_HEADER" > $(sim_debug_run_tcl) + echo "database -open default_vcd_dump -vcd -into $(sim_out_name).vcd" >> $(sim_debug_run_tcl) + echo "set probe_packed_limit 64k" >> $(sim_debug_run_tcl) + echo "probe -create $(TB) -database default_vcd_dump -depth all -all" >> $(sim_debug_run_tcl) + echo "run" >> $(sim_debug_run_tcl) + echo "database -close default_vcd_dump" >> $(sim_debug_run_tcl) + echo "exit" >> $(sim_debug_run_tcl) + + +$(sim_debug): $(sim_workdir) $(sim_debug_run_tcl) + echo "#!/usr/bin/env bash" > $(sim_debug) + echo "$$CAD_INFO_HEADER" >> $(sim_debug) + echo "LD_PRELOAD=$(base_dir)/.conda-env/lib/libstdc++.so.6 xrun +verbose +binary=super-awesome-program +permissive -R -xmlibdirname $(sim_workdir) -input $(sim_debug_run_tcl)" >> $(sim_debug) + chmod +x $(sim_debug) + + +######################################################################################### +# create vcs vpd/fsdb rules +######################################################################################### +.PRECIOUS: $(output_dir)/%.vpd %.vpd +$(output_dir)/%.vpd: $(output_dir)/% $(sim_debug) + (set -o pipefail && $(sim_debug) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(SEED_FLAG) $(VERBOSE_FLAGS) +vcdplusfile=$@ $(PERMISSIVE_OFF) $< >(spike-dasm > $<.out) | tee $<.log) + +.PRECIOUS: $(output_dir)/%.fsdb %.fsdb +$(output_dir)/%.fsdb: $(output_dir)/% $(sim_debug) + (set -o pipefail && $(sim_debug) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(SEED_FLAG) $(VERBOSE_FLAGS) +fsdbfile=$@ $(PERMISSIVE_OFF) $< >(spike-dasm > $<.out) | tee $<.log) + + +######################################################################################### +# general cleanup rules +######################################################################################### +.PHONY: clean clean-sim clean-sim-debug +clean: + rm -rf $(gen_dir) $(sim_prefix)-* ucli.key + +clean-sim: + rm -rf $(model_dir) $(build_dir)/vc_hdrs.h $(sim) $(sim).daidir ucli.key + +clean-sim-debug: + rm -rf $(model_dir_debug) $(build_dir)/vc_hdrs.h $(sim_debug) $(sim_debug).daidir ucli.key diff --git a/toolchains/riscv-tools/riscv-isa-sim b/toolchains/riscv-tools/riscv-isa-sim index e7d6aff1..cd0a5dc5 160000 --- a/toolchains/riscv-tools/riscv-isa-sim +++ b/toolchains/riscv-tools/riscv-isa-sim @@ -1 +1 @@ -Subproject commit e7d6aff19a071a059f1b9c2328ee4dac83bc677a +Subproject commit cd0a5dc55090ca8c4be4c7fb2a7937629c0eccb9 diff --git a/xcelium.mk b/xcelium.mk new file mode 100644 index 00000000..92ff34cf --- /dev/null +++ b/xcelium.mk @@ -0,0 +1,77 @@ +HELP_COMPILATION_VARIABLES += \ +" USE_VPD = set to '1' to build VCS simulator to emit VPD instead of FSDB." + +HELP_SIMULATION_VARIABLES += \ +" USE_VPD = set to '1' to run VCS simulator emitting VPD instead of FSDB." + +ifndef USE_VPD +WAVEFORM_FLAG=+fsdbfile=$(sim_out_name).fsdb +else +WAVEFORM_FLAG=+vcdplusfile=$(sim_out_name).vpd +endif + +# If ntb_random_seed unspecified, vcs uses 1 as constant seed. +# Set ntb_random_seed_automatic to actually get a random seed +ifdef RANDOM_SEED +SEED_FLAG=+ntb_random_seed=$(RANDOM_SEED) +else +SEED_FLAG=+ntb_random_seed_automatic +endif + +CLOCK_PERIOD ?= 1.0 +RESET_DELAY ?= 777.7 + +#---------------------------------------------------------------------------------------- +# gcc configuration/optimization +#---------------------------------------------------------------------------------------- +include $(base_dir)/sims/common-sim-flags.mk + + +XC_CXX_PREFIX=-Wcxx, +XC_LD_PREFIX=-Wld, + +REMOVE_RPATH=-Wl,-rpath% + +VCS_CXXFLAGS = $(addprefix $(XC_CXX_PREFIX), $(SIM_CXXFLAGS)) +VCS_LDFLAGS = $(addprefix $(XC_LD_PREFIX), $(filter-out $(REMOVE_RPATH), $(SIM_LDFLAGS))) + +# vcs requires LDFLAGS to not include library names (i.e. -l needs to be separate) +VCS_CC_OPTS = \ + $(VCS_CXXFLAGS) \ + $(VCS_LDFLAGS) \ + -enable_rpath + +#-LDFLAGS "$(filter-out -l%,$(VCS_LDFLAGS))" \ +# $(filter -l%,$(VCS_LDFLAGS)) + +VCS_NONCC_OPTS = \ + -fast_recompilation \ + -top $(TB) \ + -sv \ + -ALLOWREDEFINITION \ + -timescale 1ns/10ps \ + -define INTCNOPWR \ + -define INTC_NO_PWR_PINS \ + -define INTC_EMULATION \ + -f $(sim_common_files) \ + -logfile xrun_elab.log \ + -glsperf \ + -genafile access.txt \ + -notimingchecks \ + -delay_mode zero + +PREPROC_DEFINES = \ + -define VCS \ + -define CLOCK_PERIOD=$(CLOCK_PERIOD) \ + -define RESET_DELAY=$(RESET_DELAY) \ + -define PRINTF_COND=$(TB).printf_cond \ + -define STOP_COND=!$(TB).reset \ + -define MODEL=$(MODEL) \ + -define RANDOMIZE_MEM_INIT \ + -define RANDOMIZE_REG_INIT \ + -define RANDOMIZE_GARBAGE_ASSIGN \ + -define RANDOMIZE_INVALID_ASSIGN + +ifndef USE_VPD +PREPROC_DEFINES += +define+FSDB +endif