Documente Academic
Documente Profesional
Documente Cultură
platform
Model-based design tutorial
2.0 2009-04-14 Updated to account for releases 3.0.0 and 3.1.0 of the ADP software tools. First official
release.
3.0 2009-09-08 Updated to account for release 3.2.0 of the ADP software tools.
3.1 2010-05-12 Updated to account for release 4.1.1 of the ADP software tools.
©
Lyrtech Inc. All rights reserved.
No part of this document may be reproduced or used in any form or by any means—graphical, electronic, or
mechanical (which includes photocopying, recording, taping, and information storage/retrieval systems)—
without the express written permission of Lyrtech Inc.
To ensure the accuracy of the information contained herein, particular attention was given to usage in
preparing this document. It corresponds to the product version manufactured prior to the date appearing
on the title page. There may be differences between the document and the product, if the product was
modified after the production of the document.
Lyrtech Inc. reserves itself the right to make changes and improvements to the product described in this
document at any time and without notice.
ii
Trademarks
Acrobat, Adobe, and Reader are either registered trademarks or trademarks of Adobe Systems Incorporated
in the United States and/or other countries. IBM is a registered trademark of International Business
Machines Corporation in the United States, other countries, or both. Intel and Pentium are registered
trademarks of Intel Corporation or its subsidiaries in the United States and other countries. Microsoft,
MS-DOS, Windows, Windows NT, and the Windows logo are either registered trademarks or trademarks
of Microsoft Corporation in the United States and/or other countries. MATLAB, Simulink, and Real-Time
Workshop are registered trademarks of The MathWorks, Inc. Xilinx, Spartan, and Virtex are registered
trademarks of Xilinx, Inc. Texas Instruments, Code Composer Studio, C62x, C64x, and C67x are trademarks of
Texas Instruments Incorporated. All other product names are trademarks or registered trademarks of their
respective holders.
Warning
Do not use Lyrtech products in conjunction with life-monitoring or life-critical equipment. Failure to observe
this warning relieves Lyrtech of any and all responsibility.
FCC warning
This equipment is intended for use in a controlled environment only. It generates, uses, and can radiate
radio frequency energy and has not been tested for compliance with the limits of personal computers and
peripherals pursuant to subpart J of part 15 of the FCC rules. These rules are designed to provide reasonable
protection against radio frequency interference. Operating this equipment in other environments may cause
interference with radio communications, in which case the user must, at his/her expense, take whatever
measures are required to correct this interference.
iii
iv
Table of contents
Introduction.......................................................................................................................................... 1
Purpose and structure....................................................................................................................... 1
Conventions.................................................................................................................................. 1
Glossary of terms.......................................................................................................................... 2
Technical support.............................................................................................................................. 3
Requirements........................................................................................................................................ 5
Software requirements..................................................................................................................... 5
General......................................................................................................................................... 5
DSP development software........................................................................................................... 5
FPGA development software........................................................................................................ 5
Preliminary readings......................................................................................................................... 5
Accessing the platform’s documentation...................................................................................... 6
Using the platform’s DSP....................................................................................................................... 7
Targeting the DSP.............................................................................................................................. 7
Tutorial 1—Audio loopback simulation............................................................................................. 7
Goals............................................................................................................................................. 7
Creating a new model................................................................................................................... 7
Simulating the model.................................................................................................................... 10
Running the model on your platform........................................................................................... 11
Tutorial 2—Processing an audio signal with a FIR filter.................................................................... 16
Goals............................................................................................................................................. 16
Modifying an existing model......................................................................................................... 16
Running the model on your platform........................................................................................... 17
Using the platform’s FPGA..................................................................................................................... 19
Targeting the FPGA............................................................................................................................ 19
Tutorial 3—Incorporating an FPGA in a Simulink simulation............................................................ 19
Goals............................................................................................................................................. 19
Creating a new model................................................................................................................... 19
Configuring the simulation parameters........................................................................................ 23
Saving the model.......................................................................................................................... 23
Running the model....................................................................................................................... 23
Observing the results.................................................................................................................... 24
Stopping and disconnecting.......................................................................................................... 24
Using the platform’s mixed processor architecture............................................................................... 25
Tutorial 4—Using VPSS for streaming application in the FPGA model.............................................. 25
v
Goals............................................................................................................................................. 25
Creating a new model................................................................................................................... 25
Saving the model.......................................................................................................................... 27
Building an FPGA model................................................................................................................ 27
Observing the results.................................................................................................................... 27
Tutorial 5—Using the VPSS to stream data in a DSP model.............................................................. 28
Goals............................................................................................................................................. 28
Modifying an existing model......................................................................................................... 28
Running the model on the platform............................................................................................. 30
Using the data conversion and RF modules.......................................................................................... 33
Tutorial 6—Using the DAC in an FPGA model................................................................................... 33
Goals............................................................................................................................................. 33
Modifying an existing model......................................................................................................... 33
Building the FPGA model.............................................................................................................. 36
Observing the results.................................................................................................................... 36
Saving the model.......................................................................................................................... 36
Tutorial 7—Using the data conversion and RF modules in a DSP model.......................................... 36
Goals............................................................................................................................................. 36
Modifying an existing model......................................................................................................... 36
Building the model........................................................................................................................ 38
Connecting to the target and running the model......................................................................... 38
Observing the results.................................................................................................................... 39
Stopping and disconnecting.......................................................................................................... 39
vi
Introduction
Introduction
This document goes over one of the applicative examples supplied with the SFF SDR development
platforms. The document treats of DSP designs and FPGA designs and, once your are done, you will
be able to perform a narrow-band FM transmission to the FRS handset supplied with the low-band
platform.
Conventions
In a procedure containing several steps, the operations that you must perform are numbered (1, 2, 3…).
The diamond (◊) is used to indicate single-step procedures. Lowercase letters (a, b, c…) are be used to
indicate secondary steps in a complex procedure.
Capitals are used to identify keys on the keyboard (for example, ctrl+v). All software user interface
words (for example, names of menus, commands, dialog boxes, text boxes, and options) appear in bold
font style (for example, File).
The abbreviation N/A is used to indicate something that is not applicable or not available at the time of
press. The abbreviation NC is used to indicate no connection.
This symbol is used to call your attention to important information, crucial to the correct
operation of your product.
This symbol is used to call your attention to information that may prove useful in operating
your product, but is not vital to correct operation.
1
Introduction
Glossary of terms
Throughout this document, you will find references to the following terms. Refer to the following table
as to their definitions.
Term Definition
Application programming interface (API) An application programming interface is the interface that
a computer system, library, or application provides to allow
requests for services to be made of it by other computer
programs or to allow data to be exchanged between them.
Base design Empty design or template that is incapable of data processing and
is not instantiated in the custom logic of the board’s FPGA.
Board software development kit Abbreviated BSDK, this kit gives users the possibility to quickly
become fully functional developing C/C++ or assembly code for
the DSP, and HDL code for the FPGA through an understanding of
all Lyrtech boards’ major interfaces.
Chassis Refers to the rigid framework onto which the CPU board, Lyrtech
development platforms, and other equipment are mounted. It
also supports the shell-like case—the housing that protects all the
vital internal equipment from dust, moisture, and tampering.
cPCI CPU Host CPU of the cPCI chassis system, responsible for processing
and communications between the hardware in the cPCI chassis
and the remote computer connected to the cPCI chassis system.
Default design Design loaded by default on Lyrtech boards used for FPGA design.
Digital signal processing Digital signal processing is the study of signals in a digital
representation and the processing methods of these signals.
The algorithms required for DSP are sometimes performed using
specialized devices that use specialized microprocessors called
digital signal processors (DSP).
Digital signal processor (DSP) A digital signal processor is a specialized microprocessor designed
specifically for digital signal processing, generally in real time.
2
Introduction
Term Definition
Model-based design Refers to all the Lyrtech board-specific tools and software used
for development with the boards in MATLAB and Simulink and the
Lyrtech model-based design kit(s).
Software development Refers to development performed with and for the board with
a software development kit. Software development for a board
comes in three flavors: host software development, DSP software
development, and FPGA software development.
Technical support
Lyrtech is firmly committed to providing the highest level of customer service and product support.
If you experience any difficulties using our products or if it fails to operate as described, first refer to
the documentation accompanying the product. If you find yourself still in need of assistance visit the
technical support page in the Support section of our Web site at www.lyrtech.com.
3
Introduction
4
Requirements
Requirements
Before you can use your SFF SDR development platform in developing model-based designs, you must
meet the requirements outlined below.
For details about the exact software versions supported by your SFF SDR development
platform, refer to your platform’s quick start guide.
Software requirements
To complete all the tutorials in this guide, the following software must be installed on your computer:
General
• Advanced development platform (ADP) software tools
• MATLAB
• Simulink
• Signal Processing Blockset
• Signal Processing Toolbox
Preliminary readings
Before going through this guide, we recommend that you familiarize yourself with the following, to help
you gain a working knowledge of the SFF SDR development platform’s capabilities:
5
Requirements
Accessing the platform’s documentation
1 On the Windows Start menu, point to All Programs.
2 Point to Lyrtech, SFF SDR, and then click Documentation.
Your default Web browser starts and displays a page containing links to all the documents supplied with
the SFF SDR development platform.
6
Using the platform’s DSP
The results presented in this chapter are only supplied for illustration purposes. They are not
intended to represent actual results.
5 On the Callbacks tab, in the Model pre-load function group, Fs_DSP = 32000.
The Fs_DSP variable appears as 32000 when you open the model for the first time. It is the
sampling frequency of the audio path used later on in this tutorial.
Use the sample time as a relative time base. This means that specifying a Sample Time of
1 does not force the block to run at 1 Hz, it rather forces the block to run at a frequency relative to
other blocks’ Sample Time values.
7
Using the platform’s DSP
For example, if you specify a Sample Time of 2/48000 for block A and block B has a sample time of
1/48000, block B runs twice as fast as block A. In other words, its associated code is executed twice
as fast as that of block A.
If no I/O block forces the DSP to run at a specific sample rate, the DSP runs the code as fast as
possible. In other words, the DSP is free running. However, if you insert an I/O block such as an
audio ADC block in your model, then the Sample Time is associated to the effective sample rate
configured in the block (24 kHz, for example). This means that all the other blocks having the same
sample time as the I/O block (e.g. 24 kHz) run at the same sample rate.
If you also specify a Frame Size, then the actual frame time (i.e. the time to execute a frame) is
imposed by the following formula:
Using the model properties is a good way to ensure that all your parameters remain with
your .mdl file. You can also use a .mat file to save your MATLAB workspace parameters. Refer to
Simulink Help to learn more about model properties.
6 To add the Fs_DSP variable to the MATLAB workspace parameters, type Fs_DSP = 32000 at the
MATLAB command prompt.
Alternately, exit the model, and then reopen it.
8 Click Yes.
This configures the default simulation parameters of your SFF SDR development platform.
8
Using the platform’s DSP
Figure 2 Connecting blocks in the model
Selecting Sample Time Colors is a good way to have an overview of the sample times
of every block in your model. In the model at hand, all the blocks become red, indicating that all
the blocks have the same sample time (i.e. they are executed at the base sample time). Refer to
Simulink Help to learn more about this function.
12 On the Format tab, point to Port/Signal Displays, and then click Port Data types.
Selecting Port Data types is a good way to have an overview of the data types of every link
in your model. Refer to Simulink Help to learn more about this function.
13 On the Format tab, point to Port/Signal Displays, and then click Signal Dimensions.
Selecting Signal Dimensions is a good way to have an overview of the dimensions of the
signals, particularly when they are frame based. Refer to Simulink Help to learn more about this
9
Using the platform’s DSP
function.
4 Right-click anywhere in the windows and click Autoscale on the shortcut menu that appears.
The following results are expected.
The values on the x and y axes are accurate in terms of frequency and time because the
sample time value is equal to the sample time of the audio codec sampling frequency.
10
Using the platform’s DSP
Running the model on your platform
To take your simulation model and implement it on the SFF SDR development platform, you must
perform the procedures outlined in this section.
3 Verify that System target file is rt_sdr.tlc and that Template makefile is rt_sdr.tmf.
The code generated by the MBDK DSP solution runs indefinitely, regardless of the Stop
time parameter. This parameter, however, determines the default time range of Simulink scopes
when their Time range parameters are auto.
11
Using the platform’s DSP
Figure 6 Hardware Implementation parameters
When building a DSP model, the building folder is always your current MATLAB folder.
When the build is successful, the ### Created Executable :{model name} message appears in the
MATLAB window.
12
Using the platform’s DSP
Figure 7 Interface selection
d Click OK.
7 In the model window, click the connect to model button.
The Lyrtech development platform detection dialog box appears.
8 Select a platform that is not in a locked state, and then click Connect to Lyrtech development
platform.
Figure 8 Lyrtech development platform detection dialog box
9 When the .out file is loaded to the DSP of the platform, the model starts automatically.
Your audio signal is displayed on the time and vector scopes. Use the auto-scale feature, if
necessary. The actual aspect of the scope depends on the audio signal.
For details about targeting the DSP with the MBDK DSP solution, refer to the model-based
design guide of the SFF SDR development platform.
Observing results
The scopes react according to the signal fed to the platform. For a better real-time display quality in the
scope, proceed as follows:
13
Using the platform’s DSP
Figure 9 External mode control panel
4 Click Apply.
5 Click Close.
As a rule, when frame based, the Data Logging Size (in the DSP Options block) should be
greater than the Duration value multiplied by the frame size and the number of scopes.
14
Using the platform’s DSP
15
Using the platform’s DSP
• Clear the Button 2 to Button 5 check boxes
Switch block
• Criteria for passing first input: u2 > Threshold
5 Double-click the Digital Filter Design block.
The Digital Filter Design block implements a digital FIR or IIR filter that you design with the filter
design and analysis tool (FDA Tool).
16
Using the platform’s FPGA
• Make sure that System Generator for DSP is installed on your computer before proceeding with the
• tutorials of this chapter.
• In System Generator for DSP all the data paths are always sample based, but all the data type are •
fixed point. No floating-point data types are available.
• The results presented in this chapter are only supplied for illustration purposes. They are not •
intended to represent your actual results.
5 On the Callbacks tab, in the Model pre-load function group, type Fs_FPGA = 1e6.
The Fs_FPGA variable is created and becomes the frequency of the system clock.
The sampling frequency specified in each block is not imposed on the FPGA clock. In a
Simulink model, the sample time is merely a tag on each “step” of an algorithm. A sampling time
of 1 would produce the same bitstream file (.bit) for the FPGA. For the spectrum scope and time
scope, it is sometimes useful to see the results of the simulation in terms of clock cycles, while
sometimes it is useful to do so in terms of seconds. Using a variable allows you to switch all the
sample times of your design simultaneously. Use a sample time of 1 for clock cycle information and
a clock period cycle for the time domain and frequency domain information.
DDS stand for direct digital synthesizer. It is the main block used in this model. Refer to
System Generator for DSP Help for details.
A constant corresponding to the carrier frequency is added to the amplitude from the
Sine Wave block, which is then sent to the data port of the DDS v5_0 block. The frequency output,
controlled by the data port, thus changes as the amplitude of the sine wave changes.
18
Using the platform’s FPGA
Figure 12 Connecting blocks in the model
To get two inputs from one scope, double-click the scope block. In the window that
appears (below), click the parameters button. In the Axes group, modify Number of axes to 2. Click
OK.
19
Using the platform’s FPGA
Figure 13 Getting two inputs from one scope
9 In the Constant block connected to the WE of the DDS v5_0 block, select type Boolean and
constant value 1.
10 Double-click the DDS v5_0 block.
11 On the Advanced tab, specify the following:
• DDS clock rate (MHz): 1. This is the actual clock rate of your hardware clock. A lower clock
frequency means less points to calculate, thus a faster simulation. For the purposes of this
example, use 1 MHz.
• Spurious free dynamic range (dB): 16*6. This lowers the spurious in the output signal by
increasing the resolution (bits) of the output. As a rule, 1 bit equals 6 dB of SFDR.
• Frequency Resolution (Hz): 0.2. This impacts the number of bits of the input data type at the
data input port. To determine how many bits the port needs, at the MATLAB command prompt,
type ceil(log2(1e6/0.2)), indicating that the answer is 23 bits.
• Noise shaping: Phase dithering. This noise shaping technique is necessary as the SFDR is
between 60 dB and 102 dB.
12 On the 12 Implementation tab, select Block RAM.
13 Double-click the AddSub block.
14 On the Output Type tab, select User-Defined Precision, specify the output type as Signed, the
number of bits as 23, and the binary point as 0.
15 Double-click the Constant block connected to the AddSub block.
16 Select Signed, specify the constant value as (100e3/1e6)*2^23, specify the number of bits as 23,
and the binary point as 0.
The carrier frequency is configured through the Constant block connected to the AddSub
block. The value sent to the data input port is called phase increment. We want a 100 kHz carrier
frequency from a DDS with a 1 MHz clock. The relation is simple:
fout P
= inc_data_port
DDSclock Pinc_max
For details on phase incrementation and DDS, refers to System Generator for DSP Help.
17 Double-click the CMult block, specify (1.5e3/1e6)*2^(23–15) as the Value, specify the number of
bits as 16, and the binary point as 16.
The last value configures the peak frequency deviation. It is related to the frequency
modulation index. Frequency modulation (FM) conveys information by varying the frequency of
a carrier signal. The frequency modulation index indicates by how much the modulated variable
varies around its unmodulated level. The formula for the modulation index is:
20
Using the platform’s FPGA
D
b= f
fm
Where fm is the highest modulating frequency and Δf is the carrier frequency deviation. For
narrow-band FM, such as FRS, the modulation indices must be smaller than 1. Let us use 0.5.
The highest modulating frequency coming from the sine wave is 3 kHz; therefore, we need a
carrier frequency deviation of 1.5 kHz. The phase increment corresponding to 1.5 kHz is equal
to (1.5×103/1×106)×223. The peak value of our 16-bit sine wave is 215–1. We are looking for the
constant value K where:
10
2 In the Simulation time group, specify 1 in the Stop time text box.
3 In Solver options section, select Variable-step as the type and discrete as the solver.
4 Click OK.
System Generator for DSP produces simulation results that are bit-true and cycle-true to
the hardware it generates. To say that a simulation is bit-true means that, at the boundaries (e.g.
interfaces between the System Generator block and non-System Generator for DSP blocks), a
value produced in a simulation is identical, bit for bit, to the corresponding value produced in the
hardware.
To say that a simulation is cycle-true means that, at the boundaries, corresponding values are
produced at corresponding times. The boundaries of the design are the points where System
Generator for DSP blocks exist. When the System Generator for DSP generates hardware, the
Gateway In or Gateway Out blocks become top-level input or output ports.
21
Using the platform’s FPGA
Figure 14 Spectrum scope view of FM with a 0.5 spectrum index and Time scope quadrature signal
22
Using the platform’s mixed processor architecture
24
Using the platform’s mixed processor architecture
• For data streaming applications, configure your ren and wen as always asserted.
• Because the Synchronize Audio Codec with FPGA System Clock check box is selected in the
FPGA configuration block, the FPGA system clock and the codec clock are the same.
25
Using the platform’s mixed processor architecture
26
Using the platform’s mixed processor architecture
5 Configure the blocks as follows:
Custom Register block
• Register ID: 0
• Direction: Write to FPGA
• FPGA Data Type: Unsigned
• FPGA Binary Point: 0
• DSP Data Type: Int32
• Sample period: 128/Fs_DSP
Audio Codec Configuration block
• Sampling frequency: Defined with FPGA configuration block
VPBE block
• Packet size: 128
• Data Type: Single
• Sample period: 1/Fs_DSP
VPFE block
• Packet size: 128
• Data Type: Single
• Sample period: 1/Fs_DSP
Data Type Conversion block
• Output data type mode: int32
6 Right-click anywhere in the model window, and then click Model Properties on the shortcut menu
that appears.
7 On the Callbacks tab, in the Model pre-load function group, type Fs_DSP = 36621.
This maintains the scope accurate as this is the new sampling frequency of the codec
(37.5 MHz/1024 = 36621 Hz).
8 On the model’s Format menu, point to Block Displays, and select Sorted.
9 Update your model and make sure that VPBE is smaller than VPFE.
If it is not, open the Lyrtech priority manager block.
Select the name the VPFE block (by default, VPSS Bus or VPSS Bus 1), and then click Down until the
block is below the VPBE block.
27
Using the platform’s mixed processor architecture
Figure 18 Lyrtech priority manager
The sorted order of blocks shows the sequence in which each part of the processing is
called. In the case of the VPBE and VPFE, it is useful because if the VPFE is performed before the
VPBE, the VPSS port becomes deadlocked.
10 Double-click Set Bitstream, and then select the bitstream created during tutorial 4.
Before building the model, verify that the value of Fs_DSP is 36621. If it is not, save the
model as my_tutorial5.mdl, close the model, and then reopen it. Alternately, you can type Fs_DSP =
36621 at the MATLAB command prompt.
28
Using the platform’s mixed processor architecture
Stopping, stopping, and disconnecting
1 Click the disconnect from target button.
2 Save the model as my_tutorial5.mdl.
3 Close the model.
29
Using the platform’s mixed processor architecture
30
Using the data conversion and RF modules
32
Using the data conversion and RF modules
Signal Processing Blockset—Signal Processing Sources
• 1 × DSP Constant
Simulink—Sinks
• 2 × Terminator
10 Connect the blocks as illustrated.
Figure 21 Connecting the blocks in the model
• The negative sine is necessary to get an upper sideband signal from the analog quadrature
modulator of the RF module. This can be ascertained with a spectrum analyzer.
• The number of bits of the DDS data import port is explained in tutorial 3.
• The mult is discarded from tutorial 3 because K’s value for FRS specifications nears 1.
Before building the FPGA model, verify that the value of Fs_FPGA is 80000000. If it is
not, close the model, and then reopen it. Alternately, you can type Fs_FPGA = 80e6 at the MATLAB
command prompt.
35
Using the data conversion and RF modules
Audio Codec I/O Out block
• Clear the Normalize Audio Data Samples check box
• Clear the Enable Data Saturation check box
ADACMaster III control block
• On the DAC tab, select the Enable DAC check box.
• On the DAC tab, on the Operation Mode list, select Full Bypass.
• On the Clock and PLL tab, ADC/DAC Clock Source: Use PLL
• On the Clock and PLL tab, PLL Reference Time Base: External
• On the Clock and PLL tab, Additional Reference Time Value: 10
• On the Clock and PLL tab, Required clock for ADC, FPGA design, and DAC: 80
• On the Advanced tab, Sample time: 128/Fs_DSP
DSP Constant block
• Value: ceil((462.5625e6 -432e6) /80e6*2^29)
• Data Type: int32
• Sample Time: 128/Fs_DSP
• The equation used in calculating the DSP constant is the same as the one presented in tutorial 3
for setting the carrier frequency. The carrier frequency of FRS channel 1 is 462.5625 MHz, which
is obtained from intermediate frequency (IF) 30.5625 MHz (controlled by the DSP constant) and
heterodyned with a frequency of 432 MHz.
• Because the DAC and ADC are AC coupled, you must always work at an IF higher than 3 MHz.
10 Right-click the RF Module block and select Block properties. Enter the value 0 in the Priority field.
Because the conversion module gets its clock signal form the RF module, the latter must
be initialize first.
11 Double-click the Set Bitstream block, and then select the bitstream created in tutorial 6.
Before building the model, verify that the value of Fs_DSP is 31250. If it is not, close the
model, and then reopen it. Alternately, you can type Fs_DSP = 31250 at the MATLAB command
prompt.
36
Using the data conversion and RF modules
5 On the model’s Simulation menu, click Connect to target.
Alternately, you can click the connect to target button.
6 Click the play button.
Alternately, press CTRL+T on your keyboard.
37