# Change all cells in a library from XXX_cellName to
# YYY_cellName and change the references to the cells.
### These procedures assume that all cells are in the one library.
# Or at least all cells having the given prefix are in one library.
# You may extend these procedures to do various library cell name
# changes
# This first procedure scans all instance and instance array objects in the
# specified cell. If the an instance references a cell whose first n
# characters match old, then the reference is modified to reference a
# cell replacing the cellname's "old" prefix with the "new" prefix.
# The length of the "old" and "new" prefix need not be the same.
proc alterPrefix { cellId old new } {
edbSeq instId $cellId instance {
set inst [edbFetchObject $cellId $instId]
set masterId [lAssocFetch $inst masterId]
set minfo [edbFetchObject $cellId $masterId]
set mName [lAssocFetch $minfo cellName]
set match [string first $old $mName]
if { $match == 0 } {
set ln [string length $old]
set newCellName [format "%s%s" $new [string range $mName $ln end]]
edbModifyObject $cellId $instId -cellName $newCellName
}
}
edbSeq instId $cellId instanceArray {
set inst [edbFetchObject $cellId $instId]
set masterId [lAssocFetch $inst masterId]
set minfo [edbFetchObject $cellId $masterId]
set mName [lAssocFetch $minfo cellName]
set match [string first $old $mName]
if { $match == 0 } {
set ln [string length $old]
set newCellName [format "%s%s" $new [string range $mName $ln end]]
edbModifyObject $cellId $instId -cellName $newCellName
}
}
}
# This second procedure is the driver procedure.
# It wants 3 arguments. The first is the name of the library to
# be modified. The 2nd is the prefix of the cells currently. The
# last argument is the new prefix. Invoke the procedure by
# sourcing this file and then entering
# copyAndAlter
# As always, we recommend you tar a copy of the library
# prior to issue'ing these procedures that make large changes
# to the library.
proc changeCellPrefix { libName old new } {
# find or open the library
set libId [edbFindLibraryId $libName]
if { $libId == 0 } {
set libId [edbOpenLibrary $libName w]
}
# get the list of matching cells
set clist [edbGetLibCellIndex $libId $old* lay -globCell -cellOnly]
set ln [string length $old]
# Create a copy of each cell with a matching prefix
foreach cellName $clist {
set cellId [edbFindCellId $libId $cellName lay]
if { $cellId == 0 } {
set cellId [edbOpenCell $libId $cellName lay]
}
set newCellName [format "%s%s" $new [string range $cellName $ln end]]
puts "Copy cell $cellName to $newCellName"
edbCopyCell $libId $cellId $newCellName lay
}
# phase II updates all the references after all the cells have been created
set clist [edbGetLibCellIndex $libId $new* lay -globCell -cellOnly]
foreach cellName $clist {
puts "Alter instances of cell $cellName"
set cellId [edbFindCellId $libId $cellName lay]
alterPrefix $cellId $old $new
}
}
|