-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
target: Improve reusability of Questa Make targets
- Loading branch information
Showing
3 changed files
with
61 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ LOGS_DIR ?= logs | |
TB_DIR ?= $(SNITCH_ROOT)/target/common/test | ||
UTIL_DIR ?= $(SNITCH_ROOT)/util | ||
|
||
# Files | ||
BENDER_LOCK ?= $(ROOT)/Bender.lock | ||
|
||
# SEPP packages | ||
QUESTA_SEPP ?= | ||
VCS_SEPP ?= | ||
|
@@ -165,40 +168,6 @@ define VERILATE | |
touch $@ | ||
endef | ||
|
||
############ | ||
# Modelsim # | ||
############ | ||
|
||
$(VSIM_BUILDDIR): | ||
mkdir -p $@ | ||
|
||
# Expects vlog/vcom script in $< (e.g. as output by bender) | ||
# Expects the top module name in $1 | ||
# Produces a binary used to run the simulation at the path specified by $@ | ||
define QUESTASIM | ||
${VSIM} -c -do "source $<; quit" | tee $(dir $<)vlog.log | ||
@! grep -P "Errors: [1-9]*," $(dir $<)vlog.log | ||
$(VOPT) $(VOPT_FLAGS) -work $(VSIM_BUILDDIR) $1 -o $(1)_opt | tee $(dir $<)vopt.log | ||
@! grep -P "Errors: [1-9]*," $(dir $<)vopt.log | ||
@mkdir -p $(dir $@) | ||
@echo "#!/bin/bash" > $@ | ||
@echo 'binary=$$(realpath $$1)' >> $@ | ||
@echo 'mkdir -p $(LOGS_DIR)' >> $@ | ||
@echo 'echo $$binary > $(LOGS_DIR)/.rtlbinary' >> $@ | ||
@echo '${VSIM} +permissive ${VSIM_FLAGS} $$3 -work ${MKFILE_DIR}/${VSIM_BUILDDIR} -c \ | ||
-ldflags "-Wl,-rpath,${FESVR}/lib -L${FESVR}/lib -lfesvr -lutil" \ | ||
$(1)_opt +permissive-off ++$$binary ++$$2' >> $@ | ||
@chmod +x $@ | ||
@echo "#!/bin/bash" > [email protected] | ||
@echo 'binary=$$(realpath $$1)' >> $@.gui | ||
@echo 'mkdir -p $(LOGS_DIR)' >> $@.gui | ||
@echo 'echo $$binary > $(LOGS_DIR)/.rtlbinary' >> $@.gui | ||
@echo '${VSIM} +permissive ${VSIM_FLAGS} -work ${MKFILE_DIR}/${VSIM_BUILDDIR} \ | ||
-ldflags "-Wl,-rpath,${FESVR}/lib -L${FESVR}/lib -lfesvr -lutil" \ | ||
$(1)_opt +permissive-off ++$$binary ++$$2' >> $@.gui | ||
@chmod +x $@.gui | ||
endef | ||
|
||
####### | ||
# VCS # | ||
####### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2024 ETH Zurich and University of Bologna. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
$(VSIM_BUILDDIR): | ||
mkdir -p $@ | ||
|
||
$(VSIM_BUILDDIR)/compile.vsim.tcl: $(BENDER_LOCK) | $(VSIM_BUILDDIR) | ||
$(VLIB) $(dir $@) | ||
$(BENDER) script vsim $(VSIM_BENDER) --vlog-arg="$(VLOG_FLAGS) -work $(dir $@) " > $@ | ||
echo '$(VLOG) -work $(dir $@) $(TB_CC_SOURCES) -vv -ccflags "$(TB_CC_FLAGS)"' >> $@ | ||
echo 'return 0' >> $@ | ||
|
||
$(BIN_DIR): | ||
mkdir -p $@ | ||
|
||
# Build compilation script and compile all sources for Questasim simulation | ||
$(BIN_DIR)/$(TARGET).vsim: $(VSIM_BUILDDIR)/compile.vsim.tcl $(VSIM_SOURCES) $(TB_SRCS) $(TB_CC_SOURCES) work/lib/libfesvr.a | $(BIN_DIR) | ||
$(VSIM) -c -do "source $<; quit" | tee $(dir $<)vlog.log | ||
@! grep -P "Errors: [1-9]*," $(dir $<)vlog.log | ||
$(VOPT) $(VOPT_FLAGS) -work $(VSIM_BUILDDIR) tb_bin -o tb_bin_opt | tee $(dir $<)vopt.log | ||
@! grep -P "Errors: [1-9]*," $(dir $<)vopt.log | ||
@echo "#!/bin/bash" > $@ | ||
@echo 'binary=$$(realpath $$1)' >> $@ | ||
@echo 'mkdir -p $(LOGS_DIR)' >> $@ | ||
@echo 'echo $$binary > $(LOGS_DIR)/.rtlbinary' >> $@ | ||
@echo '$(VSIM) +permissive $(VSIM_FLAGS) $$3 -work $(MKFILE_DIR)/$(VSIM_BUILDDIR) -c \ | ||
-ldflags "-Wl,-rpath,$(FESVR)/lib -L$(FESVR)/lib -lfesvr -lutil" \ | ||
tb_bin_opt +permissive-off ++$$binary ++$$2' >> $@ | ||
@chmod +x $@ | ||
@echo "#!/bin/bash" > $@.gui | ||
@echo 'binary=$$(realpath $$1)' >> $@.gui | ||
@echo 'mkdir -p $(LOGS_DIR)' >> $@.gui | ||
@echo 'echo $$binary > $(LOGS_DIR)/.rtlbinary' >> $@.gui | ||
@echo '$(VSIM) +permissive $(VSIM_FLAGS) -work $(MKFILE_DIR)/$(VSIM_BUILDDIR) \ | ||
-ldflags "-Wl,-rpath,$(FESVR)/lib -L$(FESVR)/lib -lfesvr -lutil" \ | ||
tb_bin_opt +permissive-off ++$$binary ++$$2' >> [email protected] | ||
@chmod +x $@.gui | ||
|
||
# Clean all build directories and temporary files for Questasim simulation | ||
.PHONY: clean-vsim | ||
clean-vsim: clean-work | ||
rm -rf $(BIN_DIR)/$(TARGET).vsim $(BIN_DIR)/$(TARGET).vsim.gui $(VSIM_BUILDDIR) vsim.wlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters