Skip to content

Commit

Permalink
addrmap: Improve Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Sep 5, 2023
1 parent bf25aba commit 171f5eb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
1 change: 1 addition & 0 deletions target/sim/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/bin/
/logs/
/addrmap/
/work/
/work-vsim/
/*.log
Expand Down
68 changes: 36 additions & 32 deletions target/sim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ include $(SNITCH_ROOT)/target/common/common.mk

REGGEN ?= $(shell $(BENDER) path register_interface)/vendor/lowrisc_opentitan/util/regtool.py
OCCAMYGEN ?= $(ROOT)/util/occamygen/occamygen.py
ADDRMAPGEN ?= $(ROOT)/util/addrmapgen.py
ADDRMAPGEN ?= $(ROOT)/util/addrmap/addrmapgen.py

CLANG_FORMAT ?= $(shell which clang-format-10.0.1)

Expand All @@ -46,7 +46,9 @@ VLOG = vlog
#########################

PLATFORM_HEADERS_DIR ?= sw/shared/platform/generated
ADDRMAP_DIR ?= addrmap
TARGET_ADDRMAP_DIR ?= $(abspath addrmap)
SOURCE_ADDRMAP_DIR ?= $(ROOT)/util/addrmap
DOCS_DIR ?= $(ROOT)/docs
TARGET_SRC_DIR ?= src
TARGET_PLIC_DIR ?= src/rv_plic
TARGET_CLINT_DIR ?= src/clint
Expand Down Expand Up @@ -365,46 +367,52 @@ $(QUADCTRL_REGGEN_TARGETS): .quadctrl_reggen_targets_group
# Address Map #
###############

ADDRMAP_TARGETS = $(ADDRMAP_DIR)/addrmap.dot
ADDRMAP_TARGETS += $(ADDRMAP_DIR)/addrmap.csv
ADDRMAP_TARGETS += $(ADDRMAP_DIR)/addrmap.tex
ADDRMAP_TARGETS += $(ADDRMAP_DIR)/addrmap.md
ADDRMAP_TARGETS += $(ADDRMAP_DIR)/addrmap.png
ADDRMAP_TARGETS += $(ADDRMAP_DIR)/addrmap.pdf
ADDRMAP_CSV = $(TARGET_ADDRMAP_DIR)/addrmap.csv
ADDRMAP_DOT = $(TARGET_ADDRMAP_DIR)/addrmap.dot
ADDRMAP_TEX = $(TARGET_ADDRMAP_DIR)/addrmap.tex
ADDRMAP_TEX_TPL = $(SOURCE_ADDRMAP_DIR)/addrmap.tex.tpl
ADDRMAP_PNG = $(TARGET_ADDRMAP_DIR)/addrmap.png
ADDRMAP_MD = $(DOCS_DIR)/rm/2_addrmap.md
ADDRMAP_PDF = $(TARGET_ADDRMAP_DIR)/addrmap.pdf

ADDRMAP_TARGETS = $(ADDRMAP_DOT)
ADDRMAP_TARGETS += $(ADDRMAP_CSV)
ADDRMAP_TARGETS += $(ADDRMAP_TEX)
ADDRMAP_TARGETS += $(ADDRMAP_MD)
ADDRMAP_TARGETS += $(ADDRMAP_PNG)
ADDRMAP_TARGETS += $(ADDRMAP_PDF)

.PHONY: addrmap clean-addrmap

# Generate address map in all formats
addrmap: $(ADDRMAP_TARGETS)

clean-addrmap:
rm -rf $(ADDRMAP_TARGETS) .addrmap_occamygen_targets_group
# Delete intermediate Latex outputs
rm -rf addrmap/addrmap.aux
rm -rf addrmap/addrmap.fdb*
rm -rf addrmap/addrmap.fls
rm -rf addrmap/addrmap.log

ADDRMAP_OCCAMYGEN_TARGETS = $(ADDRMAP_DIR)/addrmap.dot $(ADDRMAP_DIR)/addrmap.csv
rm -rf $(TARGET_ADDRMAP_DIR)

$(TARGET_ADDRMAP_DIR):
mkdir $@

ADDRMAP_OCCAMYGEN_TARGETS = $(ADDRMAP_DOT) $(ADDRMAP_CSV)
$(ADDRMAP_OCCAMYGEN_TARGETS): .addrmap_occamygen_targets_group
.addrmap_occamygen_targets_group: $(CFG)
.addrmap_occamygen_targets_group: $(CFG) | $(TARGET_ADDRMAP_DIR)
@echo "[OCCAMYGEN] Generate $(ADDRMAP_OCCAMYGEN_TARGETS)"
@$(OCCAMYGEN) --cfg $(CFG) --outdir $(ADDRMAP_DIR) \
--graph $(ADDRMAP_DIR)/addrmap.dot \
--am-csv $(ADDRMAP_DIR)/addrmap.csv
@$(OCCAMYGEN) --cfg $(CFG) --outdir $(TARGET_ADDRMAP_DIR) \
--graph $(ADDRMAP_DOT) \
--am-csv $(ADDRMAP_CSV)
@touch $@

addrmap.png:
dot -Tpng addrmap/addrmap.dot > addrmap/addrmap.png
$(ADDRMAP_PNG): $(ADDRMAP_DOT) | $(TARGET_ADDRMAP_DIR)
dot -Tpng $(ADDRMAP_DOT) > $(ADDRMAP_PNG)

addrmap.tex:
@$(ADDRMAPGEN) --file addrmap/addrmap.csv --outdir addrmap --tex addrmap/addrmap.tex.tpl
$(ADDRMAP_TEX): $(ADDRMAP_CSV) $(ADDRMAP_TEX_TPL) | $(TARGET_ADDRMAP_DIR)
@$(ADDRMAPGEN) --file $(ADDRMAP_CSV) --outdir $(dir $@) --tex $(ADDRMAP_TEX_TPL)

addrmap.md:
@$(ADDRMAPGEN) --file addrmap/addrmap.csv --outdir docs --md 2_addrmap.md
$(ADDRMAP_MD): $(ADDRMAP_CSV) | $(TARGET_ADDRMAP_DIR)
@$(ADDRMAPGEN) --file $(ADDRMAP_CSV) --outdir $(dir $@) --md $(notdir $@)

addrmap.pdf: addrmap.tex
cd addrmap && latexmk -quiet -pdf addrmap.tex
$(ADDRMAP_PDF): $(ADDRMAP_TEX) | $(TARGET_ADDRMAP_DIR)
cd $(TARGET_ADDRMAP_DIR) && latexmk -quiet -pdf $(notdir $(ADDRMAP_TEX))

############
# Software #
Expand Down Expand Up @@ -595,10 +603,6 @@ help:
@echo -e "${Blue}fpga ${Black}Build a small Occamy version (CVA6 + 1xcluster) for the VCU128 FPGA board."
@echo -e ""
@echo -e "${Blue}addrmap ${Black}Generate the addressmap in the following formats: MD, PNG, TEX, PDF."
@echo -e "${Blue}addrmap.tex ${Black}Generate the TEX addrmap source."
@echo -e "${Blue}addrmap.md ${Black}Generate the MD addrmap graphic."
@echo -e "${Blue}addrmap.png ${Black}Generate the PNG addrmap graphic."
@echo -e "${Blue}addrmap.pdf ${Black}Generate the PDF addrmap graphic."
@echo -e ""
@echo -e "${Blue}clean ${Black}Clean everything except traces in logs directory."
@echo -e "${Blue}clean-bender ${Black}Clean all Bender generated files."
Expand Down

0 comments on commit 171f5eb

Please sign in to comment.