David,
Apologies again (after your PM) for how long its taken me to get to this - just been a bit busy with family rather than having time to look at the Designer's Guide site, but pretty much caught up again now...
Waveforms and vectors are specific objects in SKILL. Waveforms consist of an X and a Y vector, which are accessed like arrays, but using a particular function (drGetElem). There's also drSetElem() to update them. Some examples:
Code:a=VT("/o1")
drwave:178577432
a~>??
(xScale linear)
a~>xScale
linear
yvec=drGetWaveformYVec(a)
drvec:178569240
yvec~>??
(expression
VT("/o1") units "V"
)
yvec~>expression
VT("/o1")
yvec~>units
"V"
xvec=drGetWaveformXVec(a)
drvec:178569248
xvec~>??
(units "s" name "time")
drVectorLength(yvec)
343
drType(yvec)
double
drGetElem(yvec 0)
5.0
drGetElem(yvec 123)
1.286023
drGetElem(xvec 0)
0.0
drGetElem(xvec 123)
6.233276e-09
As you can see from this, the expression is stored as a list on the y vector (a resonable place for it to be). Of course, it gets a bit more complicated with family curves, but the famMap function is usually what you'd use to iterate over those.
Here's some example code which traverses a waveform, and does a modulo operation - it reads the source waveform, and builds a new waveform object from it. It also manipulates some of the properties on the waveform/vectors too. It's written in LISP syntax (tends to be my preference), but I think the meaning should be clear enough. You can always pp() it to convert it into C-like syntax if LISP syntax defeats you!
Code:/* abModulo.il
Author A.D.Beckett
Group Custom IC (UK), Cadence Design Systems Ltd.
Language SKILL
Date Jul 06, 2005
Modified Nov 23, 2005
By A.D.Beckett
Example use:
plot(abModulo(phaseDegUnwrapped(v("/Pif" ?result "pss_fd"))))
***************************************************
SCCS Info: @(#) abModulo.il 11/23/05.18:05:09 1.2
*/
/***************************************************************
* *
* (abModulo waveform @optional (modulo 360)) *
* *
* Take a waveform and return a modulus - strictly *
* positive. Useful for wrapping phase waveforms to be *
* between (say) 0 and 360 degrees. *
* *
***************************************************************/
(procedure (abModulo waveform @optional (modulo 360))
(cond
;---------------------------------------------------------------------
; Handle ordinary waveform
;---------------------------------------------------------------------
((drIsWaveform waveform)
(let (oldyvec newyvec len newwave yval)
(setq oldyvec (drGetWaveformYVec waveform))
(setq len (drVectorLength oldyvec))
(setq newyvec (drCreateVec 'double len))
;---------------------------------------------------------------
; Iterate over the points, computing the modulus of each point
;---------------------------------------------------------------
(for point 0 (sub1 len)
(setq yval (drGetElem oldyvec point))
(setq yval
(difference yval
(times
(fix (quotient yval modulo))
modulo)))
(drSetElem newyvec point yval)
)
;---------------------------------------------------------------
; Set the expression so the name of the waveform is correct
;---------------------------------------------------------------
(putpropq newyvec
(list 'abModulo (getq oldyvec expression) modulo) expression)
(setq newwave
(drCreateWaveform
(drGetWaveformXVec waveform)
newyvec
))
;---------------------------------------------------------------
; Inherit the plot style and scale
;---------------------------------------------------------------
(putpropq newwave (getq waveform plotStyle) plotStyle)
(putpropq newwave (getq waveform plotStyle) xScale)
newwave
)
)
;---------------------------------------------------------------------
; Family waveforms should be handled OK
;---------------------------------------------------------------------
((famIsFamily waveform)
(famMap 'abModulo waveform modulo)
) ; family
;---------------------------------------------------------------------
; And straight numbers
;---------------------------------------------------------------------
((numberp waveform)
(difference waveform
(times
(fix (quotient waveform modulo))
modulo)))
(t
(error "abModulo - can't handle %L\n" waveform)
)
)
)
Regards,
Andrew.