Product Documentation
Virtuoso Space-based Router Command Reference
Product Version IC23.1, September 2023

Tcl Examples for Inspecting Properties

This topic provides Tcl procedure examples that use these commands. The procedures in this section are included in the examples/tcl/inspectProcs.tcl file in your installation directory.

To use these procedures, do the following:

  1. On the Virtuoso Space-based Router command line, type:
    source installPath/tools/dfII/samples/rde/examples/tcl/inspectProcs.tcl 
    where installPath is the path to your installation directory.
    Procedure or Tcl command Description

    findItemsInSet

    Find Items in a Set

    findElementsOfItems

    Find Elements of Items in a Set

    createSetOfNetElementsType

    Create a Set of Net Elements of a Specific Type

    createListOfNetElementsType

    Create a List of Net Elements of a Specific Type

    findViasInNets

    Find All Vias on Nets in a Set

    findViaMaster

    Find All Vias with a Given Master on Nets in a Set

    getNetName

    Get the Names of Nets in a Set

    getGuideNetNames

    Get the Names of Nets with Guides

    selectNetsFromRouteSegments

    Select Nets from Route Segments

    getNetsFromRouteSegments

    Create a Set of Nets Containing Route Segments from Another Set

    selectRoutesFromNets

    Select Routes from Nets

    getRoutesFromNets

    Create a Set of Routes Containing Nets from Another Set

    getGuideNetSet

    Create a Set Containing Nets with Guides

    findNetConnections

    Create a Set Containing Instances Attached to Nets in a Set

    findInstancesConnectedToNets

    Find Instance Connections for Nets Matching Net Name Expression

    set2ann

    Create Annotations for Items in a Set

Find Items in a Set

This procedure prints the type property for all elements in the given set.

proc findItemsInSet {inputSet} {
  #process each item in the set. for loop
foreach inputObject [ml $inputSet] {
puts [ip type $inputObject]
}
puts "[set_count -set $inputSet] items in set."
}

The following example uses the findItemsInSet procedure and shows the output.

findItemsInSet [get_selection_set]
ctuRouteSegment
ctuRouteVia
ctuNet
ctuRoute
4 items in set.

Find Elements of Items in a Set

For each item in a set, this procedure prints the type property for the item and the type property for each of its elements, if it has elements.

proc findElementsOfItemsInSet { inputSet } {
  set i 1
# inspect each item in the set.
foreach item [ml $inputSet] {
if {[hp elements $item]} {
foreach elem [ml [ip elements $item]] {
puts "Item $i [ip type $item] element: [ip type $elem]"
}
} else { puts "Item $i has no elements." }
incr i
}
}

The following is example output for a set containing a net and a route segment:

findElementsOfItemsInSet [get_selection_set]
Item 1 ctuNet element: ctuInstTerm
Item 1 ctuNet element: ctuInstTerm
Item 1 ctuNet element: ctuRoute
Item 1 ctuNet element: ctuSteiner
Item 1 ctuNet has 4 elements.
Item 2 ctuRouteSegement has 0 elements.

Create a Set of Net Elements of a Specific Type

For each net in the input set, puts all elements of a given type into an output set. Non-net items in the set are ignored.

proc createSetOfNetElementsType { inputSet typeVal } {

set outputSet [create_set]
  foreach item [ml $inputSet] {
if {[string compare [ip type $item] "ctuNet"] == 0} {
   #process only Nets here
foreach elem [ml [ip elements $item]] {
if {[string compare [ip type $elem] $typeVal] == 0} {
add_object_to_set -object $elem -set $outputSet
}
}
}
}
return $outputSet
}

The following example creates a set containing all the routes from the nets in the selected set.

set routeSet [createSetOfNetElementsType [get_selection_set] ctuRoute ]

Create a List of Net Elements of a Specific Type

For each net in the input set, puts all elements of a given type into an output list. This procedure is identical in function to createSetOfNetElementsType except this returns a list, instead of a set.

proc createListOfNetElementsType { inputSet typeVal } {

set outputList [list]
  foreach item [ml $inputSet] {
if {[string compare [ip type $item] "ctuNet"] == 0} {
   #process only Nets here
foreach elem [ml [ip elements $item]] {
if {[string compare [ip type $elem] $typeVal] == 0} {
lappend outputList $elem
}
}
}
}
return $outputList
}

Find All Vias on Nets in a Set

Returns a set containing all vias on nets of the given set. First finds all the routes for nets in the set, then puts all the vias for those routes in the output set.

proc findViasInNets { inputSet } {
  set outputSet [create_set]
foreach route [createListOfNetElementsType $inputSet ctuRoute ] {
foreach elem [ml [ip elements $route ] ] {
if {[string compare [ip type $elem] "ctuRouteVia"] == 0} {
#found a via
# puts "Net [ip net.name $elem], Via Master [ip master.name $elem]"
add_object_to_set -object $elem -set $outputSet
}
   }
}
return $outputSet
}

The following example creates a set containing all vias on nets in the HL1 highlight set.

set vset [findViasInNets [get_highlight -name HL1]]

Find All Vias with a Given Master on Nets in a Set

Returns a set containing vias with the given master via that are contained in nets in the given set.

proc findViaMaster { inputSet masterVal } {

set viaSet [create_set]
set i 0
foreach via [ml [findViasInNets $inputSet]] {
# puts "Master $masterVal; Net [ip net.name $via], Via Master \
[ip master.name $via]"
if {[string compare [string trim [ip master.name $via] "\""] $masterVal] \
== 0} {
add_object_to_set -object $via -set $viaSet
incr i
}
}
puts "Found $i vias with master $masterVal."
return $viaSet
}

The following example creates a set containing all M2_M1 vias on nets in the selected set.

set vset [findViaMaster [get_selection_set] M2_M1]

Get the Names of Nets in a Set

This procedure returns the list of names for nets in the given set.

proc getNetName { netSet } {
set netNamesList [list]
foreach net [ml $netSet] {
set netType [string trim [ip type $net] "'"]
if {[string compare $netType "ctuNet"] == 0} {
set netName [string trim [ip name $net] "'"]
lappend netNamesList $netName
}
}
return $netNamesList
}

For example,

getNetName [get_highlight -name HL2]
net1 {in[0]} net2

Get the Names of Nets with Guides

This procedure returns a list of names of nets that contain guides (opens).

proc getGuideNetNames {} {
set netNamesList [list]
set guideSet [find_shape -shape_types guide -ignore_case true \
-no_wildcard false -silent]
foreach guide [ml $guideSet] {
set guideType [string trim [ip type $guide ] "'"]
if {[string compare $guideType "ctuGuide"] == 0} {
set netName [string trim [ip net.name $guide ] "'"]
lappend netNamesList $netName
}
}
return $netNamesList
}

Create a Set Containing Nets with Guides

This procedure returns a set containing nets with guides.

proc getGuideNetSet {} {
set netSet [create_set]
set guideSet [find_shape -shape_types guide -ignore_case true \
-no_wildcard false -silent]
foreach guide [ml $guideSet] {
set guideType [string trim [ip type $guide ] "'"]
if {[string compare $guideType "ctuGuide"] == 0} {
set net [ip net $guide ]
add_object_to_set -set $netSet -object $net
}
}
return $netSet
}

For example,

set guideSet [getGuideNetSet]
sel:d128040
getNetName $guideSet
net13 net25 net17

Select Nets from Route Segments

This procedure replaces the selected set with nets containing the route segments in the input set.

proc selectNetsFromRouteSegments { routeSegmentSet } {
set netSet [create_set]
foreach route [ml $routeSegmentSet] {
set routeType [string trim [ip type $route ] "'"]
if {[string compare $routeType "ctuRouteSegment"] == 0} {
set net [ip net $route ]
add_object_to_set -object $net -set $netSet
}
}
replace_set -set1 $netSet -set2 [get_selection_set]
}

Create a Set of Nets Containing Route Segments from Another Set

This procedure returns a set of nets from the route segments in the input set.

proc getNetsFromRouteSegments { routeSegmentSet } {
set netSet [create_set]
foreach route [ml $routeSegmentSet] {
set routeType [string trim [ip type $route ] "'"]
if {[string compare $routeType "ctuRouteSegment"] == 0} {
set net [ip net $route ]
add_object_to_set -object $net -set $netSet
}
}
return $netSet
}

Select Routes from Nets

This procedure replaces the selected set with routes from the input set of nets.

proc selectRoutesFromNets { netSet } {
set routeSet [create_set]
foreach net [ml $netSet] {
set netType [string trim [ip type $net] "'"]
if {[string compare $netType "ctuNet"] == 0} {
foreach element [ml [ip elements $net]] {
set elementType [string trim [ip type $element] "'"]
if {[string compare $elementType "ctuRoute"] == 0} {
add_object_to_set -object $element -set $routeSet
}
}
}
}
replace_set -set1 $routeSet -set2 [get_selection_set]
}

Create a Set of Routes Containing Nets from Another Set

This procedure returns a set of routes from the nets in the input set.

proc getRoutesFromNets { netSet } {
set routeSet [create_set]
foreach net [ml $netSet] {
set netType [string trim [ip type $net] "'"]
if {[string compare $netType "ctuNet"] == 0} {
foreach element [ml [ip elements $net]] {
set elementType [string trim [ip type $element] "'"]
if {[string compare $elementType "ctuRoute"] == 0} {
add_object_to_set -object $element -set $routeSet
}
}
}
}
return $routeSet
}

Create a Set Containing Instances Attached to Nets in a Set

This procedure returns a set of instances that are attached to nets in the given set.

proc findInstancesConnectedToNets {inputSet} {
set instSet [create_set]
foreach inputObject [ml $inputSet] {
set inputObjectType [ip type $inputObject]
if {[string compare $inputObjectType "ctuNet"] == 0} {
foreach element [ml [ip elements $inputObject]] {
set elementType [ip type $element]
if {[string compare $elementType "ctuInstTerm"] == 0} {
set elementInst [ip instance $element]
add_object_to_set -object $elementInst -set $instSet
}
}
} else { puts "$inputObjectType: this is not a net" }
}
puts "[set_count -set $instSet] instances are attached to selected nets."
return $instSet
}

The following example uses the findInstancesConnectedToNets procedure and adds the instances that are found to the current highlight set.

replace_set -set1 [findInstancesConnectedToNets [get_selection_set]] -set2 [get_current_highlight]

Find Instance Connections for Nets Matching Net Name Expression

This procedure finds all nets matching the input net name expression, then prints a description for each instTerm connection on each net and the total number of instTerm connections for each net.

proc findNetConnections {netName} {
set netsSet [ml [find_net -name $netName -silent true ] ]
foreach net $netsSet {
set netName [ip name $net]
puts " "
puts "Net $netName:"
set netElements [ml [ip elements $net]]
set instTermCount 0
foreach netElement $netElements {
set netElementType [ip type $netElement]
if {[string compare $netElementType "ctuInstTerm"] == 0} {
set termName [ip name $netElement]
#set instName [ip name [ip instance $netElement]]
set instName [ip instance.name $netElement]
#set instTermPins [ml [ip elements [ip term $netElement]]]
set instTermPins [ml [ip term.elements $netElement]]
set connectionType [ip termType [ip term $netElement]]
foreach instTermPin $instTermPins {
set instTermPinShapes [ml [ip elements $instTermPin]]
foreach pinShape $instTermPinShapes {
set pinShapeBounds [ip bounds $pinShape ]
#set pinShapeLayer [ip name [ip layer $pinShape ] ]
set pinShapeLayer [ip layer.name $pinShape ]
puts " Pin shape on layer $pinShapeLayer for $termName \
($connectionType) on net $netName is located at $pinShapeBounds"
}
}
incr instTermCount
}
}
puts " Net $netName has $instTermCount instTerm connections."
}
}

Create Annotations for Items in a Set

This procedure is useful when you want a quick way to zoom to each item in the set. After invoking this procedure, you can use the Annotation Browser as the navigation mechanism.

Only objects with a bounds property can be annotated using this method.
proc set2ann { myset } {
  set i 1
foreach objInSet [ml $myset] {
set objHasBounds [hp bounds $objInSet]
if ($objHasBounds) {
set objBounds [inspect_getprop -prop_name bounds -object $objInSet]
puts "\# Msg: Creating rectangle annotation at $objBounds\n"
add_rectangle -color Cyan -lineWidth 1 -rect [bounds2Bbox $objBounds]
} else {
puts "\# Msg: Error couldn’t find bounds prop on item $i. Skipping.\n"
}
incr i
}
}

The following procedure is the equivalent to set2ann but it uses ip (inspect_prop) instead of inspect_getprop and does not create some intermediate variables.

proc set2annip { myset } {
set i 1
foreach objInSet [ml $myset] {
if {[hp bounds $objInSet]} {
add_rectangle -color Cyan -lineWidth 1 \
-rect [bounds2Bbox [ip bounds $objInSet]]
} else {
puts "\# Msg: Error - couldn’t find bounds prop on item $i. Skipping.\n"
}
incr i
}
}

Annotate All Vias with a Given Master on Nets in a Set

This example annotates all M2_M1 vias on nets in the selected set.

set2ann [findViaMaster [get_selection_set] M2_M1]

Related Topics

Inspecting Properties


Return to top
 ⠀
X