Skip to content

Commit cc796b0

Browse files
committed
synthesis: add a do-yosys-coarse stage
This is the minimum time to run synthesis before reports can be made about which modules will be kept, sram sizes to be realized as flip flops. After this stage, it is possible to run the rest of synthesis in parallel for kept modules and combine the netlists. Signed-off-by: Øyvind Harboe <[email protected]>
1 parent fa7672b commit cc796b0

File tree

3 files changed

+52
-33
lines changed

3 files changed

+52
-33
lines changed

flow/Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,15 @@ yosys-dependencies: $(YOSYS_DEPENDENCIES)
445445
.PHONY: do-yosys
446446
do-yosys: $(DONT_USE_SC_LIB)
447447
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
448-
(export VERILOG_FILES=$(RESULTS_DIR)/1_synth.rtlil; \
448+
(export VERILOG_FILES=$(RESULTS_DIR)/1_yosys_coarse.rtlil; \
449449
$(TIME_CMD) $(YOSYS_EXE) $(YOSYS_FLAGS) -c $(SYNTH_SCRIPT)) 2>&1 | tee $(abspath $(LOG_DIR)/1_1_yosys.log)
450450

451+
.PHONY: do-yosys-coarse
452+
do-yosys-coarse: $(DONT_USE_SC_LIB)
453+
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
454+
(export VERILOG_FILES=$(RESULTS_DIR)/1_synth.rtlil; \
455+
$(TIME_CMD) $(YOSYS_EXE) $(YOSYS_FLAGS) -c $(SCRIPTS_DIR)/synth_coarse.tcl) 2>&1 | tee $(abspath $(LOG_DIR)/1_1_yosys_coarse.log)
456+
451457
.PHONY: do-yosys-canonicalize
452458
do-yosys-canonicalize: yosys-dependencies $(DONT_USE_SC_LIB)
453459
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
@@ -456,9 +462,12 @@ do-yosys-canonicalize: yosys-dependencies $(DONT_USE_SC_LIB)
456462
$(RESULTS_DIR)/1_synth.rtlil: $(YOSYS_DEPENDENCIES)
457463
$(UNSET_AND_MAKE) do-yosys-canonicalize
458464

459-
$(RESULTS_DIR)/1_1_yosys.v: $(RESULTS_DIR)/1_synth.rtlil
465+
$(RESULTS_DIR)/1_1_yosys.v: $(RESULTS_DIR)/1_yosys_coarse.rtlil
460466
$(UNSET_AND_MAKE) do-yosys
461467

468+
$(RESULTS_DIR)/1_yosys_coarse.rtlil: $(RESULTS_DIR)/1_synth.rtlil
469+
$(UNSET_AND_MAKE) do-yosys-coarse
470+
462471
.PHONY: do-synth
463472
do-synth:
464473
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR)

flow/scripts/synth.tcl

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,15 @@
11
source $::env(SCRIPTS_DIR)/synth_preamble.tcl
22

3-
hierarchy -check -top $::env(DESIGN_NAME)
4-
5-
if { [env_var_equals SYNTH_GUT 1] } {
6-
# /deletes all cells at the top level, which will quickly optimize away
7-
# everything else, including macros.
8-
delete $::env(DESIGN_NAME)/c:*
9-
}
10-
11-
if {![env_var_equals SYNTH_HIERARCHICAL 1]} {
12-
# Perform standard coarse-level synthesis script, flatten right away
13-
# (-flatten part of $synth_args per default)
14-
synth -run :fine {*}$::env(SYNTH_FULL_ARGS)
15-
} else {
16-
# Perform standard coarse-level synthesis script,
17-
# defer flattening until we have decided what hierarchy to keep
18-
synth -run :fine
19-
20-
if {[env_var_exists_and_non_empty MAX_UNGROUP_SIZE]} {
21-
set ungroup_threshold $::env(MAX_UNGROUP_SIZE)
22-
puts "Ungroup modules below estimated size of $ungroup_threshold instances"
23-
24-
convert_liberty_areas
25-
keep_hierarchy -min_cost $ungroup_threshold
26-
} else {
27-
keep_hierarchy
28-
}
29-
3+
if {[env_var_equals SYNTH_HIERARCHICAL 1]} {
304
# Re-run coarse-level script, this time do pass -flatten
5+
#
6+
# This is done here instead of in synth_coarse.tcl, because this part of
7+
# the flow can be done in parallel for all the kept modules as
8+
# well as being faster here, when taking SYNTH_BLACKBOXES into
9+
# account for parallel builds.
3110
synth -run coarse:fine {*}$::env(SYNTH_FULL_ARGS)
3211
}
3312

34-
json -o $::env(RESULTS_DIR)/mem.json
35-
# Run report and check here so as to fail early if this synthesis run is doomed
36-
exec -- python3 $::env(SCRIPTS_DIR)/mem_dump.py --max-bits $::env(SYNTH_MEMORY_MAX_BITS) $::env(RESULTS_DIR)/mem.json
37-
3813
if {![env_var_exists_and_non_empty SYNTH_WRAPPED_OPERATORS]} {
3914
synth -top $::env(DESIGN_NAME) -run fine: {*}$::env(SYNTH_FULL_ARGS)
4015
} else {

flow/scripts/synth_coarse.tcl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
source $::env(SCRIPTS_DIR)/synth_preamble.tcl
2+
3+
hierarchy -check -top $::env(DESIGN_NAME)
4+
5+
if { [env_var_equals SYNTH_GUT 1] } {
6+
# /deletes all cells at the top level, which will quickly optimize away
7+
# everything else, including macros.
8+
delete $::env(DESIGN_NAME)/c:*
9+
}
10+
11+
if {![env_var_equals SYNTH_HIERARCHICAL 1]} {
12+
# Perform standard coarse-level synthesis script, flatten right away
13+
# (-flatten part of $synth_args per default)
14+
synth -run :fine {*}$::env(SYNTH_FULL_ARGS)
15+
} else {
16+
# Perform standard coarse-level synthesis script,
17+
# defer flattening until we have decided what hierarchy to keep
18+
synth -run :fine
19+
20+
if {[env_var_exists_and_non_empty MAX_UNGROUP_SIZE]} {
21+
set ungroup_threshold $::env(MAX_UNGROUP_SIZE)
22+
puts "Ungroup modules below estimated size of $ungroup_threshold instances"
23+
24+
convert_liberty_areas
25+
keep_hierarchy -min_cost $ungroup_threshold
26+
} else {
27+
keep_hierarchy
28+
}
29+
}
30+
31+
json -o $::env(RESULTS_DIR)/mem.json
32+
# Run report and check here so as to fail early if this synthesis run is doomed
33+
exec -- python3 $::env(SCRIPTS_DIR)/mem_dump.py --max-bits $::env(SYNTH_MEMORY_MAX_BITS) $::env(RESULTS_DIR)/mem.json
34+
35+
write_rtlil $::env(RESULTS_DIR)/1_yosys_coarse.rtlil

0 commit comments

Comments
 (0)