Skip to content

Commit aee62a0

Browse files
authored
Merge pull request #1366 from Pinata-Consulting/makefile-floorplan-debug-macros
makefile: add make preview_macro_placement
2 parents 147bf08 + 799eadc commit aee62a0

File tree

4 files changed

+159
-136
lines changed

4 files changed

+159
-136
lines changed

flow/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@ endif
522522
#-------------------------------------------------------------------------------
523523
$(eval $(call do-step,2_4_floorplan_macro,$(RESULTS_DIR)/2_3_floorplan_tdms.odb $(RESULTS_DIR)/1_synth.v $(RESULTS_DIR)/1_synth.sdc $(MACRO_PLACEMENT) $(MACRO_PLACEMENT_TCL),macro_place))
524524

525+
$(eval $(call do-step,2_floorplan_debug_macros,$(RESULTS_DIR)/2_1_floorplan.odb $(RESULTS_DIR)/1_synth.v $(MACRO_PLACEMENT) $(MACRO_PLACEMENT_TCL),floorplan_debug_macros))
526+
525527
# STEP 5: Tapcell and Welltie insertion
526528
#-------------------------------------------------------------------------------
527529
$(eval $(call do-step,2_5_floorplan_tapcell,$(RESULTS_DIR)/2_4_floorplan_macro.odb $(TAPCELL_TCL),tapcell))
@@ -916,6 +918,18 @@ gui_route: gui_5_route.odb
916918
.PHONY: gui_final
917919
gui_final: gui_6_final.odb
918920

921+
.PHONY: preview_macro_placement
922+
923+
ifneq ($(or $(MACRO_PLACEMENT),$(MACRO_PLACEMENT_TCL)),)
924+
MACRO_PREVIEW_ODB = 2_floorplan_debug_macros.odb
925+
else
926+
MACRO_PREVIEW_ODB = 2_4_floorplan_macro.odb
927+
endif
928+
929+
preview_macro_placement:
930+
@$(UNSET_AND_MAKE) $(RESULTS_DIR)/$(MACRO_PREVIEW_ODB)
931+
@$(UNSET_AND_MAKE) gui_$(MACRO_PREVIEW_ODB)
932+
919933
.PHONY: $(foreach file,$(RESULTS_DEF),gui_$(file))
920934
$(foreach file,$(RESULTS_DEF),gui_$(file)): gui_%:
921935
DEF_FILE=$(RESULTS_DIR)/$* $(OPENROAD_GUI_CMD) $(SCRIPTS_DIR)/gui.tcl
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source $::env(SCRIPTS_DIR)/load.tcl
2+
load_design 2_1_floorplan.odb 1_synth.sdc "Debug floorplan"
3+
4+
source $::env(SCRIPTS_DIR)/macro_place_util.tcl
5+
6+
if {![info exists save_checkpoint] || $save_checkpoint} {
7+
write_db $::env(RESULTS_DIR)/2_floorplan_debug_macros.odb
8+
}

flow/scripts/macro_place.tcl

Lines changed: 1 addition & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,7 @@
11
source $::env(SCRIPTS_DIR)/load.tcl
22
load_design 2_3_floorplan_tdms.odb 1_synth.sdc "Starting macro placement"
33

4-
proc find_macros {} {
5-
set macros ""
6-
7-
set db [ord::get_db]
8-
set block [[$db getChip] getBlock]
9-
foreach inst [$block getInsts] {
10-
set inst_master [$inst getMaster]
11-
12-
# BLOCK means MACRO cells
13-
if { [string match [$inst_master getType] "BLOCK"] } {
14-
append macros " " $inst
15-
}
16-
}
17-
return $macros
18-
}
19-
20-
if {[find_macros] != ""} {
21-
# If wrappers defined replace macros with their wrapped version
22-
# # ----------------------------------------------------------------------------
23-
if {[info exists ::env(MACRO_WRAPPERS)]} {
24-
source $::env(MACRO_WRAPPERS)
25-
26-
set wrapped_macros [dict keys [dict get $wrapper around]]
27-
set db [ord::get_db]
28-
set block [ord::get_db_block]
29-
30-
foreach inst [$block getInsts] {
31-
if {[lsearch -exact $wrapped_macros [[$inst getMaster] getName]] > -1} {
32-
set new_master [dict get $wrapper around [[$inst getMaster] getName]]
33-
puts "Replacing [[$inst getMaster] getName] with $new_master for [$inst getName]"
34-
$inst swapMaster [$db findMaster $new_master]
35-
}
36-
}
37-
}
38-
39-
lassign $::env(MACRO_PLACE_HALO) halo_x halo_y
40-
lassign $::env(MACRO_PLACE_CHANNEL) channel_x channel_y
41-
set halo_max [expr max($halo_x, $halo_y)]
42-
set channel_max [expr max($channel_x, $channel_y)]
43-
set blockage_width [expr max($halo_max, $channel_max/2)]
44-
45-
46-
if {[info exists ::env(MACRO_BLOCKAGE_HALO)]} {
47-
set blockage_width $::env(MACRO_BLOCKAGE_HALO)
48-
}
49-
50-
if {[info exists ::env(MACRO_PLACEMENT_TCL)]} {
51-
source $::env(MACRO_PLACEMENT_TCL)
52-
puts "\[INFO\]\[FLOW-xxxx\] Using manual macro placement file $::env(MACRO_PLACEMENT_TCL)"
53-
} elseif {[info exists ::env(MACRO_PLACEMENT)]} {
54-
source $::env(SCRIPTS_DIR)/read_macro_placement.tcl
55-
puts "\[INFO\]\[FLOW-xxxx\] Using manual macro placement file $::env(MACRO_PLACEMENT)"
56-
read_macro_placement $::env(MACRO_PLACEMENT)
57-
} elseif {[info exists ::env(RTLMP_FLOW)]} {
58-
puts "HierRTLMP Flow enabled..."
59-
set additional_rtlmp_args ""
60-
if { [info exists ::env(RTLMP_MAX_LEVEL)]} {
61-
append additional_rtlmp_args " -max_num_level $env(RTLMP_MAX_LEVEL)"
62-
}
63-
if { [info exists ::env(RTLMP_MAX_INST)]} {
64-
append additional_rtlmp_args " -max_num_inst $env(RTLMP_MAX_INST)"
65-
}
66-
if { [info exists ::env(RTLMP_MIN_INST)]} {
67-
append additional_rtlmp_args " -min_num_inst $env(RTLMP_MIN_INST)"
68-
}
69-
if { [info exists ::env(RTLMP_MAX_MACRO)]} {
70-
append additional_rtlmp_args " -max_num_macro $env(RTLMP_MAX_MACRO)"
71-
}
72-
if { [info exists ::env(RTLMP_MIN_MACRO)]} {
73-
append additional_rtlmp_args " -min_num_macro $env(RTLMP_MIN_MACRO)"
74-
}
75-
76-
append additional_rtlmp_args " -halo_width $halo_max"
77-
78-
if { [info exists ::env(RTLMP_MIN_AR)]} {
79-
append additional_rtlmp_args " -min_ar $env(RTLMP_MIN_AR)"
80-
}
81-
if { [info exists ::env(RTLMP_AREA_WT)]} {
82-
append additional_rtlmp_args " -area_weight $env(RTLMP_AREA_WT)"
83-
}
84-
if { [info exists ::env(RTLMP_WIRELENGTH_WT)]} {
85-
append additional_rtlmp_args " -wirelength_weight $env(RTLMP_WIRELENGTH_WT)"
86-
}
87-
if { [info exists ::env(RTLMP_OUTLINE_WT)]} {
88-
append additional_rtlmp_args " -outline_weight $env(RTLMP_OUTLINE_WT)"
89-
}
90-
if { [info exists ::env(RTLMP_BOUNDARY_WT)]} {
91-
append additional_rtlmp_args " -boundary_weight $env(RTLMP_BOUNDARY_WT)"
92-
}
93-
94-
if { [info exists ::env(RTLMP_NOTCH_WT)]} {
95-
append additional_rtlmp_args " -notch_weight $env(RTLMP_NOTCH_WT)"
96-
}
97-
98-
if { [info exists ::env(RTLMP_DEAD_SPACE)]} {
99-
append additional_rtlmp_args " -dead_space $env(RTLMP_DEAD_SPACE)"
100-
}
101-
if { [info exists ::env(RTLMP_CONFIG_FILE)]} {
102-
append additional_rtlmp_args " -config_file $env(RTLMP_CONFIG_FILE)"
103-
}
104-
if { [info exists ::env(RTLMP_RPT_DIR)]} {
105-
append additional_rtlmp_args " -report_directory $env(RTLMP_RPT_DIR)"
106-
}
107-
108-
if { [info exists ::env(RTLMP_FENCE_LX)]} {
109-
append additional_rtlmp_args " -fence_lx $env(RTLMP_FENCE_LX)"
110-
}
111-
if { [info exists ::env(RTLMP_FENCE_LY)]} {
112-
append additional_rtlmp_args " -fence_ly $env(RTLMP_FENCE_LY)"
113-
}
114-
if { [info exists ::env(RTLMP_FENCE_UX)]} {
115-
append additional_rtlmp_args " -fence_ux $env(RTLMP_FENCE_UX)"
116-
}
117-
if { [info exists ::env(RTLMP_FENCE_UY)]} {
118-
append additional_rtlmp_args " -fence_uy $env(RTLMP_FENCE_UY)"
119-
}
120-
121-
122-
puts "Call Macro Placer $additional_rtlmp_args"
123-
124-
rtl_macro_placer \
125-
{*}$additional_rtlmp_args
126-
127-
puts "Delete buffers for RTLMP flow..."
128-
remove_buffers
129-
} else {
130-
macro_placement \
131-
-halo $::env(MACRO_PLACE_HALO) \
132-
-channel $::env(MACRO_PLACE_CHANNEL)
133-
}
134-
135-
source $::env(SCRIPTS_DIR)/placement_blockages.tcl
136-
block_channels $blockage_width
137-
} else {
138-
puts "No macros found: Skipping macro_placement"
139-
}
4+
source $::env(SCRIPTS_DIR)/macro_place_util.tcl
1405

1416
if {![info exists save_checkpoint] || $save_checkpoint} {
1427
write_db $::env(RESULTS_DIR)/2_4_floorplan_macro.odb

flow/scripts/macro_place_util.tcl

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
proc find_macros {} {
2+
set macros ""
3+
4+
set db [ord::get_db]
5+
set block [[$db getChip] getBlock]
6+
foreach inst [$block getInsts] {
7+
set inst_master [$inst getMaster]
8+
9+
# BLOCK means MACRO cells
10+
if { [string match [$inst_master getType] "BLOCK"] } {
11+
append macros " " $inst
12+
}
13+
}
14+
return $macros
15+
}
16+
17+
if {[find_macros] != ""} {
18+
# If wrappers defined replace macros with their wrapped version
19+
# # ----------------------------------------------------------------------------
20+
if {[info exists ::env(MACRO_WRAPPERS)]} {
21+
source $::env(MACRO_WRAPPERS)
22+
23+
set wrapped_macros [dict keys [dict get $wrapper around]]
24+
set db [ord::get_db]
25+
set block [ord::get_db_block]
26+
27+
foreach inst [$block getInsts] {
28+
if {[lsearch -exact $wrapped_macros [[$inst getMaster] getName]] > -1} {
29+
set new_master [dict get $wrapper around [[$inst getMaster] getName]]
30+
puts "Replacing [[$inst getMaster] getName] with $new_master for [$inst getName]"
31+
$inst swapMaster [$db findMaster $new_master]
32+
}
33+
}
34+
}
35+
36+
lassign $::env(MACRO_PLACE_HALO) halo_x halo_y
37+
lassign $::env(MACRO_PLACE_CHANNEL) channel_x channel_y
38+
set halo_max [expr max($halo_x, $halo_y)]
39+
set channel_max [expr max($channel_x, $channel_y)]
40+
set blockage_width [expr max($halo_max, $channel_max/2)]
41+
42+
43+
if {[info exists ::env(MACRO_BLOCKAGE_HALO)]} {
44+
set blockage_width $::env(MACRO_BLOCKAGE_HALO)
45+
}
46+
47+
if {[info exists ::env(MACRO_PLACEMENT_TCL)]} {
48+
source $::env(MACRO_PLACEMENT_TCL)
49+
puts "\[INFO\]\[FLOW-xxxx\] Using manual macro placement file $::env(MACRO_PLACEMENT_TCL)"
50+
} elseif {[info exists ::env(MACRO_PLACEMENT)]} {
51+
source $::env(SCRIPTS_DIR)/read_macro_placement.tcl
52+
puts "\[INFO\]\[FLOW-xxxx\] Using manual macro placement file $::env(MACRO_PLACEMENT)"
53+
read_macro_placement $::env(MACRO_PLACEMENT)
54+
} elseif {[info exists ::env(RTLMP_FLOW)]} {
55+
puts "HierRTLMP Flow enabled..."
56+
set additional_rtlmp_args ""
57+
if { [info exists ::env(RTLMP_MAX_LEVEL)]} {
58+
append additional_rtlmp_args " -max_num_level $env(RTLMP_MAX_LEVEL)"
59+
}
60+
if { [info exists ::env(RTLMP_MAX_INST)]} {
61+
append additional_rtlmp_args " -max_num_inst $env(RTLMP_MAX_INST)"
62+
}
63+
if { [info exists ::env(RTLMP_MIN_INST)]} {
64+
append additional_rtlmp_args " -min_num_inst $env(RTLMP_MIN_INST)"
65+
}
66+
if { [info exists ::env(RTLMP_MAX_MACRO)]} {
67+
append additional_rtlmp_args " -max_num_macro $env(RTLMP_MAX_MACRO)"
68+
}
69+
if { [info exists ::env(RTLMP_MIN_MACRO)]} {
70+
append additional_rtlmp_args " -min_num_macro $env(RTLMP_MIN_MACRO)"
71+
}
72+
73+
append additional_rtlmp_args " -halo_width $halo_max"
74+
75+
if { [info exists ::env(RTLMP_MIN_AR)]} {
76+
append additional_rtlmp_args " -min_ar $env(RTLMP_MIN_AR)"
77+
}
78+
if { [info exists ::env(RTLMP_AREA_WT)]} {
79+
append additional_rtlmp_args " -area_weight $env(RTLMP_AREA_WT)"
80+
}
81+
if { [info exists ::env(RTLMP_WIRELENGTH_WT)]} {
82+
append additional_rtlmp_args " -wirelength_weight $env(RTLMP_WIRELENGTH_WT)"
83+
}
84+
if { [info exists ::env(RTLMP_OUTLINE_WT)]} {
85+
append additional_rtlmp_args " -outline_weight $env(RTLMP_OUTLINE_WT)"
86+
}
87+
if { [info exists ::env(RTLMP_BOUNDARY_WT)]} {
88+
append additional_rtlmp_args " -boundary_weight $env(RTLMP_BOUNDARY_WT)"
89+
}
90+
91+
if { [info exists ::env(RTLMP_NOTCH_WT)]} {
92+
append additional_rtlmp_args " -notch_weight $env(RTLMP_NOTCH_WT)"
93+
}
94+
95+
if { [info exists ::env(RTLMP_DEAD_SPACE)]} {
96+
append additional_rtlmp_args " -dead_space $env(RTLMP_DEAD_SPACE)"
97+
}
98+
if { [info exists ::env(RTLMP_CONFIG_FILE)]} {
99+
append additional_rtlmp_args " -config_file $env(RTLMP_CONFIG_FILE)"
100+
}
101+
if { [info exists ::env(RTLMP_RPT_DIR)]} {
102+
append additional_rtlmp_args " -report_directory $env(RTLMP_RPT_DIR)"
103+
}
104+
105+
if { [info exists ::env(RTLMP_FENCE_LX)]} {
106+
append additional_rtlmp_args " -fence_lx $env(RTLMP_FENCE_LX)"
107+
}
108+
if { [info exists ::env(RTLMP_FENCE_LY)]} {
109+
append additional_rtlmp_args " -fence_ly $env(RTLMP_FENCE_LY)"
110+
}
111+
if { [info exists ::env(RTLMP_FENCE_UX)]} {
112+
append additional_rtlmp_args " -fence_ux $env(RTLMP_FENCE_UX)"
113+
}
114+
if { [info exists ::env(RTLMP_FENCE_UY)]} {
115+
append additional_rtlmp_args " -fence_uy $env(RTLMP_FENCE_UY)"
116+
}
117+
118+
119+
puts "Call Macro Placer $additional_rtlmp_args"
120+
121+
rtl_macro_placer \
122+
{*}$additional_rtlmp_args
123+
124+
puts "Delete buffers for RTLMP flow..."
125+
remove_buffers
126+
} else {
127+
macro_placement \
128+
-halo $::env(MACRO_PLACE_HALO) \
129+
-channel $::env(MACRO_PLACE_CHANNEL)
130+
}
131+
132+
source $::env(SCRIPTS_DIR)/placement_blockages.tcl
133+
block_channels $blockage_width
134+
} else {
135+
puts "No macros found: Skipping macro_placement"
136+
}

0 commit comments

Comments
 (0)