You can use the Communications System Toolbox™, Simulink® Coder™, and Embedded Coder® products together to generate code that you can use to implement your model for a practical application. For instance, you can create an executable from your Simulink model to run on a target chip. This chapter introduces you to the basic concepts of code generation using these tools. For more information on code generation, see Select and Configure Compiler or IDE.
In general, the code you generate from Communications System Toolbox blocks is portable ANSI® C code. After you generate the code, you can deploy it on another machine. For more information on how to do so, see Relocate Code to Another Development Environment in the Simulink Coder documentation.
There are a few Communications System Toolbox blocks that generate code with limited portability. These blocks use precompiled shared libraries, such as DLLs, to support I/O for specific types of devices and file formats. To find out which blocks use precompiled shared libraries, open the Communications System Toolbox Block Support Table.
Simulink Coder provides functions to help you set up
and manage the build information for your models. For example, one
of the Build Information Methods that Simulink Coder provides
getNonBuildFiles. This function
allows you to identify the shared libraries required by blocks in
your model. If your model contains any blocks that use precompiled
shared libraries, you can install those libraries on the target system.
The folder that you install the shared libraries in must be on the
system path. The target system does not need to have MATLAB® installed,
but it does need to be supported by MATLAB.
Communications System Toolbox blocks generate highly optimized ANSI C code. This C code is often suitable for embedded applications, and includes the following optimizations:
Function reuse (run-time libraries) — The generated code reuses common algorithmic functions via calls to shared utility functions. Shared utility functions are highly optimized ANSI/ISO C functions that implement core algorithms such as FFT and convolution.
Parameter reuse (Simulink Coder run-time parameters) — In many cases, if there are multiple instances of a block that all have the same value for a specific parameter, each block instance points to the same variable in the generated code. This process reduces memory requirements.
Blocks have parameters that affect code optimization — Various blocks, such as the FFT and Sine Wave blocks, have parameters that enable you to optimize the simulation for memory or for speed. These optimizations also apply to code generation.
Other optimizations — Use of contiguous input and output arrays, reusable inputs, overwritable arrays, and inlined algorithms provide smaller generated C code that is more efficient at run time.