MathWorks adds C code generation to Matlab

Eliminates manual translation of MATLAB algorithm code into C and C++ code for prototyping, implementation, and software integration

EDN Europe, 11 Apr 2011

MathWorks has extended the reach of its Matlab software with the introduction of Matlab Coder, which generates C or C++ code directly from algorithms described in Matlab. At present, engineers who describe their designs in Matlab at high level use a variety of different routes to executable, verified code; the main feature of these wholly or partially manual methods is that the algorithm designer hands off his work – in Matlab – to another engineer who will re-code the algorithms in C or C++. As well as capturing, the literal content of the Matlab, the coder will also be expressing the intent that the algorithm embodied in the Matlab, and the C/C++ compiler will apply optimisations. The coding process typically yields a variety of outputs such as the executable code, documentation, and library files. Matlab provides for placing the output C code within a wrapper (the “MEX” format) which the native Matlab then re-executes, to verify that its functionality reproduces the original intent.
In Matlab Coder, the algorithm designer gains the facility to generate C or C++ directly without, according the MathWorks’ executives, having to acquire the skill set of a C-coder. There will still be a process of iteration and refinement, but the algorithm designer will accomplish this alone, using the MEX wrapper to verify that the code matches the original intent. The code is fully commented has complete traceability. The Coder product does not support the whole of Matlab – but it does cover “all that an algorithm designer would use to implement a design.” MATLAB Coder supports an extensive set of MATLAB language features for algorithm development, including built-in matrix math operators and dynamic array handling. Hundreds of operators, functions, and System objects are supported, including many advanced algorithms for DSP and communications.
According to the MathWorks’ spokesman, the product generates C as does a conventional compiler, by use of a proprietary intermediate format (Matlab itself is interpretive). The company’s related Simulink product also targets hardware description languages, but the company says that the output of the Coder product is limited to C/C++, “for now”.
You can use the tool set to prototype algorithms, taking them out of Matlab to runon a PC; or, you might use the compiler to build test benches. You can also implement software acceleration, running algorithmic code at compiled-C speeds; you might pre-compile inner-loop code and once verified, call that from an application that otherwise remained in Matlab. The package also assists with floating- to fixed-point conversion.
Along with the introduction of MATLAB Coder, MathWorks released Simulink Coder and Embedded Coder. These two new products simplify code generation for Simulink and Stateflow users by combining capabilities previously available in multiple MathWorks offerings. The new products incorporate Real-Time Workshop technology, and offer full code generation support for rapid prototyping, real-time testing, and production embedded system implementation with built-in links to embedded development environments.






 

Our Sponsors



Ads by Google