Skip to content

Commit 11ef0f6

Browse files
committed
variables: cleanup, fix errors
Signed-off-by: Øyvind Harboe <[email protected]>
1 parent 6ce64c5 commit 11ef0f6

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

flow/scripts/synth.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if {[env_var_exists_and_non_empty SYNTH_HIER_SEPARATOR]} {
2121
scratchpad -set flatten.separator $::env(SYNTH_HIER_SEPARATOR)
2222
}
2323

24-
set synth_full_args $::env(SYNTH_ARGS)
24+
set synth_full_args [env_var_or_empty SYNTH_ARGS]
2525
if {[env_var_exists_and_non_empty SYNTH_OPERATIONS_ARGS]} {
2626
set synth_full_args [concat $synth_full_args $::env(SYNTH_OPERATIONS_ARGS)]
2727
} else {

flow/scripts/synth_canonicalize.tcl

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

4-
dict for {key value} $::env(VERILOG_TOP_PARAMS) {
4+
dict for {key value} [env_var_or_empty VERILOG_TOP_PARAMS] {
55
# Apply toplevel parameters
66
chparam -set $key $value $::env(DESIGN_NAME)
77
}

flow/scripts/synth_preamble.tcl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,22 @@ proc read_design_sources {} {
4848
plugin -i slang
4949
yosys read_slang -D SYNTHESIS --keep-hierarchy --compat=vcs \
5050
--ignore-assertions --top $::env(DESIGN_NAME) \
51-
{*}$vIdirsArgs {*}$::env(VERILOG_FILES) {*}$::env(VERILOG_DEFINES)
51+
{*}$vIdirsArgs {*}$::env(VERILOG_FILES) {*}[env_var_or_empty VERILOG_DEFINES]
5252
# Workaround for yosys-slang#119
5353
setattr -unset init
5454
} elseif {[env_var_equals SYNTH_HDL_FRONTEND verific]} {
5555
if {[env_var_exists_and_non_empty VERILOG_INCLUDE_DIRS]} {
56-
verific -vlog-incdir {*}$::env(VERILOG_INCLUDE_DIRS)
56+
verific -vlog-incdir {*}$::env(VERILOG_INCLUDE_DIRS)
5757
}
5858
if {[env_var_exists_and_non_empty VERILOG_DEFINES]} {
59-
verific -vlog-define {*}$::env(VERILOG_DEFINES)
59+
verific -vlog-define {*}$::env(VERILOG_DEFINES)
6060
}
6161
verific -sv2012 {*}$::env(VERILOG_FILES)
6262
} elseif {![env_var_exists_and_non_empty SYNTH_HDL_FRONTEND]} {
6363
verilog_defaults -push
64-
verilog_defaults -add {*}$::env(VERILOG_DEFINES)
64+
if {[env_var_exists_and_non_empty VERILOG_DEFINES]} {
65+
verilog_defaults -add {*}$::env(VERILOG_DEFINES)
66+
}
6567
foreach file $::env(VERILOG_FILES) {
6668
read_verilog -defer -sv {*}$vIdirsArgs $file
6769
}

flow/scripts/util.tcl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ proc append_env_var {list_name var_name prefix has_arg} {
124124
}
125125
}
126126

127+
# Non-empty defaults should go into variables.yaml, generally
128+
proc env_var_or_empty {env_var} {
129+
if {[env_var_exists_and_non_empty $env_var]} {
130+
return $::env($env_var)
131+
}
132+
return ""
133+
}
134+
127135
proc find_macros {} {
128136
set macros ""
129137

0 commit comments

Comments
 (0)