Testing TLM Components
TLM Component Test Bench Overview
The test bench generation option is controlled by the TLM Testbench tab of the Configuration Parameters dialog box. This option creates a standalone SystemC™ test bench for the generated component. The test bench works by applying test vectors against the generated TLM component and checking the results of each transaction. When you click the Verify TLM Component button on the TLM Testbench tab, the test vectors are automatically captured from a Simulink® simulation of your model .
You can configure the generated test bench to specify the timing mode and the triggering modes for input and output buffering. The latter choice allows you to indicate whether the initiator module controls moving input and output data sets between the registers and the buffers or whether the component performs the moves automatically. Optionally, the test bench can also produce verbose messages at runtime to help you see the status of the SystemC simulation.
This feature requires the ASIC Testbench for HDL Verifier add-on.
A TLM test bench is not supported when you generate a component for a host with a different operating system from your MATLAB® machine.
TLM Component Compilation
The TLM Compilation tab in the Configuration Parameters dialog box provides SystemC and TLM library location information. You can use environment variables to specify these locations.
The information you provide is used to construct makefile. You can use these makefiles to build the component and test bench. You can also use this makefile to build an executable of the TLM component and test bench outside of the MATLAB environment.
Automatic Verification of the Generated Component
The TLM Testbench tab of the configuration parameters provides a Verify TLM Component button that:
Automatically generates input stimulus and expected output data
Builds and executes the component and the test bench together
Automatically checks the outputs of the component
It performs the checking by capturing the outputs from the SystemC simulation, converting them to Simulink data, and comparing them in Simulink to the results of the Simulink simulation.
The tlmgenerator target supplies an HTML document containing details about the generated component. The document contains links to the generated source code files. Report generation can be configured via the Simulink Coder™ Report pane in the configuration parameters. Report generation is not strictly a test bench feature, but the process does include use of test bench files.
Working with Configurations
After you select configuration options, you can save them with your Simulink model. You can also restore saved configurations made in a previous session. In addition, you can save and choose from multiple configurations for a given model. See the section "Overview of Model Referencing" in the Simulink documentation. for information on working with configurations.
Considerations When Creating a TLM Component Test Bench
For optimizing your generated TLM code and achieving the desired test bench, you should keep the following considerations in mind when developing your Simulink model:
Your model can use only a single rate.
The composite signals on your model must be contiguous in memory. You can make mux and bus output signals contiguous with the Signal Conversion block.
If your model contains complex signals, you must split them first. Split complex signals with the Simulink Complex to Real-Imag block. You can then combine the signals again with the Real-Imag to Complex block on the other side of your design.
Your design can contain a Triggered or Enabled subsystem, but the design you generate cannot itself be a Triggered or Enabled subsystem.
HDL Verifier™ can generate a Simulink design that involves continuous time signals. When the Simulink simulation and the captured vector replay in SystemC, they may not yield exactly the same results. The plot of the difference reveals essentially the same curve with numerical differences that are more pronounced at signal transitions, as shown in the following MATLAB Figure windows.
This difference occurs because the Simulink signal capture necessarily makes the signals discrete and thus the same exact data is not used in both the Simulink and stand-alone SystemC simulations. You can improve the fidelity of the discrete signal simulation in SystemC by choosing a smaller fundamental step size in Simulink before clicking Verify TLM Component.