Skip to content

Commit 2caf38b

Browse files
authored
Merge pull request #2398 from Pinata-Consulting/scripts-cleanup-4
scripts: tcl info exist/s cleanup
2 parents 108a106 + f003fae commit 2caf38b

File tree

8 files changed

+34
-30
lines changed

8 files changed

+34
-30
lines changed

flow/scripts/gui.tcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ source $::env(SCRIPTS_DIR)/util.tcl
33
source $::env(SCRIPTS_DIR)/read_liberty.tcl
44

55
# Read def
6-
if {[info exist ::env(DEF_FILE)]} {
6+
if {[env_var_exists_and_non_empty DEF_FILE]} {
77
# Read lef
88
read_lef $::env(TECH_LEF)
99
read_lef $::env(SC_LEF)
10-
if {[info exist ::env(ADDITIONAL_LEFS)]} {
10+
if {[env_var_exists_and_non_empty ADDITIONAL_LEFS]} {
1111
foreach lef $::env(ADDITIONAL_LEFS) {
1212
read_lef $lef
1313
}
@@ -49,6 +49,6 @@ proc read_timing {input_file} {
4949
fast_route
5050
}
5151

52-
if {![info exist ::env(GUI_NO_TIMING)]} {
52+
if {![env_var_equals GUI_NO_TIMING 1]} {
5353
read_timing $input_file
5454
}

flow/scripts/load.tcl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ proc load_design {design_file sdc_file} {
1414
if {$ext == ".v"} {
1515
read_lef $::env(TECH_LEF)
1616
read_lef $::env(SC_LEF)
17-
if {[info exist ::env(ADDITIONAL_LEFS)]} {
17+
if {[env_var_exists_and_non_empty ADDITIONAL_LEFS]} {
1818
foreach lef $::env(ADDITIONAL_LEFS) {
1919
read_lef $lef
2020
}
@@ -51,13 +51,13 @@ proc get_verilog_cells_for_design { } {
5151
}
5252

5353
proc write_eqy_verilog {filename} {
54-
# Filter out cells with no verilog/not needed for equivalence such
55-
# as fillers and tap cells
56-
if {[info exist ::env(REMOVE_CELLS_FOR_EQY)]} {
57-
write_verilog -remove_cells $::env(REMOVE_CELLS_FOR_EQY) $::env(RESULTS_DIR)/$filename
58-
} else {
59-
write_verilog $::env(RESULTS_DIR)/$filename
60-
}
54+
# Filter out cells with no verilog/not needed for equivalence such
55+
# as fillers and tap cells
56+
if {[env_var_exists_and_non_empty REMOVE_CELLS_FOR_EQY]} {
57+
write_verilog -remove_cells $::env(REMOVE_CELLS_FOR_EQY) $::env(RESULTS_DIR)/$filename
58+
} else {
59+
write_verilog $::env(RESULTS_DIR)/$filename
60+
}
6161
}
6262

6363
proc write_eqy_script_for_sky130hd {} {

flow/scripts/resize.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if { [env_var_exists_and_non_empty SLEW_MARGIN] && $::env(SLEW_MARGIN) > 0.0} {
3333

3434
repair_design {*}$additional_args
3535

36-
if { [info exists env(TIE_SEPARATION)] } {
36+
if { [env_var_exists_and_non_empty TIE_SEPARATION] } {
3737
set tie_separation $env(TIE_SEPARATION)
3838
} else {
3939
set tie_separation 0

flow/scripts/save_images.tcl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
source $::env(SCRIPTS_DIR)/util.tcl
2+
13
gui::save_display_controls
24

35
set height [[[ord::get_db_block] getBBox] getDY]
@@ -35,7 +37,7 @@ gui::set_display_controls "Layers/*" visible false
3537
gui::set_display_controls "Instances/Physical/*" visible false
3638
save_image -resolution $resolution $::env(REPORTS_DIR)/final_placement.webp
3739

38-
if {[info exist ::env(PWR_NETS_VOLTAGES)] && [string length $::env(PWR_NETS_VOLTAGES)] > 0} {
40+
if {[env_var_exists_and_non_empty PWR_NETS_VOLTAGES]} {
3941
gui::set_display_controls "Heat Maps/IR Drop" visible true
4042
gui::set_heatmap IRDrop Layer $::env(IR_DROP_LAYER)
4143
gui::set_heatmap IRDrop ShowLegend 1

flow/scripts/synth.tcl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source $::env(SCRIPTS_DIR)/synth_preamble.tcl
22

33
source $::env(SYNTH_STOP_MODULE_SCRIPT)
44

5-
if { [info exist ::env(SYNTH_GUT)] && $::env(SYNTH_GUT) == 1 } {
5+
if { [env_var_equals SYNTH_GUT 1] } {
66
hierarchy -check -top $::env(DESIGN_NAME)
77
# /deletes all cells at the top level, which will quickly optimize away
88
# everything else, including macros.
@@ -20,7 +20,7 @@ renames -wire
2020
opt -purge
2121

2222
# Technology mapping of adders
23-
if {[info exist ::env(ADDER_MAP_FILE)] && [file isfile $::env(ADDER_MAP_FILE)]} {
23+
if {[env_var_exists_and_non_empty ADDER_MAP_FILE] && [file isfile $::env(ADDER_MAP_FILE)]} {
2424
# extract the full adders
2525
extract_fa
2626
# map full adders
@@ -31,7 +31,7 @@ if {[info exist ::env(ADDER_MAP_FILE)] && [file isfile $::env(ADDER_MAP_FILE)]}
3131
}
3232

3333
# Technology mapping of latches
34-
if {[info exist ::env(LATCH_MAP_FILE)]} {
34+
if {[env_var_exists_and_non_empty LATCH_MAP_FILE]} {
3535
techmap -map $::env(LATCH_MAP_FILE)
3636
}
3737

@@ -42,7 +42,7 @@ foreach cell $::env(DONT_USE_CELLS) {
4242

4343
# Technology mapping of flip-flops
4444
# dfflibmap only supports one liberty file
45-
if {[info exist ::env(DFF_LIB_FILE)]} {
45+
if {[env_var_exists_and_non_empty DFF_LIB_FILE]} {
4646
dfflibmap -liberty $::env(DFF_LIB_FILE) {*}$dfflibmap_args
4747
} else {
4848
dfflibmap -liberty $::env(DONT_USE_SC_LIB) {*}$dfflibmap_args

flow/scripts/synth_hier_report.tcl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
source $::env(SCRIPTS_DIR)/util.tcl
2+
13
proc write_keep_hierarchy {} {
2-
if { ![info exist ::env(SYNTH_HIERARCHICAL)] || $::env(SYNTH_HIERARCHICAL) == 0 } {
4+
if { ![env_var_equals SYNTH_HIERARCHICAL 1] } {
35
set out_script_ptr [open $::env(SYNTH_STOP_MODULE_SCRIPT) w]
46
close $out_script_ptr
57
return
@@ -9,11 +11,11 @@ proc write_keep_hierarchy {} {
911

1012
synthesize_check {}
1113

12-
if { [info exist ::env(ADDER_MAP_FILE)] && [file isfile $::env(ADDER_MAP_FILE)] } {
14+
if { [env_var_exists_and_non_empty ADDER_MAP_FILE] && [file isfile $::env(ADDER_MAP_FILE)] } {
1315
techmap -map $::env(ADDER_MAP_FILE)
1416
}
1517
techmap
16-
if {[info exist ::env(DFF_LIB_FILE)]} {
18+
if {[env_var_exists_and_non_empty DFF_LIB_FILE]} {
1719
dfflibmap -liberty $::env(DFF_LIB_FILE)
1820
} else {
1921
dfflibmap -liberty $::env(DONT_USE_SC_LIB)
@@ -24,7 +26,7 @@ proc write_keep_hierarchy {} {
2426
tee -o $::env(REPORTS_DIR)/synth_hier_stat.txt stat {*}$stat_libs
2527

2628
set ungroup_threshold 0
27-
if { [info exist ::env(MAX_UNGROUP_SIZE)] && $::env(MAX_UNGROUP_SIZE) > 0 } {
29+
if { [env_var_exists_and_non_empty MAX_UNGROUP_SIZE] && $::env(MAX_UNGROUP_SIZE) > 0 } {
2830
set ungroup_threshold $::env(MAX_UNGROUP_SIZE)
2931
puts "Ungroup modules of size $ungroup_threshold"
3032
}

flow/scripts/synth_preamble.tcl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ yosys -import
22

33
source $::env(SCRIPTS_DIR)/util.tcl
44

5-
if {[info exist ::env(CACHED_NETLIST)]} {
5+
if {[env_var_exists_and_non_empty CACHED_NETLIST]} {
66
exec cp $::env(CACHED_NETLIST) $::env(RESULTS_DIR)/1_1_yosys.v
7-
if {[info exist ::env(CACHED_REPORTS)]} {
7+
if {[env_var_exists_and_non_empty CACHED_REPORTS]} {
88
exec cp {*}$::env(CACHED_REPORTS) $::env(REPORTS_DIR)/.
99
}
1010
exit
1111
}
1212

1313
# Setup verilog include directories
1414
set vIdirsArgs ""
15-
if {[info exist ::env(VERILOG_INCLUDE_DIRS)]} {
15+
if {[env_var_exists_and_non_empty VERILOG_INCLUDE_DIRS]} {
1616
foreach dir $::env(VERILOG_INCLUDE_DIRS) {
1717
lappend vIdirsArgs "-I$dir"
1818
}
@@ -39,19 +39,19 @@ foreach file $::env(VERILOG_FILES) {
3939
read_liberty -lib {*}$::env(DONT_USE_LIBS)
4040

4141
# Apply toplevel parameters (if exist)
42-
if {[info exist ::env(VERILOG_TOP_PARAMS)]} {
42+
if {[env_var_exists_and_non_empty VERILOG_TOP_PARAMS]} {
4343
dict for {key value} $::env(VERILOG_TOP_PARAMS) {
4444
chparam -set $key $value $::env(DESIGN_NAME)
4545
}
4646
}
4747

4848
# Read platform specific mapfile for OPENROAD_CLKGATE cells
49-
if {[info exist ::env(CLKGATE_MAP_FILE)]} {
49+
if {[env_var_exists_and_non_empty CLKGATE_MAP_FILE]} {
5050
read_verilog -defer $::env(CLKGATE_MAP_FILE)
5151
}
5252

5353
# Mark modules to keep from getting removed in flattening
54-
if {[info exist ::env(PRESERVE_CELLS)]} {
54+
if {[env_var_exists_and_non_empty PRESERVE_CELLS]} {
5555
# Expand hierarchy since verilog was read in with -defer
5656
hierarchy -check -top $::env(DESIGN_NAME)
5757
foreach cell $::env(PRESERVE_CELLS) {
@@ -77,13 +77,13 @@ set abc_args [list -script $abc_script \
7777

7878
# Exclude dont_use cells. This includes macros that are specified via
7979
# LIB_FILES and ADDITIONAL_LIBS that are included in LIB_FILES.
80-
if {[info exist ::env(DONT_USE_CELLS)] && $::env(DONT_USE_CELLS) != ""} {
80+
if {[env_var_exists_and_non_empty DONT_USE_CELLS]} {
8181
foreach cell $::env(DONT_USE_CELLS) {
8282
lappend abc_args -dont_use $cell
8383
}
8484
}
8585

86-
if {[info exist ::env(SDC_FILE_CLOCK_PERIOD)] && [file isfile $::env(SDC_FILE_CLOCK_PERIOD)]} {
86+
if {[env_var_exists_and_non_empty SDC_FILE_CLOCK_PERIOD] && [file isfile $::env(SDC_FILE_CLOCK_PERIOD)]} {
8787
puts "Extracting clock period from SDC file: $::env(SDC_FILE_CLOCK_PERIOD)"
8888
set fp [open $::env(SDC_FILE_CLOCK_PERIOD) r]
8989
set clock_period [string trim [read $fp]]

flow/util/write_net_rc_script.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source $::env(UTILS_DIR)/write_net_rc.tcl
77
estimate_parasitics -placement
88
record_wire_rc gpl
99

10-
if {[info exist env(FASTROUTE_TCL)]} {
10+
if {[env_var_exists_and_non_empty FASTROUTE_TCL]} {
1111
source $env(FASTROUTE_TCL)
1212
} else {
1313
set_global_routing_layer_adjustment $env(MIN_ROUTING_LAYER)-$env(MAX_ROUTING_LAYER) 0.5

0 commit comments

Comments
 (0)