rm split-bb-files.py
This commit is contained in:
10
common.mk
10
common.mk
@@ -249,14 +249,6 @@ $(TOP_MODS_FILELIST) $(MODEL_MODS_FILELIST) $(ALL_MODS_FILELIST) $(BB_MODS_FILEL
|
|||||||
$(SED) -i 's/\.\///' $(BB_MODS_FILELIST)
|
$(SED) -i 's/\.\///' $(BB_MODS_FILELIST)
|
||||||
sort -u $(TOP_MODS_FILELIST) $(MODEL_MODS_FILELIST) $(BB_MODS_FILELIST) > $(ALL_MODS_FILELIST)
|
sort -u $(TOP_MODS_FILELIST) $(MODEL_MODS_FILELIST) $(BB_MODS_FILELIST) > $(ALL_MODS_FILELIST)
|
||||||
|
|
||||||
$(TOP_BB_MODS_FILELIST) $(MODEL_BB_MODS_FILELIST) &: $(BB_MODS_FILELIST) $(MFC_TOP_HRCHY_JSON) $(FINAL_ANNO_FILE)
|
|
||||||
$(base_dir)/scripts/split-bb-files.py \
|
|
||||||
--in-bb-f $(BB_MODS_FILELIST) \
|
|
||||||
--in-top-hrchy-json $(MFC_TOP_HRCHY_JSON) \
|
|
||||||
--in-anno-json $(FINAL_ANNO_FILE) \
|
|
||||||
--out-top-bb-f $(TOP_BB_MODS_FILELIST) \
|
|
||||||
--out-model-bb-f $(MODEL_BB_MODS_FILELIST)
|
|
||||||
|
|
||||||
$(TOP_SMEMS_CONF) $(MODEL_SMEMS_CONF) &: $(MFC_SMEMS_CONF) $(MFC_MODEL_HRCHY_JSON_UNIQUIFIED)
|
$(TOP_SMEMS_CONF) $(MODEL_SMEMS_CONF) &: $(MFC_SMEMS_CONF) $(MFC_MODEL_HRCHY_JSON_UNIQUIFIED)
|
||||||
$(base_dir)/scripts/split-mems-conf.py \
|
$(base_dir)/scripts/split-mems-conf.py \
|
||||||
--in-smems-conf $(MFC_SMEMS_CONF) \
|
--in-smems-conf $(MFC_SMEMS_CONF) \
|
||||||
@@ -280,7 +272,7 @@ $(MODEL_SMEMS_FILE) $(MODEL_SMEMS_FIR) &: $(MODEL_SMEMS_CONF) | $(TOP_SMEMS_FILE
|
|||||||
# note: {MODEL,TOP}_BB_MODS_FILELIST is added as a req. so that the files get generated,
|
# 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
|
# 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) $(TOP_BB_MODS_FILELIST) $(MODEL_BB_MODS_FILELIST)
|
$(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\)$$' > $@
|
sort -u $(sim_files) $(ALL_MODS_FILELIST) | grep -v '.*\.\(svh\|h\)$$' > $@
|
||||||
echo "$(TOP_SMEMS_FILE)" >> $@
|
echo "$(TOP_SMEMS_FILE)" >> $@
|
||||||
echo "$(MODEL_SMEMS_FILE)" >> $@
|
echo "$(MODEL_SMEMS_FILE)" >> $@
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import json
|
|
||||||
import argparse
|
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
# Schema of *.f emitted by circt
|
|
||||||
"""
|
|
||||||
<gen-src-dir>/<long-name>/gen-collateral/SimUART.cc
|
|
||||||
<gen-src-dir>/<long-name>/gen-collateral/AsyncQueueSource.sv
|
|
||||||
<gen-src-dir>/<long-name>/gen-collateral/AsyncQueueSink.sv
|
|
||||||
<gen-src-dir>/<long-name>/gen-collateral/AsyncQueueSource_1.sv
|
|
||||||
<gen-src-dir>/<long-name>/gen-collateral/AsyncQueueSink_1.sv
|
|
||||||
<gen-src-dir>/<long-name>/gen-collateral/AsyncQueueSource_2.sv
|
|
||||||
<gen-src-dir>/<long-name>/gen-collateral/AsyncQueueSink_2.sv
|
|
||||||
<gen-src-dir>/<long-name>/gen-collateral/AsyncResetSynchronizerShiftReg_w4_d3_i0.sv
|
|
||||||
"""
|
|
||||||
|
|
||||||
def bfs_collect_submodules(tree):
|
|
||||||
output = set()
|
|
||||||
q = [(tree['instance_name'], tree['module_name'], tree['instances'])]
|
|
||||||
|
|
||||||
while len(q) != 0:
|
|
||||||
front = q[0]
|
|
||||||
q.pop(0)
|
|
||||||
|
|
||||||
(inst, mod, child) = front
|
|
||||||
output.add(mod)
|
|
||||||
for c in child:
|
|
||||||
q.append((c['instance_name'], c['module_name'], c['instances']))
|
|
||||||
return output
|
|
||||||
|
|
||||||
def write_lines_to_file(lines, file_path):
|
|
||||||
with open(file_path, "w") as fp:
|
|
||||||
for line in lines:
|
|
||||||
fp.write("%s\n" % line)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = argparse.ArgumentParser(description='Create *.model.bb.f and *.top.bb.f blackbox filelists')
|
|
||||||
parser.add_argument('--in-bb-f', type=str, required=True, help='All blackbox files filelist (includes both MODEL/TOP files)')
|
|
||||||
parser.add_argument('--in-top-hrchy-json', type=str, required=True, help='List containing hierarchy of top modules (top-module-hierarchy.json)')
|
|
||||||
parser.add_argument('--in-anno-json', type=str, required=True, help='Anno. file with blackbox annotations')
|
|
||||||
parser.add_argument('--out-top-bb-f', type=str, required=True, help='List of blackbox files for TOP')
|
|
||||||
parser.add_argument('--out-model-bb-f', type=str, required=True, help='List of blackbox files for MODEL')
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# module_path -> list of bb paths (not fully resolved paths)
|
|
||||||
mod_bb_dict = defaultdict(list)
|
|
||||||
with open(args.in_anno_json, "r") as f:
|
|
||||||
anno_data = json.load(f)
|
|
||||||
for anno in anno_data:
|
|
||||||
if 'BlackBoxInlineAnno' in anno['class']:
|
|
||||||
mod_bb_dict[anno['target']].append(anno['name'])
|
|
||||||
if 'BlackBoxPathAnno' in anno['class']:
|
|
||||||
mod_bb_dict[anno['target']].append(anno['path'])
|
|
||||||
|
|
||||||
with open(args.in_top_hrchy_json) as ihj:
|
|
||||||
ihj_data = json.load(ihj)
|
|
||||||
top_inner_modules = bfs_collect_submodules(ihj_data)
|
|
||||||
|
|
||||||
with open(args.in_bb_f) as ibf:
|
|
||||||
lines = ibf.read().splitlines()
|
|
||||||
|
|
||||||
tbfs = set()
|
|
||||||
for mod_path, bb_files in mod_bb_dict.items():
|
|
||||||
leaf_mod = mod_path.split('.')[-1]
|
|
||||||
|
|
||||||
# if matched, add the fully resolved path to the top bb filelist
|
|
||||||
if leaf_mod in top_inner_modules:
|
|
||||||
for line in lines:
|
|
||||||
for bb_file in bb_files:
|
|
||||||
if bb_file in line:
|
|
||||||
tbfs.add(line)
|
|
||||||
|
|
||||||
# now tbfs should be complete (need to remove tbf files from original bb file for model bb)
|
|
||||||
mbfs = set()
|
|
||||||
for line in lines:
|
|
||||||
if not line in tbfs:
|
|
||||||
mbfs.add(line)
|
|
||||||
|
|
||||||
write_lines_to_file(tbfs, args.out_top_bb_f)
|
|
||||||
write_lines_to_file(mbfs, args.out_model_bb_f)
|
|
||||||
@@ -54,14 +54,14 @@ def generate_copy(c, sfx):
|
|||||||
bash(f"sed -i s/\"module {cur_name}\"/\"module {new_name}\"/ {new_file}")
|
bash(f"sed -i s/\"module {cur_name}\"/\"module {new_name}\"/ {new_file}")
|
||||||
return new_file
|
return new_file
|
||||||
|
|
||||||
def dfs_update_modules(tree, common_fnames, visited, ext_dict):
|
def dfs_update_modules(tree, common_fnames, visited):
|
||||||
# List of direct submodules to update
|
# List of direct submodules to update
|
||||||
childs_to_update = list()
|
childs_to_update = list()
|
||||||
for child in tree['instances']:
|
for child in tree['instances']:
|
||||||
# We don't have to change stuff that are under the dut
|
# We don't have to change stuff that are under the dut
|
||||||
if (child['module_name'] == args.dut):
|
if (child['module_name'] == args.dut):
|
||||||
continue
|
continue
|
||||||
if dfs_update_modules(child, common_fnames, visited, ext_dict):
|
if dfs_update_modules(child, common_fnames, visited):
|
||||||
childs_to_update.append(child['module_name'])
|
childs_to_update.append(child['module_name'])
|
||||||
if (child['module_name']) in common_fnames:
|
if (child['module_name']) in common_fnames:
|
||||||
child['module_name'] = child['module_name'] + "_" + MODEL_SFX
|
child['module_name'] = child['module_name'] + "_" + MODEL_SFX
|
||||||
@@ -87,7 +87,7 @@ def bfs_update(tree, common_fnames, ext_dict, filelist):
|
|||||||
(inst, mod, child, parent) = front
|
(inst, mod, child, parent) = front
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cur_file = mod + "." + ext_dict[mod]
|
cur_file = mod + "." + ext_dict[mod][0]
|
||||||
except:
|
except:
|
||||||
cur_file = mod + ".sv"
|
cur_file = mod + ".sv"
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ def bfs_update(tree, common_fnames, ext_dict, filelist):
|
|||||||
new_file = generate_copy(cur_file, MODEL_SFX)
|
new_file = generate_copy(cur_file, MODEL_SFX)
|
||||||
filelist.append((mod, new_file))
|
filelist.append((mod, new_file))
|
||||||
if parent is not None and ((parent, mod) not in updated_submodule):
|
if parent is not None and ((parent, mod) not in updated_submodule):
|
||||||
parent_file = os.path.join(args.gcpath, parent + "." + ext_dict[parent])
|
parent_file = os.path.join(args.gcpath, parent + "." + ext_dict[parent][0])
|
||||||
bash(f"sed -i s/\"{mod} \"/\"{mod}_{MODEL_SFX} \"/ {parent_file}")
|
bash(f"sed -i s/\"{mod} \"/\"{mod}_{MODEL_SFX} \"/ {parent_file}")
|
||||||
updated_submodule.add((parent, mod))
|
updated_submodule.add((parent, mod))
|
||||||
mod_updated = True
|
mod_updated = True
|
||||||
@@ -165,6 +165,10 @@ def write_filelist_model(modules, out_file, ext_dict):
|
|||||||
else:
|
else:
|
||||||
df.write(f"{fname}\n")
|
df.write(f"{fname}\n")
|
||||||
|
|
||||||
|
if len(ext_dict[m]) > 1:
|
||||||
|
assert(len(ext_dict[m]) == 2)
|
||||||
|
df.write(f"{args.target_dir}/{m}.{ext_dict[m][1]}\n")
|
||||||
|
|
||||||
def get_file_ext(all_filelist):
|
def get_file_ext(all_filelist):
|
||||||
ext_dict = dict()
|
ext_dict = dict()
|
||||||
with open(all_filelist) as fl:
|
with open(all_filelist) as fl:
|
||||||
@@ -174,7 +178,9 @@ def get_file_ext(all_filelist):
|
|||||||
ext = fname_strip[-1]
|
ext = fname_strip[-1]
|
||||||
fname_strip.pop()
|
fname_strip.pop()
|
||||||
module = ".".join(fname_strip)
|
module = ".".join(fname_strip)
|
||||||
ext_dict[module] = ext
|
if module not in ext_dict.keys():
|
||||||
|
ext_dict[module] = list()
|
||||||
|
ext_dict[module].append(ext)
|
||||||
return ext_dict
|
return ext_dict
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -197,7 +203,7 @@ def main():
|
|||||||
visited = set()
|
visited = set()
|
||||||
filelist = list()
|
filelist = list()
|
||||||
bfs_update(imhj_data, common_modules, ext_dict, filelist)
|
bfs_update(imhj_data, common_modules, ext_dict, filelist)
|
||||||
dfs_update_modules(imhj_data, common_modules, visited, ext_dict)
|
dfs_update_modules(imhj_data, common_modules, visited)
|
||||||
json.dump(imhj_data, out_file, indent=2)
|
json.dump(imhj_data, out_file, indent=2)
|
||||||
write_filelist_model(set(filelist), args.out_model_filelist, ext_dict)
|
write_filelist_model(set(filelist), args.out_model_filelist, ext_dict)
|
||||||
|
|
||||||
|
|||||||
@@ -186,10 +186,6 @@ MODEL_MODS_FILELIST ?= $(build_dir)/$(long_name).model.f
|
|||||||
# list of all blackbox files (may be included in the top/model.f files)
|
# list of all blackbox files (may be included in the top/model.f files)
|
||||||
# this has the build_dir appended
|
# this has the build_dir appended
|
||||||
BB_MODS_FILELIST ?= $(build_dir)/$(long_name).bb.f
|
BB_MODS_FILELIST ?= $(build_dir)/$(long_name).bb.f
|
||||||
# top blackbox module files to include
|
|
||||||
TOP_BB_MODS_FILELIST ?= $(build_dir)/$(long_name).top.bb.f
|
|
||||||
# model blackbox module files to include (not including top blackbox modules)
|
|
||||||
MODEL_BB_MODS_FILELIST ?= $(build_dir)/$(long_name).model.bb.f
|
|
||||||
# all module files to include (top, model, bb included)
|
# all module files to include (top, model, bb included)
|
||||||
ALL_MODS_FILELIST ?= $(build_dir)/$(long_name).all.f
|
ALL_MODS_FILELIST ?= $(build_dir)/$(long_name).all.f
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ VLSI_RTL = $(build_dir)/syn.f
|
|||||||
ifneq ($(CUSTOM_VLOG), )
|
ifneq ($(CUSTOM_VLOG), )
|
||||||
RTL_DEPS = $(CUSTOM_VLOG)
|
RTL_DEPS = $(CUSTOM_VLOG)
|
||||||
else
|
else
|
||||||
RTL_DEPS = $(TOP_MODS_FILELIST) $(TOP_BB_MODS_FILELIST) $(TOP_SMEMS_FILE)
|
RTL_DEPS = $(TOP_MODS_FILELIST) $(TOP_SMEMS_FILE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(VLSI_RTL): $(RTL_DEPS)
|
$(VLSI_RTL): $(RTL_DEPS)
|
||||||
@@ -80,7 +80,7 @@ ifneq ($(CUSTOM_VLOG), )
|
|||||||
> $(VLSI_RTL)
|
> $(VLSI_RTL)
|
||||||
$(foreach file,$^,echo $(file) >> $(VLSI_RTL))
|
$(foreach file,$^,echo $(file) >> $(VLSI_RTL))
|
||||||
else
|
else
|
||||||
cat $(TOP_MODS_FILELIST) $(TOP_BB_MODS_FILELIST) | sort -u > $(VLSI_RTL)
|
cat $(TOP_MODS_FILELIST) | sort -u > $(VLSI_RTL)
|
||||||
echo $(TOP_SMEMS_FILE) >> $(VLSI_RTL)
|
echo $(TOP_SMEMS_FILE) >> $(VLSI_RTL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user