Tcl Tip of the Day

In EDA tcl is the scripting language.  Tcl has its quirks but it’s extremely flexible and powerful… and often misunderstood.

I’m going to try to start to semi-regularly post Tcl tips and tricks that might be helpful to EDA engineers and non-EDA engineers alike. So here goes….

Tip #1 Use {} braces to isolate a variable in a longer a string.

If I have a variables for  process, voltage, and temperature.

set process 1.0
set voltage 0.8
set temperature -40

 

And I want to create a file name with the process, voltage, and temperature embedded in it along with the units V and C. Here’s one way:

set filename library_${process}_${voltage}V_${temperature}C.lib

 

Note how the curly braces are used to wrap process, voltage, and temperature variables. No tricky escaping or temporary variables needed.

Read more about Tcl’s variable syntax here: http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm

 

Tags:

No comments yet.

Leave a Reply