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 Build and Edit a Model Interactively.
Create Model Using Wireless HDL Toolbox Model Template
Click the Simulink button, , or type
simulinkat the MATLAB® command prompt.
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
samplecontrolbus. You can design an HDL-targeted algorithm within
The templates also configure the model for HDL code generation. Both templates:
Configure solver settings equivalent to calling
Display data rates and data types in the Model Editor
Create an instance of
samplecontrolbusin the workspace (in
The simulation time, input data, and block parameters are defined in the callback
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
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.
InitFcn defines placeholder input frames and settings for
the Frame Input From Workspace, Frame To Samples, and
Samples To Frame blocks.
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
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
samplecontrolbus type, using the Sample Control Bus
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
The model has a single data rate because all signals in the model represent streaming samples.