defining a TCL variable for a part of variable name

Discussion in 'Cadence' started by utku.ozcan, Sep 26, 2006.

  1. utku.ozcan

    utku.ozcan 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


    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.ozcan, Sep 26, 2006
  2. 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

    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 {

    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 Bjerkem, Sep 26, 2006
  3. 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 {

    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 Bjerkem, Sep 27, 2006
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.