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

A


Learning More about the Cosimulation Interface

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.

The following topics provide additional information about the AMS-MATLAB/Simulink cosimulation interface:

Using Framed and Unframed Signals

Simulink provides different testbenches for framed and unframed data.

To open the tb_sine configuration, do the following in the CIW:

  1. Choose File – Open.
    The File Open form appears.
  2. In the File group box, select the following:
    Field Selection

    Library

    AMSDcouple

    Cell

    tb_sine

    View

    config

  3. Click OK.
    The Open Configuration form appears.
  4. In the Open for editing group box, selet yes for both Configuration and Top Cell View.
  5. Click OK.
    The configuration appears in the Viruoso® Hierarchy Editor. The schematic appears in the schematic editor.
To run the AMSD MATLAB cosimulation, ensure that the config view for AMS simulation is saved and its hierarchy is updated.

Ensure the following:

To start the AMS Designer simulation, do the following in the Hierarchy Editor:

  1. Choose Plugins – AMS.
    AMS appears on the menu banner. You must initialize a run directory before you can access any of the AMS menu selections.
  2. Choose AMS – Initialize.
  3. Fill out the form and click OK.
  4. Choose AMS – Netlist and Run Options.
  5. (Optional) On the Netlist and Run Options form, click Save/Plot to select signals to plot.
    Ensure that AMS Unified Netlister with xrun (recommended) is selected on this form.
  6. Click Run.

Using the Sine Testbench with Unframed Coupling

To open the Sine Testbench (unframed signals) from the Simulink library, do the following:

  1. In the MATLAB Command Window, type the following command to open the library:
    open SimCouplerLib.mdl 

  2. Double-click Sine Testbench (unframed signals).
  3. In the testbench schematic window, double-click the SimulinkCoupler to view its parameters.
    This SimulinkCoupler supports event-driven simulation and fixed-rate synchronization.

For event-based simulation:

For fixed-rate synchronization:

  1. Specify a Sample time of 10e-6 to sample the signal at 100 kHz.
    This value satisfies the sampling theorem since the highest sine frequency is 20 kHz.
  2. Choose Simulation – Start to start the Simulink simulation.
  3. Start the AMS Designer/xmsim simulation (click Run on the Netlist and Run form).
    You do not need to make any changes on the AMS Designer side.
    You will notice that this simulation runs faster.
  4. You can view the sampled signals in SimVision and Simulink.
  5. You can run this simulation using reduced values for Sample time (down to 1e-6) for more accurate sampling.

Using the Sine Testbench with Framed Coupling

Some telecommunication simulations work with a data-stream-driven simulation. Some DSP algorithms process a data frame instead of single samples. Simulink provides framed signals for this purpose. To increase the simulation performance, cosimulation also supports framed signals. To investigate framed signals, do the following:

  1. In the Library: SimCouplerLib window, double-click Sine Testbench (framed signals).
  2. In the testbench schematic window, double-click the SimulinkCoupler to view its parameters.
    1. You can specify the number of input and output ports.
    2. If you turn on Show advanced options, you can also specify the socket port.
    3. Notice that the Frame mode is framed.
    4. Simulink determines the frame length from the connected input signals.
  3. If you simulated the unframed example before, rerun the simulator and view the signals in Simulink.
  4. In the Frame size field, type 10.
  5. Rerun the AMS Designer simulator.
    The result is the same. The simulation takes a bit more time.
    You can explore several different frame sizes. The maximum valid frame length is 10000.

Running Event-Based and Fixed-Rate Simulation

Fixed-rate synchronization can be useful if the model contains signals with different sampling rates (high and low) and the interface connects only to a low sampling rate block. If the signals exchanged between AMS Designer and Simulink are at the lower rates, fixed-rate synchronization with a dedicated sample time can improve the simulation performance significantly. Here is an example:

  1. In the Library: SimCouplerLib window, double-click Testbench for event as compared to fixed rate synchronization.
    • The sine wave generator (Sine Wave) produces a 2 KHz sine wave sampled at 10 us. Simulink transmits the sine wave signal to the AMS Designer simulator.
    • The pulse generator (Pulse Generator) produces a high-frequency pulse with a period of 100 ns (which is 100 times faster than the sampling rate of the sine wave).
  2. In the Virtuoso® 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_event_fixed

    View

    config

  4. On the Open Configuration form, select yes for Top Cell View to open the schematic.
  5. Click OK.
    The Adder component adds the two signals from Simulink.
  6. To start the simulation in event-based mode, do the following:
    1. Double-click the coupler module on the Simulink schematic.
    2. Verify that the Sample time is -1 to turn on the event-based mode.
    3. Click OK to close the form.
    4. Choose Simulation – Start.
  7. In SimVision, display Signal_1, Signal_2, and Sum.
  8. Start the AMS Designer simulation.
    The simulation takes about 30 seconds. The sine waves appear in Simulink and in SimVision. You can mark the computed data points.
  9. After finishing the run, go back to Simulink and change the sync mode in the coupler module to fixed rate with a sample time of 0.00001 (equal to the sampling rate of the sine source).
  10. Run the Simulink simulation again.
  11. Go back to SimVision and restart the simulator.
  12. Start the AMS Designer simulation.
    The simulation finishes after about 5 seconds. The high-frequency pulse no longer influences data exchange between the simulators.

You can resimulate this example using different sample times.

In other examples where the sampling rate changes over time, the event-based synchronization might be the better choice. Decide carefully what synchronization scheme fits best with your design.

If you look at the computed signal points in the SimVision waveform plot, you will see that the values are not necessarily updated at equidistant points even if you choose fixed-rate in the Simulink coupler. AMS Designer's analog solver controls the timing of these data points and can introduce more simulation points if necessary between two synchronization points.

Using the Coupler Module in Feedback Loops

You can use coupling in feedback loops. In this example testbench (tb_sine_loop), Simulink generates two sine waves and transmits them to AMS Designer and AMS Designer feeds one of the signals back to Simulink. The second signal is unused.

Simulink compares the feed-through sine wave with the original signal. The coupler has additional input and output pins and there is another feedback loop inside AMS Designer. Simulink adds a constant of 0.1 to the coupler output and the signal connects to the third coupler input. After each cycle, Simulink increases the signal by 0.1. You can observe this behavior in the Simulink or in the AMS Designer window. At the beginning of simulation, the program initializes the signal to zero.

To open the Virtuoso® schematic, do the following:

  1. In the command interpreter window (CIW), choose File – Open.
    The File Open form appears.
  2. In the File group box, select the following:
    Field Selection

    Library

    AMSDcouple

    Cell

    tb_sine_loop

    View

    config

  3. On the Open Configuration form, select yes for Configuration and for Top Cell View.
  4. Click OK.
  5. In the Virtuoso® Hierarchy Editor, choose Plugins – AMS.
  6. Once you have initialized the run directory for AMS, choose AMS – Netlist and Run and click Run.
  7. In SimVision, display the Loop signal.

You can decide whether to use the Loop Testbench with unframed or framed signals in Simulink:

Using the Loop Testbench with Unframed Coupling

To use the loop testbench with unframed coupling, do the following:

  1. In the Library: SimCouplerLib window, double-click Loop Testbench (unframed signals).
  2. On the testbench schematic, double-click SimulinkCoupler to review its parameters.
  3. Choose Simulation – Start.
  4. Start the AMS Designer simulation.
  5. After each cycle, increase the signal by 0.1.
    A ramp appears in the plot windows. The two sine waves match.
  6. Switch the coupling block to fixed port rate and view the changes on the ramp and the two sine waves.

Using the Loop Testbench with Framed Coupling

To use the loop testbench with framed coupling, do the following:

  1. In the Library: SimCouplerLib window, double-click Loop Testbench (framed signals).
  2. On the testbench schematic, double-click SimulinkCoupler to review its parameters.
  3. Choose Simulation – Start.
  4. Start the AMS Designer simulation.
    The signal increases once for each frame.
    The signal values are equal within each frame.
    The signal has steps, depending on the frame size.
    The frame size in the feedback loop path equals the frame size of the sine waves (defined in the buffer blocks).
  5. Change the frame size and view the changes in the results.
You must handle feedback loops in cosimulation carefully. In this example, you can see that the behavior of feedback signals can vary depending on different simulation settings. Review your design carefully around possible loops and decide how to integrate the loops in the cosimulation. With the default settings, Simulink displays a warning:
Warning: Block diagram 'loop_tb' contains 1 algebraic loop(s). 

For more information about loops, use type the following command in the MATLAB Command Window:

sldebug loop_tb 

The Simulink debugger command-line prompt appears:

(sldebug @0): >> 

To eliminate the warning message, do the following:

  1. In the Simulink testbench window, choose Simulation – Configuration Parameters.
    The Configuration Parameters form appears.
  2. In the Select tree, select Diagnostics.
  3. In the Algebraic loop field, select none.
  4. Click OK.

Running AMS-MATLAB/Simulink Cosimulation on Other Platforms

You can run AMS-MATLAB/Simulink cosimulation on Linux, Solaris, HP, IBM, and Windows platforms. If you are running cosimulation from MATLAB under Windows, you must add the path to the coupler in the Cadence® IUS installation hierarchy in MATLAB using the addpath command. For example:

addpath('/grid/cadence/install/ius57/lnx86/tools/affirma_ams/etc/matlab'); 
addpath('/home/cadence/tutorial/AMS-MATLAB/matlab');
addpath('/home/cadence/tutorial/AMS-MATLAB/matlab/tutorial');


Return to top
 ⠀
X