Product Documentation
Spectre AMS Designer Cosimulation with MathWorks MATLAB/Simulink
Product Version IC23.1, June 2023

1


AMS-MATLAB/Simulink Cosimulation

AMS-MATLAB/Simulink cosimulation stands for cosimulation using the Spectre AMS Designer simulator and The MathWorks MATLAB®/Simulink®. ADE stands for the Virtuoso Analog Design Environment.
Use IC 6.1.3, IUS 8.1 or later, and MATLAB704R14 or MATLAB R2007b or MATLAB R2008a for this tutorial. The estimated time to complete this tutorial is about one hour.

See the following topics for tutorial details:

Introducing AMS-MATLAB/Simulink Cosimulation

Concept engineering and system-level simulation tools such as MATLAB®/Simulink® support the specification of high-level system concepts in the early stages of a design.

The picture above shows the top-level schematic for the system-level model of a wireless LAN (the IEEE 802.11a demo). The transmitter blocks encode and modulate binary random data and send the orthogonal frequency-division multiplexing (OFDM) signal to a white Gaussian noise channel model. The receiver blocks demodulate and decode the channel output. Finally, the system compares the received bits with the original bit stream to compute the bit error rate.

The tutorial database libraries include the IEEE 802.11a demo designs.

The standard compatible system-level model of the wireless LAN link comprises standard Simulink library modules. You can use this system-level model as the golden reference for the implementation of the system components.

Using cosimulation with the Spectre AMS Designer simulator and The MathWorks MATLAB®/Simulink® (AMS-MATLAB/Simulink cosimulation), you can include the design and simulation of analog and mixed-signal subsystems in your system-level simulation. You can take into account the effects originating from the analog RF parts of the transmitter and receiver.

The RF circuit in this example uses a complex base-band modeling approach. AMS-MATLAB/Simulink cosimulation supports all kinds of circuits, including base-band designs.

You can design your analog and mixed-signal subsystems using Cadence® Virtuoso® software. You can simulate these designs using the Virtuoso Spectre RF and AMS Designer circuit simulators.

The picture below shows the RF transmitter module design for this tutorial consisting of filters, an up-converting mixer, and an amplifier. For faster simulation time, we modeled the complex base-band domain of the RF components using the Verilog®-A modeling language. You can use this same approach to perform equivalent behavioral pass-band and transistor-level simulations.

When measuring the RF subsystem characteristics (such as intercept points, noise figure, and corner frequencies), you might think you can use only simple one- and two-tone sinusoidal sources as stimuli. Using AMS-MATLAB/Simulink cosimulation, you can use more realistic stimuli such as modulated signals. You can also achieve the corresponding post-processing required for system performance evaluation.

AMS-MATLAB/Simulink cosimulation combines the best of system-level simulation with analog and RF simulation. Simulink provides large libraries of DSP algorithms for generating complicated signals and for post-processing. Virtuoso® software provides an optimal design environment for analog/RF and mixed-signal subsystems. The Spectre AMS Designer and Xcelium Mixed-Signal simulator is a powerful single-kernel, mixed-signal simulator for transistor-level circuits and all common behavioral languages.

Understanding the Different Cosimulation Flows

AMS-MATLAB/Simulink cosimulation supports different flows that support different groups of users:

Flow Description

ADE Flow

Run cosimulation by starting MATLAB/Simulink from the Virtuoso® Analog Design Environment (ADE)

This flow is for users who are familiar with ADE.

See

Simulink Flow

Run the cosimulation from MATLAB/Simulink (without starting ADE) using the runSimulation script that comes from the ADE flow

This flow is for users who do not need to use the Virtuoso Studio Design Environment or who need to debug in the Simulink environment.

See “Running Cosimulation from MATLAB/Simulink”.

AMS Environment Flow

Start MATLAB first, then start the AMS environment from the Virtuoso hierarchy editor (HED), and run simulations separately using each of these programs

You can use this same flow from ADE, but this tutorial will cover only the flow from the AMS environment (HED).

See “Running Cosimulation from the Spectre AMS Designer Environment”.

Setting Up the AMS-MATLAB/Simulink Cosimulation Example

To set up the example files, do the following in a terminal window:

  1. Make and change to a directory for the example:
    mkdir amsTutorials 
    cd amsTutorials 
  2. Copy the migration example files to this directory:
    cp -r $CDSHOME/tools/dfII/samples/tutorials/AMS/MATLABCosimulation.tar.gz . 
  3. Decompress the archive file:
    gunzip MATLABCosimulation.tar.gz 
    tar xf MATLABCosimulation.tar 
  4. Change to the following directory:
    cd MATLABCosimulation 
  5. Source the setup file:
    source SETUP 
    The SETUP file sets the MATLABPATH and TUT_DIR environment variables.

This tutorial demonstrates cosimulation using the IEEE 802.11a demo that appears in “Introducing AMS-MATLAB/Simulink Cosimulation”. To set up the cosimulation, do the following:

  1. Verify that the standalone simulations run successfully in MATLAB/Simulink and AMS Designer.
  2. Place and configure the coupler module on the Simulink schematic.
    See “Adding the Simulink Coupler Module to the Testbench”.
  3. Place and configure the corresponding coupler module on the ADE schematic.
    See “Placing the coupler_2_3_a Instance on the Schematic”.

You are ready to run cosimulation using each of the three flows outlined in “Understanding the Different Cosimulation Flows”.

Modifying the Simulink Model

To modify the Simulink model, do the following:

  1. Start MATLAB software:
    matlab & 
  2. In the MATLAB Command Window, type the following command to open the library containing the coupler module and other examples:
    open SimCouplerLib.mdl 

    1. To open an example, double-click its blue symbol.
    2. To insert the coupler module, drag-and-drop the Coupler Module from the AMS Designer – Simulink Cosimulation Library.
      If you are using MATLAB version R13 (instead of R14), you must open the SimCouplerLib_r13 at this point by double-clicking the yellow box. While the coupling technology is equivalent in both MATLAB releases, the MATLAB demo and the standard Simulink libraries are slightly different. R14 designs are not backward compatible with R13.
  3. Double-click Step 1 (leftmost green box) to open the end-to-end design for a wireless LAN transmission system.
    See the picture in “Introducing AMS-MATLAB/Simulink Cosimulation”.
  4. Choose Simulation – Start.
    A spectrum scope and scatter diagram appear.
    The minor deviations in the scatter diagram originated from the noisy channel.
    In the testbench window, the bit error rate information appears at the output of the Error Rate Calculation block.
  5. Observe that the bit error rate is zero.

Increasing the Noise for the AWGN Channel

To increase the noise for the AWGN channel, do the following:

  1. In the testbench window, double-click the AWGN block.
    The Function Block Parameters form appears.
  2. In the SNR (dB) field, change the signal-to-noise ratio from 20 to 13.
  3. Click Apply.
  4. Choose Simulation – Start to start the simulation again.
    The final plots look like this:
    The scatter diagram shows some distortion. After some seconds, bit errors do occur.
  5. Change the SNR back to 20.

Adding the Simulink Coupler Module to the Testbench

To add the Simulink coupler module to the testbench, do the following:

  1. Drag-and-drop the SimulinkCoupler block from the Library window (see “Modifying the Simulink Model”) to the testbench window (see above for placement position).
    We place the coupler block between the OFDM Transmitter and the AWGN block to include the analog transmitter RF front end in this system testbench.
  2. Double-click the SimulinkCoupler block.
    The Function Block Parameters window appears.
  3. In the Number of input pins field, type 3.
    While the third input pin is not necessary in this case, it illustrates how signals flow and how we will create the coupler in the Virtuoso® design environment.
  4. In the Number of output pins field, type 2.
  5. In the Frame mode field, select framed.
  6. Click OK.
    The SimulinkCoupler block has the correct number of pins.
    You can resize the SimulinkCoupler block so that it fits better with the signal lines.
  7. (Optional) To view details about the framed signals, choose Format – Port/Signal Displays – Signal Dimensions in the testbench window.
    Signal dimensions appear on the schematic.
    Later sections contain descriptions of other SimulinkCoupler parameters.

Converting Complex Signals to Real and Imaginary Parts

The signals in this example are complex-valued signals. Before simulating with AMS Designer, you must split these complex signals into their real and imaginary parts. The Simulink library contains the converters we need for this purpose.

  1. In the testbench window, choose View – Simulink Library.
    The Library window appears.
  2. Double-click Math Operations.
    The math operator and conversion blocks appear.
    The conversions we want for this tutorial appear in the bottom right corner.
  3. Drag-and-drop the Complex to Real-Imag block from the Library window to the testbench window and place it on the left side of the SimulinkCoupler block.
  4. Drag-and-drop the Real-Imag to Complex block from the Library window to the testbench window and place it on the right side of the SimulinkCoupler block.
  5. Rewire the testbench schematic to accomodate the new blocks.

Inserting an Ideal Gain Block in the Testbench Schematic

Because the analog/RF subsystem will eventually change the signal level, we will insert an ideal gain block at the output of the coupler block so that we can adapt the signal level properties of the digital base-band receiver.

  1. In the testbench window, choose View – Simulink Library.
    The Library window appears.
  2. Double-click Math Operations.
    The math operator and conversion blocks appear.
  3. Drag-and-drop the Gain block from the Library window to the testbench window and place it near the output of the SimulinkCoupler block.
  4. To rotate the block, right-click and choose Format – Rotate Block.
    See the picture in “Adding the Simulink Coupler Module to the Testbench”.
  5. Double-click the Gain block.
    The Function Block Parameters form appears.
  6. In the Gain field, type 0.04.
  7. Click OK.
  8. Rewire the testbench schematic to accomodate the Gain block.

Rewiring the Testbench Schematic

If you do not want to rewire the testbench schematic, you can double-click Step 2 (tutorial2r14.mdl, the green box on the right) instead. See the picture in “Modifying the Simulink Model”.

You can rewire the design as follows:

  1. Right-click the wire you want to remove and select Cut.
    For example, you will cut the wire between the OFDM Transmitter and AWGN blocks to fit the SimulinkCoupler block, and you will cut the wire between the AWGN and Simulation off down sampling action blocks to fit the Gain block.
  2. Hover the mouse pointer over the module pin you want to connect until it changes to a cross.
  3. Click-and-drag from the beginning connection point to the destination connection point and release the mouse button.
    You can connect the blocks quickly by clicking the first block, then holding down the Ctrl key while clicking the second one.

Once you rewire the testbench schematic, it should look like the picture in “Adding the Simulink Coupler Module to the Testbench”. Using two Spectrum Scope blocks—one before and one after the SimulinkCoupler block—we can compare the before and after signals.

To add the second Spectrum Scope block before the SimulinkCoupler block, do the following:

  1. Right-click Spectrum Scope1 and select Copy.
  2. Right-click near where you want to place the second one and select Paste.
  3. To flip the block so that the port is on the left, right-click it and choose Format – Flip Block.
  4. Hover the mouse pointer over the port until it changes to a cross.
  5. Click-and-drag to connect it to the output of the OFDM Transmitter block.

The Simulink model is ready for cosimulation. The Simulink model automatically detects information about the frame size and sampling time.

Setting the Simulink Stop Time

To set the stop time of the Simulink simulation, do the following:

  1. In the testbench window, choose Simulation – Configuration Parameters.
    The Configuration Parameters form appears.
  2. In the Stop time field, type 1000e-6 (to match the 1m stop time in the ADE setup later).
  3. Click OK.

Opening the Virtuoso Schematic

To open the schematic for this tutorial, do the following:

  1. Start the Virtuoso® software:
    virtuoso & 
  2. In the command interpreter window (CIW), choose File – Open.
    The File Open form appears.
  3. In the File group box, select the following:
    Field Selection

    Library

    AMSDcouple

    Cell

    tb_ieee_802_11a_demo_template

    View

    config

  4. Click OK.
    The Open Configuration form appears.
  5. Click OK.
    The RF Transmitter System Testbench schematic appears.
    The schematic contains
    • A driver module to scale the coupler output
    • The RF transmitter model
    • A simple line termination using resistors

    The pieces that the MATLAB/Simulink design provides are
    • A signal source for an 802.11a system
    • The related post-processing algorithms
The AMSDcouple library contains additional examples—such as tb_sine, tb_sine100, and tb_event_fixed. These examples have corresponding designs in MATLAB/Simulink. You can use these examples to explore cosimulation. See also Appendix A, “Learning More about the Cosimulation Interface.”

Creating the Coupler in the Schematic Window

You can create a coupler in the schematic window using either of two methods. The first method is the one we recommend.

How you perform cosimulation depends on which method you use.

Creating a Coupler Using the Fixed-Cell Method

The following steps show you how to create a fixed coupler with two inputs and three outputs. Because we have already created such a fixed coupler (coupler_2_3_a) and made it available in the AMSDcoupler library, so you need not perform these steps.

To create a coupler using the fixed-cell method, do the following:

  1. In the schematic window, choose Launch – Mixed Signal Options – AMS.
    AMS appears on the menu banner.
  2. Choose AMS – Simulink® Coupler Creation.
    The Simulink® Fixed Cell Coupler Creation form appears.
  3. In the Number of input pins field, type 2.
  4. In the Number of output pins field, type 3.
  5. Click Generate Fixed Coupler.
    The software creates a coupler with two inputs and three outputs with the name coupler_2_3_a.
  6. Click Close.

Creating a Coupler Using the simulinkCoupler Method

The simulinkCoupler is a parameterized cell (Pcell) that does not have a fixed number of pins: You can change the number of pins to fit different designs. To select, configure, and place a simulinkCoupler instance, do the following:

  1. In the schematic window, type i to open the Add Instance form.
  2. Click Browse to open the Library Browser.
  3. In the Library column, select analogLib.
  4. In the Cell column, scroll down and select simulinkCoupler.
  5. On the Add Instance form, change the number of input pins and the number of output pins to whatever you need.
  6. In the schematic window, click to place the simulinkCoupler instance.
  7. Choose File – Check and Save.

Placing the coupler_2_3_a Instance on the Schematic

You can skip this section if you choose to open the finished schematic that we ship with this tutorial: AMSDcoupler/tb_ieee_802_11a_demo/schematic.

To place the coupler_2_3_a instance on the schematic, do the following:

  1. In the schematic window, choose Create – Instance (or type i).
    The Add Instance form appears.
  2. Click Browse.
  3. In the Library Browser window that appears, select the following:

    Library

    AMSDcouple

    Cell

    coupler_2_3_a

    View

    symbol


    This library/cell/view appears in the appropriate fields on the Add Instance form.
  4. Move your mouse cursor over the WLAN Signal block on the schematic and click to place the coupler instance to the left of the driver instance.
  5. Press Esc.
  6. Wire up the instance according to the following picture (or you can open the finished schematic that we provide: AMSDcoupler/tb_ieee_802_11a_demo/schematic).
    The bottom right pin on the coupler instance connects to a pin whose name is out and whose direction is output.
  7. Choose File – Check and Save.

You can view object properties for the coupler instance by doing the following:

  1. Select the coupler instance.
  2. Choose Edit – Properties – Objects (or type q).
    The Edit Object Properties form appears.
  3. When you are finished viewing the object properties for the coupler, click Cancel.

Viewing the Entire AMS-MATLAB/Simulink Signal Flow

The following diagram shows the entire signal flow through the MATLAB®/Simulink® and Cadence® Virtuoso® environments.

Each sink (coupler input pin) acts as a signal source (output pin) in the other environment. The signal flows into the three input pins on the Simulink schematic, out the three output pins on the Virtuoso schematic, out the two output pins on the Simulink schematic, and through the rest of the design on the Simulink schematic.

Exiting MATLAB

To exit MATLAB, do the following:


Return to top
 ⠀
X