Skip to content

Commit 21a6cec

Browse files
committed
synthesis: better reports for exploring MAX_UNGROUP_SIZE
Seperate the concern of collecting area of modules and implementing a policy. First a report is collected, such as: $ cat results/asap7/riscv32i/base/keep_hierarchy.tcl 0.291600 $paramod\mux2\WIDTH=s32'00000000000000000000000000000001 0.306180 \magcompare2c 0.641520 \magcompare2b 0.801900 $paramod\mux2\WIDTH=s32'00000000000000000000000000000100 0.991440 $paramod\mux2\WIDTH=s32'00000000000000000000000000000101 2.084940 \ROM 3.076380 \aludec 4.009500 \maindec 6.794280 $paramod\mux2\WIDTH=s32'00000000000000000000000000100000 6.794280 $paramod\mux2\WIDTH=s32'00000000000000000000000000100000 In synthesis, MAX_UNGROUP_SIZE is used to select which of these modules to keep and which to flatten. For some design there is little guesswork involved when looking at this report and picking a MAX_UNGROUP_SIZE. The names of targets in the makefile, variables and report names could be revised to reflect this seperation of concerns to improve readability, but leave that for a followup PR. Signed-off-by: Øyvind Harboe <[email protected]>
1 parent defc349 commit 21a6cec

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

flow/scripts/synth.tcl

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

3-
source $::env(SYNTH_STOP_MODULE_SCRIPT)
3+
hierarchy -check -top $::env(DESIGN_NAME)
4+
5+
set ungroup_threshold 0
6+
if { $::env(MAX_UNGROUP_SIZE) > 0 } {
7+
set ungroup_threshold $::env(MAX_UNGROUP_SIZE)
8+
puts "Ungroup modules of size greater than $ungroup_threshold"
9+
}
10+
11+
set fp [open $::env(SYNTH_STOP_MODULE_SCRIPT) r]
12+
while {[gets $fp line] != -1} {
13+
set fields [split $line " "]
14+
set area [lindex $fields 0]
15+
set module_name [lindex $fields 1]
16+
17+
if {[expr $area > $ungroup_threshold]} {
18+
puts "Keeping $area $module_name"
19+
select -module $module_name
20+
setattr -mod -set keep_hierarchy 1
21+
select -clear
22+
} else {
23+
puts "Flattening $area $module_name"
24+
}
25+
}
26+
close $fp
427

528
if { [env_var_equals SYNTH_GUT 1] } {
6-
hierarchy -check -top $::env(DESIGN_NAME)
729
# /deletes all cells at the top level, which will quickly optimize away
830
# everything else, including macros.
931
delete $::env(DESIGN_NAME)/c:*

flow/scripts/synth_hier_report.tcl

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ proc write_keep_hierarchy {} {
2525

2626
tee -o $::env(REPORTS_DIR)/synth_hier_stat.txt stat {*}$stat_libs
2727

28-
set ungroup_threshold 0
29-
if { [env_var_exists_and_non_empty MAX_UNGROUP_SIZE] && $::env(MAX_UNGROUP_SIZE) > 0 } {
30-
set ungroup_threshold $::env(MAX_UNGROUP_SIZE)
31-
puts "Ungroup modules of size $ungroup_threshold"
32-
}
3328
hierarchy -check -top $::env(DESIGN_NAME)
3429
set fptr [open $::env(REPORTS_DIR)/synth_hier_stat.txt r]
3530
set contents [read -nonewline $fptr]
@@ -53,8 +48,8 @@ proc write_keep_hierarchy {} {
5348
}
5449
}
5550
}
56-
set out_script_ptr [open $::env(SYNTH_STOP_MODULE_SCRIPT) w]
57-
puts $out_script_ptr "hierarchy -check -top $::env(DESIGN_NAME)"
51+
52+
set areas {}
5853
foreach module $module_list {
5954
tee -o $::env(REPORTS_DIR)/synth_hier_stat_temp_module.txt stat -top "$module" {*}$stat_libs
6055
set fptr1 [open $::env(REPORTS_DIR)/synth_hier_stat_temp_module.txt r]
@@ -63,18 +58,17 @@ proc write_keep_hierarchy {} {
6358
set split_cont1 [split $contents1 "\n"]
6459
foreach line $split_cont1 {
6560
if {[regexp { +Chip area for top module '(\S+)': (.*)} $line -> module_name area]} {
66-
if {[expr $area > $ungroup_threshold]} {
67-
puts "Preserving module: $module_name (area: $area)"
68-
puts $out_script_ptr "select -module {$module_name}"
69-
puts $out_script_ptr "setattr -mod -set keep_hierarchy 1"
70-
puts $out_script_ptr "select -clear"
71-
} else {
72-
puts "Flattening module $module_name (area: $area)"
73-
}
61+
lappend areas "$area $module_name"
7462
}
7563
}
7664
file delete -force $::env(REPORTS_DIR)/synth_hier_stat_temp_module.txt
7765
}
66+
set areas [lsort -index 0 -real $areas]
67+
68+
set out_script_ptr [open $::env(SYNTH_STOP_MODULE_SCRIPT) w]
69+
foreach {line} $areas {
70+
puts $out_script_ptr $line
71+
}
7872
close $out_script_ptr
7973
}
8074

0 commit comments

Comments
 (0)