next up previous contents index
Next: File Formats Up: Margin Analysis Previous: Example Monte Carlo Analysis   Contents   Index

Circuit Margin Optimization

There are three scripts which implement a margin optimization algorithm used by Clark Hamilton at NIST. These files (kept in the scripts directory) are optimize, margins, and merit. The main script is optimize, which is invoked with the name of the file to be optimized as an argument.

This facility is for advanced users. The present status of the scripts is unknown, and it is possible that they may require modification before use. They are provided as an example of how the WRspice scripting facility can be employed for optimization.

An example input file, which defines and initializes various variables and vectors as well as providing a circuit to optimize, is shown below. To perform optimization, one gives ``optimize filename''.

    .check
    set checkiterate = 3
    let checkN1 = 0
    compose checkPNTS values 1n 2n
    let value[19] = 0
    let flags[19] = 0
    let flags[0] = 1
    let value[0] = .8
    .control
    if (TIME >= checkPNTS[0])
    &#32   checkFAIL = 0
    &#32   if ((abs(v(1)) > 1.5) or (abs(v(1)) < .5))
    &#32       checkFAIL = 1
    &#32   endif
    endif
    .endc
    optimization test
    i1 0 1 pulse(0 1 0 1n)
    r1 1 0 $&value[0]
    .tran .01n 1.1n
    .end

This is the simplest way to input the file, alternatively one could set the shell variables and vectors externally and/or use a bound codeblock for pass/fail evaluation.

The margins script, called by optimize calls the check command. The variable checkiterate must be set to a nonzero value up to 10. This is the binary search depth for finding the operating range.

The vectors checkN1 and value must be defined, checkN1 is the index into the value array of the variable being adjusted. It is altered by the scripts, but it and value must be defined before the script is input or in the header as shown.

The vector checkPNTS is the array of points where analysis is performed. Note that due to some strangeness, at least two entries must exist.

The value array is initialized to the starting values. The flags vector contains 1 for each entry in the array which is to be varied, the others are treated as constants.

The lengths of the vectors value and flags is 20, which is assumed in the optimization script.

After the analysis is complete, the value array will contain the optimized values. Two other arrays, lower and upper, are created, and contain the lower and upper limit for each value index.

The scripts provided can be customized by the user for more specific applications, or used as templates for different types of analysis. It is recommended that such scripts be defined as codeblocks to speed execution.


next up previous contents index
Next: File Formats Up: Margin Analysis Previous: Example Monte Carlo Analysis   Contents   Index
Stephen R. Whiteley 2017-10-02