fixes
This commit is contained in:
@@ -248,6 +248,7 @@ $(TOP_MODS_FILELIST) $(MODEL_MODS_FILELIST) $(ALL_MODS_FILELIST) $(BB_MODS_FILEL
|
|||||||
--mod-filelist $(MODEL_MODS_FILELIST) \
|
--mod-filelist $(MODEL_MODS_FILELIST) \
|
||||||
--gen-collateral-path $(GEN_COLLATERAL_DIR) \
|
--gen-collateral-path $(GEN_COLLATERAL_DIR) \
|
||||||
--model-hier-json $(MFC_MODEL_HRCHY_JSON) \
|
--model-hier-json $(MFC_MODEL_HRCHY_JSON) \
|
||||||
|
--out-model-hier-json $(MFC_MODEL_HRCHY_JSON_UNIQUIFIED) \
|
||||||
--dut $(TOP)
|
--dut $(TOP)
|
||||||
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)
|
||||||
|
|
||||||
@@ -259,10 +260,10 @@ $(TOP_BB_MODS_FILELIST) $(MODEL_BB_MODS_FILELIST) &: $(BB_MODS_FILELIST) $(MFC_T
|
|||||||
--out-top-bb-f $(TOP_BB_MODS_FILELIST) \
|
--out-top-bb-f $(TOP_BB_MODS_FILELIST) \
|
||||||
--out-model-bb-f $(MODEL_BB_MODS_FILELIST)
|
--out-model-bb-f $(MODEL_BB_MODS_FILELIST)
|
||||||
|
|
||||||
$(TOP_SMEMS_CONF) $(MODEL_SMEMS_CONF) &: $(MFC_SMEMS_CONF) $(MFC_MODEL_HRCHY_JSON)
|
$(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) \
|
||||||
--in-model-hrchy-json $(MFC_MODEL_HRCHY_JSON) \
|
--in-model-hrchy-json $(MFC_MODEL_HRCHY_JSON_UNIQUIFIED) \
|
||||||
--dut-module-name $(TOP) \
|
--dut-module-name $(TOP) \
|
||||||
--model-module-name $(MODEL) \
|
--model-module-name $(MODEL) \
|
||||||
--out-dut-smems-conf $(TOP_SMEMS_CONF) \
|
--out-dut-smems-conf $(TOP_SMEMS_CONF) \
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import argparse
|
|||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
import sh
|
import sh
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="")
|
parser = argparse.ArgumentParser(description="")
|
||||||
@@ -13,28 +13,35 @@ parser.add_argument("--top-filelist", type=str, required=True, help="Abs path to
|
|||||||
parser.add_argument("--mod-filelist", type=str, required=True, help="Abs path to <top>.<model>.model.f")
|
parser.add_argument("--mod-filelist", type=str, required=True, help="Abs path to <top>.<model>.model.f")
|
||||||
parser.add_argument("--gen-collateral-path", dest="gcpath", type=str, required=True, help="Abs path to the gen-collateral directory")
|
parser.add_argument("--gen-collateral-path", dest="gcpath", type=str, required=True, help="Abs path to the gen-collateral directory")
|
||||||
parser.add_argument("--model-hier-json", type=str, required=True, help="Path to hierarchy JSON emitted by firtool. Must include DUT as a module.")
|
parser.add_argument("--model-hier-json", type=str, required=True, help="Path to hierarchy JSON emitted by firtool. Must include DUT as a module.")
|
||||||
|
parser.add_argument("--out-model-hier-json", type=str, required=True, help="Path to updated hierarchy JSON emitted by this script.")
|
||||||
parser.add_argument('--dut', type=str, required=True, help='Name of the DUT module.')
|
parser.add_argument('--dut', type=str, required=True, help='Name of the DUT module.')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
MODEL_SFX=str(datetime.date.today().year)
|
||||||
|
|
||||||
|
def bash(cmd):
|
||||||
|
fail = os.system(cmd)
|
||||||
|
if fail:
|
||||||
|
print(f'[*] failed to execute {cmd}')
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print(cmd)
|
||||||
|
|
||||||
def get_filelist(filelist):
|
def get_filelist(filelist):
|
||||||
f = open(filelist, "r")
|
|
||||||
lines = f.readlines()
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
fnames = []
|
fnames = []
|
||||||
for line in lines:
|
with open(filelist) as f:
|
||||||
try:
|
lines = f.readlines()
|
||||||
fname = line.split("/")[-1].replace("\n", "")
|
for line in lines:
|
||||||
fnames.append(fname)
|
try:
|
||||||
except:
|
fname = line.split("/")[-1].strip()
|
||||||
print(f"Something is wrong about this line {line}")
|
fnames.append(fname)
|
||||||
|
except:
|
||||||
|
print(f"Something is wrong about this line '{line}'")
|
||||||
return fnames
|
return fnames
|
||||||
|
|
||||||
def update_filelist(cur_file, new_file):
|
def update_filelist(cur_file, new_file):
|
||||||
sh.sed("-i", f"s/\b{cur_file}\b/{new_file}/", os.path.join(args.gcpath, args.mod_filelist))
|
bash(f"echo \"{args.gcpath}/{new_file}\" >> {os.path.join(args.gcpath, args.mod_filelist)}")
|
||||||
|
|
||||||
|
|
||||||
def generate_copy(c, sfx):
|
def generate_copy(c, sfx):
|
||||||
(cur_name, ext) = os.path.splitext(c)
|
(cur_name, ext) = os.path.splitext(c)
|
||||||
@@ -45,23 +52,20 @@ def generate_copy(c, sfx):
|
|||||||
new_file = os.path.join(args.gcpath, new_file)
|
new_file = os.path.join(args.gcpath, new_file)
|
||||||
|
|
||||||
shutil.copy(cur_file, new_file)
|
shutil.copy(cur_file, new_file)
|
||||||
sh.sed("-i", f"s/\b{cur_name}\b/{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, top_fnames):
|
||||||
|
|
||||||
def dfs_update_modules(tree, common_fnames, visited, top_fnames, updated_modules):
|
|
||||||
# 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) or (child['module_name'] in visited):
|
if (child['module_name'] == args.dut) or (child['module_name'] in visited):
|
||||||
continue
|
continue
|
||||||
if dfs_update_modules(child, common_fnames, visited, top_fnames, updated_modules):
|
if dfs_update_modules(child, common_fnames, visited, top_fnames):
|
||||||
childs_to_update.append(child['module_name'])
|
childs_to_update.append(child['module_name'])
|
||||||
if (child['module_name'] + ".sv") in common_fnames:
|
if (child['module_name'] + ".sv") in common_fnames:
|
||||||
child['module_name'] = child['module_name'] + "_Model"
|
child['module_name'] = child['module_name'] + "_" + MODEL_SFX
|
||||||
updated_modules.append(child['module_name'])
|
|
||||||
|
|
||||||
cur_module = tree['module_name']
|
cur_module = tree['module_name']
|
||||||
cur_file = cur_module + ".sv"
|
cur_file = cur_module + ".sv"
|
||||||
@@ -69,7 +73,7 @@ def dfs_update_modules(tree, common_fnames, visited, top_fnames, updated_modules
|
|||||||
|
|
||||||
# cur_file is in the common list, generate a new file
|
# cur_file is in the common list, generate a new file
|
||||||
if cur_file in common_fnames:
|
if cur_file in common_fnames:
|
||||||
new_file = generate_copy(cur_file, "Model")
|
new_file = generate_copy(cur_file, MODEL_SFX)
|
||||||
update_filelist(cur_file, os.path.basename(new_file))
|
update_filelist(cur_file, os.path.basename(new_file))
|
||||||
|
|
||||||
# has some child to update, but new_file wasn't generated
|
# has some child to update, but new_file wasn't generated
|
||||||
@@ -78,29 +82,23 @@ def dfs_update_modules(tree, common_fnames, visited, top_fnames, updated_modules
|
|||||||
|
|
||||||
for submodule_name in childs_to_update:
|
for submodule_name in childs_to_update:
|
||||||
if (submodule_name + ".sv") in common_fnames:
|
if (submodule_name + ".sv") in common_fnames:
|
||||||
sh.sed("-i", f"s/\b{submodule_name}\b/{submodule_name}_Model/", new_file)
|
bash(f"sed -i s/\"{submodule_name}\"/\"{submodule_name}_{MODEL_SFX}\"/ {new_file}")
|
||||||
|
|
||||||
visited.add(cur_module)
|
visited.add(cur_module)
|
||||||
return (new_file is not None)
|
return (new_file is not None)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
top_fnames = set(get_filelist(args.top_filelist))
|
top_fnames = set(get_filelist(args.top_filelist))
|
||||||
mod_fnames = set(get_filelist(args.mod_filelist))
|
mod_fnames = set(get_filelist(args.mod_filelist))
|
||||||
common_fnames = top_fnames.intersection(mod_fnames)
|
common_fnames = top_fnames.intersection(mod_fnames)
|
||||||
|
|
||||||
imhj = open(args.model_hier_json, "r")
|
with open(args.model_hier_json) as imhj:
|
||||||
imhj_data = json.load(imhj)
|
imhj_data = json.load(imhj)
|
||||||
|
|
||||||
visited = set()
|
|
||||||
updated_modules = list()
|
|
||||||
dfs_update_modules(imhj_data, common_fnames, visited, top_fnames, updated_modules)
|
|
||||||
|
|
||||||
out_file = open(args.model_hier_json, "w")
|
|
||||||
json.dump(imhj_data, out_file, indent=2)
|
|
||||||
out_file.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
with open(args.out_model_hier_json, "w+") as out_file:
|
||||||
|
visited = set()
|
||||||
|
dfs_update_modules(imhj_data, common_fnames, visited, top_fnames)
|
||||||
|
json.dump(imhj_data, out_file, indent=2)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ SFC_ANNO_FILE ?= $(build_dir)/$(long_name).sfc.anno.json
|
|||||||
# firtool compiler outputs
|
# firtool compiler outputs
|
||||||
MFC_TOP_HRCHY_JSON ?= $(build_dir)/top_module_hierarchy.json
|
MFC_TOP_HRCHY_JSON ?= $(build_dir)/top_module_hierarchy.json
|
||||||
MFC_MODEL_HRCHY_JSON ?= $(build_dir)/model_module_hierarchy.json
|
MFC_MODEL_HRCHY_JSON ?= $(build_dir)/model_module_hierarchy.json
|
||||||
|
MFC_MODEL_HRCHY_JSON_UNIQUIFIED ?= $(build_dir)/model_module_hierarchy.uniquified.json
|
||||||
MFC_SMEMS_CONF ?= $(build_dir)/$(long_name).mems.conf
|
MFC_SMEMS_CONF ?= $(build_dir)/$(long_name).mems.conf
|
||||||
# hardcoded firtool outputs
|
# hardcoded firtool outputs
|
||||||
MFC_FILELIST = $(GEN_COLLATERAL_DIR)/filelist.f
|
MFC_FILELIST = $(GEN_COLLATERAL_DIR)/filelist.f
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ $(SIM_CONF): $(sim_common_files)
|
|||||||
echo " top_module: $(VLSI_TOP)" >> $@
|
echo " top_module: $(VLSI_TOP)" >> $@
|
||||||
echo " tb_name: ''" >> $@ # don't specify -top
|
echo " tb_name: ''" >> $@ # don't specify -top
|
||||||
echo " input_files:" >> $@
|
echo " input_files:" >> $@
|
||||||
for x in $$(comm -23 <(cat $(MODEL_MODS_FILELIST) $(MODEL_BB_MODS_FILELIST) | sort -u) <(sort $(VLSI_RTL))) $(MODEL_SMEMS_FILE) $(SIM_FILE_REQS); do \
|
for x in $$(cat $(MODEL_MODS_FILELIST) $(MODEL_BB_MODS_FILELIST) | sort -u) $(MODEL_SMEMS_FILE) $(SIM_FILE_REQS); do \
|
||||||
echo ' - "'$$x'"' >> $@; \
|
echo ' - "'$$x'"' >> $@; \
|
||||||
done
|
done
|
||||||
echo " input_files_meta: 'append'" >> $@
|
echo " input_files_meta: 'append'" >> $@
|
||||||
|
|||||||
Reference in New Issue
Block a user