Skip to content

Commit 78651c2

Browse files
authored
Merge pull request #3297 from Pinata-Consulting/synthesis-consistent-naming-and-hash
synthesis: more consistent naming of logs and results
2 parents d233eee + 22bfa72 commit 78651c2

File tree

7 files changed

+27
-25
lines changed

7 files changed

+27
-25
lines changed

flow/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ synth-report: synth
258258

259259
.PHONY: do-synth-report
260260
do-synth-report:
261-
($(TIME_CMD) $(OPENROAD_CMD) $(SCRIPTS_DIR)/synth_metrics.tcl) 2>&1 | tee $(abspath $(LOG_DIR)/1_1_yosys_metrics.log)
261+
($(TIME_CMD) $(OPENROAD_CMD) $(SCRIPTS_DIR)/synth_metrics.tcl) 2>&1 | tee $(abspath $(LOG_DIR)/1_2_yosys_metrics.log)
262262

263263
.PHONY: memory
264264
memory:
@@ -282,24 +282,24 @@ yosys-dependencies: $(YOSYS_DEPENDENCIES)
282282

283283
.PHONY: do-yosys
284284
do-yosys: $(DONT_USE_SC_LIB)
285-
$(SCRIPTS_DIR)/synth.sh $(SYNTH_SCRIPT) $(LOG_DIR)/1_1_yosys.log
285+
$(SCRIPTS_DIR)/synth.sh $(SYNTH_SCRIPT) $(LOG_DIR)/1_2_yosys.log
286286

287287
.PHONY: do-yosys-canonicalize
288288
do-yosys-canonicalize: yosys-dependencies $(DONT_USE_SC_LIB)
289289
$(SCRIPTS_DIR)/synth.sh $(SCRIPTS_DIR)/synth_canonicalize.tcl $(LOG_DIR)/1_1_yosys_canonicalize.log
290290

291-
$(RESULTS_DIR)/1_synth.rtlil: $(YOSYS_DEPENDENCIES)
291+
$(RESULTS_DIR)/1_1_yosys_canonicalize.rtlil: $(YOSYS_DEPENDENCIES)
292292
$(UNSET_AND_MAKE) do-yosys-canonicalize
293293

294-
$(RESULTS_DIR)/1_1_yosys.v: $(RESULTS_DIR)/1_synth.rtlil
294+
$(RESULTS_DIR)/1_2_yosys.v: $(RESULTS_DIR)/1_1_yosys_canonicalize.rtlil
295295
$(UNSET_AND_MAKE) do-yosys
296296

297297
.PHONY: do-synth
298298
do-synth:
299299
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR)
300-
cp $(RESULTS_DIR)/1_1_yosys.v $(RESULTS_DIR)/1_synth.v
300+
cp $(RESULTS_DIR)/1_2_yosys.v $(RESULTS_DIR)/1_synth.v
301301

302-
$(RESULTS_DIR)/1_synth.v: $(RESULTS_DIR)/1_1_yosys.v
302+
$(RESULTS_DIR)/1_synth.v: $(RESULTS_DIR)/1_2_yosys.v
303303
$(UNSET_AND_MAKE) do-synth
304304

305305
.PHONY: clean_synth

flow/scripts/synth.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
source $::env(SCRIPTS_DIR)/synth_preamble.tcl
2-
read_checkpoint $::env(RESULTS_DIR)/1_synth.rtlil
2+
read_checkpoint $::env(RESULTS_DIR)/1_1_yosys_canonicalize.rtlil
33

44
hierarchy -check -top $::env(DESIGN_NAME)
55

@@ -145,7 +145,7 @@ if { ![env_var_exists_and_non_empty SYNTH_WRAPPED_OPERATORS] } {
145145
}
146146

147147
# Write synthesized design
148-
write_verilog -nohex -nodec $::env(RESULTS_DIR)/1_1_yosys.v
148+
write_verilog -nohex -nodec $::env(RESULTS_DIR)/1_2_yosys.v
149149
# One day a more sophisticated synthesis will write out a modified
150150
# .sdc file after synthesis. For now, just copy the input .sdc file,
151151
# making synthesis more consistent with other stages.

flow/scripts/synth_canonicalize.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ hierarchy -check -top $::env(DESIGN_NAME)
1010
# Get rid of unused modules
1111
opt_clean -purge
1212
# The hash of this file will not change if files not part of synthesis do not change
13-
write_rtlil $::env(RESULTS_DIR)/1_synth.rtlil
13+
write_rtlil $::env(RESULTS_DIR)/1_1_yosys_canonicalize.rtlil

flow/scripts/synth_metrics.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
utl::set_metrics_stage "synth__{}"
22
source $::env(SCRIPTS_DIR)/load.tcl
3-
load_design 1_1_yosys.v 1_synth.sdc
3+
load_design 1_2_yosys.v 1_synth.sdc
44

55
report_metrics 1 "Post synthesis" false false

flow/scripts/synth_preamble.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ erase_non_stage_variables synth
88
# floorplan step to be re-executed.
99
if { [env_var_exists_and_non_empty SYNTH_NETLIST_FILES] } {
1010
if { [llength $::env(SYNTH_NETLIST_FILES)] == 1 } {
11-
log_cmd exec cp -p $::env(SYNTH_NETLIST_FILES) $::env(RESULTS_DIR)/1_1_yosys.v
11+
log_cmd exec cp -p $::env(SYNTH_NETLIST_FILES) $::env(RESULTS_DIR)/1_2_yosys.v
1212
} else {
1313
# The date should be the most recent date of the files, but to
1414
# keep things simple we just use the creation date
15-
log_cmd exec cat {*}$::env(SYNTH_NETLIST_FILES) > $::env(RESULTS_DIR)/1_1_yosys.v
15+
log_cmd exec cat {*}$::env(SYNTH_NETLIST_FILES) > $::env(RESULTS_DIR)/1_2_yosys.v
1616
}
1717
log_cmd exec cp -p $::env(SDC_FILE) $::env(RESULTS_DIR)/1_synth.sdc
1818
if { [env_var_exists_and_non_empty CACHED_REPORTS] } {

flow/util/genElapsedTime.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,22 @@ def print_log_dir_times(logdir, args):
6262
int(line.split("Peak memory: ")[1].split("KB")[0]) / 1024
6363
)
6464

65-
# content hash for .odb file alongside .log file is useful to
65+
# content hash for the result file alongside .log file is useful to
6666
# debug divergent results under what should be identical
6767
# builds(such as local and CI builds)
68-
odb_file = pathlib.Path(
69-
str(f).replace("logs/", "results/").replace(".log", ".odb")
70-
)
71-
if odb_file.exists():
72-
hasher = hashlib.sha1()
73-
with open(odb_file, "rb") as odb_f:
74-
while chunk := odb_f.read(16 * 1024 * 1024):
75-
hasher.update(chunk)
76-
odb_hash = hasher.hexdigest()
77-
else:
78-
odb_hash = "N/A"
68+
for ext in [".odb", ".rtlil", ".v"]:
69+
result_file = pathlib.Path(
70+
str(f).replace("logs/", "results/").replace(".log", ext)
71+
)
72+
if result_file.exists():
73+
hasher = hashlib.sha1()
74+
with open(result_file, "rb") as odb_f:
75+
while chunk := odb_f.read(16 * 1024 * 1024):
76+
hasher.update(chunk)
77+
odb_hash = hasher.hexdigest()
78+
break
79+
else:
80+
odb_hash = "N/A"
7981

8082
if not found:
8183
print("No elapsed time found in", str(f), file=sys.stderr)

flow/util/genMetrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def extract_metrics(
288288
# Accumulate time
289289
# =========================================================================
290290

291-
extractGnuTime("synth", metrics_dict, logPath + "/1_1_yosys.log")
291+
extractGnuTime("synth", metrics_dict, logPath + "/1_2_yosys.log")
292292
extractGnuTime("floorplan", metrics_dict, logPath + "/2_1_floorplan.log")
293293
extractGnuTime("floorplan_io", metrics_dict, logPath + "/2_2_floorplan_io.log")
294294
extractGnuTime(

0 commit comments

Comments
 (0)