Skip to content

Commit

Permalink
Merge pull request #1832 from ucb-bar/ext-verilog
Browse files Browse the repository at this point in the history
EXT_FILELISTS and EXT_INCDIR APIs for including external verilog projects
  • Loading branch information
jerryz123 authored Mar 21, 2024
2 parents 93c7f73 + 39f28ae commit b4aae0d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
9 changes: 7 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,13 @@ $(MODEL_SMEMS_FILE) $(MODEL_SMEMS_FIR) &: $(TAPEOUT_CLASSPATH_TARGETS) $(MODEL_S
# note: {MODEL,TOP}_BB_MODS_FILELIST is added as a req. so that the files get generated,
# however it is really unneeded since ALL_MODS_FILELIST includes all BB files
########################################################################################
$(sim_common_files): $(sim_files) $(ALL_MODS_FILELIST) $(TOP_SMEMS_FILE) $(MODEL_SMEMS_FILE) $(BB_MODS_FILELIST)
sort -u $(sim_files) $(ALL_MODS_FILELIST) | grep -v '.*\.\(svh\|h\)$$' > $@
$(sim_common_files): $(sim_files) $(ALL_MODS_FILELIST) $(TOP_SMEMS_FILE) $(MODEL_SMEMS_FILE) $(BB_MODS_FILELIST) $(EXT_FILELISTS)
ifneq (,$(EXT_FILELISTS))
cat $(EXT_FILELISTS) > $@
else
rm -f $@
endif
sort -u $(sim_files) $(ALL_MODS_FILELIST) | grep -v '.*\.\(svh\|h\)$$' >> $@
echo "$(TOP_SMEMS_FILE)" >> $@
echo "$(MODEL_SMEMS_FILE)" >> $@

Expand Down
4 changes: 3 additions & 1 deletion scripts/insert-includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ def process(inF, outF):
# for each include found, search through all dirs and replace if found, error if not
for num, line in enumerate(inFile, 1):
match = re.match(r"^ *`include +\"(.*)\"", line)
if match:
if match and match.group(1) != "uvm_macros.svh":
print("[INFO] Replacing includes for {}".format(match.group(1)))
# search for include and replace
found = False
for d in incDirs:
potentialIncFileName = d + "/" + match.group(1)
if os.path.exists(potentialIncFileName):
found = True
print("[INFO] Found missing include in {}".format(potentialIncFileName))
with open(potentialIncFileName, 'r') as incFile:
for iline in incFile:
outFile.write(iline)
Expand Down
4 changes: 3 additions & 1 deletion sims/vcs/vcs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ VCS_NONCC_OPTS = \
-sverilog +systemverilogext+.sv+.svi+.svh+.svt -assert svaext +libext+.sv \
+v2k +verilog2001ext+.v95+.vt+.vp +libext+.v \
-debug_pp \
+incdir+$(GEN_COLLATERAL_DIR)
-top $(TB) \
+incdir+$(GEN_COLLATERAL_DIR) \
$(addprefix +incdir+,$(EXT_INCDIRS))

VCS_PREPROC_DEFINES = \
+define+VCS
Expand Down
1 change: 1 addition & 0 deletions sims/verilator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ VERILATOR_NONCC_OPTS = \
$(VERILATOR_PREPROC_DEFINES) \
--top-module $(TB) \
--vpi \
$(addprefix +incdir+,$(EXT_INCDIRS)) \
-f $(sim_common_files)

#----------------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ BB_MODS_FILELIST ?= $(build_dir)/$(long_name).bb.f
# all module files to include (top, model, bb included)
ALL_MODS_FILELIST ?= $(build_dir)/$(long_name).all.f

# external filelists. Users, or project-supplied make fragments can append filelists
# with absolute paths here
EXT_FILELISTS ?=
# external verilog incdirs. Users, or project-supplied make fragments can append to this
EXT_INCDIRS ?=

BOOTROM_FILES ?= bootrom.rv64.img bootrom.rv32.img
BOOTROM_TARGETS ?= $(addprefix $(build_dir)/, $(BOOTROM_FILES))

Expand Down
5 changes: 4 additions & 1 deletion vlsi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ VLSI_RTL = $(build_dir)/syn.f
ifneq ($(CUSTOM_VLOG), )
RTL_DEPS = $(CUSTOM_VLOG)
else
RTL_DEPS = $(TOP_MODS_FILELIST) $(TOP_SMEMS_FILE)
RTL_DEPS = $(TOP_MODS_FILELIST) $(TOP_SMEMS_FILE) $(EXT_FILELISTS)
endif

$(VLSI_RTL): $(RTL_DEPS)
Expand All @@ -82,6 +82,9 @@ ifneq ($(CUSTOM_VLOG), )
else
cat $(TOP_MODS_FILELIST) | sort -u > $(VLSI_RTL)
echo $(TOP_SMEMS_FILE) >> $(VLSI_RTL)
ifneq ($(EXT_FILELISTS),)
cat $(EXT_FILELISTS) >> $(VLSI_RTL)
endif
endif

#########################################################################################
Expand Down

0 comments on commit b4aae0d

Please sign in to comment.