Product Documentation
OCEAN Reference
Product Version IC23.1, September 2023

3


Introduction to SKILL

This chapter introduces you to the basic concepts that can help you get started with the Virtuoso® SKILL programming language. In this chapter, you can find information about

The Advantages of SKILL

The SKILL programming language lets you customize and extend your design environment. SKILL provides a safe, high-level programming environment that automatically handles many traditional system programming operations, such as memory management. SKILL programs can be immediately run in the Virtuoso environment.

SKILL is ideal for rapid prototyping. You can incrementally validate the steps of your algorithm before incorporating them in a larger program.

SKILL leverages your investment in Cadence technology because you can combine existing functionality and add new capabilities.

SKILL lets you access and control all the components of your tool environment: the User Interface Management System, the Design Database, and the commands of any integrated design tool. You can even loosely couple proprietary design tools as separate processes with SKILL’s interprocess communication facilities.

Naming Conventions

The recommended naming scheme is to use uppercase and lowercase characters to separate your code from code developed by Cadence.

All code developed by Cadence Design Systems typically names global variables and functions with up to three lowercase characters, that signify the code package, and the name starting with an uppercase character. For example, dmiPurgeVersions() or hnlCellOutputs. All code developed outside Cadence should name global variables by starting them with an uppercase character, such as AcmeGlobalForm.

Arithmetic Operators

SKILL provides many arithmetic operators. Each operator corresponds to a SKILL function, as shown in the following table.

Sample SKILL Operators
Operators in Descending Precedence Underlying Function

**

exponentiation

*
/

multiply
divide

+

plus
minus

==
!=

equal
nequal

=

assignment

Scaling Factors

SKILL provides a set of scaling factors that you can add to the end of a decimal number (integer or floating point) to achieve the scaling you want.

The scaling factors are listed in the following table.

Scaling Factors
Character Name Multiplier Examples

Y

Yotta

1024

10Y [ 10e+25 ]

Z

Zetta

1021

10Z [ 10e+22 ]

E

Exa

1018

10E [ 10e+19 ]

P

Peta

1015

10P [ 10e+16 ]

T

Tera

1012

10T [ 1.0e13 ]

G

Giga

109

10G [ 10,000,000,000 ]

M

Mega

106

10M [ 10,000,000 ]

K

Kilo

103

10K [ 10,000 ]

%

percent

10-2

5% [ 0.05 ]

m

milli

10-3

5m [ 5.0e-3 ]

u

micro

10-6

1.2u [ 1.2e-6 ]

n

nano

10-9

1.2n [ 1.2e-9 ]

p

pico

10-12

1.2p [ 1.2e-12 ]

f

femto

10-15

1.2f [ 1.2e-15 ]

a

atto

10-18

1.2a [ 1.2e-18 ]

z

zepto

10-21

1.2z [ 1.2e-21 ]

y

yocto

10-24

1.2y [ 1.2e-24 ]

The characters used for scaling factors depend on your target simulator. For example, if you are using cdsSpice, the scaling factor for M is different than shown in the previous table, because cdsSpice is not case sensitive. In cdsSpice, M and m are both interpreted as 10-3, so ME or me is used to signify 106.

Relational and Logical Operators

This section introduces you to

Relational Operators

Use the following operators to compare data values. SKILL generates an error if the data types are inappropriate. These operators all return t or nil.  

Sample Relational Operators
Operator Arguments Function Example Return Value
< numeric lessp 3 < 5 3 < 2 t nil

<=

numeric

leqp

3 <= 4

t

>

numeric

greaterp

5 > 3

t

>=

numeric

geqp

4 >=3

t

==

numeric
string
list

equal

3.0 == 3
"abc" == "ABc"

t
nil

!= numeric string list nequal "abc" != "ABc" t

Knowing the function name is helpful because error messages mention the function (greaterp below) instead of the operator ( > ).

1 > "abc" 
Message: *Error* greaterp: can’t handle (1 > "abc")

Logical Operators

SKILL considers nil as FALSE and any other value as TRUE. The and (&&) and or (||) operators only evaluate their second argument if it is required for determining the return result.  

Sample Logical Operators

Operator Arguments Function Example Return Value

&&

general

and

3 && 5
5 && 3
t && nil
nil && t

5
3
nil
nil

||

general

or

3 || 5
5 || 3
t || nil
nil || t

3
5
t
t

The && and || operators return the value last computed. Consequently, both && and || operators can be used to avoid cumbersome if or when expressions.

The following example illustrates the difference between using && and || operators and using if or when expressions.

You do not need to use

If (usingcolor then 
currentcolor=getcolor( )
else
currentcolor=nil
)

Instead use

currentcolor=usingcolor && getcolor( )

Using &&

When SKILL creates a variable, it gives the variable a value of unbound to indicate that the variable has not been initialized yet. Use the boundp function to determine whether a variable is bound. The boundp function

Suppose you want to return the value of a variable trMessages. If trMessages is unbound, retrieving the value causes an error. Instead, use the expression

boundp( ’trMessages ) && trMessages

Using ||

Suppose you have a default name, such as noName, and a variable, such as userName. To use the default name if userName is nil, use the following expression:

userName || "noName"

SKILL Syntax

This section describes SKILL syntax, which includes the use of special characters, comments, spaces, parentheses, and other notation.

Special Characters

Certain characters are special in SKILL. These include the infix operators such as less than (<), colon (:), and assignment (=). The following table lists these special characters and their meaning in SKILL.

All nonalphanumeric characters (other than _ and ?) must be preceded (escaped) by a backslash (\) when you use them in the name of a symbol.

Special Characters in SKILL
Character Name Meaning

\

backslash

Escape for special characters

( )

parentheses

Grouping of list elements, function calls

[ ]

brackets

Array index, super right bracket

single quotation mark

Specifies a symbol (quoting the expression prevents its evaluation)

quotation mark

String delimiter

,

comma

Optional delimiter between list elements

;

semicolon

Line-style comment character

+, , *, /

arithmetic

For arithmetic operators; the /* and */ combinations are also used as comment delimiters

!,^,&,|

logical

For logical operators

<,>,=

relational

For relational and assignment operators;
< and > are also used in the specification of bit fields

?

question mark

If first character, implies keyword parameter

%

percent sign

Used as a scaling character for numbers

White Space

White space sometimes takes on semantic significance and a few syntactic restrictions must therefore be observed.

Write function calls so the name of a function is immediately followed by a left parenthesis; no white space is allowed between the function name and the parenthesis. For example

f(a b c) and g() are legal function calls, but f (a b c) and g () are illegal.

The unary minus operator must immediately precede the expression it applies to. No white space is allowed between the operator and its operand. For example

-1, -a, and -(a*b) are legal constructs, but - 1, - a, and - (a*b) are illegal.

The binary minus (subtract) operator should either be surrounded by white space on both sides or be adjacent to non-white space on both sides. To avoid ambiguity, one or the other method should be used consistently. For example:

a - b and a-b are legal constructs for binary minus, but a -b is illegal.

Comments

SKILL permits two different styles of comments. One style is block oriented, where comments are delimited by /* and */. For example:

/* This is a block of (C style) comments
comment line 2
comment line 3 etc.
*/

The other style is line- oriented where the semicolon (;) indicates that the rest of the input line is a comment. For example:

x = 1            ; comment following a statement
; comment line 1
; comment line 2 and so forth

For simplicity, line-oriented comments are recommended. Block-oriented comments cannot be nested because the first */ encountered terminates the whole comment.

Role of Parentheses

Parentheses () delimit the names of functions from their argument lists and delimit nested expressions. In general, the innermost expression of a nested expression is evaluated first, returning a value used in turn to evaluate the expression enclosing it, and so on until the expression at the top level is evaluated. There is a subtle point about SKILL syntax that C programmers, in particular, must notice.

Parentheses in C

In C, the relational expression given to a conditional statement such as if, while, and switch must be enclosed by an outer set of parentheses for purely syntactical reasons, even if that expression consists of only a single Boolean variable. In C, an if statement might look like

if (done) i=0; else i=1;

Parentheses in SKILL

In SKILL, parentheses are used for specifying lists, calling functions, delimiting multiple expressions, and controlling the order of evaluation. You can write function calls in prefix notation

(fn2 arg1 arg2) or (fn0)

as well as in the more conventional algebraic form

fn2(arg1 arg2) or fn0()

The use of syntactically redundant parentheses causes variables, constants, or expressions to be interpreted as the names of functions that need to be further evaluated. Therefore,

For example, because if evaluates its first argument as a logical expression, a variable containing the logical condition to be tested should be written without any surrounding parentheses; the variable by itself is the logical expression. This is written in SKILL as

if( done then i = 0 else i = 1)

Line Continuation

SKILL places no restrictions on how many characters can be placed on an input line, even though SKILL does impose an 8,191 character limit on the strings being entered. The parser reads as many lines as needed from the input until it has read in a complete form (that is, expression). If there are parentheses that have not yet been closed or binary infix operators whose right sides have not yet been given, the parser treats carriage returns (that is, newlines) just like spaces.

Because SKILL reads its input on a form-by-form basis, it is rarely necessary to “continue” an input line. There might be times, however, when you want to break up a long line for aesthetic reasons. In that case, you can tell the parser to ignore a carriage return in the input line, by preceding it immediately with a backslash (\).

string = "This is \
a test."
=> "This is a test."

Arithmetic and Logical Expressions

Expressions are SKILL objects that also evaluate to SKILL objects. SKILL performs a computation as a sequence of function evaluations. A SKILL program is a sequence of expressions that perform a specified action when evaluated by the SKILL interpreter.

There are two types of primitive expressions in SKILL that pertain to OCEAN: constants and variables.

Constants

A constant is an expression that evaluates to itself. That is, evaluating a constant returns the constant itself. Examples of constants are 123, 10.5, and "abc".

Variables

A variable stores values used during the computation. The variable returns its value when evaluated. Examples of variables are a, x, and init_var.

When the interpreter evaluates a variable whose value has not been initialized, it displays an error message telling you that you have an unbound variable. For example, you get an error message when you misspell a variable because the misspelling creates a new variable.

myVariable

causes an error message because it has been referenced before being assigned, whereas

myVariable = 5

works.

When SKILL creates a variable, it gives the variable an initial value of unbound. It is an error to evaluate a variable with this value because the meaning of unbound is that-value-which-represents-no-value. unbound is not the same as nil.

Using Variables

You do not need to declare variables in SKILL as you do in C. SKILL creates a variable the first time it encounters the variable in a session. Variable names can contain

The first character of a variable must be an alphanumeric character or an underscore. Use the assignment operator to store a value in a variable. You enter the variable name to retrieve its value.

lineCount = 4            => 4
lineCount => 4
lineCount = "abc" => "abc"
lineCount   => "abc"

Creating Arithmetic and Logical Expressions

Constants, variables, and function calls can be combined with the infix operators, such as less than (<), colon (:), and greater than (>) to form arithmetic and logical expressions. For example: 1+2, a*b+c, x>y.

You can form arbitrarily complicated expressions by combining any number of the primitive expressions described above.


Return to top
 ⠀
X