From 078de512abbacff74efc27706cac46fa465e3de6 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Thu, 2 Nov 2023 17:49:18 -0700 Subject: [PATCH] Bump to firtool 1.58.0 --- common.mk | 2 -- conda-reqs/chipyard.yaml | 2 +- scripts/insert-includes.py | 69 ++++++++++++++++++++++++++------------ 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/common.mk b/common.mk index 95af7725..d5efb31a 100644 --- a/common.mk +++ b/common.mk @@ -248,7 +248,6 @@ $(SFC_MFC_TARGETS) &: $(TAPEOUT_CLASSPATH_TARGETS) $(FIRRTL_FILE) $(FINAL_ANNO_F --format=fir \ --dedup \ --export-module-hierarchy \ - --emit-metadata \ --verify-each=true \ --warn-on-unprocessed-annotations \ --disable-annotation-classless \ @@ -257,7 +256,6 @@ $(SFC_MFC_TARGETS) &: $(TAPEOUT_CLASSPATH_TARGETS) $(FIRRTL_FILE) $(FINAL_ANNO_F --lowering-options=$(shell cat $(MFC_LOWERING_OPTIONS)) \ --repl-seq-mem \ --repl-seq-mem-file=$(MFC_SMEMS_CONF) \ - --repl-seq-mem-circuit=$(MODEL) \ --annotation-file=$(SFC_ANNO_FILE) \ --split-verilog \ -o $(GEN_COLLATERAL_DIR) \ diff --git a/conda-reqs/chipyard.yaml b/conda-reqs/chipyard.yaml index 81a3ea67..1ce28ac0 100644 --- a/conda-reqs/chipyard.yaml +++ b/conda-reqs/chipyard.yaml @@ -29,7 +29,7 @@ dependencies: - conda-gcc-specs - binutils - - firtool==1.30.0 # from ucb-bar channel - https://github.com/ucb-bar/firtool-feedstock + - firtool==1.58.0 # from ucb-bar channel - https://github.com/ucb-bar/firtool-feedstock # misc - autoconf diff --git a/scripts/insert-includes.py b/scripts/insert-includes.py index ed6fed73..8262c251 100755 --- a/scripts/insert-includes.py +++ b/scripts/insert-includes.py @@ -1,6 +1,7 @@ #!/usr/bin/env python -# replaces a `include with the full include file +# replaces a `include with the full include file. +# recursively replaces `include's until none are left # # args # $1 - file to remove includes from @@ -12,6 +13,8 @@ import sys import re import os +import tempfile +import shutil inVlog = sys.argv[1] outVlog = sys.argv[2] @@ -24,28 +27,52 @@ if inVlog == outVlog: incDirs = sys.argv[3:] print("[INFO] Searching following dirs for includes: " + str(incDirs)) -# open file -with open(inVlog, 'r') as inFile: - with open(outVlog, 'w') as outFile: - # for each include found, search through all dirs and replace if found, error if not - for num, line in enumerate(inFile, 1): +def process(inF, outF): + # open file + with open(inF, 'r') as inFile: + with open(outF, 'w') as outFile: + # 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: + # search for include and replace + found = False + for d in incDirs: + potentialIncFileName = d + "/" + match.group(1) + if os.path.exists(potentialIncFileName): + found = True + with open(potentialIncFileName, 'r') as incFile: + for iline in incFile: + outFile.write(iline) + break + + # must find something to include with + if not found: + sys.exit("[ERROR] Couldn't replace include \"" + str(match.group(1)) + "\" found on line " + str(num)) + else: + outFile.write(line) + +inF = inVlog + +while True: + # create a copy of the input + fd, temp_path = tempfile.mkstemp() + shutil.copy2(inF, temp_path) + + with open(temp_path, 'r') as inFile: + anyIncludes = False + for line in inFile: match = re.match(r"^ *`include +\"(.*)\"", line) if match: - # search for include and replace - found = False - for d in incDirs: - potentialIncFileName = d + "/" + match.group(1) - if os.path.exists(potentialIncFileName): - found = True - with open(potentialIncFileName, 'r') as incFile: - for iline in incFile: - outFile.write(iline) - break + anyIncludes = True + break - # must find something to include with - if not found: - sys.exit("[ERROR] Couldn't replace include \"" + str(match.group(1)) + "\" found on line " + str(num)) - else: - outFile.write(line) + if anyIncludes: + process(temp_path, outVlog) + inF = outVlog + os.remove(temp_path) + else: + os.remove(temp_path) + break print("[INFO] Success. Writing output to: " + str(outVlog))