Newsletters - MATLAB News & Notes
DSP Applications: Blurring the Line Between Simulation and Implementation
by Dave Koh and Kelly Bletsis
You are a DSP engineer tasked with designing and implementing a 15-band digital audio equalizer on a Texas Instruments™ (TI) DSP. You use MATLAB® to start the design process.
From there, you can design your filters, test their frequency responses against performance requirements, and then simulate the entire equalizer system. You might assume that you must then switch from MATLAB to Code Composer Studio™, TI's real-time implementation environment. In this article, we'll show how MATLAB® Link for Code Composer Studio™ Development Tools makes this switch unnecessary because it connects MATLAB with TI Code Composer Studio and all supported TI DSPs, including C2800™, C5000™, and C6000™.
Hardware Setup
- TI TMS320C6711 DSK evaluation board
- TI TMDX326040A stereo daughter card with analog-to-digital converter (ADC) and a digital-to-analog converter (DAC) operating at 48 kHz
- PC connected to the DSK via TI XDS-560 emulator, providing data transfer between the host and the C6711 DSP at rates approaching 2 MB/s
Equalizer Specifications
- 15-bands compliant with the two-thirds octave International Standards Organization (ISO) frequency specifications
- 20 -20,000 Hz range
- +/-12 dB boost/cut per sub-band
- 12 dB/octave out-of-band rollover
- Nominal 5% center frequency accuracy
Sub-Band Filter Design
With our own requirements and those of the two-thirds octave ISO frequency specifications in mind, we assess digital filter designs using the Filter Design and Analysis Tool (FDATool) in the Signal Processing Toolbox (see Figure 1). Using the FDATool GUI, we test a number of design methods, including Hamming-windowed and Kaiser-windowed finite impulse response (FIR), and Butterworth and Chebyshev Type II infinite impulse response (IIR). After fine tuning, we save a number of filter design coefficients sets generated by the FDATool.
![]() |
Figure 1. FDA Tool. Click on image to see enlarged view. |
Hybrid Simulation
Traditionally, DSP software development involves iterations of algorithm simulations followed by prototyping candidate designs on the DSP. If, however, portions of the DSP implementation could be integrated into the PC simulation, hardware constraints may be considered earlier in the design phase-leading to better decisions and fewer design candidates. Figures 2 and 3 show the execution paths of two hybrid simulations built for the equalizer application. The red switches indicate that any component of the design may be run either in MATLAB or on the DSP.
![]() |
Figure 2. Frame-based, real-time simulation. Click on image to see enlarged view. |
![]() |
Figure 3. Entire data set, non-real-time simulation.Click on image to see enlarged view. |
We create a project for Code Composer Studio by writing DSP code that transfers data to and from the host using Real-Time Data Exchange (RTDX™), TI's real-time communications protocol. Then, by calling RTDX read-and-write functions of MATLAB Link for Code Composer Studio, we execute equalizer algorithms in MATLAB in frame-based, real-time streaming mode (Figure 2). We assess the fourth-order IIR designs in this fashion:
frame = double(r.readmsg('ochan1','int16'));
% get ADC data from DSP
output = output + gain*filter(handles.Hd,frame);
% apply Filter and Gain
r.writemsg('ichan1',int16(output));
% send EQ results to DSP
The computational burden of the 100-plus taps of the FIR equalizer designs could not meet the real-time requirements of the streaming mode on our PC. We needed to define another simulation scheme, depicted by Figure 3. In this batch mode, ADC frame data sent by the DSP is concatenated and saved as a WAV file. The entire recorded data set is then read and processed by the equalizer simulation in non-real-time. But when the output of the equalizer is played through the speakers, it sounds as if it were being streamed in real time.
After evaluation, one FIR and two IIR designs meet our specifications. Of the three, the IIR designs are preferable because they correspond more closely to their traditional analog filter counterparts constructed of op amps and require fewer multiply-accumulate operations than FIRs.
Since the target is a 32-bit DSP, it is natural to implement the equalizer in single precision for best possible floating-point performance. However, Chebyshev and Butterworth IIR designs became unstable with the application of single-precision coefficients. We return to the FDATool and each IIR as cascaded second-order sections (SOS), which are less susceptible to quantization effects. Subsequent analysis with the Filter Design Toolbox reveals that the SOS filters are stable.
Implementation and Verification
Once we have written and inserted equalizer code into the project for Code Composer Studio created earlier, we can apply MATLAB Link for Code Composer Studio to automate testing and verification.
We write a MATLAB script to invoke the DSP function call capability of MATLAB Link for Code Composer Studio to test the IIR filters.
From there, we follow these steps:
- Select a known signal.
- Process the signal using IIR functions from the Signal Processing Toolbox, and simultaneously run the signal through IIR filters on the DSP.
- Compare the results.
![]() |
Figure 4. Simulation vs. DSP implementation plots. Click on image to see enlarged view. |
![]() |
Figure 5. Graphic equalizer user interface with options for MATLAB only simulation, MATLAB and DSP hybrid simulation, and DSP-only implementation. Click on image to see enlarged view. |
If the IIR filters are implemented correctly on the DSP, the difference in results is merely the effect of quantization, as shown in Figure 4.
Since MATLAB Link for Code Composer Studio provides DSP memory-write operations, we can change IIR filter coefficients without recom-piling. We test both IIR implementations in a consistent, automated way with a single MATLAB script by simply exchanging coefficient sets.
After isolated filter testing, we verify the entire equalizer design by stringing DSP function calls and comparing them with the simulation results. Finally, we insert RTDX instrumentation code, which runs on the DSP, to send intermediate results to MATLAB, where they are displayed while the DSP is running. Figure 5 shows the equalizer.
In this example, we have shown that when design tools are integrated with DSP implementation tools, we can select the best design before prototyping, thus minimizing the implementation of designs whose performance is compromised by embedded hardware limitations.
For more information visit:
|
Store




