parameter-passingtclbracketsproc

Tcl: pass argument with square brackets to procedure (SDC)


I want to build a SDC simulator. here's my proc:

proc set_false_path { body ... }
proc get_pins { body ...}

And I use tcl build-in "source" to read the SDC file, MY_SDC_FILE.sdc (there are lots file in MY_SDC_FILE.sdc)

In file, there is a command:

set_false_path -through [get_pins my_pin[1]]

It will report "invalid command name "1" error

I try to do proc like "proc 1 { body ...}", but is time-consuming if have case like [100000]. any way to fix error, thanks.


Solution

  • You can avoid this problem with appropriate quoting:

    set_false_path -through [get_pins {my_pin[1]}]
    

    Tcl's quoting rules are documented at https://www.tcl-lang.org/man/tcl/TclCmd/Tcl.htm