articles

System design needs to rise above ìC-levelî

By
MathWorks

5Ken describes how it is now possible to choose from a wider palette than one containing just traditional software and EDA tools – and how this is especially helpful for design problems such as optimizing high-speed mixed-signal designs.

Two different applications of Model-Based Design can illustrate its advantages over C-based design methods. In the first example, automatic code generation from MATLAB programs replaces fixed-point design and hand-coding in C. In the second example, multidomain models enable system architects to perform high-speed simulations of mixed-signal designs and analyze the interaction of algorithms, digital hardware, and analog circuits. In both cases, algorithm developers and system architects can characterize the impact of design decisions on system behavior, iterate designs faster, and catch integration problems and design flaws at an earlier stage.

Figure 1 shows how Model-Based Design supports both implementation and verification workflows using system models. This approach permits design, testing, and simulation of algorithms and multidomain systems in an integrated environment prior to hardware or software implementation.

Figure1
Figure 1: Comparison of traditional processes (left) to Model-Based Design (right). In traditional processes, gaps between different engineering specializations and tools inhibit electronic system development. Model-Based Design connects engineering disciplines and teams in an integrated design workflow to speed design cycles and lower verification costs.
(click graphic to zoom by 1.9x)


Automating MATLAB to C translation

For DSP and other algorithm-centric designs, MATLAB has been a popular tool with developers for many reasons. The chief reason is that it offers a high-level programming language, easy design explorations, and a flexible environment. Likewise, programming in C for implementation on embedded processors and DSPs is prevalent among software engineers. However, translation of floating-point MATLAB code to implementation in fixed-point C code is typically a manual task, which makes the verification of the implementation more difficult.

Manual translation from MATLAB code to C code involves low-level details such as data-type assignments, memory allocations, and optimizations for computational load and memory. A great deal of effort goes into keeping MATLAB code and C code equivalent. Extensive time is spent on producing and verifying the handwritten C code, which often introduces additional errors into the system. Also, many iterations of testing and verification, including trial and error, are required before the two different codes can become compatible.

Generating embeddable C code directly from MATLAB code streamlines design iterations. Developers use language, interactivity, and visualization capabilities within the MATLAB environment. Matrix-based operations, polymorphism, variable-size data, fixed-point numerical representations, and other MATLAB features are automatically translated to C code, keeping the focus on design improvements rather than on maintaining multiple copies of source code written in different languages.

Take, for instance, the Kalman filter algorithm, widely used in tracking applications like GPS and geolocation services. Figure 2 shows MATLAB code for the Kalman filter algorithm. Expressed in 17 lines of MATLAB code, this algorithm can be automatically converted to C using the MATLAB command emlc.

Figure2
Figure 2: Kalman filter algorithm expressed in 17 lines of MATLAB code.
(click graphic to zoom by 1.9x)

 

The equivalent C code uses for-loops for scalar computations of the matrix operations and comprises 144 lines. Because data types for all variables of the algorithm were introduced at compile time, the designer has the flexibility to explore alternative implementations and develop multiple versions of the algorithm destined for different processors. The generated C code is readable, and it contains the same comments as the original MATLAB code, inserted at corresponding lines of the algorithm.

Figure 3 shows that the output of the Kalman filter algorithm (blue) tracks the observed signal (red) quite well. But does it track well enough? Unlike writing C code by hand, generating code automatically from MATLAB enables developers to keep the design in an environment where they can quickly analyze results and iterate designs to meet the system requirements. Because the C code produces exactly the same results as the MATLAB code, they can avoid the problems that occur when the implementation diverges from the original algorithm source.

Figure3
Figure 3: Visualizing the tracking performance of the Kalman filter algorithm in MATLAB. Maintaining the design in MATLAB instead of C code facilitates rapid analysis and design iterations.
(click graphic to zoom by 1.4x)

 

System-level simulation of mixed-signal designs

Complex systems such as OFDM-based and MIMO-based LTE or WiMAX wireless devices have mixed-signal aspects that prove particularly challenging to traditional approaches. Circuit-level RF/analog and digital tools don’t communicate well or offer high-level behavioral abstractions, making it hard to examine the dynamic behavior of components such as an RF amplifier in the context of system behavior. This issue is significant because the performance of the RF/analog portion of the circuit is tightly coupled to the performance of the digital parts in ways that are often difficult to predict.

The inability to observe these system-level interactions, combined with prohibitively slow simulation times in circuit-level tools, limits the number of design variations that can be explored within the project time constraints. As a result, engineers are likely to make suboptimal tradeoffs in performance, area, and power that might lead to poor design quality, increased development time, and higher costs. Model-Based Design offers a faster, more cost-effective approach by supporting system-level integration of analog and digital components in a single multidomain environment, as shown in Figure 4.

Figure4
Figure 4: Workflow for Model-Based Design that facilitates multidomain modeling of advanced wireless devices, including analog, digital, and software components.
(click graphic to zoom)

 

Figure 5 shows the use of MATLAB and Simulink to model a wireless communication system based on the IEEE 802.16-2004 OFDM physical link. This model includes the baseband and RF sections of the transmitter and baseband section of the receiver. The transmitter, which is primarily a high-power amplifier, can be designed with a high-level behavioral model of a DPD amplifier using a Simulink model.

Figure5
Figure 5: Using MATLAB and Simulink to model a wireless communication system based on the IEEE 802.16-2004 OFDM physical link.
(click graphic to zoom by 1.9x)


These systems use complex digital waveforms with high data rate and spectral efficiency, so the peak-to-average power ratio (PAPR) requirement is high. In general, the power amplifier in a transmitter design must be operated in a relatively linear mode of operation to meet the spectral emission specifications of the standard. Because of the high PAPR, the amplifier in these transmitters must be backed off considerably from the peak efficiency operating point. To recover the efficiency while still meeting spectral emission specifications, the transmitter incorporates digital predistortion (DPD) of the power amplifier.

While the DPD algorithm can compensate for the nonlinear effects of the amplifier, the model has the ability to evaluate key system-level metrics, including error vector magnitude (EVM), adjacent channel leakage ratio (ACLR), and bit-error rate (BER), and their impact on the overall system performance. Designers can optimize the RF amplifier performance within the overall wireless communication system all prior to prototyping or implementation. (See Figure 6.) And designers can interface the model to measurement equipment in the test lab to further verify the efficacy of the DPD algorithm using live measured data from the actual power amplifier.

Figure6
Figure 6: Behavioral model for RF power amplifier and DPD algorithm. This model enables system designers to explore, optimize, and test the algorithm design under the full range of operating conditions before building a hardware prototype.
(click graphic to zoom by 1.9x)


Interfacing to hardware and software development tools

To maintain a continuous verification workflow, multiple interfaces are available to connect system-level models and algorithms developed in MATLAB and Simulink to digital and analog hardware simulators from major EDA vendors, as well as popular embedded software IDEs and real-time operating systems. These interfaces support cosimulation and additional automation for the code-generation process.

Summary

Some of the most pressing system-level problems are difficult to address with traditional software and EDA. Unlike C-based ESL tools, Model-Based Design tools address these issues by connecting concept generation to implementation through automatic code generation, and enable engineers to solve complex design problems such as optimizing high-speed mixed-signal designs. With interfaces to many EDA and embedded development tools, Model-Based Design with MATLAB and Simulink creates a unified workflow that alleviates the limitations of dissimilar tools and workflow gaps.

Ken Karnofsky is the Senior Strategist for Signal Processing Applications at The MathWorks. Through his 20 years of experience, first with BBN Technologies, then with The MathWorks, Ken has been involved in development and marketing of software for signal processing and data analysis technologies. Ken holds a degree in Systems Engineering from the University of Pennsylvania. He can be reached at Ken.Karnofsky@Mathworks.com.

 

The MathWorks

www.mathworks.com

>

©MMX DSP-FPGA.com. An OpenSystems Media, LLC publication.

About this Magazine and Website | Contact Us | DSP-FPGA.com Media Kits