Any circuit you design uses parts that will vary depending on many factors that are not under your control. All components that you use, such as resistors or capacitors, have a tolerance. A 50Ω resistor with a precision of ± 1%, can vary between 49.5 Ω to 50.5Ω. But your design is made of several parts and the variation across all the parts will add up to make predictions almost impossible. Not to mention, each variation may follow a distribution pattern, and the cost is generally inversely proportional to tolerance. So, how do you manage cost and yet achieve desired output from your circuit for the thousands of pieces built using different components? The solution is to run a Monte Carlo analysis on your circuits. Monte Carlo predicts the behavior of a circuit statistically when part values are varied within their tolerance range. You can use Monte Carlo to predict the yield of your manufactured designs.

Monte Carlo predicts the yield for each measurement you have defined for your circuit. To make the prediction, Monte Carlo uses random values from distribution tables, such as a Gaussian table, of all devices that have non-zero tolerances. But, you need not worry, because all you need to do to run Monte Carlo is define tolerances.

PSpice Advanced Analysis Monte Carlo gives you the following advantages over convention Monte Carlo or equivalent analyses:

- Computation efficiency: You can analyze multiple goals at once. For example, if you want to calculate the yield for two goals - phase shift and total noise - and run 10,000 steps, Monte Carlo will need only 10,000 steps and not 20,000 steps. In addition, you can perform dynamic yield calculations by changing ranges.
- Variety of plots: You can not only choose between Cumulative Distribution Graph and Probability Density Graphs but you can also configure bins on the go.
- Flexibility in assigning tolerance based on the component type: Set tolerances on component value (resistors and capacitors), model parameter (BJT), subcircuit model parameters, global variables, and voltage and current sources (DC values).

You will use the *RF Amplifier* demo design (*File* – *Open* – *Demo Designs*) in OrCAD® Capture to follow along with the steps. If you are using any other design, just ensure that you have done the following:

1. Assigned tolerance to the design components.

2. Defined one or more simulation profiles of any of the following types and run them with expected results: Time Domain (transient), DC Sweep, or AC Sweep/Noise analyses.

See Simulation Profiles in Five Steps to know more about profiles.

3. Defined the measurements of interest.

See the *Setting Up Measurements* section of How to Use Measurements to Optimize Your Design for the steps to create measurements.

### Setting Up and Running Monte Carlo

Perform the following steps to open PSpice Advanced Analysis after you have successfully run the PSpice simulation and created measurements:

1. In OrCAD Capture, choose *PSpice* – *Advanced Analysis* – *Monte Carlo*.

The PSpice Advanced Analysis window appears.

If you are using the demo design and the measurements are already imported for you, proceed to step 4.

2. Click the text *Click here to import measurement created within PSpice* to open the Import Measurement(s) dialog.

3. Select the measurements you want to import and click *OK*. In this example, select the four measurements listed for the AC profile.

4. Ensure all the measurements are included in the analysis.

A checkmark in the On/Off column shows that the measurement is included. Clear the checkmark to exclude a measurement from the next analysis.

5. Choose *Edit* – *Profile Settings*.

The analysis is set for 100 runs. You can edit the value. A higher number of runs provides a better result, but the simulation time increases.

6. Click *OK*.

7. Start the analysis by clicking the *Start/Resume* icon.

The Monte Carlo analysis runs, and you start seeing status messages in the output window.

Monte Carlo calculates a nominal value for each measurement using the original parameter values.

After the nominal runs, Monte Carlo randomly calculates the value of each variable parameter based on its tolerance and a flat (uniform) distribution function.

For each profile, Monte Carlo uses the calculated parameter values, evaluates the measurements, and saves the measurement values.

Monte Carlo repeats the above calculations for the specified number of runs, then calculates and displays statistical data for each measurement.

### Reviewing Monte Carlo Results

To review the results, do the following steps:

1. For each measurement, observe the Yield value calculated, and the statistical results reported for the following:

a. Mean

b. Std Dev (Standard Deviation)

c. 3 Sigma

d. 6 Sigma

e. Median.

A yield value close to 100% is acceptable.

2. Select any of the measurements, say, *Max(DB(V(Load)))*.

The selected row is highlighted, and a triangle appears in the left-most column indicating that the row can be sorted.

3. Observe the Probability Density Graph. Hover over a bar to see details.

A probability Density Function (PDF) graph shows the number of runs for a measurement value range. The graph is displayed as a bar chart with the following properties:

• It has 10 bins or bars as specified as the default value in the Profile Settings dialog. You can change the number of bins; for example, increase the number of bins for more details.

• The x-axis displays the measurement values for all the Monte Carlo runs. In this example, it shows the values of Max(DB(V(Load))) – the selected measurement.

• The y-axis shows the number of runs with measurements between the x-axis bin ranges or bar. For example, if you hover over the bar for the bin ranges 9.20472 and 9.43311, you see that the number of runs with this measurement range is 29.

You can change the Y-axis to show percentage runs instead of absolute runs by right-clicking and choosing the *MCYaxis (Absolute/Percent)* toggle option.

4. Right-click and choose the *MC Graph (PDF/CDF)* toggle option to display the Cumulative Distribution Function (CDF) graph.

The CDF graph shows the number of runs with a measurement value and all values less than it.

Observe that the number of runs is shown as a percentage. You can change that to an absolute number by choosing the MCYaxis (Absolute/Percent) toggle option.

5. Click the *Raw Meas* tab.

This shows Raw Measurements, which is a read-only table with a one-to-one relationship with the Statistics tab. This table lists the value for each measurement for every run.

6. Double-click a row to sort the values. Double-click the left-most column of the selected measurement to put the measurements in ascending order.

Run 98 has the lowest value for Max(DB(V(Load))). You can double-click again to see the measurement values in descending order.

You can also copy the values from the table to an external application for further recording, communication, or analysis.

### Restricting Calculation Range: Dynamic Yield Calculation

You can change the Cursor Min and Cursor Max values and calculate the results for the changed values to quickly view statistical results for a different min / max range.

To change the range and view new results, do the following steps:

1. Change the cursor values by either one of the following methods:

a. Edit the values for a measurement.

b. Select an existing min or max line by clicking the line and then click again to place the line at a new location.

2. Right-click and choose *Restrict Calculation Range*.

The statistical and yield values are recalculated based on the new range.

### Conclusion

Monte Carlo makes it easy for you to deal with the randomness inherent in any practical system by predicting the behavior of a circuit statistically, and then, goes beyond to provide you with the yield.

You have already explored several Advanced Analysis topics in the last few posts:

- Smoke Analysis (Managing the Stress Levels of Design Components)
- Sensitivity Analysis (Creating Predictable Designs Using Sensitivity Analysis)
- Optimization:
- Using Measurements (How to Use Measurements to Optimize Your Design)
- Using Curve-fitting (Using Curve-Fitting to Optimize a Design)

In the next post, you will explore the final major topic of this series on Advanced Analysis — Parametric Plotter.

Do SUBSCRIBE to be updated about upcoming blogs. If you have any topic you want us to cover or any feedback for us, you can write to us at pcbbloggers@cadence.com.