SKILL Codes, PCell Creation
SKILL programming language is based on artificial intelligence laanguage Lisp. SKILL lets us quickly and easily customize existing CAD applications and helps us develop new applications. This document describes basics of SKILL and its applications.
- Notation by other languages:
fun( arg1 arg2 .....)
- Notation by Lisp language :
(fun arg1 arg2 .....)
SKILL is command language of cadence environment. Whenever we use menus, bindkyes etc. the cadence software triggers SKILL functions to complete the tasks. Other SKILL functions compute or retrieve data from designs. We can enter SKILL functions directly on a command line insted of gui mode.
Term | Definition |
---|---|
Bindkeys | A bindkey associates a SKILL function with a keyboard event. |
CIW | Command Interpreter Window |
SKILL function | A named, parameterizable body of one or more SKILL expressions. |
SKILL procedure | This term is used interchangeably with the term SKILL function. |
SKILL interpreter | The SKILL interpreter executes SKILL programs within the Cadence environment. |
SKILL Process | A separate UNIX process that can submit SKILL functions directly to the SKILL interpreter. |
The simplest SKILL expression is a data item. SKILL data is case sensitive.
Sample SKILL Data items:
Data Type | Syntax Example |
---|---|
integer | 5 |
floating point | 5.3 |
text string | "Mary had a little lamb" |
Function names are case sensitive. Function name with its arguments inside parentheses is stated to call a function.
Example: strname("My" "name" "is" "akhil")
Operators in Descending Precedence | Underlying Function | Operation |
---|---|---|
** | expt | arithmetic |
*, / | times, quotient | arithmetic |
+, – | plus, difference | arithmetic |
++s, s++ | preincrement,postincrement | arithmetic |
== | equal | tests for equality |
!= | nequal | tests for inequality |
= | setq | assignment |
SKILL List is the ordered collection of the SKILL data objects.
Sample general lists:
List | Explanation |
---|---|
(1 2 3) | A list containing the integer constants 1, 2, and 3 |
(1) | A list containing the single element 1 |
() | An empty list (same as the special atom nil) |
(1 (2 3) 4) | A list containing another list as its second element |
- List can be created either using single qoute operator(') or list function.
'(1 2 3) => (1 2 3)
list(1 2 3) => (1 2 3)
- Adding an element to the front of a list using
cons
function
result = '(2 3) => (2 3)
result = cons( 1 result) => (1 2 3)
- Merging two lists using
append
function
list1 = '(1 2 3) => (1 2 3)
list2 = '(4 5 6) => (4 5 6)
list_final = append(list1 list2) => (1 2 3 4 5 6)
- Retrieving 1st element of a list using
car
function
numbers = '(1 2 3)
car(numbers) => 1
- Retrieving tail of the list using
cdr
function
numbers = '(1 2 3)
cdr(numbers) => (2 3)
- Retriving an element given an index using
nth
function
numbers = '(1 2 3)
nth(1 numbers) => 2
- Member function
numbers = '(1 2 3)
member(4 numbers) => nil
member(2 numbers) => (2 3) ; it finds where 2 is present in the list and prints all the elements from 2 till last element.
- length function
numbers = '(1 2 3)
length(numbers) => 3 ; it gives the length of the list.
This section introduces how to
- Display values using default formats and application-specific formats
- Write UNIX text files
- Read UNIX text files
- Using
print
function
for(i 1 3 print("hello"))
=> "hello" "hello" "hello"
- Using
println
function
for(i 1 3 println("hello"))
=> "hello"
"hello"
"hello"
- Using
printf
function
aList = '(1 2 3)
printf("\n This is a list: %L" aList)
=> This is a list: (1 2 3)
To write text data to a file
- Use the outfile function to obtain an output port on a file.
- Use an optional output port parameter to the print and println functions and/or use a required port parameter to the fprintf function.
- Close the output port with the close function.
myPort = outfile("/home/vsao/myfile")
for(i 1 3
println(list("Number:" i) myport)
)
close(myport)
=> ("Number:" 1)
("Number:" 2)
("Number:" 3)
To read a text file
- Use the infile function to obtain an input port.
- Use the gets function to read the file a line at a time and/or use the fscanf function to convert text fields upon input.
- Close the input port with the close function.
inPort = infile( "~/.cshrc" )
when( inPort
while( gets( nextLine inPort )
println( nextLine )
)
close( inPort )
)
Note: We can use fprintf() for printing insted of println() and fscanf() in place of gets() for reading the data.
This section introduces you to
- Relational Operators: <, <=, >, >=, ==, !=
- Logical Operators: !, &&, ||
- Branching: if, when, unless
- Multi-way Branching: case
- Iteration: for, foreach
Relational operators are used to compare data values and returns t
or nil
value accordingly.
Examples:
1. 3 < 5 => t
2. 10 > 2 => nil
3. "abc" != "ABc" => t
In logical operations SKILL considers nil
as false and any other value as true.
Examples:
1. 3 && 5 => 5
5 && 3 => 3
t && nil => nil
nil && t => nil
2. 3 || 5 => 3
5 || 3 => 5
t || nil => t
nil || t => t
- The if function
Example:
colour = "Red"
if( colour == "Red" then
println("colour is Red")
++ colourCount
else
println("colour is not Red")
)
- The when & unless function
Examples:
when( colour == "Red"
println("color is Red")
++ colourCount
) ;end of when
unless(colour == "Red" || colour == "Blue"
println("colour is either Red or Blue")
++colourCount
) ;end of unless
- The case function
Examples:
case( colour
( "red"
++redCount
println("colour is Red")
)
( "blue"
++blueCount
println("colour is Blue")
)
( "green"
++greenCount
println("colour is green")
)
( t
println("colour is not red, blue or green")
)
) ;end of case
The value of variable colour is compared against values red, blue and green. If SKILL finds a match then several expressions in that body are evaluated. If no match is found, the final body is evaluated.
- The for function
sum = 0
for( i 1 5
sum = sum + i
println(sum)
)
=> 1
3
6
10
15