Skip to content

Commit 445d0ed

Browse files
committed
build: include timing info in output info.
1 parent ef5d43b commit 445d0ed

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/niar/build.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,36 @@ def execute_build():
9292
with logtime(logging.DEBUG, "programming"):
9393
platform.toolchain_program(products, np.name)
9494

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

100+
nextpnr_report = np.path.build(subdir, f"{np.name}.tim")
99101
logger.info("Device utilisation:")
100102
heading = re.compile(r"^Info: Device utilisation:$", flags=re.MULTILINE)
101103
next_heading = re.compile(r"^Info: Placed ", flags=re.MULTILINE)
102-
log_file_between(
103-
logging.INFO, np.path.build(subdir, f"{np.name}.tim"), heading, next_heading, prefix="Info: "
104-
)
104+
log_file_between(logging.INFO, nextpnr_report, heading, next_heading, prefix="Info: ")
105105

106+
timing_report = None
107+
max_freq = re.compile(r"^Info: Max frequency for clock '", flags=re.MULTILINE)
108+
slack_histo = re.compile(r"^Info: Slack histogram:", flags=re.MULTILINE)
109+
with open(nextpnr_report, "r") as f:
110+
for line in f:
111+
if max_freq.match(line):
112+
timing_report = [line]
113+
elif timing_report is not None:
114+
timing_report.append(line)
115+
116+
if timing_report is None:
117+
logger.warn("Couldn't extract timing information from nextpnr log")
118+
else:
119+
for line in timing_report:
120+
if slack_histo.match(line):
121+
break
122+
line = line.rstrip()
123+
line = line.removeprefix("Info: ")
124+
logger.log(logging.INFO, line)
106125

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

0 commit comments

Comments
 (0)