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
- Naming Conventions
- Arithmetic Operators
- Scaling Factors
- Relational and Logical Operators
- SKILL Syntax
- Arithmetic and Logical Expressions
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.
| Operators in Descending Precedence | Underlying Function |
|---|---|
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.
- Scaling factors must appear immediately after the numbers they affect. Spaces are not allowed between a number and its scaling factor.
- Only the first nonnumeric character that appears after a number is significant. Other characters following the scaling factor are ignored. For example, for the value 2.3mvolt, the m is significant, and the volt is discarded. In this case, volt is only for your reference.
- If the number being scaled is an integer, SKILL tries to keep it an integer; the scaling factor must be representable as an integer (that is, the scaling factor is an integral multiplier and the result does not exceed the maximum value that can be represented as an integer). Otherwise, a floating-point number is returned.
The scaling factors are listed in the following table.
| Character | Name | Multiplier | Examples | |
|---|---|---|---|---|
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.
| Operator | Arguments | Function | Example | Return Value |
|---|---|---|---|---|
< |
|
|
3 < 5
3 < 2 |
t
nil |
!= |
|
|
"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.
| Operator | Arguments | Function | Example | Return Value |
|---|---|---|---|---|
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.
If (usingcolor then
currentcolor=getcolor( )
else
currentcolor=nil
)
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.
_ and ?) must be preceded (escaped) by a backslash (\) when you use them in the name of a symbol.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
as well as in the more conventional algebraic form
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,
-
Never enclose a constant or a variable in parentheses by itself; for example,
(1),(x). -
For arithmetic expressions involving infix operators, you can use as many parentheses as necessary to force a particular order of evaluation, but never put a pair of parentheses immediately outside another pair of parentheses; for example,
((a + b)): the expression delimited by the inner pair of parentheses would be interpreted as the name of a function.
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
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