Is it possible to generate HDL code (VHDL) of a Simulink variant reference model in a way that the "active variant" is selectable through VHDL generics?

1 view (last 30 days)
In MATLAB documentation for variant subsystem/model it is stated that "HDL Coder generates code for only the active variant". I want to generate HDL code once for all variants of my model, so not only for the active variant but for all of them and select the active variant with a VHDL generic. Is that possible?
Another way to reach my goal would be in instructing HDL Coder to generate a single VHDL entity with two or more VHDL architectures where each architecture is a variant of the model (the selection of the architecture could than be made through filelist or through VHDL-configuration construct). Is that second option possible?

Accepted Answer

Kiran Kintali
Kiran Kintali on 7 Oct 2020
HDL Coder compiles away all the inactive variants and generates code only for the active variant. Can you share a sample model and expected generated HDL code for the model? We would like to know how you switch between the variants after all variants are generated.
  1 Comment
Martin Roy
Martin Roy on 7 Oct 2020
I would expect a solution where a wrapper (modx_wrapper) would select the proper architecture of modx through a generic (IMPLEMENTATION_ID). There would be a single VHDL entity definition of modx but many architecture definitions (modx_arch_0, modx_arch_1), where each architecture corresponds to a variant of the model. Here is an example:
entity modx_wrapper is
generic(
IMPLEMENTATION_ID : natural;
);
port(
...
);
end modx_wrapper;
architecture rtl of modx_wrapper is
:
if (IMPLEMENTATION_ID = 0) generate -- First variant
modx_inst : entity component_lib.modx(modx_arch_0)
port map (
...
);
end generate;
if (IMPLEMENTATION_ID = 1) generate -- Second variant
modx_inst : entity component_lib.modx(modx_arch_1)
port map (
...
);
end generate;
:
end rtl;

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!