Multirate Model Requirements for HDL Code Generation
Model Configuration Parameters
Before generating HDL code, configure the parameters of your model using the
hdlsetup
command. This sets up your multirate model for HDL
code generation. This section summarizes settings applied to the model by
hdlsetup
that are relevant to multirate code generation.
These include:
Solver options that are recommended or required for HDL code generation:
Type:
Fixed-step
.Solver:
Discrete (no continuous states)
. Other fixed-step solvers could be selected, but this option is usually best for simulating discrete systems.Treat each discrete rate as a separate task: Clear for single tasking mode.
hdlsetup
configures the following Diagnostics / Sample time options for all models:Multitask data transfer:
error
Single task data transfer:
error
In multirate models intended for HDL code generation, Rate Transition blocks must be explicitly inserted when blocks running at different rates are connected. Set Multitask data transfer and Single task data transfer to
error
to detect illegal rate transitions before code is generated.
To learn more about the settings that hdlsetup
configures,
see Check for model parameters suited for HDL code generation.
Sample Rate
HDL Coder™ requires that at least one valid sample rate (sample time > 0) must
exist in the model. If all rates are 0, –1, or –2, the
code generator (makehdl
) and compatibility checker
(checkhdl
) terminates with an error message.
Blocks To Use For Rate Transitions
Use Rate Transition blocks, rather than the following blocks, to create rate transitions in models intended for HDL code generation:
Delay
Tapped Delay
Unit Delay
Unit Delay Enabled
Zero-Order Hold
The Delay blocks listed should be configured to have the same input and output sample rates.
Zero-Order Hold blocks must be configured with inherited (-1) sample times.