Ocean and SKILL

11 March 2020 Link


Introduction

  • Cadence has embedded Lisp programming language to control and extend the Cadence EDA suite.
  • Ocean is the name of the API that can be used for controlling and manipulating simulations.

Cheat Sheet

Lists

Creating lists

  • list(a b c) - list function creates a list
  • ' Operator - '(1 2 3) - ' Operator creates a list from teh following data
Note: ' Operator does not work on sub lists

Manipulating Lists

  • cons( 1 oldList) - cons function adds 1 element to the beginning of the list. The element can be any data type.
  • append(list1 list2) - append function creates a new list by combining the argument lists.
  • car(list1) - returns the 1st element from the list list1
  • cdr(list1) - returns the tail of the list list1 i.e. all but the 1st element.
  • nth(1 list1) - returns the element at the given index from list1. The index numbering starts from 0
  • member(1 list1) - tells if the given data (1st argument) is a member of the list1 (second argument)
  • length(list1) - Gives the number of elements in the list

Data Types

  • To convert string to number use evalstring()

System Commands

  1. Get Host name: > getHostName()

Flow Control

For Loop

for( i 0 5
    print(i)
)


Tricks


Plotting

Plot a list

The following commands will plot the given list in a waveform window and then make only dots available:
xlist=list(-40 25 85);
ylist=list(1.135u 1.249u 1.2971u);
win=newWindow();
awvPlotList(win list(ylist) xlist);
plotStyle('scatterPlot);

Playing with waveform windows

Create new window
   newWindow()  ;; would return the windowId
Select or get Current Window
currentWindow([windowId])
Get Current Waveform window
To get the current waveform window
hiGetCurrentWindow()
Add Title
Add title tot he current waveform window
addTitle("Waveform title")
Create Sub Window
addSubwindow()  ;; would return the window number
Get/Set current sub window
currentSubwindow([subWindowNum])
Plot into different strips
displayMode("strip")
plot(getData("/VIN") ?strip 1)

Nyquist plot in Cadence


Plotting Nyquist Plot

Found this info here
Use the following commands after running the stb analysis
load "~/cadence/skill/abConcatWaveforms.il"
lg = getData("loopGain" ?result "stb")
; abConcatWaveforms externally defined
lg2 = abConcatWaveforms(flip(conjugate(lg)) lg)
w = newWindow()
ocnYvsYplot(?wavex real(lg2) ?wavey imag(lg2))

The abConcatWaveforms.il file is here
The file's content is:
/* abConcatWaveforms.il

Author     A.D.Beckett
Group      Custom IC (UK), Cadence Design Systems Ltd.
Language   SKILL
Date       Jan 08, 2009
Modified
By

Function to concatenate waveforms.

For example:

new=abConcatWaveforms(flip(sig) sig)

will produce a new waveform made out of a flipped version of
the input signal, glued to the original input signal.

***************************************************

SCCS Info: @(#) abConcatWaveforms.il 01/08/09.15:41:29 1.1

*/

/*****************************************************************
*                                                                *
*             (abConcatWaveforms (wave1 [waves...]))             *
*                                                                *
*  Function to concatenate a number of waveforms. The function   *
*   takes an arbitrary number of waveforms (assumed to all be    *
*  waveforms or families of the same number of dimensions), and  *
* concatenates the axes together. Note that care should be taken *
*  if the x-axes overlap, because this merely concatenates the   *
*              vectors without any checking at all.              *
*                                                                *
*****************************************************************/

(defun abConcatWaveforms (wave1 @rest waves)
   (let (xVec yVec newX newY newLen len)
     (cond
       ((drIsWaveform wave1)
        (setq newLen (drVectorLength (drGetWaveformXVec wave1)))
        (foreach wave waves
                (setq newLen (plus newLen
                                   (drVectorLength (drGetWaveformXVec wave))))
                )
        (setq newX (drCreateVec (drGetWaveformXType wave1) newLen))
        (setq newY (drCreateVec (drGetWaveformYType wave1) newLen))
        (foreach wave (cons wave1 waves)
                (setq xVec (drGetWaveformXVec wave))
                (setq yVec (drGetWaveformYVec wave))
                (setq len (drVectorLength xVec))
                (for pos 0 (sub1 len)
                     (drAddElem newX (drGetElem xVec pos))
                     (drAddElem newY (drGetElem yVec pos))
                     )
                )
        (drCreateWaveform newX newY)
        ) ; is waveform
       ((famIsFamily wave1)
        (apply 'famMap (constar 'abConcatWaveforms wave1 waves))
        ) ; is family
       (t
        (error "abConcatWaveforms - can't handle %L\n" wave1)
        )
       ) ; cond
     ) ; let
   ) ; defun

Also See



Convert Wave to List

  • Use the following Skill function to do that:
/************************************************************************
*                                                                       *
*                  (abWaveToList wave @key transpose)                   *
*                                                                       *
*    Take a waveform object, and return it as a list of xy pairs. Or    *
* if transpose is set, it returns a list of x values followed by a list *
*                             of y values.                              *
*                                                                       *
************************************************************************/


(procedure (abWaveToList wave @key transpose)
  (let (xList yList xyList len
        (xVec (drGetWaveformXVec wave))
        (yVec (drGetWaveformYVec wave))
        )
       (setq len (drVectorLength xVec))
       ;-----------------------------------------------------------------
       ; Return value of this if is the list
       ;-----------------------------------------------------------------
       (if transpose
           (progn
            (for i 0 (sub1 len)
                 (setq xList (tconc xList (drGetElem xVec i)))
                 (setq yList (tconc yList (drGetElem yVec i)))
                 )
            (list (car xList) (car yList))
            )
           ; else
           (progn
            (for i 0 (sub1 len)
                 (setq xyList (tconc xyList (list (drGetElem xVec i)
                                                  (drGetElem yVec i))))
                 )
            (car xyList)
            )
           ) ; if
       ) ; let
  ) ; procedure