Main Content

Configure the Simulink Environment for Hardware Design

About Simulink Model Templates

Simulink® model templates provide common configuration settings and best practices for new models. Instead of using the default canvas of a new model, select a template model to help you get started.

For more information on Simulink model templates, see Open Models.

Create Model Using Wireless HDL Toolbox Model Template

  1. Click the Simulink button, , or type simulink at the MATLAB® command prompt.

  2. On the Simulink start page, find the Wireless HDL Toolbox™ section, and click the Streaming Data from MATLAB or Framed Data from MATLAB template.

A new model, with the template contents and settings, opens in the Simulink Editor. Select Save to save the model.

Alternatively, you can create a new model from the template on the command line. For example:

new_system my_whdl_Fmodel FromTemplate whdl_framed_data.sltx
open_system my_whdl_Fmodel
new_system my_whdl_Smodel FromTemplate whdl_streaming_data.sltx
open_system my_whdl_Smodel

Wireless HDL Toolbox Model Templates

Both Wireless HDL Toolbox model templates include an empty subsystem, HDL Algorithm. This subsystem accepts and returns streaming data and accompanying control signals using the samplecontrolbus. You can design an HDL-targeted algorithm within this subsystem.

The templates also configure the model for HDL code generation. Both templates:

  • Configure solver settings equivalent to calling hdlsetup (HDL Coder)

  • Display data rates and data types in the Model Editor

  • Create an instance of samplecontrolbus in the workspace (in InitFcn)

The simulation time, input data, and block parameters are defined in the callback function, InitFcn. To view or edit this function, on the Modeling tab, expand Model Settings and click Model Properties, and then on the Callbacks tab, click InitFcn*.

Framed Data Template

The Framed Data from MATLAB template imports framed data from the MATLAB workspace, assuming all frames are the same size. Then, it converts the data to a sample stream by using the Frame To Samples block.

The output of the HDL Algorithm subsystem is connected to a Samples To Frame block. This block converts the output back to framed data for export to the MATLAB workspace.

The InitFcn defines placeholder input frames and settings for the Frame Input From Workspace, Frame To Samples, and Samples To Frame blocks.

The StopFcn applies the valid signal to the output data and creates a single variable in the workspace.

The model has one data rate for the framed data and a faster data rate for the sample stream. You can display these rates as different colors in the Simulink model.

Streaming Data Template

Use the Streaming Data from MATLAB template when your data stream has different-sized frames. The InitFcn defines placeholder input frames and uses the whdlFramesToSamples function to convert framed data to vectors of data and control signals. The From Workspace block imports these variables to the model.

To connect to the HDL Algorithm subsystem and any Wireless HDL Toolbox blocks that you add inside it, the model converts the control signals to the samplecontrolbus type, using the Sample Control Bus Creator block.

The model exports the streaming data and control signals back to the MATLAB workspace. The StopFcn uses the whdlSamplesToFrames function to convert them back to framed data.

The model has a single data rate because all signals in the model represent streaming samples.

See Also



Related Topics