Updated 5 min readLayout Automation
Virtuoso layout automation with SKILL
Automate Cadence Virtuoso layout with real SKILL: open cellviews, draw rails with dbCreateRect, place instances, bind keys and trap errors with errset.
By the SkyCadEda engineering teamHow these notes are written
On this page
Virtuoso layout automation means writing Cadence SKILL that edits the layout database directly: open a cellview, create shapes and instances, query what is there, save. SKILL is the extension language built into Virtuoso, so a script can do anything the layout editor does, in batch or from a bindkey, without clicking through forms. The examples below use only documented database (db*) and layout editor (le*) functions.
What is Virtuoso layout automation?
Most layout time goes into work that follows a rule: rails at a fixed pitch, tap and fill cells along a row, labels on every pin, the same via stack on fifty nets, a guard structure around every device of one type. Each of these is a few lines of SKILL once you know the rule. Larger jobs, such as placing a matched array from a schematic or generating a padring from a spreadsheet, are the same calls in a loop.
Cadence SKILL is a Lisp-derived language. You can write it in C-like syntax (dbSave(cv)) or Lisp syntax ((dbSave cv)); both run in the same interpreter. Layout objects are reached through database handles and the ~> operator, so cv~>instances is the list of instances in a cellview and inst~>cellName is the master cell name of one of them.
What SKILL scripts do in custom layout
- Geometry generation: rails, straps, rings, fill and dummy patterns with
dbCreateRect,dbCreatePathanddbCreatePolygon. - Placement: rows of taps, decaps or fill, arrays of unit cells and matched devices with
dbCreateInst. - Connectivity: nets, terminals and pins with
dbCreateNet,dbCreateTermanddbCreatePin, so the layout carries the connectivity that LVS and the router expect. - Audits before DRC/LVS: shapes on unexpected layers, unlabeled pins, instances from the wrong library, off-grid origins.
- PCells: device and structure generators whose geometry is a SKILL function of their parameters.
- Editor productivity: bindkeys, menus and forms that call your functions on the cellview being edited (
geGetEditCellView()).
A short query shows the style. This prints every instance of a given master in the open cellview, with its origin:
let((cv)
cv = geGetEditCellView()
foreach(inst cv~>instances
when(inst~>cellName == "nch"
printf("%s %L\n" inst~>name inst~>xy))))Example: drawing power rails with SKILL
Here is a complete, small function that draws horizontal rails across a region at a fixed pitch and attaches them alternately to VSS and VDD. It uses plain database calls, so it works in batch and in an open editor window.
procedure(SkyDrawRails(cv box @key (layer "M1") (width 0.6) (pitch 4.0)
(vdd "VDD") (vss "VSS"))
let((x0 x1 y y1 n netV netG rect)
x0 = xCoord(lowerLeft(box))
x1 = xCoord(upperRight(box))
y = yCoord(lowerLeft(box))
y1 = yCoord(upperRight(box))
netV = or(dbFindNetByName(cv vdd) dbCreateNet(cv vdd))
netG = or(dbFindNetByName(cv vss) dbCreateNet(cv vss))
n = 0
while(y <= y1
rect = dbCreateRect(cv list(layer "drawing")
list(x0:(y - width/2) x1:(y + width/2)))
dbAddFigToNet(rect if(zerop(mod(n 2)) netG netV))
y = y + pitch
n = n + 1)
n)) ; number of rails drawnCalling it from a batch script, with an error trap and a save only on success:
let((cv result)
cv = dbOpenCellViewByType("myLib" "core" "layout" "maskLayout" "a")
unless(cv error("cannot open myLib/core/layout"))
result = errset(SkyDrawRails(cv list(0:0 120:80) ?layer "M1" ?pitch 3.6) t)
if(result
then printf("drew %d rails\n" car(result))
dbSave(cv)
else printf("rail generation failed: %L\n" errset.errset))
dbClose(cv))Run it headless with virtuoso -nograph -replay rails.il (put exit() at the end of the file), or load it in the CIW and call it on the window you are editing. To place cells along the same rows, open the master once and create instances in a loop:
master = dbOpenCellViewByType("stdLib" "tapcell" "layout")
for(i 0 9
dbCreateInst(cv master sprintf(nil "TAP%d" i) list(i*12.0 0) "R0"))For shapes you need to find again later, Relative Object Design (ROD) objects carry a name that a later step can look up, which is easier to maintain than searching by coordinates.
Why SKILL and not Python or Tcl
Virtuoso's extension language is SKILL. Tcl is the command language of Cadence digital tools such as Innovus, Genus and Tempus, and of most Synopsys tools, but it is not how you script the Virtuoso layout editor. Python has no native access to the open Virtuoso database; it reaches it through a bridge that sends SKILL to the running session.
- SKILL runs inside the Virtuoso process, so database edits, undo, the selected set and the current window are all available to it.
- PCells, CDF callbacks, bindkeys, menus and forms are all SKILL. There is no other language for them in Virtuoso.
- Python is still the better choice around the session: job submission, parsing Calibre or Pegasus results, diffing reports, dashboards.
To make a function available as a key in the layout editor, bind it in your .cdsinit:
hiSetBindKey("Layout" "Shift<Key>F6"
"SkyDrawRails(geGetEditCellView() list(0:0 120:80))")The interactive editor commands (leHiCreateInst(), leHiCreatePath() and the other leHi* functions) are what the menus call. Bind those when you want the normal interactive command; call the db* functions when you want a script to create geometry without prompting.
Practices that keep SKILL code maintainable
- Give every global function a short project prefix that starts with an uppercase letter (
SkyDrawRails,SkyCheckPins). Cadence functions use lowercase prefixes such asdb,le,ge,hiandsch, and the SKILL Language User Guide recommends that customer code start with an uppercase letter to avoid collisions. Do not build on undocumented Cadence functions; they can change or disappear between releases. - Keep variables local with
letorprog. Undeclared variables in SKILL are global and leak between scripts. - Trap errors with
errsetaround anything that edits the database, and save only when the edit succeeded. Raise your own failures witherror()so the caller sees one message. - Open cellviews in the mode you need (
"r"to read,"a"to edit) and close what you open, especially in batch loops over many cells. - Keep layer names, widths and pitches out of the code: pass them as
@keyarguments or read them from the technology file, so a node change does not mean editing every function. - Keep the
.ilfiles in Git and test each function on a small reference cell before running it across a library.
If you need this built for your PDK and flow, see our Cadence layout services. For language basics, start with the Cadence SKILL scripting guide.
Frequently asked questions
How do I run a SKILL script in Virtuoso?
Type load("myscript.il") in the CIW, or add the load call to your .cdsinit so it runs at startup. For batch jobs, start Virtuoso without a GUI (virtuoso -nograph -replay myscript.il) and end the script with exit(). Functions you load are then callable from the CIW, from bindkeys and from menus.
Does SKILL have try/catch error handling?
Not under that name. SKILL uses errset(): it evaluates an expression and returns a list holding the result, or nil if an error was raised, with the error details left in errset.errset. You raise your own errors with error(). catch is a Tcl command and does not apply here.
Should I use SKILL or Python for Virtuoso automation?
SKILL for anything that touches the open database, the layout editor or PCells, because it runs inside Virtuoso with direct access to cellviews, shapes and instances. Python fits outside the session: launching batch jobs, parsing DRC/LVS results and building reports. Bridges such as the open-source skillbridge package let Python call SKILL in a running session when you need both.
Related reading
More engineering notes
Working through a problem like this?
Tell us about your flow: the tools, the PDK, what is failing and when it needs to be clean.