Rename variables | Small fixes | Move out-srcs to new dir

This commit is contained in:
abejgonzalez
2022-10-13 15:39:48 -07:00
committed by joey0320
parent f5914ec9e9
commit 9f2fd22cc0
6 changed files with 133 additions and 115 deletions

View File

@@ -92,7 +92,7 @@ endif
#########################################################################################
# copy over bootrom files
#########################################################################################
$(build_dir):
$(build_dir) $(OUT_DIR):
mkdir -p $@
$(BOOTROM_TARGETS): $(build_dir)/bootrom.%.img: $(TESTCHIP_RSRCS_DIR)/testchipip/bootrom/bootrom.%.img | $(build_dir)
@@ -119,11 +119,11 @@ define firtool_extra_anno_contents
},
{
"class": "sifive.enterprise.firrtl.TestHarnessHierarchyAnnotation",
"filename": "$(FIRTOOL_TB_MOD_HIER_JSON)"
"filename": "$(FIRTOOL_MODEL_HRCHY_JSON)"
},
{
"class": "sifive.enterprise.firrtl.ModuleHierarchyAnnotation",
"filename": "$(FIRTOOL_MOD_HIER_JSON)"
"filename": "$(FIRTOOL_TOP_HRCHY_JSON)"
}
]
endef
@@ -138,7 +138,14 @@ firrtl: $(FIRRTL_FILE) $(FINAL_ANNO_FILE)
#########################################################################################
# create verilog files rules and variables
#########################################################################################
CIRCT_TARGETS = $(FIRTOOL_SMEMS_CONF) $(FIRTOOL_MOD_HIER_JSON) $(FIRTOOL_TB_MOD_HIER_JSON) $(FIRTOOL_SMEMS_JSON) $(FIRTOOL_TB_SMEMS_JSON) $(FIRTOOL_FILELIST) $(FIRTOOL_BB_MODS_FILELIST)
FIRTOOL_TARGETS = \
$(FIRTOOL_SMEMS_CONF) \
$(FIRTOOL_TOP_SMEMS_JSON) \
$(FIRTOOL_TOP_HRCHY_JSON) \
$(FIRTOOL_MODEL_MOD_HRCHY_JSON) \
$(FIRTOOL_MODEL_SMEMS_JSON) \
$(FIRTOOL_FILELIST) \
$(FIRTOOL_BB_MODS_FILELIST)
# DOC include start: FirrtlCompiler
$(TOP_TARGETS) $(HARNESS_TARGETS) &: $(FIRRTL_FILE) $(ANNO_FILE) $(VLOG_SOURCES)
@@ -169,19 +176,19 @@ $(CIRCT_TARGETS): firrtl_temp
@echo "" > /dev/null
# hack: lower to middle firrtl if Fixed types are found
firrtl_temp: $(FIRRTL_FILE) $(FINAL_ANNO_FILE) $(VLOG_SOURCES)
$(FIRTOOL_TARGETS) &: $(FIRRTL_FILE) $(FINAL_ANNO_FILE) $(VLOG_SOURCES)
$(call run_scala_main,tapeout,barstools.tapeout.transforms.GenerateTop,\
--no-dedup \
--output-file $(SFC_FIRRTL_START) \
--output-file $(SFC_FIRRTL_BASENAME) \
--output-annotation-file $(SFC_ANNO_FILE) \
--target-dir $(build_dir) \
--target-dir $(OUT_DIR) \
--input-file $(FIRRTL_FILE) \
--annotation-file $(FINAL_ANNO_FILE) \
--log-level $(FIRRTL_LOGLEVEL) \
--allow-unrecognized-annotations \
-X $(if $(shell grep "Fixed<" $(FIRRTL_FILE)),middle,none) \
$(EXTRA_FIRRTL_OPTIONS))
$(if $(shell grep "Fixed<" $(FIRRTL_FILE)),mv $(SFC_FIRRTL_START).mid.fir $(SFC_FIRRTL_FILE),)
$(if $(shell grep "Fixed<" $(FIRRTL_FILE)),mv $(SFC_FIRRTL_BASENAME).mid.fir $(SFC_FIRRTL_FILE),)
firtool \
--export-module-hierarchy \
--emit-metadata \
@@ -197,30 +204,32 @@ firrtl_temp: $(FIRRTL_FILE) $(FINAL_ANNO_FILE) $(VLOG_SOURCES)
--repl-seq-mem-circuit=$(MODEL) \
--repl-seq-mem-file=$(FIRTOOL_SMEMS_CONF) \
--split-verilog \
-o $(build_dir) \
-o $(OUT_DIR) \
$(SFC_FIRRTL_FILE)
sed -i 's/.*/& /' $(FIRTOOL_SMEMS_CONF) # need trailing space for SFC macrocompiler
# DOC include end: FirrtlCompiler
$(TOP_MODS_FILELIST) $(TB_MODS_FILELIST) $(ALL_MODS_FILELIST) $(BB_MODS_FILELIST) &: $(FIRTOOL_TB_MOD_HIER_JSON) $(FIRTOOL_FILELIST) $(FIRTOOL_BB_MODS_FILELIST)
$(TOP_MODS_FILELIST) $(MODEL_MODS_FILELIST) $(ALL_MODS_FILELIST) $(BB_MODS_FILELIST) &: $(FIRTOOL_MODEL_MOD_HRCHY_JSON) $(FIRTOOL_FILELIST) $(FIRTOOL_BB_MODS_FILELIST)
$(base_dir)/scripts/split-module-files.py \
--tb-hier-json $(FIRTOOL_TB_MOD_HIER_JSON) \
--model-hier-json $(FIRTOOL_MODEL_HRCHY_JSON) \
--dut $(TOP) \
--out-dut-filelist $(TOP_MODS_FILELIST) \
--out-tb-filelist $(TB_MODS_FILELIST) \
--out-model-filelist $(MODEL_MODS_FILELIST) \
--in-all-filelist $(FIRTOOL_FILELIST) \
--build-dir $(build_dir)
cat $(TOP_MODS_FILELIST) $(TB_MODS_FILELIST) > $(ALL_MODS_FILELIST)
sed -i 's/\.\///' $(ALL_MODS_FILELIST)
sed -e 's;^;$(build_dir)/;' $(FIRTOOL_BB_MODS_FILELIST) > $(BB_MODS_FILELIST)
--target-dir $(OUT_DIR)
sed -e 's;^;$(OUT_DIR)/;' $(FIRTOOL_BB_MODS_FILELIST) > $(BB_MODS_FILELIST)
sed -i 's/\.\///' $(TOP_MODS_FILELIST)
sed -i 's/\.\///' $(MODEL_MODS_FILELIST)
sed -i 's/\.\///' $(BB_MODS_FILELIST)
sort -u $(TOP_MODS_FILELIST) $(MODEL_MODS_FILELIST) $(BB_MODS_FILELIST) > $(ALL_MODS_FILELIST)
$(TOP_SMEMS_CONF) $(HARNESS_SMEMS_CONF) &: $(FIRTOOL_SMEMS_JSON) $(FIRTOOL_TB_SMEMS_JSON) $(FIRTOOL_SMEMS_CONF)
$(TOP_SMEMS_CONF) $(HARNESS_SMEMS_CONF) &: $(FIRTOOL_TOP_SMEMS_JSON) $(FIRTOOL_MODEL_SMEMS_JSON) $(FIRTOOL_SMEMS_CONF)
$(base_dir)/scripts/split-mems-conf.py \
--in-smems-conf $(FIRTOOL_SMEMS_CONF) \
--in-dut-smems-json $(FIRTOOL_SMEMS_JSON) \
--in-tb-smems-json $(FIRTOOL_TB_SMEMS_JSON) \
--in-dut-smems-json $(FIRTOOL_TOP_SMEMS_JSON) \
--in-model-smems-json $(FIRTOOL_MODEL_SMEMS_JSON) \
--out-dut-smems-conf $(TOP_SMEMS_CONF) \
--out-tb-smems-conf $(HARNESS_SMEMS_CONF)
--out-model-smems-conf $(HARNESS_SMEMS_CONF)
# This file is for simulation only. VLSI flows should replace this file with one containing hard SRAMs
MACROCOMPILER_MODE ?= --mode synflops
@@ -234,8 +243,8 @@ $(HARNESS_SMEMS_FILE) $(HARNESS_SMEMS_FIR) &: $(HARNESS_SMEMS_CONF) | $(TOP_SMEM
########################################################################################
# remove duplicate files and headers in list of simulation file inputs
########################################################################################
$(sim_common_files): $(sim_files) $(ALL_MODS_FILELIST) $(BB_MODS_FILELIST) $(TOP_SMEMS_FILE) $(HARNESS_SMEMS_FILE)
sort -u $(sim_files) $(ALL_MODS_FILELIST) $(BB_MODS_FILELIST) | grep -v '.*\.\(svh\|h\)$$' > $@
$(sim_common_files): $(sim_files) $(ALL_MODS_FILELIST) $(TOP_SMEMS_FILE) $(HARNESS_SMEMS_FILE)
sort -u $(sim_files) $(ALL_MODS_FILELIST) | grep -v '.*\.\(svh\|h\)$$' > $@
echo "$(TOP_SMEMS_FILE)" >> $@
echo "$(HARNESS_SMEMS_FILE)" >> $@

View File

@@ -25,41 +25,41 @@ from typing import List, Optional
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Use CIRCT (firtool) smems JSONs to create DUT and test harness smems confs')
parser.add_argument('--in-smems-conf', type=str, required=True, help='')
parser.add_argument('--in-dut-smems-json', type=str, required=True, help='')
parser.add_argument('--in-tb-smems-json', type=str, required=True, help='')
parser.add_argument('--out-dut-smems-conf', type=str, required=True, help='')
parser.add_argument('--out-tb-smems-conf', type=str, required=True, help='')
parser.add_argument('--in-smems-conf', type=str, required=True, help='Overall smems conf file that contains all memory definitions')
parser.add_argument('--in-dut-smems-json', type=str, required=True, help='JSON indicating which mem modules are in the DUT')
parser.add_argument('--in-model-smems-json', type=str, required=True, help='JSON indicating which mem modules are in the top-most level module (but not in the DUT)')
parser.add_argument('--out-dut-smems-conf', type=str, required=True, help='Smems conf with only DUT mem module definitions')
parser.add_argument('--out-model-smems-conf', type=str, required=True, help='Smems conf with only top-most level mem module definitions (not including DUT modules)')
args = parser.parse_args()
with open(args.in_smems_conf) as isc:
with open(args.in_dut_smems_json) as idsj:
with open(args.in_tb_smems_json) as itsj:
idsj_data = json.load(idsj)
itsj_data = json.load(itsj)
with open(args.in_smems_conf) as isc, \
open(args.in_dut_smems_json) as idsj, \
open(args.in_model_smems_json) as itsj:
idsj_data = json.load(idsj)
itsj_data = json.load(itsj)
dut_mods = set()
for e in idsj_data:
dut_mods.add(e['module_name'])
dut_mods = set()
for e in idsj_data:
dut_mods.add(e['module_name'])
tb_mods = set()
for e in itsj_data:
tb_mods.add(e['module_name'])
model_mods = set()
for e in itsj_data:
model_mods.add(e['module_name'])
with open(args.out_dut_smems_conf, "w") as odsc:
with open(args.out_tb_smems_conf, "w") as otsc:
for l in isc:
sl = l.split()
with open(args.out_dut_smems_conf, "w") as odsc, \
open(args.out_model_smems_conf, "w") as otsc:
for l in isc:
sl = l.split()
# the line can't be split then stop immediately (normally an empty file)
if len(sl) > 2:
name = sl[1]
# the line can't be split then stop immediately (normally an empty file)
if len(sl) > 2:
name = sl[1]
if name in dut_mods:
odsc.write(l)
elif name in tb_mods:
otsc.write(l)
else:
assert False, "Unable to find smem CONF module in firtool emitted JSON files."
else:
exit(0)
if name in dut_mods:
odsc.write(l)
elif name in model_mods:
otsc.write(l)
else:
assert False, "Unable to find smem CONF module in firtool emitted JSON files."
else:
exit(0)

View File

@@ -54,15 +54,15 @@ def find_mod_by_name(js: dict, name: str) -> Optional[List[dict]]:
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Convert CIRCT (firtool) hierarchy JSON into DUT and test harness filelists')
parser.add_argument('--tb-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('--dut', type=str, required=True, help='Name of the DUT module.')
parser.add_argument('--out-dut-filelist', type=str, required=True, help='Path to output filelist including all modules under the DUT.')
parser.add_argument('--out-tb-filelist', type=str, required=True, help='Path to output filelist including all modules under the top-most module but not modules under the DUT.')
parser.add_argument('--out-model-filelist', type=str, required=True, help='Path to output filelist including all modules under the top-most module but not modules under the DUT.')
parser.add_argument('--in-all-filelist', type=str, required=True, help='Path to input filelist that has all modules (relative paths).')
parser.add_argument('--build-dir', type=str, required=True, help='Path to where module sources are located (combined with --in-all-filelist gives the absolute path to module sources).')
parser.add_argument('--target-dir', type=str, required=True, help='Path to where module sources are located (combined with --in-all-filelist gives the absolute path to module sources).')
args = parser.parse_args()
with open(args.tb_hier_json) as f:
with open(args.model_hier_json) as f:
j = json.load(f)
dut_tops = find_mod_by_name(j, args.dut)
@@ -71,42 +71,41 @@ if __name__ == "__main__":
dut_top = dut_tops[0]
dut_mods = set(get_modules(dut_top))
tb_mods = set(get_modules(j)) - dut_mods
both_mods = dut_mods.intersection(tb_mods)
model_mods = set(get_modules(j)) - dut_mods
both_mods = dut_mods.intersection(model_mods)
assert len(both_mods) == 0
with open(args.out_dut_filelist, 'w') as df:
with open(args.in_all_filelist) as fl:
# add paths that correspond to modules to output file
for path in fl:
writeOut = False
for dm in dut_mods:
if dm in path:
writeOut = True
break
with open(args.out_dut_filelist, 'w') as df, \
open(args.in_all_filelist) as fl:
# add paths that correspond to modules to output file
for path in fl:
writeOut = False
for dm in dut_mods:
if dm in path:
writeOut = True
break
# prepend the build directory to get filelist with absolute paths
if writeOut:
if not args.build_dir in path:
df.write(f"{args.build_dir}/{path}")
else:
df.write(f"{path}")
# prepend the target directory to get filelist with absolute paths
if writeOut:
if not args.target_dir in path:
df.write(f"{args.target_dir}/{path}")
else:
df.write(f"{path}")
with open(args.out_model_filelist, 'w') as df, \
open(args.in_all_filelist) as fl:
# add paths that correspond to modules to output file
for path in fl:
writeOut = False
for dm in model_mods:
if dm in path:
writeOut = True
break
with open(args.out_tb_filelist, 'w') as df:
with open(args.in_all_filelist) as fl:
# add paths that correspond to modules to output file
for path in fl:
writeOut = False
for dm in tb_mods:
if dm in path:
writeOut = True
break
# prepend the build directory to get filelist with absolute paths
if writeOut:
if not args.build_dir in path:
df.write(f"{args.build_dir}/{path}")
else:
df.write(f"{path}")
# prepend the target directory to get filelist with absolute paths
if writeOut:
if not args.target_dir in path:
df.write(f"{args.target_dir}/{path}")
else:
df.write(f"{path}")

View File

@@ -38,13 +38,13 @@ SIM_FILE_REQS += \
$(ROCKETCHIP_RSRCS_DIR)/vsrc/TestDriver.v
# copy files but ignore *.h files in *.f since vcs has +incdir+$(build_dir)
$(sim_files): $(SIM_FILE_REQS) | $(build_dir)
cp -f $^ $(build_dir)
$(sim_files): $(SIM_FILE_REQS) | $(OUT_DIR)
cp -f $^ $(OUT_DIR)
$(foreach file,\
$^,\
$(if $(filter %.h,$(file)),\
,\
echo "$(addprefix $(build_dir)/, $(notdir $(file)))" >> $@;))
echo "$(addprefix $(OUT_DIR)/, $(notdir $(file)))" >> $@;))
#########################################################################################
# import other necessary rules and variables

View File

@@ -66,13 +66,13 @@ SIM_FILE_REQS += \
$(ROCKETCHIP_RSRCS_DIR)/csrc/remote_bitbang.cc
# copy files and add -FI for *.h files in *.f
$(sim_files): $(SIM_FILE_REQS) | $(build_dir)
cp -f $^ $(build_dir)
$(sim_files): $(SIM_FILE_REQS) | $(OUT_DIR)
cp -f $^ $(OUT_DIR)
$(foreach file,\
$^,\
$(if $(filter %.h,$(file)),\
echo "-FI $(addprefix $(build_dir)/, $(notdir $(file)))" >> $@;,\
echo "$(addprefix $(build_dir)/, $(notdir $(file)))" >> $@;))
echo "-FI $(addprefix $(OUT_DIR)/, $(notdir $(file)))" >> $@;,\
echo "$(addprefix $(OUT_DIR)/, $(notdir $(file)))" >> $@;))
#########################################################################################
# import other necessary rules and variables
@@ -181,7 +181,7 @@ VERILATOR_CXXFLAGS = \
-DTEST_HARNESS=V$(VLOG_MODEL) \
-DVERILATOR \
-include $(build_dir)/$(long_name).plusArgs \
-include $(build_dir)/verilator.h
-include $(OUT_DIR)/verilator.h
VERILATOR_LDFLAGS = $(SIM_LDFLAGS)

View File

@@ -143,40 +143,46 @@ ifeq ($(GENERATOR_PACKAGE),hwacha)
long_name=$(MODEL_PACKAGE).$(CONFIG)
endif
# chisel generated outputs
FIRRTL_FILE ?= $(build_dir)/$(long_name).fir
ANNO_FILE ?= $(build_dir)/$(long_name).anno.json
# chisel anno modification output
FIRTOOL_EXTRA_ANNO_FILE ?= $(build_dir)/$(long_name).extrafirtool.anno.json
FINAL_ANNO_FILE ?= $(build_dir)/$(long_name).appended.anno.json
SFC_FIRRTL_FILE ?= $(build_dir)/$(long_name).sfc.fir
SFC_FIRRTL_START ?= $(build_dir)/$(long_name).sfc
# scala firrtl compiler (sfc) outputs
SFC_FIRRTL_BASENAME ?= $(build_dir)/$(long_name).sfc
SFC_FIRRTL_FILE ?= $(SFC_FIRRTL_BASENAME).fir
SFC_ANNO_FILE ?= $(build_dir)/$(long_name).sfc.anno.json
FIRTOOL_MOD_HIER_JSON ?= $(build_dir)/modulehierarchy.json
FIRTOOL_TB_MOD_HIER_JSON ?= $(build_dir)/tbmodulehierarchy.json
# firtool compiler outputs
FIRTOOL_TOP_HRCHY_JSON ?= $(build_dir)/top_module_hierarchy.json
FIRTOOL_MODEL_HRCHY_JSON ?= $(build_dir)/model_module_hierarchy.json
FIRTOOL_SMEMS_CONF ?= $(build_dir)/$(long_name).mems.conf
FIRTOOL_SMEMS_JSON ?= $(build_dir)/metadata/seq_mems.json
FIRTOOL_TB_SMEMS_JSON ?= $(build_dir)/metadata/tb_seq_mems.json
# hardcoded firtool outputs
FIRTOOL_FILELIST = $(OUT_DIR)/filelist.f
FIRTOOL_BB_MODS_FILELIST = $(OUT_DIR)/firrtl_black_box_resource_files.f
FIRTOOL_TOP_SMEMS_JSON = $(OUT_DIR)/metadata/seq_mems.json
FIRTOOL_MODEL_SMEMS_JSON = $(OUT_DIR)/metadata/tb_seq_mems.json
# macrocompiler smems in/output
TOP_SMEMS_CONF ?= $(build_dir)/$(long_name).top.mems.conf
TOP_SMEMS_FILE ?= $(build_dir)/$(long_name).top.mems.v
TOP_SMEMS_FILE ?= $(build_dir)/vsrc/$(long_name).top.mems.v
TOP_SMEMS_FIR ?= $(build_dir)/$(long_name).top.mems.fir
HARNESS_SMEMS_CONF ?= $(build_dir)/$(long_name).harness.mems.conf
HARNESS_SMEMS_FILE ?= $(build_dir)/$(long_name).harness.mems.v
HARNESS_SMEMS_FILE ?= $(build_dir)/vsrc/$(long_name).harness.mems.v
HARNESS_SMEMS_FIR ?= $(build_dir)/$(long_name).harness.mems.fir
FIRTOOL_FILELIST ?= $(build_dir)/filelist.f
# all module files to include (includes top modules)
ALL_MODS_FILELIST ?= $(build_dir)/$(long_name).all.f
# top module files to include
TOP_MODS_FILELIST ?= $(build_dir)/$(long_name).top.f
# tb module files to include (not including top modules)
TB_MODS_FILELIST ?= $(build_dir)/$(long_name).tb.f
# list of all blackbox files (may be included in the top/tb.f files)
FIRTOOL_BB_MODS_FILELIST ?= $(build_dir)/firrtl_black_box_resource_files.f
# model module files to include (not including top modules)
MODEL_MODS_FILELIST ?= $(build_dir)/$(long_name).model.f
# list of all blackbox files (may be included in the top/model.f files)
# this has the build_dir appended
BB_MODS_FILELIST ?= $(build_dir)/firrtl_black_box_resource_files.final.f
BB_MODS_FILELIST ?= $(build_dir)/$(long_name).bb.f
# all module files to include (top, model, bb included)
ALL_MODS_FILELIST ?= $(build_dir)/$(long_name).all.f
BOOTROM_FILES ?= bootrom.rv64.img bootrom.rv32.img
BOOTROM_TARGETS ?= $(addprefix $(build_dir)/, $(BOOTROM_FILES))
@@ -244,8 +250,12 @@ binary_hex= $(sim_out_name).loadmem_hex
#########################################################################################
# build output directory for compilation
#########################################################################################
# output for all project builds
gen_dir=$(sim_dir)/generated-src
# per-project output directory
build_dir=$(gen_dir)/$(long_name)
# final generated collateral per-project
OUT_DIR ?= $(build_dir)/gen-collateral
#########################################################################################
# assembly/benchmark variables