Instructions:
- Load the desired netlist
- Source this tcl file
- Output: Generates the flat level netlist of the design loaded.
# This procedure is to check whether the given pin is a
# BJT Substrate pin or not.
proc isBjtSubstrate {pin} {
if {(![cdb pin $pin isNpnCollector]) && (![cdb pin $pin isNpnEmitter]) && (![cdb pin $pin isNpnBase]) \
&& (![cdb pin $pin isPnpCollector]) && (![cdb pin $pin isPnpEmitter]) && (![cdb pin $pin isPnpBase])} {
return 1
} else {
return 0
}
}
#######################################################
#
# THIS IS THE ENTRY POINT OF EXECUTION
#
#######################################################
# Get the hierarchy name...the file name will be .netlist
set hierarchyName [cdb getHierarchyName]
set fp [open "$hierarchyName.netlist" "w"]
#######################################################
#
# EDITING THIS FILE EXAMPLE.
# iF YOU WANT TO INCLUDE THE GLOBAL NETS AS WELL
# THEN MAKE THIS AN if {1} INSTAED OF if {0}
#
#######################################################
if {0} {
cscan nets {
set globalNets [list]
if {[cdb net %n isGlobal]} {
lappend globalNets %n
}
puts $fp ".GLOBAL [join $globalNets " " ] "
}
}
#######################################################
#
# ACTUAL FLATTENING OF INSTANCES IS HERE
# DO NOT CHANGE THE PRINT STATEMENT ORDER
# AND THE ORDER OF PINS IN THE RESPECTIVE LISTS
#
#######################################################
cscan instances {
# get common information needed for all instances
set pinsList [cdb inst %i getPins]
set pinCount [llength $pinsList]
set primType [cdb inst %i getCell]
# enw list for every instance
set netsToPrint [list %i]
# Case 1: MOS Transistors
if {[cdb inst %i isPmos] || [cdb inst %i isNmos]} {
# Print Order: DRAIN GATE SOURCE BULK SUBSTRATE (If exists)
set drainNet [cdb pin %i-D getNet]
set gateNet [cdb pin %i-G getNet]
set sourceNet [cdb pin %i-S getNet]
lappend netsToPrint $drainNet $gateNet $sourceNet
# If the MOS device has the 4th terminal (bulk) then add that as well.
if {$pinCount == 4} {
lappend netsToPrint [cdb pin %i-B getNet]
}
} elseif {[cdb inst %i isResistor] || [cdb inst %i isCapacitor]} { ;# Case 2: Resisitors and Capacitors
# Print Order: Any order between A B SUB (if exists)
foreach pin $pinsList {
lappend netsToPrint [cdb pin $pin getNet]
}
} elseif {[cdb inst %i isDiode]} { ;# Case 3: Diodes
# Pins Order ANODE CATHODE SUB
set anodeNet [cdb pin %i-A getNet]
set cathodeNet [cdb pin %i-C getNet]
lappend netsToPrint $anodeNet $cathodeNet
} elseif {[cdb inst %i isPnp] || [cdb inst %i isNpn]} { ;# Case 4: BJTs
# Pins Order: Collector Base Emitter Substrate
set collectorNet [cdb pin %i-C getNet]
set baseNet [cdb pin %i-B getNet]
set emitterNet [cdb pin %i-E getNet]
lappend netsToPrint $collectorNet $baseNet $emitterNet
# if the BJT device has the substarte terminal and other extra terminals....append into list
if {$pinCount > 3} {
foreach pin $pinsList {
if {[isBjtSubstrate $pin]} {
lappend netsToPrint [cdb pin $pin getNet]
}
}
}
} else {
# none of the prims match
# may be uncategorized primitive.
# havent has a case with this...
# so let it be as a safety measure.
}
# For one instance...print into file
puts $fp "[join $netsToPrint " "] $primType"
}
close $fp