Manuals >User's Guide >Creating and Running Macros
Print version of this Book (PDF file)
prevnext

An Example Macro

This section provides an example to improve your understanding of what a Macro can accomplish and how some if its features can be used. This example (code listing below) benchmarks the quality of the DC extraction in the pn_diode.mdl file. Load this file to view and run the example. Before running this example, you must define TNOM in your System Variables Table.

After performing Read Model you should be able to edit the diode model. By selecting Read Macro from the menu associated with its list of Macros, you can load pn_test.mac, so you don't have to enter the text appearing below. After loading the Macro file, perform the Edit menu choice for the newly loaded Macro test_extract, Execute the Macro by selecting its name and clicking on Execute.

The Macro code is included below. The comments within the Macro should clarify what the Macro is doing.

Figure 40 Example Macro
 ! This macro will perturb model parameters,
! automatically call an extraction,
! and then compare the extracted parameters
! to the original, "perturbed" parameters
! perturb model parameters 
IS = IS * 0.5
N   = N * 1.2
RS  = RS * 2.1
! save perturbed model parameter values 
is1 = IS  
n1  = N  
rs1 = RS
! simulate with perturbed parameters and 
! then compute and print rms error between 
! meas. & sim. current  
iccap_func("/diode/dc/idvd", "simulate")
error = RMSerror(/diode/dc/idvd/ia.m,/diode/dc/idvd/ia.s,0)  
print "RMS error before extraction: " ; error
! call extraction to clean up parameters  
iccap_func("/diode/dc", "extract")
! display plot if user desires


prevnext