From 4ac0d95ceb7db711e4f3c84a2b0b50afffefb120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Mon, 10 Aug 2026 15:56:24 +0200 Subject: [PATCH] flow: refactor io_placement to avoid propagating intermediate ODB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change modifies io_placement to write a script with pin locations rather than passing a messy intermediate ODB to global placement. Since io_placement.tcl writes a pin placement script without persisting its intermediate database state to the next stage, POST_IO_PLACEMENT is moot. Furthermore, if FLOORPLAN_DEF is set, no design is even loaded, causing POST_IO_PLACEMENT to fail if a script tries to use it. Any placement modifications should be done in PRE_GLOBAL_PLACE instead. Signed-off-by: Øyvind Harboe --- flow/Makefile | 28 ++++++++++----------- flow/scripts/detail_place.tcl | 6 ++--- flow/scripts/global_place.tcl | 9 +++---- flow/scripts/global_place_skip_io.tcl | 25 ------------------- flow/scripts/io_placement.tcl | 35 +++++++++++++++++++-------- flow/scripts/resize.tcl | 4 +-- 6 files changed, 47 insertions(+), 60 deletions(-) delete mode 100644 flow/scripts/global_place_skip_io.tcl diff --git a/flow/Makefile b/flow/Makefile index 5d40220097..2ad6cb69f3 100644 --- a/flow/Makefile +++ b/flow/Makefile @@ -484,37 +484,35 @@ clean_floorplan: place: $(RESULTS_DIR)/3_place.odb \ $(RESULTS_DIR)/3_place.sdc # ============================================================================== -# STEP 1: Global placement without placed IOs, timing-driven, and routability-driven. +# STEP 1: IO placement #------------------------------------------------------------------------------- -$(eval $(call do-step,3_1_place_gp_skip_io,$(RESULTS_DIR)/2_floorplan.odb $(RESULTS_DIR)/2_floorplan.sdc $(LIB_FILES),global_place_skip_io)) +$(eval $(call do-step,3_1_place_iop,$(RESULTS_DIR)/2_floorplan.odb $(RESULTS_DIR)/2_floorplan.sdc $(LIB_FILES),io_placement,.tcl)) -$(eval $(call do-step,3_2_place_iop,$(RESULTS_DIR)/3_1_place_gp_skip_io.odb,io_placement)) - -# STEP 3: Global placement with placed IOs, timing-driven, and routability-driven. +# STEP 2: Global placement with placed IOs, timing-driven, and routability-driven. #------------------------------------------------------------------------------- -$(eval $(call do-step,3_3_place_gp,$(RESULTS_DIR)/3_2_place_iop.odb $(RESULTS_DIR)/2_floorplan.sdc $(LIB_FILES),global_place)) +$(eval $(call do-step,3_2_place_gp,$(RESULTS_DIR)/2_floorplan.odb $(RESULTS_DIR)/3_1_place_iop.tcl $(RESULTS_DIR)/2_floorplan.sdc $(LIB_FILES),global_place)) -# STEP 4: Resizing & Buffering +# STEP 3: Resizing & Buffering #------------------------------------------------------------------------------- -$(eval $(call do-step,3_4_place_resized,$(RESULTS_DIR)/3_3_place_gp.odb $(RESULTS_DIR)/2_floorplan.sdc,resize)) +$(eval $(call do-step,3_3_place_resized,$(RESULTS_DIR)/3_2_place_gp.odb $(RESULTS_DIR)/2_floorplan.sdc,resize)) .PHONY: clean_resize clean_resize: - rm -f $(RESULTS_DIR)/3_4_place_resized.odb + rm -f $(RESULTS_DIR)/3_3_place_resized.odb -# STEP 5: Detail placement +# STEP 4: Detail placement #------------------------------------------------------------------------------- -$(eval $(call do-step,3_5_place_dp,$(RESULTS_DIR)/3_4_place_resized.odb,detail_place)) +$(eval $(call do-step,3_4_place_dp,$(RESULTS_DIR)/3_3_place_resized.odb,detail_place)) -$(eval $(call do-copy,3_place,3_5_place_dp.odb,)) +$(eval $(call do-copy,3_place,3_4_place_dp.odb,)) -# detail_place writes 3_place.sdc alongside 3_5_place_dp.odb (constraints +# detail_place writes 3_place.sdc alongside 3_4_place_dp.odb (constraints # are unchanged during placement), mirroring how synth writes 1_synth.sdc. -$(RESULTS_DIR)/3_place.sdc: $(RESULTS_DIR)/3_5_place_dp.odb +$(RESULTS_DIR)/3_place.sdc: $(RESULTS_DIR)/3_4_place_dp.odb .PHONY: do-place do-place: - $(UNSET_AND_MAKE) do-3_1_place_gp_skip_io do-3_2_place_iop do-3_3_place_gp do-3_4_place_resized do-3_5_place_dp do-3_place + $(UNSET_AND_MAKE) do-3_1_place_iop do-3_2_place_gp do-3_3_place_resized do-3_4_place_dp do-3_place # Clean Targets #------------------------------------------------------------------------------- diff --git a/flow/scripts/detail_place.tcl b/flow/scripts/detail_place.tcl index c29d9ab90c..007bb3b1e9 100644 --- a/flow/scripts/detail_place.tcl +++ b/flow/scripts/detail_place.tcl @@ -1,7 +1,7 @@ utl::set_metrics_stage "detailedplace__{}" source $::env(SCRIPTS_DIR)/load.tcl erase_non_stage_variables place -load_design 3_4_place_resized.odb 2_floorplan.sdc +load_design 3_3_place_resized.odb 2_floorplan.sdc source_step_tcl PRE DETAIL_PLACE source $::env(PLATFORM_DIR)/setRC.tcl @@ -34,7 +34,7 @@ proc do_dpl { } { set result [catch { do_dpl } errMsg] if { $result != 0 } { - orfs_write_db $::env(RESULTS_DIR)/3_5_place_dp-failed.odb + orfs_write_db $::env(RESULTS_DIR)/3_4_place_dp-failed.odb error $errMsg } @@ -42,5 +42,5 @@ report_metrics 3 "detailed place" true false source_step_tcl POST DETAIL_PLACE -orfs_write_db $::env(RESULTS_DIR)/3_5_place_dp.odb +orfs_write_db $::env(RESULTS_DIR)/3_4_place_dp.odb orfs_write_sdc $::env(RESULTS_DIR)/3_place.sdc diff --git a/flow/scripts/global_place.tcl b/flow/scripts/global_place.tcl index 5822ef47c2..842347f5ce 100644 --- a/flow/scripts/global_place.tcl +++ b/flow/scripts/global_place.tcl @@ -1,7 +1,8 @@ utl::set_metrics_stage "globalplace__{}" source $::env(SCRIPTS_DIR)/load.tcl erase_non_stage_variables place -load_design 3_2_place_iop.odb 2_floorplan.sdc +load_design 2_floorplan.odb 2_floorplan.sdc +source $::env(RESULTS_DIR)/3_1_place_iop.tcl source_step_tcl PRE GLOBAL_PLACE set_dont_use $::env(DONT_USE_CELLS) @@ -46,8 +47,6 @@ if { $min_phi > $max_phi } { MAX_PLACE_STEP_COEF ($max_phi)" } -lappend global_placement_args -force_center_initial_place - lappend global_placement_args -min_phi_coef $::env(MIN_PLACE_STEP_COEF) lappend global_placement_args -max_phi_coef $::env(MAX_PLACE_STEP_COEF) @@ -64,7 +63,7 @@ proc do_placement { global_placement_args } { set result [catch { do_placement $global_placement_args } errMsg] if { $result != 0 } { - orfs_write_db $::env(RESULTS_DIR)/3_3_place_gp-failed.odb + orfs_write_db $::env(RESULTS_DIR)/3_2_place_gp-failed.odb error $errMsg } @@ -79,4 +78,4 @@ report_metrics 3 "global place" false false source_step_tcl POST GLOBAL_PLACE -orfs_write_db $::env(RESULTS_DIR)/3_3_place_gp.odb +orfs_write_db $::env(RESULTS_DIR)/3_2_place_gp.odb diff --git a/flow/scripts/global_place_skip_io.tcl b/flow/scripts/global_place_skip_io.tcl deleted file mode 100644 index 38c58917d4..0000000000 --- a/flow/scripts/global_place_skip_io.tcl +++ /dev/null @@ -1,25 +0,0 @@ -source $::env(SCRIPTS_DIR)/load.tcl -erase_non_stage_variables place -load_design 2_floorplan.odb 2_floorplan.sdc -source_step_tcl PRE GLOBAL_PLACE_SKIP_IO - -if { [env_var_exists_and_non_empty FLOORPLAN_DEF] } { - puts "FLOORPLAN_DEF is set. Skipping global placement without IOs" -} elseif { [all_pins_placed] } { - puts "All pins are placed. Skipping global placement without IOs" -} else { - set global_placement_args {} - append_env_var global_placement_args GPL_RANDOM_SEED -random_seed 1 - - log_cmd global_placement -skip_io -density [place_density_with_lb_addon] \ - -pad_left $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \ - -pad_right $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \ - {*}[env_var_or_empty GLOBAL_PLACEMENT_ARGS] \ - {*}$global_placement_args -} - -source_step_tcl POST GLOBAL_PLACE_SKIP_IO - -report_design_area - -orfs_write_db $::env(RESULTS_DIR)/3_1_place_gp_skip_io.odb diff --git a/flow/scripts/io_placement.tcl b/flow/scripts/io_placement.tcl index 5ad95bad51..2238fc7a29 100644 --- a/flow/scripts/io_placement.tcl +++ b/flow/scripts/io_placement.tcl @@ -2,22 +2,37 @@ source $::env(SCRIPTS_DIR)/load.tcl erase_non_stage_variables place if { - ![env_var_exists_and_non_empty FLOORPLAN_DEF] && - ![env_var_exists_and_non_empty FOOTPRINT] && - ![env_var_exists_and_non_empty FOOTPRINT_TCL] + [env_var_exists_and_non_empty FLOORPLAN_DEF] || + [env_var_exists_and_non_empty FOOTPRINT] || + [env_var_exists_and_non_empty FOOTPRINT_TCL] } { - load_design 3_1_place_gp_skip_io.odb 2_floorplan.sdc + puts "Pin placement already provided by floorplan initialization. Writing empty placeholder script." + close [open $::env(RESULTS_DIR)/3_1_place_iop.tcl w] +} else { + load_design 2_floorplan.odb 2_floorplan.sdc source_step_tcl PRE IO_PLACEMENT + + set global_placement_args {} + append_env_var global_placement_args GPL_RANDOM_SEED -random_seed 1 + + log_cmd global_placement -skip_io -density [place_density_with_lb_addon] \ + -pad_left $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \ + -pad_right $::env(CELL_PAD_IN_SITES_GLOBAL_PLACEMENT) \ + {*}[env_var_or_empty GLOBAL_PLACEMENT_ARGS] \ + {*}$global_placement_args + log_cmd place_pins \ -hor_layers $::env(IO_PLACER_H) \ -ver_layers $::env(IO_PLACER_V) \ {*}[env_var_or_empty PLACE_PINS_ARGS] + report_design_area - orfs_write_db $::env(RESULTS_DIR)/3_2_place_iop.odb - write_pin_placement $::env(RESULTS_DIR)/3_2_place_iop.tcl -} else { - orfs_copy_db $::env(RESULTS_DIR)/3_1_place_gp_skip_io.odb $::env(RESULTS_DIR)/3_2_place_iop.odb -} + write_pin_placement $::env(RESULTS_DIR)/3_1_place_iop.tcl -source_step_tcl POST IO_PLACEMENT + if { [env_var_exists_and_non_empty DEBUG_IO_PLACEMENT_ODB] } { + orfs_write_db $::env(RESULTS_DIR)/3_1_place_iop_debug.odb + } + + source_step_tcl POST IO_PLACEMENT +} diff --git a/flow/scripts/resize.tcl b/flow/scripts/resize.tcl index 73321e7f81..77b5d89941 100644 --- a/flow/scripts/resize.tcl +++ b/flow/scripts/resize.tcl @@ -1,7 +1,7 @@ utl::set_metrics_stage "placeopt__{}" source $::env(SCRIPTS_DIR)/load.tcl erase_non_stage_variables place -load_design 3_3_place_gp.odb 2_floorplan.sdc +load_design 3_2_place_gp.odb 2_floorplan.sdc source_step_tcl PRE RESIZE log_cmd estimate_parasitics -placement @@ -44,4 +44,4 @@ puts "Pin count before $pin_count_before, after [sta::network_leaf_pin_count]" source_step_tcl POST RESIZE -orfs_write_db $::env(RESULTS_DIR)/3_4_place_resized.odb +orfs_write_db $::env(RESULTS_DIR)/3_3_place_resized.odb