ServicesHow we workDesign flowInsightsAboutCareersTalk to an engineer

ARRAY in TCL

During execution, we can have a few variables which we need. So we can take these variables in the form of array in tcl.

  • Scripting
  • TCL

What is Array?#

During execution, we can have a few variables which we need. So we can take these variables in the form of array in tcl.

set array(index) value ;

The way we set variables, in the same way we set an array. The only difference is that it comes with a pattern of variables.

set numbers (0) 10 ;
set numbers (1) 20;
puts $numbers (0)
puts $numbers (1)

Result : 10
20

Size of Array#

[array size variable_name]

set numbers (0) 10 ;
set numbers (1) 20;

[array size numbers]

Results : 2

We can have conditional statements and loops in array.

set numbers (0) 10;
set numbers (1) 20;

for {set index 0} {$index < [array size numbers]} {incr index} {
puts “numbers($index) : $numbers ($index)”
}

Result: number (0) : 10
number (1) : 20

Similar to 'for' loop, we can use foreach loop as well.

set numbers (0) 10;
set numbers (1) 20;

foreach index [array names numbers] {
puts “numbers($index) : $numbers ($index)”
}

Result: number (0) : 10
number (1) : 20

Written by

Swasti Pujari

Associate Director, Backend Engineering at CoreIC Technologies, with 15+ years in VLSI Physical Design and backend engineering. Previously Practice Head at UST Global, leading Physical Design, STA, EMIR, DFT, and Physical Verification. Delivered 3nm, 6nm and 7nm projects for AMD, Intel, and Microchip, and published IEEE research on hybrid AI-EDA floorplanning.