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.
Tasking mode: Must be explicitly
set to SingleTasking
. Do not set Tasking
mode to Auto
.
hdlsetup
configures the following Diagnostics / Sample
time options for all models:
Multitask rate transition: error
Single task rate transition: 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 rate transition and Single
task rate transition to error
to
detect illegal rate transitions before code is generated.
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.
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.