defining a TCL variable for a part of variable name

Guest
I am using Simvision standalone to debug design, ie. I open the
snapshot and a waveform database. No simulation. And I am trying to
control Simvision with TCL script.

I have a problem with following syntax in TCL script for Simvision:

set hier testbench.dut.subblock

set block_out [list
{ $hier.data_out[32:16] } \
{ $hier.data_out[15:0] } \
]

waveform add -signals [lindex $block_out 0]
waveform add -signals [lindex $block_out 1]

What I want to do, is, to group bit-selects of some Verilog signals as
list member in Tcl, and I want to access them as a list member. However
the TCL interpreter in Simvision interprets the list definition not
correctly:

$hier.data_out[32:16]

The interpreter does not take the value of $hier variable, but as
string "$hier". I want the tool to take it as a variable. What am I
doing wrong here?

Utku
 
utku.ozcan@gmail.com wrote:

I have a problem with following syntax in TCL script for Simvision:

set hier testbench.dut.subblock

set block_out [list
{ $hier.data_out[32:16] } \
{ $hier.data_out[15:0] } \
]

waveform add -signals [lindex $block_out 0]
waveform add -signals [lindex $block_out 1]

What I want to do, is, to group bit-selects of some Verilog signals as
list member in Tcl, and I want to access them as a list member. However
the TCL interpreter in Simvision interprets the list definition not
correctly:

$hier.data_out[32:16]

The interpreter does not take the value of $hier variable, but as
string "$hier". I want the tool to take it as a variable. What am I
doing wrong here?
Tcl does not expand any variables inside {} unless you ask it to.

Did you try to run the command without the variable, like this? Did it
work?

set block_out [list
{ testbench.dut.subblock.data_out[32:16] } \
{ testbench.dut.subblock.data_out[15:0] } \
]

You could try

set block_out [list
$hier.data_out\[32:16\] \
$hier.data_out\[15:0\] \
]

or also

set block_out {
$hier.data_out\[32:16\]
$hier.data_out\[15:0\]
}

but that last one is generating a proper list only as long as each list
item does not have a whitespace in it. (Which doesn't look very likely
the way you use it)

--
Svenn
 
Svenn Bjerkem wrote:

You could try
....

or also

set block_out {
$hier.data_out\[32:16\]
$hier.data_out\[15:0\]
}
You could try, but this will not work. I was too quick on that one as
you see: There are {}'s in there, and Tcl leaves everything between {}
the way it is when it first evaluates the program. You have to force
Tcl to replace variables:

set block_out [subst $block_out]

will perform a round of substitution on your block_out data. A last
alternative could then be:

set block_out {
$hier.data_out[32:16]
$hier.data_out[15:0]
}

set block_out [subst -nocommand $block_out] which will leave your []'s
alone. You will need to protect any $ that you need to keep after
substitution with a \ (\$)

--
Svenn
 

Welcome to EDABoard.com

Sponsor

Back
Top