Skip to content

Commit

Permalink
build: include timing info in output info.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Jul 4, 2024
1 parent ef5d43b commit 445d0ed
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/niar/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,36 @@ def execute_build():
with logtime(logging.DEBUG, "programming"):
platform.toolchain_program(products, np.name)

yosys_report = np.path.build(subdir, f"{np.name}.rpt")
heading = re.compile(r"^\d+\.\d+\. Printing statistics\.$", flags=re.MULTILINE)
next_heading = re.compile(r"^\d+\.\d+\. ", flags=re.MULTILINE)
log_file_between(logging.INFO, np.path.build(subdir, f"{np.name}.rpt"), heading, next_heading)
log_file_between(logging.INFO, yosys_report, heading, next_heading)

nextpnr_report = np.path.build(subdir, f"{np.name}.tim")
logger.info("Device utilisation:")
heading = re.compile(r"^Info: Device utilisation:$", flags=re.MULTILINE)
next_heading = re.compile(r"^Info: Placed ", flags=re.MULTILINE)
log_file_between(
logging.INFO, np.path.build(subdir, f"{np.name}.tim"), heading, next_heading, prefix="Info: "
)
log_file_between(logging.INFO, nextpnr_report, heading, next_heading, prefix="Info: ")

timing_report = None
max_freq = re.compile(r"^Info: Max frequency for clock '", flags=re.MULTILINE)
slack_histo = re.compile(r"^Info: Slack histogram:", flags=re.MULTILINE)
with open(nextpnr_report, "r") as f:
for line in f:
if max_freq.match(line):
timing_report = [line]
elif timing_report is not None:
timing_report.append(line)

if timing_report is None:
logger.warn("Couldn't extract timing information from nextpnr log")
else:
for line in timing_report:
if slack_histo.match(line):
break
line = line.rstrip()
line = line.removeprefix("Info: ")
logger.log(logging.INFO, line)

def construct_top(np: Project, platform: Platform, **kwargs):
sig = inspect.signature(np.top)
Expand Down

0 comments on commit 445d0ed

Please sign in to comment.