Skip to content

Commit

Permalink
[Analysis] try to infer restype-to-index dynamically from report
Browse files Browse the repository at this point in the history
  • Loading branch information
maltanar authored and iksnagreb committed Apr 3, 2024
1 parent b435655 commit 79a9015
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/finn/analysis/fpgadataflow/post_synth_res.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def post_synth_res(model, override_synth_report_filename=None):
else:
raise Exception("Please run synthesis first")

# TODO build these indices based on table headers instead of harcoding
restype_to_ind_default = {
"LUT": 2,
"SRL": 5,
Expand All @@ -74,13 +73,36 @@ def post_synth_res(model, override_synth_report_filename=None):
"BRAM_36K": 9,
"BRAM_18K": 10,
"URAM": 11,
"DSP48": 12,
"DSP": 12,
}

if model.get_metadata_prop("platform") == "alveo":
restype_to_ind = restype_to_ind_vitis
# format: (human_readable_name_in_report, canonical_name)
res_types_to_search = [
("Total LUTs", "LUT"),
("SRLs", "SRL"),
("FFs", "FF"),
("RAMB36", "BRAM_36K"),
("RAMB18", "BRAM_18K"),
("URAM", "URAM"),
("DSP Blocks", "DSP"),
]

# try to infer resource type to table index by
# looking at the names in headings
header_row = root.findall(".//*[@contents='Instance']/..")
if header_row != []:
headers = [x.attrib["contents"] for x in list(header_row[0])]
restype_to_ind = {}
for res_type_name, res_type in res_types_to_search:
if res_type_name in headers:
restype_to_ind[res_type] = headers.index(res_type_name)
else:
restype_to_ind = restype_to_ind_default
# could not infer resource types from header
# fall back to default indices
if model.get_metadata_prop("platform") == "alveo":
restype_to_ind = restype_to_ind_vitis
else:
restype_to_ind = restype_to_ind_default

def get_instance_stats(inst_name):
row = root.findall(".//*[@contents='%s']/.." % inst_name)
Expand Down

0 comments on commit 79a9015

Please sign in to comment.