Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

SpectreRF Workshop

Using the SpectreRF MATLAB Toolbox


MMSIM6.1

February 2006
SpectreRF MATLAB Toolbox Workshop

Contents
SPECTRERF MATLAB TOOLBOX ............................................................................................................................ 3

Purpose ...................................................................................................................................................................... 3

Audience..................................................................................................................................................................... 3

Overview .................................................................................................................................................................... 3

INTRODUCTION TO THE SPECTRERF MATLAB TOOLBOX ............................................................................................. 3

THE DESIGN EXAMPLE: A DIFFERENTIAL LNA ................................................................................................ 4

EXAMPLE MEASUREMENTS USING THE SPECTRERF MATLAB TOOLBOX ............................................ 4

LAB 1: SMALL SIGNAL GAIN (SP) .................................................................................................................................. 4

LAB 2: LARGE SIGNAL NOISE SIMULATION (PSS AND PNOISE) ................................................................................... 10

LAB 3: GAIN COMPRESSION AND TOTAL HARMONIC DISTORTION (SWEPT PSS)......................................................... 12

LAB 4: IP3 MEASUREMENT---PSS PLUS PAC ANALYSIS .............................................................................................. 16

LAB 5: IP3 MEASUREMENT---QPSS ANALYSIS WITH SHOOTING OR FLEXIBLE BALANCE ENGINE ............................. 17

LAB 6: IP3 MEASUREMENT---RAPID IP3 USING AC ANALYSIS..................................................................................... 18

LAB 7: IP3 MEASUREMENT ---RAPID IP3 USING PSS PLUS PAC ANALYSIS ................................................................ 19

CONCLUSION ............................................................................................................................................................... 20

REFERENCE ................................................................................................................................................................. 20

February 2006 -2- Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

SpectreRF MATLAB Toolbox


The procedures described in this workshop are deliberately broad and generic. Your specific
design might require procedures that are slightly different from those described here.

Purpose

This workshop describes how to use SpectreRF and the SpectreRF MATLAB toolbox to measure
parameters that are important in the design verification of low noise amplifiers (LNA).

Audience

Users of Spectre and SpectreRF.

Overview

This application note describes the basic steps required to use the SpectreRF MATLAB toolbox.

Introduction to the SpectreRF MATLAB Toolbox

MATLAB, as a powerful mathematical and graphical tool, provides rich data processing and
display functionalities. The SpectreRF toolbox provides customers with the ability to customize
their own measurements and displays. The toolbox includes functions that provide the ability to
read in the PSF and SST2 format simulation results, and to filter and plot the data. The toolbox
also provides several measurement functions such as IP3 and compression point. This document
uses an LNA design as an example to show how to use the SpectreRF MATLAB toolbox.

February 2006 -3- Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

The Design Example: A Differential LNA


The LNA measurements described in this workshop are calculated using the SpectreRF toolbox in
MATLAB, but you still need to set up and run Spectre in the Analog Design Environment (ADE).
For more detailed information about the LNA design, refer to SpectreRF Workshop: LNA
Design Using SpectreRF.

Example Measurements Using the SpectreRF


MATLAB Toolbox
Begin your examination of the flow by bringing up the Cadence Design Framework II
environment and MATLAB:
To begin,
Action 0-1: Move into the ./lna directory.
cd ./lna

Action 0-2: Start the icfb tool.


icfb&

Action 0-3: Start the MATLAB tool.


matlab&

Action 0-4: In the CIW window, select Tools – Library Manager.

Lab 1: Small Signal Gain (SP)

Action 1-0: Follow the instructions in the SpectreRF Workshop: LNA Design Using
SpectreRF to complete Actions 1-1 to 1-11.
Action 1-12: In the MATLAB console window, type the following information.
resdir = ‘simulation/Diff_LNA_test/spectre/schematic/psf’;
datasets = cds_srr(resdir);
signals = cds_srr(resdir, 'sp-sp');
gt = cds_gt('schematic-sp/psf', 'sp-sp');
hold on
cds_plotsig(gt, '', '', 'db10')

February 2006 -4- Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

The resdir command defines the results directory, datasets includes names of
all datasets, signals returns the list of signals grouped by unit type, gt returns the
transducer gain. The last command plotted gt in db10.
The cds_gt measurement is written by the MATLAB script.You can read the
cds_gt.m file under the toolbox install path. In this file, you read out four
S-parameters with cds_sp. The four S-parameters are all in a special structure that
includes sweep information. For the description of this structure, refer to
SpectreRF MATLAB Toolbox App-note. The value field name is the first string of
the info field and you get the name with the command vname =
char(s11.info(1));, then use commands similar to s11v =
eval(sprintf('s11.%s', vname)); to get the 4 vectors of S-parameters. With
the right equation you can get the GT value. With ga = s11; you copy the structure
of s11 to the result, then evaluate the value to return the result.
The cds_plot command shows the waveform of the signal. The usage is
cds_plot (sig, expr, sweep, type), where sig is the signal data returned by
cds_srr or other toolbox commands, expr is an expression to select data (the
same as the parameter for cds_evalsig), sweep is the sweep name used for the
X-axes, type is the display type for complex data with possible values of mag,
phase, real, imag, both, db10, and db20.
Action1-13: Type the following commands in the MATLAB console
ga = cds_ga(resdir, 'sp-sp');
gp = cds_gp(resdir, 'sp-sp');
cds_plotsig(ga, '', '', 'db10')
cds_plotsig(gp, '', '', 'db10')

These commands calculate ga (available power gain) and gp (operating power gain)
and plot them. With the hold on command that you used in Action 1-12, these three
results plot in the same figure. The script files cds_ga.m and cds_gp.m are similar
to the cds_gt.m script file but with different equations.

February 2006 -5- Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

Action 1-14: Close the figure window, go back to the MATLAB console, and run the following
commands:
hold on
cds_select(resdir, 'sp-sp');
gmax = cds_gmax;
cds_plotsig(gmax, '', '', 'db10')
gmsg = cds_gmsg;
cds_plotsig(gmsg, '', '', 'db10')
gumx = cds_gumx;
cds_plotsig(gumx, '', '', 'db10')

These commands calculate gmax (Maximum Transducer Power Gain), gmsg


(Maximum Stability Gain), and gumx (Maximum Unilateral Transducer Power
Gain), and plot them in the same figure.

February 2006 -6- Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

If you do not want to input the results directory and dataset name every time, you
can use cds_select to set them globally as the default values. For guidance, refer
to cds_gmax.m, which tells you how to use the global variables cds_gresultDir
and cds_gresult. The script files cds_gmax.m, cds_gmsg.m, and cds_gumx.m
are also similar with cds_gt.m. You use them to get the S-parameter with cds_srr,
then calculate.
Action 1-19: Ignore Actions 1-15 to 1-18 in the “SpectreRF Workshop: LNA Design Using
SpectreRF.” Smith-charts are not implemented in MATLAB.
Action 1-20: Close the figure window, go back to the MATLAB console, and run the following
commands:
hold on
kf = cds_kf;
b1f = cds_b1f;
cds_plotsig(kf)
cds_plotsig(b1f)

These commands calculate kf (stability factor) and b1f (alternative stability factor)
and plot them in the same figure.

February 2006 -7- Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

Action 1-21: Close the figure window, go back to the MATLAB console, and run the following
commands:
hold off
NF = cds_srr(resdir, 'sp-noise.sp', 'F');
cds_plotsig(NF, '', '', 'db10')

The noise figure is stored in the noise dataset. The cds_srr command reads it out
directly. You get the following plot:

February 2006 -8- Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

Action 1-22: Close the figure window, go back to the MATLAB console, and run the following
commands:
hold on
vswrn1 = cds_vswr(1);
vswrn2 = cds_vswr(2);
cds_plotsig(vswrn1, '', '', 'db20')
cds_plotsig(vswrn2, '', '', 'db20')

The cds_vswr command returns the "voltage standing wave ratio" waveform. The
command uses the index of the port as a parameter. You get the following
waveforms:

February 2006 -9- Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

Action 1-23: Close the figure window, return to ADE, and continue with the LNA Workshop.

Lab 2: Large Signal Noise Simulation (PSS and Pnoise)

Action 2-0: Follow the instructions in the LNA Workshop to complete Action 2-1 to Action
2-15.
Action 2-16 Go to the MATLAB console, and run clear to clean the variables in memory. Then
run the following commands:
resdir = ‘simulation/Diff_LNA_test/spectre/schematic/psf’;
td = cds_srr(resdir, 'pss-td.pss', 'RFout');
fd = cds_srr(resdir, 'pss-fd.pss', 'RFout');
subplot(2,1,1)
cds_stemsig(fd, '','', 'mag')
subplot(2,1,2)
cds_plotsig(td)
td2fd = cds_fft(td);
cds_stemsig(td2fd, '','', 'mag')
fd2 = cds_evalsig(td2fd, 'freq<=2.5e10');
cds_stemsig(fd2, '','', 'mag')

These commands illustrate how to use time domain and frequency data. The
commands first select out the td and fd data from the pss results and place them in
February 2006 - 10 - Product Version 6.1
SpectreRF MATLAB Toolbox Workshop

different datasets. The cds_fft command does a Discrete Fourier Transform. Then
the commands get another copy of the frequency domain data from the time domain
data.
Then the commands plot both sets of frequency data and compare them. To do this,
they use the cds_stemsig command to plot discrete data in the same way as
cds_plot is used to plot continuous data. The usage of these two commands is the
same.

If you read cds_fft.m, you can see how the FFT is done. Because the time domain
data from SpectreRF is not evenly distributed in time, the cds_interpsig
command, which uses interpolation, is used to distribute the time points evenly.
The basic usage is cds_interpsig(sig, sweep, Num, 'method'). sig is the
signal data returned by cds_srr. sweep is the name of the sweep data that needs to
be distributed. For cds_fft, the sweep is time, but notice that cds_interpsig
can work for all types of sweeps. num is the number points that exist after
interpolation. method specifies alternate methods with possible values of linear,
cubic, nearest, and spline. The last three parameter of cds_interpsig are
optional. After running the cds_interpsig command, cds_fft copys sweep
information from the signal and fills in the frequency sweep information. Then call
the fft command (building command of Matlab) to get the frequency data. To
support multi-sweep results like Monte Carlo, you do a sweep to do fft for each
additional sweep.

February 2006 - 11 - Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

The cds_evalsig command helps you select out the special data from a sweep.
The usage is cds_evalsig(sig, expr). The parameter expr can be any
expression using <, >, =, >=, &, |, and so on.
Action 2-17: Close the figure window, go back to the MATLAB console and run the following
commands:
hold off
NF = cds_srr(resdir, 'pnoise-pnoise', 'NF');
cds_plotsig(NF, '', '', 'db10')

You get the following plot for the noise figure:

Action 2-18: Close the figure window, return to ADE, and continue with the LNA Workshop.

Lab 3: Gain Compression and Total Harmonic Distortion


(Swept PSS)

Action 3-0: Follow the instructions in the LNA workshop to complete Action 3-1 to Action 3-9.
Action 3-10: Go to the MATLAB console, and run clear to clean the variables in memory. Then
run the commands:

February 2006 - 12 - Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

resdir = ‘simulation/Diff_LNA_test/spectre/schematic/psf’;
fdout = cds_srr(resdir, 'sweeppss_pss_fd-sweep', 'RFout')
cds_compression(fdout, '', 1)

You get the frequency domain data from the pss sweep, so you see the two sweep
names, freq and prf. As frequency domain data, you can also see a field named
harmonic. The vector sizes of harmonic and freq are the same. You can select
harmonic 1 with the command cds_evalsig(fdout, 'freq=2.4e+09') or
with the command cds_harmonic(fdout, 1).
cds_compression is a command for the n-dB compression point. The usage is
cds_compression(vport, iport, harm, rport, gcomp, curve). vport
is the voltage of the port. iport is the current of the port, the default value is
vport/rport. harm is the harmonic value, with a default value of 1. rport is a
resistor of the port, with a default value of 50.0. gcomp is the number of dB units,
with a default default value of 1. curve controls the curve display, with a default of
'on', can be 'off'. So the command cds_compression(fdout, '', 1) is
equivalent to cds_compression(fdout, '', 1, 50, 1, 'on'). If you look at
the cds_compression.m file, you can see how to get iport from vport.
Because vport is a structure, it cannot be calculated directly, but, instead, the whole
structure has to be copied and then you can obtain the field values for the calculation.
Then you can get the current and voltage curve with the cds_harmonic command
and calculate the power curve in dBm. Finally you get the n_dB compression power
with interpolation.
You get the following figure:

February 2006 - 13 - Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

Action 3-11: Run the following commands in the MATLAB console:


out30 = cds_evalsig(fdout, 'prf=-30');
cds_stemsig(out30, '', '', 'db20');

These commands select out the frequency signal of prf = -30 and plot it.

February 2006 - 14 - Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

Action 3-12: Run the following commands in the MATLAB console:


cds_harmonic(fdout, 1);
thd = cds_thd(fdout, 2.4e+09)
cds_plotsig(thd)

In this step, you use the cds_harmonic command to get the frequency of the first
harmonic. The command returns harmonic [1] is frequency 2.4e+09. Then
you use the cds_thd command to calculate the total harmonic distortion (THD).
The cds_thd command only has two parameters. The first is the signal structure
and the second is the fundamental frequency.
The THD plot appears in the figure window.

February 2006 - 15 - Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

Action 3-12: Close the figure window, return to ADE, and continue with the LNA Workshop.

Lab 4: IP3 Measurement---PSS Plus PAC analysis

Action 4-0: Follow the instructions in the LNA workshop to complete Action 4-1 to Action 4-12.
Action 4-13: Go to the MATLAB console, and run clear to clean the variables in memory. Then
run the following commands:
resdir = ‘simulation/Diff_LNA_test/spectre/schematic/psf’;
RFout = cds_srr(resdir, 'sweeppss_pac-sweep', 'RFout');
cds_ipn(RFout, -2, 0, -40)

In this lab, you calculate the IP3 with pac results. You use the cds_ipn command to
get the IPN results. The usage of this command is
[ipn_in, ipn_out] = cds_ipn(vport, harmspur, harmref, epoint, rport,
ordspur, iport, epref, ordref, curve).

vport is thevoltage of the port; harmspur is the up order harmonic value;


harmref is the reference order (1st order) harmonic value; epoint is the input
power extrapolation point; rport is the resistor of the port, with a default value is
50.0; ordspur is the up order number, with a default value is 3; iport is the
current of the port, with a default value of vport/rport; epref is the input power
reference point, with a default value of epoint; ordref is the reference order

February 2006 - 16 - Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

number, with a default value of 1; curve controls the curve display, with a default
value of 'on', can be 'off'.
If you compare the parameters of cds_ip3 with the parameters in the DirectPlot
results of Action 4-14, you find that they are exactly the same.
Here you could get an input referred IP3 value of -7.7245 and the IP3 curve shown
below. To get the output IP3, use a command like [in, out] = cds_ipn(…).

Action 4-14: Close the figure window, return to ADE, and continue with the LNA Workshop.

Lab 5: IP3 Measurement---QPSS Analysis with Shooting or


Flexible Balance Engine

Action 5-0: Follow the instructions in the LNA workshop to complete Action 5-1 to Action 5-21.
Action 5-22: Go to the MATLAB console. Run the following commands:
resdir = ‘simulation/Diff_LNA_test/spectre/schematic/psf’;
rfout_qpss = cds_srr(resdir, 'qpss-fi.qpss', 'RFout')
[in out] = cds_ipn(rfout_qpss, [2 -1], [0 1], -40)

These commands use the QPSS data to calculate IP3. For guidance on using the
cds_ipn command, see Lab 4.
Because RFout_qpss is QPSS frequency domain data, it has fields that are used to
store harmonic information. The harmUnit_info field contains the names of the
harm index of each fund name. In this workshop, the names are RF_harm_index

February 2006 - 17 - Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

and RF2_harm_index. These two strings are also field names of RFout_qpss.
RF_harm_index lists all the harmonics of fund RF in the results.
RF2_harm_index lists all the harmonics of fund RF2. The lengths of the
RF_harm_index and RF2_harm_index vectors are the same as the length of the
freq vector. You can use the cds_harmonic command to deal with them. If you
want harmonic [2, -1], for example, you can use the command h3 =
cds_harmonic(RFout_qpss, [2 -1]).
In this case the input referred IP3 point is -7.8104, when the output referred IP3 is
7.5078. The curve of IP3 is shown in the figure (for flexible balance results).

Action 5-23: Close the figure window, return to ADE, and continue with the LNA Workshop.

Lab 6: IP3 Measurement---Rapid IP3 using AC analysis

Action 6-0: Follow the instructions in the LNA workshop to complete Action 6-1 to Action 6-10.
Action 6-11: Go to the MATLAB console. Run the following commands:
resdir = ‘simulation/Diff_LNA_test/spectre/schematic/psf’;
[in out] = cds_rapidip3(resdir, 'ac-ip3')

For Rapid IP3 measurements in AC analysis and PAC analysis, the results data
include the single point output power. So the parameters of cds_rapidip3 are the
results directory and the name of the dataset. The return values are the same as with

February 2006 - 18 - Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

cds_ipn. The first value is the input referred IP3 point and the second value is the
output referred IP3 point.
In this case, the input referred IP3 point is -7.8018 when the output referred IP3 is
7.5171. The curve of IP3 is shown in the figure.

Action 6-12: Close the figure window, return to ADE, and continue with the LNA Workshop.

Lab 7: IP3 Measurement ---Rapid IP3 using PSS Plus PAC


Analysis

Action 7-0: Follow the instructions in the LNA workshop to complete Action 7-1 to Action 7-12.
Action 7-13: Go to the MATLAB console. Run the commands:
resdir = ‘simulation/Diff_LNA_test/spectre/schematic/psf’;
[in out] = cds_rapidip3(resdir, 'pac-ip3')

The cds_rapidip3 command here is almost the same as in Lab 6. The only
difference is that because you used a pac analyses, you use the pac-ip3 dataset.
In this case, the input referred IP3 point is -7.8076, when the output referred IP3
point is 7.5153. The IP3 curve is shown in the figure.

February 2006 - 19 - Product Version 6.1


SpectreRF MATLAB Toolbox Workshop

Action 7-14: Close the figure window, return to ADE, and continue with the LNA Workshop.

Conclusion
This application note discusses how to use the SpectreRF MATLAB toolbox to do RF
measurements. During the course of the workshop, you replayed the LNA design workshop with
MATLAB. Some useful toolbox commands such as cds_srr, cds_evalsig, and
cds_harmonic are discussed. All of these measurements are implemented as MATLAB scripts,
so with these examples you could write your own measurements.

Reference
[1] SpectreRF Workshop--LNA Design Using SpectreRF, MMSIM6.0USR2
[2] SpectreRF MATLAB Toolbox Application Notes.

February 2006 - 20 - Product Version 6.1

You might also like