Skip to content

Commit 9f3ad44

Browse files
authored
Merge pull request #2517 from Pinata-Consulting/sdc-pick-algorithm
Sdc pick algorithm
2 parents d5e6cb0 + 0802485 commit 9f3ad44

File tree

7 files changed

+42
-21
lines changed

7 files changed

+42
-21
lines changed

flow/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,8 @@ $(eval $(call do-step,2_1_floorplan,$(RESULTS_DIR)/1_synth.v $(RESULTS_DIR)/1_sy
645645
#-------------------------------------------------------------------------------
646646
$(eval $(call do-step,2_2_floorplan_io,$(RESULTS_DIR)/2_1_floorplan.odb $(IO_CONSTRAINTS),io_placement_random))
647647

648+
$(eval $(call do-copy,2_floorplan,2_1_floorplan.sdc,,.sdc))
649+
648650
# STEP 3: Macro Placement
649651
#-------------------------------------------------------------------------------
650652
$(eval $(call do-step,2_3_floorplan_macro,$(RESULTS_DIR)/2_2_floorplan_io.odb $(RESULTS_DIR)/1_synth.v $(RESULTS_DIR)/1_synth.sdc $(MACRO_PLACEMENT) $(MACRO_PLACEMENT_TCL),macro_place))

flow/scripts/floorplan.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,4 @@ if { [env_var_exists_and_non_empty POST_FLOORPLAN_TCL] } {
194194
}
195195

196196
write_db $::env(RESULTS_DIR)/2_1_floorplan.odb
197-
write_sdc -no_timestamp $::env(RESULTS_DIR)/2_floorplan.sdc
197+
write_sdc -no_timestamp $::env(RESULTS_DIR)/2_1_floorplan.sdc

flow/scripts/io_placement_random.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source $::env(SCRIPTS_DIR)/load.tcl
22
erase_non_stage_variables floorplan
33

44
if {![env_var_equals IS_CHIP 1]} {
5-
load_design 2_1_floorplan.odb 2_floorplan.sdc
5+
load_design 2_1_floorplan.odb 2_1_floorplan.sdc
66
lappend ::env(PLACE_PINS_ARGS) -random
77
source $::env(SCRIPTS_DIR)/io_placement_util.tcl
88
write_db $::env(RESULTS_DIR)/2_2_floorplan_io.odb

flow/scripts/macro_place.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source $::env(SCRIPTS_DIR)/load.tcl
22
erase_non_stage_variables floorplan
3-
load_design 2_2_floorplan_io.odb 2_floorplan.sdc
3+
load_design 2_2_floorplan_io.odb 2_1_floorplan.sdc
44

55
source $::env(SCRIPTS_DIR)/macro_place_util.tcl
66

flow/scripts/pdn.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source $::env(SCRIPTS_DIR)/load.tcl
22
erase_non_stage_variables floorplan
3-
load_design 2_4_floorplan_tapcell.odb 2_floorplan.sdc
3+
load_design 2_4_floorplan_tapcell.odb 2_1_floorplan.sdc
44

55
source $::env(PDN_TCL)
66
pdngen

flow/scripts/tapcell.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source $::env(SCRIPTS_DIR)/load.tcl
22
erase_non_stage_variables floorplan
33

4-
load_design 2_3_floorplan_macro.odb 2_floorplan.sdc
4+
load_design 2_3_floorplan_macro.odb 2_1_floorplan.sdc
55

66
if {[env_var_exists_and_non_empty TAPCELL_TCL]} {
77
source $::env(TAPCELL_TCL)

flow/scripts/util.tcl

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,43 @@ proc recover_power {} {
4646
report_power
4747
}
4848

49+
proc extract_stage {input_file} {
50+
if {![regexp {/([0-9])_(([0-9])_)?} $input_file match num1 _ num2]} {
51+
puts "ERROR: Could not determine design stage from $input_file"
52+
exit 1
53+
}
54+
lappend number_groups $num1
55+
if {$num2!=""} {
56+
lappend number_groups $num2
57+
} else {
58+
lappend number_groups "0"
59+
}
60+
}
61+
4962
proc find_sdc_file {input_file} {
50-
# Determine design stage (1 ... 6)
51-
set input_pieces [split [file tail $input_file] "_"]
52-
set design_stage [lindex $input_pieces 0]
53-
if { [llength $input_pieces] == 3 } {
54-
set start [expr $design_stage - 1]
55-
} else {
56-
set start $design_stage
57-
}
58-
# Read SDC, first try to find the most recent SDC file for the stage
59-
set sdc_file ""
60-
for {set s $start} {$s > 0} {incr s -1} {
61-
set sdc_file [glob -nocomplain -directory $::env(RESULTS_DIR) -types f "${s}_\[A-Za-z\]*\.sdc"]
62-
if {$sdc_file != ""} {
63-
break
64-
}
63+
# canonicalize input file, sometimes it is called with an input
64+
# file relative to $::env(RESULTS_DIR), other times with
65+
# an absolute path
66+
if { ![file exists $input_file] } {
67+
set input_file [file join $::env(RESULTS_DIR) $input_file]
68+
}
69+
set input_file [file normalize $input_file]
70+
71+
set stage [extract_stage $input_file]
72+
set design_stage [lindex $stage 0]
73+
set sdc_file ""
74+
75+
set exact_sdc [string map {.odb .sdc} $input_file]
76+
set sdc_files [glob -nocomplain -directory $::env(RESULTS_DIR) -types f "\[1-9+\]_\[1-9_A-Za-z\]*\.sdc"]
77+
set sdc_files [lsort -decreasing -dictionary $sdc_files]
78+
set sdc_files [lmap file $sdc_files {file normalize $file}]
79+
foreach name $sdc_files {
80+
if {[lindex [lsort -decreasing -dictionary [list $name $exact_sdc] ] 0] == $exact_sdc} {
81+
set sdc_file $name
82+
break
6583
}
66-
return [list $design_stage $sdc_file]
84+
}
85+
return [list $design_stage $sdc_file]
6786
}
6887

6988
proc env_var_equals {env_var value} {

0 commit comments

Comments
 (0)