CMP EMBEDDED.COM

Login | Register     Welcome Guest  
HOME DESIGN PRODUCTS COLUMNS E-LEARNING CONFERENCES CODE FORUMS/BLOGS NEWSLETTERS CONTACT FEATURES RSS RSS

Automating the generation of code



Embedded.com

The MathWorks Real-Time Workshop Embedded Coder version 2 enablesthe generation, test, and deployment of highly efficient production C code for use in real-time embedded systems. Central to the tool is a concise code format with minimal memory and computational requirements.

The generated code ROM and RAM size and execution speed are comparable to optimized, hand-written C code. Real-Time Workshop Embedded Coder provides a reduction in development time while increasing reliability. It also enables customization, documentation, test, and validation of the generated code, all within the Simulink environment.

It is fully compatible with Stateflow and Stateflow Coder. It generates code for discrete-time Simulink models and includes comments and tags that link code segments back to the block diagram. Symbol names and function boundaries can be preserved to increase readability. It can be configured either for use with legacy code and calibration systems or to generate code for an entire project.

Often when designing for implementation on microcontrollers, DSPs, or other production CPUs beyond the scope of rapid prototyping and hardware-in-the-loop systems, additional design considerations become necessary. The tool extends the model-based design capabilities of Simulink, Stateflow, and Real-Time Workshop by adding a software engineering dimension to Simulink, specifically for deploying complex embedded systems.

The embedded real-time (ERT) code format produces C code optimized for minimal RAM and ROM usage and high CPU throughput. This differs from standard Real-Time Workshop code formats, which can include additional overhead to support continuous-time systems, signal viewing, and other rapid prototyping-specific debugging features.

Embedded Coder's ERT code format removes these facilities to achieve the smallest footprint possible for the generated code. ERT supports single-, multi-, and asynchronous rates, as well as single tasking and multitasking. A model generated with the ERT code format can represent a stand-alone application or a component feature in a larger system.

In a single operation, the tool generates code for a specified subsystem block in a model, and automatically creates an associated Simulink S-function. This allows importation of the generated code back into Simulink for validation with the plant model. Using the new block as a direct replacement for the original controller subsystem, closed-loop simulations can be run to validate the simulation performance of the code to be deployed. This step is typically used for unit testing prior to running generated code on a chosen microcontroller.

HTML code generation reporting

Real-Time Workshop Embedded Coder creates a comprehensive HTML code generation report. This report describes code modules and identifies optimizations applied during code generation for a model. A summary section includes version, date, and options used during code generation. When selected options result in non-optimal code, further code optimizations that are available are highlighted. This is an indication that applying the noted optimizations can further improve code efficiency. Another section includes a table of generated source files. When viewed in the MATLAB Help browser, hyperlinks in the source files link to the relevant blocks in the model, making the code extremely traceable.

There is a flexible environment that gives control over the generated code. Control is provided for variable naming, data types, storage class, and other attributes of parameters and signals using the Simulink Data Class Designer to create Simulink data objects.

In production or fast-turnaround development environments, it is essential to be able to read, understand, and customize the generated code. To do this the tool allows the control of function boundaries, preservation of expressions, and application of optimizations on multiple blocks for further reductions in code size. Each of these features enables the adjustment of the style, structure, and size of the generated code. The origin of the generated code can be traced to blocks and signals in the model.

High-level coding optimizations that are often difficult to apply during manual coding can also be used. Custom blocks can be added as inlined S-functions or wrapper-style S-functions that are typically used for developing a custom library of I/O device drivers.

With the ERT code format, further reductions in code size can be achieved by eliminating initialization and shutdown code that may be unnecessary for a particular application.

Real-Time Workshop Embedded Coder supports Simulink discrete-time blocks, Stateflow, and blocks from the Fixed-Point Blockset. Simulink continuous-time blocks are not supported.

To use the tool, Matlab 6.1, Simulink 4.1, Real-Time Workshop 4.1 are required as well as a host platform C compiler (Microsoft Visual C/C++ or Watcom C/C++), and a cross-compiler for the target processor.

Stateflow Coder 4.1 is also required when generating code for Simulink models containing Stateflow charts.


First Embedded Coder add-on targets MPC555

The Embedded Target for Motorola MPC555 is an add-on product for use with the Real-Time Workshop Embedded Coder. It provides a complete and unified set of tools for developing embedded applications for the Motorola MPC555 processor.

This tool will accelerate embedded product development on the MPC555 platform by providing the ability to test, analyse and refine automatically generated code from The MathWorks Real-Time Workshop Embedded Coder directly on the microcontroller.

Prior to Embedded Target for Motorola MPC555, designing with 32-bit microcontrollers could be a lengthy process. Engineers could spend three months or more developing code suitable for use on the MCU The MathWorks says it now takes only minutes to automatically generate the code, download it, and get it running on a third-party evaluation board.

Embedded Target for MPC555 allows users to perform several additional functions that provide all the pieces necessary for designers to deploy their code.

These functions include:

Processor-in-the-loop co-simulation, which provides engineers with the ability to evaluate software running on the processor;

Mid- to late-cycle design, analysis and refinement for production microcontrollers, which allows for the fine-tuning of algorithms and the ability to make feature enhancements to product designs currently in production, enabling users to avoid capital expenditures for generic target rapid prototyping tools; and

Application deployment, which provides initialisation and driver software for the MPC555 processor, allowing the application to run either on an evaluation board or on hardware that will be used in production.


Published in Embedded Systems (Europe) June 2002

1

Rate this article: Low High
Current rating
  • .
Embedded.com Career Center
Looking for a new job?
SEARCH JOBS

Browse all jobs

SPONSOR
RECENT JOB POSTINGS





 :