What you can learn from above is that how various options and switches are included as a part of your command. Now in the above case, let’s say, set_multi_cpu_usage has 2 switches, 1) to provide number of threads 2) a ‘help’ command explaining the usage – These are pretty standard switches you would see in any set_multi_cpu_usage command in a
standard EDA tool
We will pass both options to the command proc shown above and see how it gets resolved using tcl interface. When you type the command “set_multi_cpu_usage -localCpu 8 -help”, the expectation is to set local number of threads to 8 and print the usage of the command as well
This is how it works. First set default values for the options:
array set options {-localCpu <num_of_threads> -help
“”}
Then enter a loop that processes the arguments, if there are any (left).
while {[llength $args]} {
During each iteration, look at the first element in the argument list:
switch -glob -- [lindex $args 0] {
String-match ("glob") matching is used to make it possible to have abbreviated option names.
If a value option is
found, use lassign to copy the value to the corresponding member of the options array and to remove the first two elements in the argument list.
-localCpu {set args [lassign $args - options(-localCpu)]}
The last “puts” command will dump the Opentimer Command “set_num_threads 8”. This will get passed to Opentimer, and Opentimer will take it from here