Skip to content

Commit 8ea7b36

Browse files
committed
Merge branch 'master' into print-place-density-lb-addon
Signed-off-by: Matt Liberty <[email protected]>
2 parents acbe1f0 + d59ddd4 commit 8ea7b36

11 files changed

+246
-230
lines changed

flow/Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ include $(PLATFORM_DIR)/config.mk
180180

181181
# Enables hierarchical yosys
182182
export SYNTH_HIERARCHICAL ?= 0
183-
export SYNTH_STOP_MODULE_SCRIPT = $(RESULTS_DIR)/keep_hierarchy.tcl
183+
export SYNTH_STATS = $(RESULTS_DIR)/synth_stats.txt
184184
export HIER_REPORT_SCRIPT = $(SCRIPTS_DIR)/synth_hier_report.tcl
185185
export MAX_UNGROUP_SIZE ?= 0
186186

@@ -461,6 +461,9 @@ do-synth-report:
461461

462462
.PHONY: memory
463463
memory:
464+
if [ -f $(RESULTS_DIR)/mem_hierarchical.json ]; then \
465+
python3 $(SCRIPTS_DIR)/mem_dump.py $(RESULTS_DIR)/mem_hierarchical.json; \
466+
fi
464467
python3 $(SCRIPTS_DIR)/mem_dump.py $(RESULTS_DIR)/mem.json
465468

466469
# ==============================================================================
@@ -516,10 +519,10 @@ $(RESULTS_DIR)/1_synth.v: $(RESULTS_DIR)/1_1_yosys.v
516519

517520
.PHONY: clean_synth
518521
clean_synth:
519-
rm -f $(RESULTS_DIR)/1_* $(RESULTS_DIR)/mem.json
522+
rm -f $(RESULTS_DIR)/1_* $(RESULTS_DIR)/mem*.json
520523
rm -f $(REPORTS_DIR)/synth_*
521524
rm -f $(LOG_DIR)/1_*
522-
rm -f $(SYNTH_STOP_MODULE_SCRIPT)
525+
rm -f $(SYNTH_STATS)
523526
rm -f $(SDC_FILE_CLOCK_PERIOD)
524527
rm -rf _tmp_yosys-abc-*
525528

flow/designs/intel16/gcd/metadata-base-ok.json

+167-171
Large diffs are not rendered by default.

flow/designs/intel16/gcd/rules-base.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"compare": "<="
3333
},
3434
"detailedroute__route__wirelength": {
35-
"value": 2564,
35+
"value": 3020,
3636
"compare": "<="
3737
},
3838
"detailedroute__route__drc_errors": {
@@ -52,7 +52,7 @@
5252
"compare": ">="
5353
},
5454
"finish__design__instance__area": {
55-
"value": 273,
55+
"value": 360,
5656
"compare": "<="
5757
},
5858
"finish__timing__drv__setup_violation_count": {

flow/scripts/global_place.tcl

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ set_dont_use $::env(DONT_USE_CELLS)
77

88
fast_route
99

10-
source $::env(SCRIPTS_DIR)/set_place_density.tcl
11-
1210
set global_placement_args {}
1311

1412
# Parameters for routability mode in global placement
@@ -21,8 +19,8 @@ if {$::env(GPL_TIMING_DRIVEN)} {
2119
lappend global_placement_args {-timing_driven}
2220
}
2321

24-
proc do_placement {place_density global_placement_args} {
25-
set all_args [concat [list -density $place_density \
22+
proc do_placement {global_placement_args} {
23+
set all_args [concat [list -density [place_density_with_lb_addon] \
2624
-pad_left $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \
2725
-pad_right $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT)] \
2826
$global_placement_args]
@@ -34,7 +32,7 @@ proc do_placement {place_density global_placement_args} {
3432
log_cmd global_placement {*}$all_args
3533
}
3634

37-
set result [catch {do_placement $place_density $global_placement_args} errMsg]
35+
set result [catch {do_placement $global_placement_args} errMsg]
3836
if {$result != 0} {
3937
write_db $::env(RESULTS_DIR)/3_3_place_gp-failed.odb
4038
error $errMsg

flow/scripts/global_place_skip_io.tcl

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ load_design 2_floorplan.odb 2_floorplan.sdc
66
if { [env_var_exists_and_non_empty FLOORPLAN_DEF] } {
77
puts "FLOORPLAN_DEF is set. Skipping global placement without IOs"
88
} else {
9-
source $::env(SCRIPTS_DIR)/set_place_density.tcl
9+
set place_density [place_density_with_lb_addon]
1010

1111
if { 0 != [llength [array get ::env GLOBAL_PLACEMENT_ARGS]] } {
12-
global_placement -skip_io -density $place_density \
13-
-pad_left $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \
14-
-pad_right $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \
15-
{*}$::env(GLOBAL_PLACEMENT_ARGS)
12+
log_cmd global_placement -skip_io -density $place_density \
13+
-pad_left $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \
14+
-pad_right $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \
15+
{*}$::env(GLOBAL_PLACEMENT_ARGS)
1616
} else {
17-
global_placement -skip_io -density $place_density \
18-
-pad_left $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \
19-
-pad_right $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT)
17+
log_cmd global_placement -skip_io -density $place_density \
18+
-pad_left $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \
19+
-pad_right $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT)
2020
}
2121
}
2222

flow/scripts/macro_place_util.tcl

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ if {[find_macros] != ""} {
5757
append_env_var additional_rtlmp_args RTLMP_FENCE_UX -fence_ux 1
5858
append_env_var additional_rtlmp_args RTLMP_FENCE_UY -fence_uy 1
5959

60-
source $::env(SCRIPTS_DIR)/set_place_density.tcl
61-
append additional_rtlmp_args " -target_util $place_density"
60+
append additional_rtlmp_args " -target_util [place_density_with_lb_addon]"
6261

6362
set all_args $additional_rtlmp_args
6463

flow/scripts/set_place_density.tcl

-13
This file was deleted.

flow/scripts/synth.tcl

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
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_STATS) 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 module $module_name (area: $area)"
19+
select -module $module_name
20+
setattr -mod -set keep_hierarchy 1
21+
select -clear
22+
} else {
23+
puts "Flattening module $module_name (area: $area)"
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:*
1032
}
1133

12-
synthesize_check $::env(SYNTH_FULL_ARGS)
34+
synthesize_check mem $::env(SYNTH_FULL_ARGS)
1335

1436
# rename registers to have the verilog register name in its name
1537
# of the form \regName$_DFF_P_. We should fix yosys to make it the reg name.

flow/scripts/synth_hier_report.tcl

+14-20
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ source $::env(SCRIPTS_DIR)/util.tcl
22

33
proc write_keep_hierarchy {} {
44
if { ![env_var_equals SYNTH_HIERARCHICAL 1] } {
5-
set out_script_ptr [open $::env(SYNTH_STOP_MODULE_SCRIPT) w]
5+
set out_script_ptr [open $::env(SYNTH_STATS) w]
66
close $out_script_ptr
77
return
88
}
99

1010
source $::env(SCRIPTS_DIR)/synth_preamble.tcl
1111

12-
synthesize_check {}
12+
synthesize_check mem_hierarchical {}
1313

1414
if { [env_var_exists_and_non_empty ADDER_MAP_FILE] && [file isfile $::env(ADDER_MAP_FILE)] } {
1515
techmap -map $::env(ADDER_MAP_FILE)
@@ -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,27 +48,26 @@ 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 {
59-
tee -o $::env(REPORTS_DIR)/synth_hier_stat_temp_module.txt stat -top "$module" {*}$stat_libs
60-
set fptr1 [open $::env(REPORTS_DIR)/synth_hier_stat_temp_module.txt r]
54+
tee -o $::env(OBJECTS_DIR)/synth_hier_stat_temp_module.txt stat -top "$module" {*}$stat_libs
55+
set fptr1 [open $::env(OBJECTS_DIR)/synth_hier_stat_temp_module.txt r]
6156
set contents1 [read -nonewline $fptr1]
6257
close $fptr1
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
}
76-
file delete -force $::env(REPORTS_DIR)/synth_hier_stat_temp_module.txt
64+
file delete -force $::env(OBJECTS_DIR)/synth_hier_stat_temp_module.txt
65+
}
66+
set areas [lsort -index 0 -real $areas]
67+
68+
set out_script_ptr [open $::env(SYNTH_STATS) w]
69+
foreach {line} $areas {
70+
puts $out_script_ptr $line
7771
}
7872
close $out_script_ptr
7973
}

flow/scripts/synth_preamble.tcl

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ puts $constr "set_driving_cell $::env(ABC_DRIVER_CELL)"
107107
puts $constr "set_load $::env(ABC_LOAD_IN_FF)"
108108
close $constr
109109

110-
proc synthesize_check {synth_args} {
110+
proc synthesize_check {report synth_args} {
111111
# Generic synthesis
112112
log_cmd synth -top $::env(DESIGN_NAME) -run :fine {*}$synth_args
113-
json -o $::env(RESULTS_DIR)/mem.json
113+
json -o $::env(RESULTS_DIR)/$report.json
114114
# Run report and check here so as to fail early if this synthesis run is doomed
115-
exec -- python3 $::env(SCRIPTS_DIR)/mem_dump.py --max-bits $::env(SYNTH_MEMORY_MAX_BITS) $::env(RESULTS_DIR)/mem.json
115+
exec -- python3 $::env(SCRIPTS_DIR)/mem_dump.py --max-bits $::env(SYNTH_MEMORY_MAX_BITS) $::env(RESULTS_DIR)/$report.json
116116
synth -top $::env(DESIGN_NAME) -run fine: {*}$synth_args
117117
# Get rid of indigestibles
118118
chformal -remove

flow/scripts/util.tcl

+17
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,20 @@ proc erase_non_stage_variables {stage_name} {
136136
}
137137

138138
set global_route_congestion_report $::env(REPORTS_DIR)/congestion.rpt
139+
140+
proc place_density_with_lb_addon {} {
141+
# check the lower boundary of the PLACE_DENSITY and add PLACE_DENSITY_LB_ADDON if it exists
142+
if {[info exist ::env(PLACE_DENSITY_LB_ADDON)]} {
143+
set place_density_lb [gpl::get_global_placement_uniform_density \
144+
-pad_left $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \
145+
-pad_right $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT)]
146+
set place_density [expr $place_density_lb + ((1.0 - $place_density_lb) * $::env(PLACE_DENSITY_LB_ADDON)) + 0.01]
147+
if {$place_density > 1.0} {
148+
utl::error FLW 24 "Place density exceeds 1.0 (current PLACE_DENSITY_LB_ADDON = $::env(PLACE_DENSITY_LB_ADDON)). Please check if the value of PLACE_DENSITY_LB_ADDON is between 0 and 0.99."
149+
}
150+
puts "Placement density is $place_density, computed from PLACE_DENSITY_LB_ADDON $::env(PLACE_DENSITY_LB_ADDON) and lower bound $place_density_lb"
151+
} else {
152+
set place_density $::env(PLACE_DENSITY)
153+
}
154+
return $place_density
155+
}

0 commit comments

Comments
 (0)