I am trying to do calibration using pre-run script.
The code below does not work which is kind of expected because I am still trying to figure this out.
Is it possible to monitor the calibration when the pre-run script is running?
How can I debug it when I am having error?
The measurement expressions here are error free because I used it during calibration using multiple tests and calcVal.
I am trying to use pre-run hoping to make the flow simpler.
The error message:
The code:
;Use let() to avoid creating global variables
(let (CODE_CHOSEN, TRAN_TOT)
;Debug printf statements are written to the Job log
printf("pre run: Hello World!\n")
;Initialize and inherit the test setup from the current point
ocnxlLoadCurrentEnvironment(?noAnalysis nil)
;Define the analysis if different from the main setup
;Sweep the calibration variable
paramAnalysis("VEN_DAC" ?start 0 ?stop 1.2 ?step 1.2
paramAnalysis("CODE" ?start 0 ?stop 2 ?step 1
analysis('dc ?saveOppoint t ?param "vdc" ?start "1m" ?stop "1200m" ?step "1m" )
analysis('tran ?start 0 ?stop 1u ?step 10n )
))
;analysis('dc ?saveOppoint t ?param "vdc" ?start "1m" ?stop "1200m" ?step "1m" )
;analysis( ’tran ?start 0 ?stop 1u ?step 10n )
;Run a simulation
ocnxlRunCalibration()
;Measurement to find the calibrated value
TRAN_TOT = (cross(VT("/VOUT_INV") 0.6 1 "falling" nil nil nil) - cross(VT("/VOUT_INV") 0.6 1 "rising" nil nil nil))
printf("pre run: TRAN_TOT = %f\n" TRAN_TOT)
CODE_CHOSEN = if((TRAN_TOT == nil) "use_untrimmed" if((VAR("TOT_CHOSEN_UNTRIMMED") == nil) VAR("CODE") if((abs((TRAN_TOT - VAR("TOT_TYP"))) < abs((VAR("TOT_CHOSEN_UNTRIMMED") - VAR("TOT_TYP")))) VAR("CODE") "use_untrimmed")))
printf("pre run: CODE_CHOSEN = %f\n" CODE_CHOSEN)
;Add the calibrated result value to the outputs table
ocnxlAddOrUpdateOutput("TRAN_TOT" TRAN_TOT)
ocnxlAddOrUpdateOutput("CODE_CHOSEN" CODE_CHOSEN)
;Update the main simulation environment with the calibrated result
ocnxlUpdatePointVariable("CODE" CODE_CHOSEN)
ocnCloseSession()
)