- Type
startFinder()in the CIW.- This opens the Skill finder which is comprehensive searchable database of ALL available skill functions.
- support.cadence.com
- This is the Cadence support site. An amazing resource for examples and manuals.
- Skill is an interactive language. You can code directly in the CIW it compiles as soon as it's entered.
- Skill is based on Lisp.
- Skill files should have a .il extension
- By convension all variables and functions are camelCase.
- Cadence functions start out lowerCase
- User functions should start UpperCase to avoid conflict.
- Comments are prefixed with ;
- Block comments use the /* */ convension
- You can copy and paste ( or type ) code right in the CIW!
- You can load Skill code from a file
load("/some/path/to/YourCode.il")
- Skill isn't a strongly typed language
- This means you can reuse the same variable with different data.
- By default variables are global
someNumber = 0
someText = "This is a string"
someList = list( "Aspen" "Cam" "Shelly" "Riley" )
bool1 = t ; skill equivalent to true
bool2 = nil ; skill equivalent to false
bool1 = "THIS IS REUSED"
You can get the value of a variable 2 different way
-
In the CIW type the name of the variable and hit enter
- The value will be printed to the CIW.
-
Use the printf function to print the variable
printf("Some Variable: %L" someNumber)
\+ ;addition
\- ;subtraction
\* ;multiplication
\/ ;division
\> < >= <= ; greater than, less than, etc
~> ;arrow operator
-> ;arrow operator
% ;modulo
= ;assignment
== ;equality
|| ;or
&& ;and
!= ; not equal
? ;query
?? ;query
Most of skill relys on database id (dbId from now on) which is just the unique identifier for a particular object
2 of the most used functions in skill are:
;Get the cellviews database id
cv = dbGetEditCellView()
;get the dbid's of the selected objects
selSet = geGetSelSet()
2 more functions to know that will come in handy later are car and cadr.
These functions only work with lists.
car( someList ) gets the 1st item from a list
cadr( someList ) gets the 2nd item from a list
;Store a list of coordinates to a variable
coordPair = list( 10 10 )
coordx = car( coordPair ) ;gets the 1st item from a list
coordy = cadr( coordPair ) ;gets the 2nd item from a list
The dbId's give us access to lots of amazing information
The dbId's contain a property list which is just a list of key/value pairs.
We ask for information from the property list using the
~> and the ->.
To get a list of the key from a propety list we use the ? operator after the arrow operator.
cv~>?
To get all the key/value pairs from a propety list we use the ?? operator after the arrow operator.
cv~>??
OUTPUT HERE
You can ask for a specific value from the property list by doing:
cellname = cv~>cellName
This returns the name of the current cellview as a string.
Flow control is how we make the real magic of Skill, and programming in general, happen.
- Conditional
- Branching
- Loops
Skill has when, unless statements.
These either stop or allow a section of code to execute depending on the input.
When example:
;Set our variable
test = t
when( test == t
;do some stuff here
printf("Test was true\n")
)
Unless example:
;Set our variable
test = nil
unless( test == t
;do some stuff here
printf("Test was nil\n")
)
I hate unless statements they confuse me.
Branching tells Skill to do different things depending on the input.
The if or case statements are the means that we do that.
In an if statement if the input criteria evaluates to true ( t )the first branch executes. If it evaluates to false ( nil ) it leaves the if or continues to the else statement.
This can be literally read as:
IF var is equal to Rob THEN print this.
;Set our variable
var = "Rob"
if(var == "Rob" then
printf("My name is Rob\n")
);if
This can be literally read as:
IF var is greater than 25 THEN print this, ELSE print that.
;Set our Variable
var = 10
if(var > 25 then
printf("Var is greater than 25\n")
else
printf("Var is less than 10\n")
);if
Case example can be found in the Cadence documents.
Loops are a means to repeat a section of code more then once.
Skill has for, foreach, while, until
The foreach is my goto loop in Skill. The reason for that is when I need to iterate on something in Skill it is usually a list. A foreach breaks the list down into each of it's individual list cells and provides that cell to the loop as a local variable.
;get a list of the selected items
cvInstances = geGetSelSet()
foreach( inst cvInstance
;check inst obj to make sure its an instance
if( inst~>objType == "inst" then
printf("CellName %L Coordinates %L\n" inst~>cellName inst~>xy)
);if
);foreach
Functions are blocks of codes; similar to an instance in layout; that can be recalled later multiple times.
Best practices for functions
-
They should have a descriptive name.
RDcreateFile- Make sure the name is unique
-
Should only perform a single task
-
Should be short. Long code is hard to follow.
-
ALWAYS use a
letstatementletkeeps variables scoped to the function. Keeps them from becoming global
Function Example:
;;Define out function
defun( RDcheckWire ( input )
let( (isInputAWire)
isInputAWire = nil
if( input~>objType == "pathSeg" then
isInputAWire = t
);if
isInputAWire ;return
);let
);defun
;;;;END OF FUNCTION
;;Call our function
if( RDcheckWire( obj )
printf("The object is a wire\n")
);if