当前位置:文档之家› SpectreRF_simulink_example

SpectreRF_simulink_example

Co-Simulation with SpectreRF MATLAB/ Simulink Tutorial

Product Version 6.1.1

November 2006

2006 Cadence Design Systems, Inc. All rights reserved.

Printed in the United States of America.

Cadence Design Systems, Inc., 555 River Oaks Parkway, San Jose, CA 95134, USA

Trademarks:Trademarks and service marks of Cadence Design Systems, Inc. (Cadence) contained in this document are attributed to Cadence with the appropriate symbol.For queries regarding Cadence’s trademarks, contact the corporate legal department at the address shown above or call 800.862.4522.

All other trademarks are the property of their respective holders.

Restricted Print Permission:This publication is protected by copyright and any unauthorized use of this publication may violate copyright,trademark,and other laws.Except as speci?ed in this permission statement, this publication may not be copied, reproduced, modi?ed, published, uploaded, posted, transmitted, or distributed in any way,without prior written permission from Cadence.This statement grants you permission to print one (1) hard copy of this publication subject to the following conditions:

1.The publication may be used solely for personal, informational, and noncommercial purposes;

2.The publication may not be modi?ed in any way;

3.Any copy of the publication or portion thereof must include all original copyright, trademark, and other

proprietary notices and this permission statement; and

4.Cadence reserves the right to revoke this authorization at any time, and any such use shall be

discontinued immediately upon written notice from Cadence.

Disclaimer: Information in this publication is subject to change without notice and does not represent a commitment on the part of Cadence. The information contained herein is the proprietary and con?dential information of Cadence or its licensors,and is supplied subject to,and may be used only by Cadence’s customer in accordance with, a written agreement between Cadence and its customer. Except as may be explicitly set forth in such agreement, Cadence does not make, and expressly disclaims, any representations or warranties as to the completeness, accuracy or usefulness of the information contained in this document. Cadence does not warrant that use of such information will not infringe any third party rights, nor does Cadence assume any liability for damages or costs of any kind that may result from use of such information.

Restricted Rights:Use,duplication,or disclosure by the Government is subject to restrictions as set forth in FAR52.227-14 and DFAR252.227-7013 et seq. or its successor.

Contents

Cosimulation with SpectreRF MATLAB?/Simulink T utorial . . .5 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 T utorial 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..5 Preparing the Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 Validating the Simulink Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 Modifying the Design and Setting Up the cosimulation . . . . . . . . . . . . . . . . . . . . . . .10 For ADE Users. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 For Users of Standalone SpectreRF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Cosimulation with SpectreRF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 T utorial 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 First Use Mode (for Users of ADE). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 Viewing the Netlist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26 Running the Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 Second Use Mode (for ADE and Standalone Users). . . . . . . . . . . . . . . . . . . . . . . . .31 Q&A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33

Cosimulation with SpectreRF MATLAB?/ Simulink Tutorial

Introduction

The high level system concept is often speci?ed in the early stages of design work. This process is well supported by both concept engineering and system-level simulation tools such as MA TLAB?/Simulink?.

Cosimulation using SpectreRF and MA TLAB/Simulink combines the best of system-level simulation with lower-level analog and RF simulation.Simulink provides large libraries of DSP algorithms for generating complicated signals and post processing while SpectreRF supports transient and envelope analysis of common RF and communication circuits,such as mixers, oscillators, sample and holds, and switched capacitor ?lters at both the transistor and behavioral levels.

T o run the tutorials described here, Cadence recommends using software versions MMSIM6.1 USR1 or later, and MA TLAB R14 or later, with Simulink? and the signal process blockset installed.

It takes about an hour to run through the two tutorials described in this document. Tutorial 1

T utorial 1 describes cosimulation for the system-level module of a wireless LAN.Figure1-1 on page6 shows the system-level schematic. The transmitter blocks encode and modulate binary random data and send the OFDM signal to a white Gaussian noise channel model.

The receiver blocks demodulate and decode the channel output.Finally,the received bits are compared with the original bit stream to compute the bit error rate.

Figure 1-1 End-To-End System-Level Simulation with Simulink

The designs for the tutorial are provided in the tutorial database libraries.Assuming that the standalone simulations work correctly in MA TLAB/Simulink and SpectreRF,only three steps are required to set up the cosimulation:

1.Insert and con?gure the SpectreRF Engine in the Simulink schematic.

2.Setup the netlist to adopt the SpectreRF and MA TLAB cosimulation.

3.Run the cosimulation.

The steps are described in detail in the following sections.

Preparing the Environment

1.Copy the ?le

`cds_root spectre`/tools/spectre/examples/SpectreRF_workshop/

SpectreRF_simulink_example.tar.Z

to your directory.

The`cds_root spectre` command in one way to determine where the Spectre simulator is installed.If you already know the path to the Spectre hierarchy,you can just substitute it into path given above.

2.Unpack the ?le with

zcat SpectreRF_simulink_example.tar.Z | tar xvf -

3.In the working directory of the cosimulation package, type

cd SpectreRF_simulink_example

This is the best place to start MA TLAB, because the cosimulation modules load

automatically here in accordance with the statements provided in the startup.m ?le.

4.Add the SpectreRF and MA TLAB/Simulink engine install paths to the MATLABPATH

environment variable. Y ou can automate this step by adding the appropriate command to your.cshrc ?le. For example, if you are using a C shell, you can add the command setenv MATLABPATH `cds_root spectre`/tools/spectre/simulink:${MATLABPATH}

Validating the Simulink Design

1.Start MA TLAB, by typing

matlab &

The spectrerf_demo library opens.

Figure 1-2 Simulink Library for cosimulation

2.This library contains the SpectreRF engine block module for this tutorial (distinguished

by the Cadence logo and labeled SpectreRF Engine).Y ou can insert the coupler module in any Simulink design by dragging and dropping it from this library.

3.Double-click the ?rst green box labeled LAN 802.11 T utorial1.

The tutorial1 library opens.

Figure 1-3 Library Including Modi?ed and Unmodi?ed Models

4.Double-click the unmodified block.

The end-to-end design for a wireless LAN transmission system opens (see Figure1-1 on page6). This design contains the main DSP algorithms of a wireless LAN 802.11a physical layer for the transmitter and the receiver chains. It generates a standard-compliant 802.11a signal and implements the related post-processing algorithms.

5.In the window displaying the LAN transmission system schematic of Figure1-1 on

page6, click Simulation — Start.

A spectrum scope and a scatter diagram come up. The minor deviations in the scatter

diagram originate from the noisy channel. Look at the bit error rate (BER) display. The BER is zero.

6.(Optional) Double-click the AWGN block and increase the noise by changing the

parameter signal to noise ratio SNR (dB) to 13. Click Simulation — Start to start the

simulation again.The scatter diagram is now distorted and after some seconds bit errors do occur. The ?nal plots from the unmodi?ed testbench look like Figure1-4 on page9. Figure 1-4 Result from Unmodi?ed Testbench

Modifying the Design and Setting Up the cosimulation

The following steps set up the cosimulation.There is a complete setup in T utorial demo that can be used as a reference.

1.Drag and drop the SpectreRF Engine block(the block that contains the Cadence logo,

located on top of the green boxes)into the testbench and place the block at the top right corner.

This step inserts the analog transmitter RF-front end within the system testbench

between the OFDM Transmitter and AWGN channel.

2.Double-click the SpectreRF Engine block.

The Function Block Parameters window opens.

Figure 1-5 Function Block Parameters Window

The ?elds have the following meanings:

Field Meaning

Number of input pins The number of input pins to the engine block

(0…100). The input to the block is the input signal

from Simulink.

Number of output pins The number of output pins from the engine block

(0…100). The output from the block is the resulting

signal from the SpectreRF simulator.

Frame size The number of samples per frame (any positive

integer or-1;default:-1).Set this value to-1to inherit

the frame size from the input.

Sample time Sample period of the block, in seconds (default: -1).

The Sample time is the frame period, not the time

between the samples inside the frame.Set this value

to -1 to inherit the sample period of the connected

blocks.

Socket port The number of the service that is identi?ed by TCP/

IP. Normally, the system reverses port numbers less

than 1024, so this value can range from 1024 to

65535 (default: 38520).

Simulation response timeout Maximum time, in seconds, to wait for an answer

from the SpectreRF simulator during simulation.

During simulation, if MA TLAB does not receive a

response from Spectre before the timeout period

expires, simulation ends with an error.

Socket mode TCP or UDP. Choose UDP if frame size is less 50.

TCP and UDP are two different translate protocols in

TCP/IP.Without CRC,UDP is usually faster in a good

net environment with small data packages and TCP

is usually better for large data packages.

Spectre command Used to run a Spectre simulation. This parameter

enables a use mode where Spectre is called

internally by the Simulink simulation.

Show engine port labels If checked, the SpectreRF Engine shows the label

information.

3.Set the Frame mode ?eld to -1 to use an inherited frame size.

This Simulink testbench uses framed signals.

4.Set the parameter Socket port to any value from 1024 to 6553

5.

5.Click OK.

The form closes and the SpectreRF Engine block is updated with the correct number of pins.

6.In the testbench window, select Format — Port/Signal Displays — Signal

Dimensions.

The signal dimension display is switched on so you can see details of the framed signals used.In this case the frame size between OFDM Transmitter with oversampling and AWGN is 320.

7.Select View — Simulink library to display the library browser. Double-click Math

Operations.

The library appears. The tutorial uses complex valued signals. Before the signal is

transmitted to SpectreRF the complex signals must be split into their real and imaginary parts.Simulink provides a converter for this purpose.The desired converters are located at the bottom right corner in this library.

8.Drag and drop the Complex to Real-Imag block before the SpectreRF Engine

block and drag and drop the Real-Imag to Complex block after the SpectreRF Engine block in the schematic.

9.Insert an ideal gain block at the output of the coupler block.The gain block is in the Math

Operations library.

Because the analog/RF subsystem changes the signal level, the gain block is required to adapt the signal level to the properties of the digital base-band receiver.

10.Double-click the placed Gain block and set the Gain to 0.04.

11.Delete the wire between the OFDM T ransmitter and the AWGN channel,by right clicking

on the wire and choosing cut.

12.Connect the signals as shown in Figure1-6 on page13.

T o make each signal connection, move the mouse pointer over the module pin. The pointer changes to a cross. Press the left mouse button, move the cursor to the

destination pin and release the button.

Figure 1-6 Testbench with Additional Modules for cosimulation

The Simulink model is ready for cosimulation.All other information about frame size and sampling time is detected automatically within the Simulink model.

13.Choose Simulation — Configuration Parameters.

The Con?guration Parameters form opens.

14.In the Stop time ?eld, set the stop time of the Simulink simulation to 1000e-6.

The Con?guration Parameters form looks like this:

Figure 1-7 Simulink Simulation Settings

15.Click OK.

16.Save the modi?ed design by choosing file — save as.

This completes the necessary modi?cations on the MATLAB side.T o continue,you can use the Simulink schematic that you modi?ed, or you can use the already modi?ed schematic included in the tutorial database.

For ADE Users

This section describes how to set up a cosimulation using the Analog Design Environment (ADE). If you are using the standalone version of SpectreRF, skip this section and go on to “For Users of Standalone SpectreRF” on page17.

Figure 1-8 Baseband Model for RF Front-End Transmitter

This schematic includes an RF transmitter module design with?lters,an up-converting mixer, and an ampli?er. T o speed-up the simulations, the RF components are modeled in the complex base-band domain using Verilog-A. Y ou can use the same approach to perform equivalent behavioral pass-band and transistor-level simulations.

Note:This schematic has two placed pwl vsources in the input.These are used as input to test the model.For cosimulation,these two sources are overloaded and generate output with the input data from MA TLAB.

1.Start the icms tool from the SpectreRF_simulink_example directory, using the

command

icms &

The version of icms must be release IC5.1.4.1 USR4 ISR62 or later.

2.Open the schematic view of the cell COSIM/tutorial1.

3.Open the Virtuoso Analog Design Environment from the schematic editor by choosing

Tools — Analog Environment.

4.Choose Setup — Matlab/Simulink — Setting.

The Cosimulation Options form appears.

5.In the Cosimulation Options form,click the Select button located beside Cosimulation

inputs. Switch to the schematic viewer, where you see the following information below the schematic.

Select source instance as cosimulation inputs. Press Esc when done.

Select the vsources VI and VQ, then press the Esc key.

6.In the Cosimulation Options form,click the Select button beside Cosimulation outputs.

Switch to the schematic viewer, where you see the following information below the schematic.

Select Net/Terminal as cosimulation outputs. Press Esc when done.

Select the TX_AFE_OUT_BB_I and TX_AFE_OUT_BB_Q nets, then press the Esc key.

The Cosimulation Options form looks like this:

Figure 1-9 Cosimulation Options Form for Tutorial 1

7.Ensure that the value of Cosimulation socket port is the same as the port value of the

SpectreRF Engine block de?ned in the previous section.

8.In the Cosimulation Options form, turn on Enabled. Make sure that Start MATLAB is

set to no. (The usage of the ADDITIONAL SETTING values is described in the next section of the tutorial.)

9.Click OK to close the form.

https://www.doczj.com/doc/db2814738.html,e the Choosing Analyses form to set up a tran analysis.

The Stop Time can be any value.The SpectreRF simulator synchronizes the stop time with Simulink.

The Choosing Analyses window looks like this:

Figure 1-10 Setup for the tran Analysis

11.Create a netlist and make sure the simulinkCosim cosim statement appears in it. For Users of Standalone SpectreRF

If you already generated a netlist using ADE,skip this section and go on to“Cosimulation with SpectreRF” on page19.

The netlist used in this tutorial is based on the behavioral RF Front-End transmitter model. The schematic, shown in Figure1-8 on page15, can be found in the tutorial1 directory.

1.Edit the netlist ?le tutorial1/tutorial1.scs.

2.Add a cosim statement in the netlist.

For example,

matlab cosim server="bj2lnx20" port=38525 inputs=["VI:wave" "VQ:wave"]

outputs=[TX_AFE_OUT_BB_I TX_AFE_OUT_BB_Q]

The parameters for the cosim statement are described below:

Table 1-1 Parameters of the cosim Statement

Parameter Meaning

design Refers to the ?le Simulink associates with the netlist.

design="env_d.mdl"

means the testbench whose ?le is env_d.mdl.

inputs Input vector to identify the ?ow from MA TLAB to SpectreRF Engine.

The format is

[“instance_name:wave” “instance_name1:wave” …]

where wave, is a key word.

Note:The sequence of instances in square brackets follows the same

one as the SpectreRF Engine port labels.This label information can be

found by double-clicking the SpectreRF Engine and then by

checking the Show engine port labels at the bottom in Function

Block Parameters of the SpectreRF Engine.

Once the inputs are set in the netlist,the sources(such as VI and VQ

in the step2 example) associated with the inputs are meaningless

and their parameters (such as type=sine freq=2M

fundname="n2" for VQ source) do not affect the simulation.

outputs Output vector from SpectreRF Engine to MA TLAB. It can be the net name or terminal name of interest. Note that if net name is selected,

only voltage is given; if terminal name is set, only current is output.

T o get current in an envlp analysis, you must add probes in the

topology.

port The one on the server running MA TLAB.Its value should be the same as the value in the SpectreRF Engine in your current MA TLAB design. server The name of the machine that MA TLAB starts. It can be set with the machine name or with the IP address of that machine. The accepted

form is

server = ”155.110.110.110”

and

server = “bj2lnx20”

server=localhost means that Spectre and MA TLAB use the same

machine.

After the above steps, the netlist is ready for simulation.

Cosimulation with SpectreRF

1.Open the testbench.

Y ou can use the one you just saved or the modified one that is provided in the tutorial1library.

2.In the MA TLAB design window, click Simulation , click Start .

The MA TLAB desktop issues the following message.

block 'modified/SpectreRF Engine':(COSIM_OK)Waiting for incoming connection on port 38520, timeout: 60 sec ...

Then quickly do step 3.

Note:The time interval between step 2 and step 3 must be within the Simulation

response timeout de?ned as Function Block Parameters of the SpectreRF Engine (by double-clicking the SpectreRF Engine ).

3.In the ADE window, click Netlist and Run or enter the command

spectre tutorial1/tutorial1.scs

The cosimulation begins.The MA TLAB desktop issues a message similar to the following when simulation ends.

block 'modified/SpectreRF Engine': (COSIM_OK) Simulation finished

silent

T ells MA TLAB whether to open the window during simulation. If silent=yes , the testbench window is opened.timeout The period of time MA TLAB spends waiting for a response from the

Spectre simulator.

timeout=60

stops MA TLAB if it does not receive any response.

Table 1-1 Parameters of the cosim Statement,continued

The result plots are generated.

Figure 1-11 Simulation Results as Spectral Plots

4.After the cosimulation?nishes,review the MA TLAB/Simulink output(see Figure1-11on

page20 and Figure1-12 on page21).

相关主题
文本预览
相关文档 最新文档