# An example of what you can do with slam & Tcl
# In this case, we build a simple stream dump utility that
# prints to the screen (and the log file slam.log) a dump
# of the contents of a stream file.
# Usage (at the slam prompt): simpleStreamAndDump streamFileName dummyLibraryName
# Procedure dumps out the physical information about a given cell
proc printCellInfo { cellId } {
foreach type { rectangle polygon path wire instance
instanceArray
pin via viaArray text } {
edbSeq loopVar $cellId $type
{
puts [edbFetchObject $cellId $loopVar]
}
}
}
# Procedure dumps all the cells in the library
proc printAllCellsInLib { libId } {
foreach cTuple [edbGetLibCellIndex $libId -split]
{
set cName [lindex $cTuple
0]
set vName [lindex $cTuple
1]
set ver [lindex
$cTuple 2]
set cellId [edbFindCellId
$libId $cName $vName $ver ]
set didOpen 0
if { $cellId == 0 } {
set cellId [edbOpenCell $libId $cName $vName $ver -mode read]
set didOpen 1
}
if { $cellId != 0 } {
puts "\n\nDump information about $cName $vName $ver"
printCellInfo $cellId
if { $didOpen == 1 } { edbAbortAndCloseCell $cellId }
}
}
}
# Procedure creates [if it doesn't exist] a library,
# streams it in and dumps using the two procedures above
proc simpleStreamAndDump { streamFileName libName } {
set didOpen 0
if { [edbIsNameLibrary $libName] == 0 } {
set libId [edbCreateLibrary
$libName ssoft.cfg]
set didOpen 1
} else {
set libId [edbFindLibraryId
$libName]
if { $libId == 0 } {
set libId [edbOpenLibrary $libName w]
set didOpen 1
}
}
if { $libId != 0 } {
readStream $libId $streamFileName
printAllCellsInLib $libId
if { $didOpen == 1 } { edbCloseLibrary
$libId }
}
}
# Procedure modifies any text objects that use () to using <>
# for modifying text that had incorrectly labelled arrays.
# To use, type modTextParenToAngle libName cellName viewName
# at the slam prompt.
# Note this procedure would require an editor key to execute.
proc modTextParenToAngle { libName cellName viewName } {
set libId [edbFindLibraryId $libName]
set closeLib 0
if { $libId == 0 } {
set libId [edbOpenLibrary $libName w]
set closeLib 1
}
set cellId [edbFindCellId $libId $cellName $viewName]
set closeCell 0
if { $cellId == 0 } {
set closeCell 1
set cellId [edbOpenCell $libId $cellName $viewName]
}
edbSeq loopVar $cellId text {
set txt [lAssocFetch [edbFetchObject $cellId $loopVar] text]
regsub -all "\\\(" $txt "<" t1
regsub -all "\\\)" $t1 ">" t1
if { $t1 != $txt } {
puts "Substitute text $t1 for text $txt"
edbModifyObject $cellId $loopVar -text $t1
}
}
if { $closeCell == 1 } {
edbSaveAndCloseCell $cellId
}
if { $closeLib == 1 } {
edbCloseLibrary $libId
}
}
|