I have an Ocean script that has a few design Variables defined using desVar as follows
desVar("simTemp" 27) desVar("simVdd" 1.0)
simVdd is my supply Voltage. I have to measure the propagation delay of my circuit and for that I need to find the delay between my input signal crossing the vdd/2 value and the output signal crossing the vdd/2 mark. In most cases, when the supply voltage is a constant, the calculator expression for delay is
delay(?wf1 v("/D1" ?result "tran") ?value1 0.5 ?edge1 "rising" ?nth1 1 ?td1 0.0 ?wf2 v("/CMPLT32" ?result "tran") ?value2 0.5 ?edge2 "rising" ?nth2 1 ?td2 nil ?stop nil ?multiple nil)
However now in my case, because the supply voltage was changing with each run, I needed a calculate the vdd/2 value at run time in my Ocean script.
The correct way to do this is as follows.
halfVdd = evalstring(desVar("simVdd"))/2.0
Of course the reference manual would have a long description of the correct way and the different options that can be used with evalString, however I was led in the correct direction by this post.
Also note the 2.0 in the denominator. Without the 2.0, I ended up having the halfVdd value set to ‘0’ when simVdd was 1, as it was doing an integer division and not treating the evaluated value as a real number. This was something that I had to figure out myself.
And then the delay expression would be
delay(?wf1 v("/D1" ?result "tran") ?value1 halfVdd ?edge1 "rising" ?nth1 1 ?td1 0.0 ?wf2 v("/CMPLT32" ?result "tran") ?value2 halfVdd ?edge2 "rising" ?nth2 1 ?td2 nil ?stop nil ?multiple nil)