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.
Solver options that are recommended or required for HDL code generation:
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.
hdlsetupconfigures the following Diagnostics / Sample time options for all models:
Multitask data transfer:
Single task data transfer:
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
errorto detect illegal rate transitions before code is generated.
To learn more about the settings that
see Check for model parameters suited for HDL code generation.
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:
Unit Delay Enabled
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.