-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
synthesis: minimal synthesis to drive MAX_UNGROUP_SIZE policy
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
- Loading branch information
Showing
4 changed files
with
38 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,19 @@ | ||
source $::env(SCRIPTS_DIR)/synth_preamble.tcl | ||
|
||
# Hierarchical synthesis | ||
synth -top $::env(DESIGN_NAME) | ||
if { [info exist ::env(ADDER_MAP_FILE)] && [file isfile $::env(ADDER_MAP_FILE)] } { | ||
techmap -map $::env(ADDER_MAP_FILE) | ||
} | ||
techmap | ||
if {[info exist ::env(DFF_LIB_FILE)]} { | ||
dfflibmap -liberty $::env(DFF_LIB_FILE) | ||
} else { | ||
dfflibmap -liberty $::env(DONT_USE_SC_LIB) | ||
} | ||
puts "abc [join $abc_args " "]" | ||
abc {*}$abc_args | ||
|
||
tee -o $::env(REPORTS_DIR)/synth_hier_stat.txt stat {*}$stat_libs | ||
|
||
if { [info exist ::env(REPORTS_DIR)] && [file isfile $::env(REPORTS_DIR)/synth_hier_stat.txt] } { | ||
set ungroup_threshold 0 | ||
if { [info exist ::env(MAX_UNGROUP_SIZE)] && $::env(MAX_UNGROUP_SIZE) > 0 } { | ||
set ungroup_threshold $::env(MAX_UNGROUP_SIZE) | ||
puts "Ungroup modules of size $ungroup_threshold" | ||
} | ||
hierarchy -check -top $::env(DESIGN_NAME) | ||
set fptr [open $::env(REPORTS_DIR)/synth_hier_stat.txt r] | ||
set contents [read -nonewline $fptr] | ||
close $fptr | ||
set split_cont [split $contents "\n"] | ||
set hierarchy_section 0 | ||
set module_list {} | ||
foreach line $split_cont { | ||
if {[regexp {=== design hierarchy ===} $line]} { | ||
set hierarchy_section 1 | ||
continue | ||
} | ||
if {[regexp { Number of wires.*} $line ]} { | ||
set hierarchy_section 0 | ||
continue | ||
} | ||
if { $hierarchy_section == 1 } { | ||
if {[regexp { +(\S+) +.*} $line -> module_name]} { | ||
lappend module_list $module_name | ||
puts "Found module $module_name" | ||
} | ||
} | ||
} | ||
set out_script_ptr [open $::env(OBJECTS_DIR)/mark_hier_stop_modules.tcl w] | ||
puts $out_script_ptr "hierarchy -check -top $::env(DESIGN_NAME)" | ||
foreach module $module_list { | ||
tee -o $::env(REPORTS_DIR)/synth_hier_stat_temp_module.txt stat -top "$module" {*}$stat_libs | ||
set fptr1 [open $::env(REPORTS_DIR)/synth_hier_stat_temp_module.txt r] | ||
set contents1 [read -nonewline $fptr1] | ||
close $fptr1 | ||
set split_cont1 [split $contents1 "\n"] | ||
foreach line $split_cont1 { | ||
if {[regexp { +Chip area for top module '(\S+)': (.*)} $line -> module_name area]} { | ||
puts "Area of module $module_name is $area" | ||
if {[expr $area > $ungroup_threshold]} { | ||
puts "Preserving hierarchical module: $module_name" | ||
puts $out_script_ptr "select -module {$module_name}" | ||
puts $out_script_ptr "setattr -mod -set keep_hierarchy 1" | ||
puts $out_script_ptr "select -clear" | ||
} | ||
} | ||
} | ||
file delete -force $::env(REPORTS_DIR)/synth_hier_stat_temp_module.txt | ||
} | ||
close $out_script_ptr | ||
set ungroup_threshold 0 | ||
if { [info exist ::env(MAX_UNGROUP_SIZE)] && $::env(MAX_UNGROUP_SIZE) > 0 } { | ||
set ungroup_threshold $::env(MAX_UNGROUP_SIZE) | ||
puts "Ungroup modules of size $ungroup_threshold" | ||
} | ||
|
||
# Minimal hierarchical synthesis to use number of cells to drive policy | ||
# of whether to flatten a module or not. | ||
synth -run :coarse -top $::env(DESIGN_NAME) | ||
# These commands are cherry-picked from the "synth -run coarse:" list | ||
# of commands in the Yosys manual. | ||
# | ||
# 'proc' pass is called 'procs' to avoid conflict with tcl 'proc' command | ||
procs | ||
memory -nomap | ||
memory_map | ||
json -o $::env(OBJECTS_DIR)/synth.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import json | ||
import sys | ||
|
||
|
||
def main(args): | ||
threshold = int(args[2]) | ||
with open(args[0], "r") as f: | ||
synth = json.load(f) | ||
|
||
print("Preserving hierarchical modules...") | ||
with open(args[1], "w") as f: | ||
for name, module in synth["modules"].items(): | ||
if len(module["cells"]) > threshold: | ||
f.write("select -module {\\" + name + "}\n") | ||
f.write("setattr -mod -set keep_hierarchy 1\n") | ||
f.write("select -clear\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
main(sys.argv[1:]) |