From d8b2992cb6de130325f3b555037ce96770e4b5b6 Mon Sep 17 00:00:00 2001 From: joonho hwangbo <55655504+joey0320@users.noreply.github.com> Date: Wed, 1 Mar 2023 23:44:05 -0800 Subject: [PATCH] Remove Duplicate Compiler Flags (#1367) * Remove Duplicate Compiler Flags * Cleanup & fixes for MultipleMMIO * bump barstools * Update common.mk * Update common.mk --------- Co-authored-by: Abraham Gonzalez --- common.mk | 32 ++++++++++++++++++++++---------- tools/barstools | 2 +- variables.mk | 2 ++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/common.mk b/common.mk index 18fe519acf..7c4cf6c390 100644 --- a/common.mk +++ b/common.mk @@ -127,10 +127,20 @@ define mfc_extra_anno_contents } ] endef +define sfc_extra_low_transforms_anno_contents +[ + { + "class": "firrtl.stage.RunFirrtlTransformAnnotation", + "transform": "barstools.tapeout.transforms.ExtraLowTransforms" + } +] +endef export mfc_extra_anno_contents -$(FINAL_ANNO_FILE) $(MFC_EXTRA_ANNO_FILE): $(ANNO_FILE) +export sfc_extra_low_transforms_anno_contents +$(EXTRA_ANNO_FILE) $(MFC_EXTRA_ANNO_FILE) $(SFC_EXTRA_ANNO_FILE) &: $(ANNO_FILE) echo "$$mfc_extra_anno_contents" > $(MFC_EXTRA_ANNO_FILE) - jq -s '[.[][]]' $(ANNO_FILE) $(MFC_EXTRA_ANNO_FILE) > $(FINAL_ANNO_FILE) + echo "$$sfc_extra_low_transforms_anno_contents" > $(SFC_EXTRA_ANNO_FILE) + jq -s '[.[][]]' $(ANNO_FILE) $(MFC_EXTRA_ANNO_FILE) > $(EXTRA_ANNO_FILE) .PHONY: firrtl firrtl: $(FIRRTL_FILE) $(FINAL_ANNO_FILE) @@ -150,7 +160,6 @@ SFC_MFC_TARGETS = \ SFC_REPL_SEQ_MEM = --infer-rw --repl-seq-mem -c:$(MODEL):-o:$(SFC_SMEMS_CONF) - # DOC include start: FirrtlCompiler # There are two possible cases for this step. In the first case, SFC # compiles Chisel to CHIRRTL, and MFC compiles CHIRRTL to Verilog. Otherwise, @@ -162,8 +171,7 @@ SFC_REPL_SEQ_MEM = --infer-rw --repl-seq-mem -c:$(MODEL):-o:$(SFC_SMEMS_CONF) # hack: lower to low firrtl if Fixed types are found # hack: when using dontTouch, io.cpu annotations are not removed by SFC, # hence we remove them manually by using jq before passing them to firtool -$(SFC_MFC_TARGETS) &: $(FIRRTL_FILE) $(FINAL_ANNO_FILE) $(VLOG_SOURCES) - rm -rf $(GEN_COLLATERAL_DIR) +$(SFC_LEVEL) $(EXTRA_FIRRTL_OPTIONS) $(FINAL_ANNO_FILE) &: $(FIRRTL_FILE) $(EXTRA_ANNO_FILE) $(SFC_EXTRA_ANNO_FILE) ifeq (,$(ENABLE_CUSTOM_FIRRTL_PASS)) $(eval SFC_LEVEL := $(if $(shell grep "Fixed<" $(FIRRTL_FILE)), low, none)) $(eval EXTRA_FIRRTL_OPTIONS += $(if $(shell grep "Fixed<" $(FIRRTL_FILE)), $(SFC_REPL_SEQ_MEM),)) @@ -171,6 +179,11 @@ else $(eval SFC_LEVEL := low) $(eval EXTRA_FIRRTL_OPTIONS += $(SFC_REPL_SEQ_MEM)) endif + if [ $(SFC_LEVEL) = low ]; then jq -s '[.[][]]' $(EXTRA_ANNO_FILE) $(SFC_EXTRA_ANNO_FILE) > $(FINAL_ANNO_FILE); fi + if [ $(SFC_LEVEL) = none ]; then cat $(EXTRA_ANNO_FILE) > $(FINAL_ANNO_FILE); fi + +$(SFC_MFC_TARGETS) &: $(FIRRTL_FILE) $(FINAL_ANNO_FILE) $(VLOG_SOURCES) $(SFC_LEVEL) $(EXTRA_FIRRTL_OPTIONS) + rm -rf $(GEN_COLLATERAL_DIR) $(call run_scala_main,tapeout,barstools.tapeout.transforms.GenerateModelStageMain,\ --no-dedup \ --output-file $(SFC_FIRRTL_BASENAME) \ @@ -180,13 +193,12 @@ endif --annotation-file $(FINAL_ANNO_FILE) \ --log-level $(FIRRTL_LOGLEVEL) \ --allow-unrecognized-annotations \ - -DX $(SFC_LEVEL) \ -X $(SFC_LEVEL) \ - $(EXTRA_FIRRTL_OPTIONS)) # -X and -DX are duplicates to allow for extra FIRRTL passes to be run + $(EXTRA_FIRRTL_OPTIONS)) -mv $(SFC_FIRRTL_BASENAME).lo.fir $(SFC_FIRRTL_FILE) # Optionally change file type when SFC generates LowFIRRTL - @if [ "$(SFC_LEVEL)" = low ]; then cat $(SFC_ANNO_FILE) | jq 'del(.[] | select(.target | test("io.cpu"))?)' > /tmp/unnec-anno-deleted.sfc.anno.json; fi - @if [ "$(SFC_LEVEL)" = low ]; then cat /tmp/unnec-anno-deleted.sfc.anno.json | jq 'del(.[] | select(.class | test("SRAMAnnotation"))?)' > /tmp/unnec-anno-deleted2.sfc.anno.json; fi - @if [ "$(SFC_LEVEL)" = low ]; then cat /tmp/unnec-anno-deleted2.sfc.anno.json > $(SFC_ANNO_FILE) && rm /tmp/unnec-anno-deleted.sfc.anno.json && rm /tmp/unnec-anno-deleted2.sfc.anno.json; fi + @if [ $(SFC_LEVEL) = low ]; then cat $(SFC_ANNO_FILE) | jq 'del(.[] | select(.target | test("io.cpu"))?)' > /tmp/unnec-anno-deleted.sfc.anno.json; fi + @if [ $(SFC_LEVEL) = low ]; then cat /tmp/unnec-anno-deleted.sfc.anno.json | jq 'del(.[] | select(.class | test("SRAMAnnotation"))?)' > /tmp/unnec-anno-deleted2.sfc.anno.json; fi + @if [ $(SFC_LEVEL) = low ]; then cat /tmp/unnec-anno-deleted2.sfc.anno.json > $(SFC_ANNO_FILE) && rm /tmp/unnec-anno-deleted.sfc.anno.json && rm /tmp/unnec-anno-deleted2.sfc.anno.json; fi firtool \ --format=fir \ --dedup \ diff --git a/tools/barstools b/tools/barstools index 9760528f1d..30900965f0 160000 --- a/tools/barstools +++ b/tools/barstools @@ -1 +1 @@ -Subproject commit 9760528f1de2b1a52a11476e76d25909b31d1def +Subproject commit 30900965f0cc2d5046e2160dd9c700805a8e0542 diff --git a/variables.mk b/variables.mk index 1312cbe387..a89d23a0f4 100644 --- a/variables.mk +++ b/variables.mk @@ -146,6 +146,7 @@ endif # chisel generated outputs FIRRTL_FILE ?= $(build_dir)/$(long_name).fir ANNO_FILE ?= $(build_dir)/$(long_name).anno.json +EXTRA_ANNO_FILE ?= $(build_dir)/$(long_name).extra.anno.json # chisel anno modification output MFC_EXTRA_ANNO_FILE ?= $(build_dir)/$(long_name).extrafirtool.anno.json @@ -154,6 +155,7 @@ FINAL_ANNO_FILE ?= $(build_dir)/$(long_name).appended.anno.json # scala firrtl compiler (sfc) outputs SFC_FIRRTL_BASENAME ?= $(build_dir)/$(long_name).sfc SFC_FIRRTL_FILE ?= $(SFC_FIRRTL_BASENAME).fir +SFC_EXTRA_ANNO_FILE ?= $(build_dir)/$(long_name).extrasfc.anno.json SFC_ANNO_FILE ?= $(build_dir)/$(long_name).sfc.anno.json # firtool compiler outputs