MathWorks Extends Code-Generation Capabilities Across its Tool Portfolio

Submitted by BDTI on Wed, 05/18/2011 - 21:00

The MathWorks—maker of MATLAB modeling environment—has launched a trio of new code-generation tools called MATLAB Coder, Simulink Coder, and Embedded Coder. With these automatic code-generation products, The MathWorks aims to eliminate the need for development teams to maintain parallel development efforts—modeling algorithms in MATLAB, for instance, while separately coding in C or C++ for embedded implementation. MATLAB users will get direct code-generation capability for the first time without having to use Simulink.

MathWorks has offered code-generation capabilities for a decade. However, until now these capabilities were tied to Simulink and the Real-Time Workshop add-on that generated C code from Simulink models. While the Simulink code-generation capability could be used to generate C or C++ from MATLAB functions encapsulated within Simulink, this was awkward for many engineers who prefer MATLAB to Simulink.  In addition, the earlier code-generation capability covered a relatively small portion of the MATLAB language. (MATLAB is a math-centric programming language and simulation platform that is widely used for algorithm development and modeling across many application domains. Simulink is a more specialized tool used to simulate and analyze dynamic systems.)

The new trio of products repackage The MathWorks’ code generation capabilities into products targeted at different use models, and significantly extend the usefulness of the code-generation capability. The development is probably most important to MATLAB users—a far larger community than that of Simulink users.

The new MATLAB Coder product allows developers to generate C and C++ code directly from their MATLAB programs.  The new code generator covers a far greater subset of the MATLAB language than what was previously available via Real-Time Workshop. MATLAB Coder supports the bulk of the language that engineers might use in algorithm development, including matrices and arrays, classes and data types, programming constructs, and functions. The coder can also generate MEX (MATLAB Executable) files that can be called from within the MATLAB environment to accelerate computationally-intensive portions of MATLAB simulations.

MATLAB Coder does not support all MATLAB objects.  According to The MathWorks, however, the bulk of the unsupported functionality is associated with features such as graphics and user interfaces that would typically not be utilized in an embedded system.

According to The MathWorks, the MATLAB Coder product will enable engineering teams using MATLAB to change the way they work, yielding better productivity.  Before, a development team would develop a model of an application in MATLAB and then manually convert that model into C or C++ for deployment on a target system. Testing on the target would lead to an iterative process that might include more work in MATLAB tuning the algorithms followed by more C/C++ work to keep the MATLAB and C/C++ representations in sync.

This manual conversion process has been a roadblock to development teams for two reasons. First, converting a MATLAB model to C or C++ requires good coding skills and is time consuming. Second, most MATLAB users develop algorithms using floating-point math and with little initial thought about the target hardware. In many cases, the software designers doing the conversion must painstakingly convert floating-point algorithms to fixed-point for implementation on a fixed-point target.

With MATLAB Coder, the design team can model and iterate purely in the MATLAB environment, according to MathWorks. The team can maintain the code base in MATLAB and only generate new C or C++ code, libraries, or MEX files when changes occur in the MATLAB code. Moreover, the developers can declare data types in MATLAB—for instance specifying fixed-point data types and explicit variable lengths—and MATLAB Coder will generate fixed-point code.

The new Simulink Coder, meanwhile, is essentially the former Real-Time Workshop product renamed. Typical applications include simulation acceleration, rapid prototyping, and hardware-in-the-loop testing. Simulink Coder does add the ability to generate code from state charts and flow diagrams described using The MathWorks’ Stateflow tool.

The new Embedded Coder product is derived from the prior Real-Time Workbench Embedded Coder product and is utilized to optimize code targeted for specific embedded processors. The new version adds support for third party IDEs such as Texas Instruments’ Code Composer Studio and Analog Devices’ Visual DSP++ and can be used either with MATLAB Coder or Simulink Coder. Figure 1 summarizes the Coder product family.

    Coder Product Family    

Figure 1. The new Coder product family from The MathWorks includes separate MATLAB, Simulink, and Embedded code-generation products.

Embedded Coder supports a relatively broad range of processors in terms of automating the process of generating code that is ready to run on the target processor. Embedded Coder also supports performance optimizations, such as the replacement of C code with intrinsic functions developed by a semiconductor vendor for a specific embedded processor. For now, however, support for intrinsic functions and other optimizations is limited to a few processor families including some popular DSPs from companies such as TI and Analog Devices. The company hopes to support more processors in the future and will offer APIs that allow semiconductor companies to add target-specific optimization support.

The new code-generation product portfolio from The MathWorks will likely benefit MATLAB users who use MATLAB as a high-level starting point for creating embedded software.  And MEX support in the code generator may make MATLAB Coder attractive to engineers working exclusively on algorithm design.  According to The MathWorks, MATLAB customers will get access to code-generation capabilities at a lower cost compared to the prior requirement of licensing both MATLAB and Simulink.

Add new comment

Log in or register to post comments