HDL Coder Generic parameters

8 ビュー (過去 30 日間)
Ander Albizu
Ander Albizu 2021 年 3 月 11 日
コメント済み: Shomit Dutta 2021 年 3 月 19 日
Good morning, I have a single doubt about generics. I continue the next steps to achieve that the HDL Coder generates generic parameter.
  1. Set "Generate parameterized HDL code from masked subsystem" active in the configuration
  2. Set the subsystem like atomic
  3. Create a mask
  4. Generate a Simulink Parameter in the base workspace
myParam = Simulink.Parameter;
myParam.CoderInfo.StorageClass = 'ExportedGlobal';
myParam.Value = 2;
myParam.Min = 1;
myParam.Max = 3;
myParam.DataType = 'uint32';
myParam.CoderInfo.Identifier = 'D_SENSING_DSP_MIDDLE_TS';
Finally I set the myParam in the Mask value.
With this 5 steps I get the generic parameter (Ander) like you can see in the file:
ARCHITECTURE rtl OF invInverterModulations IS
340
341 -- Component Declarations
342 COMPONENT invSubsystem
343 GENERIC( Ander : integer
344 );
345 PORT( clk : IN std_logic;
346 Clk_resetx : IN std_logic;
347 enb : IN std_logic;
348 dsp_control : IN std_logic_vector(31 DOWNTO 0); --
But the problem is that then the HDL Coder set the value of myParam.Value to the Generic Parameter:
BEGIN
427 u_Subsystem : invSubsystem
428 GENERIC MAP( Ander => 2
429 )
430 PORT MAP( clk => clk,
431 Clk_resetx => Clk_resetx,
432 enb => clk_enable,
433 dsp_control => DspControl, -- uint32
434 dsp_half_period => DspHalf_Period, -- uint32
435 dsp_dx => DspDx, -- uint32
436 dsp_dy => DspDy, -- uint32
My idea is to set the Value of Ander outside of this code, because this is a component that we want to use with different Ander values and we want to avoid the code generation for each Ander values. Is this possible? Or it is imposible to generate code depending in the identifier? I know that this is possible in embedded coder but in HDL coder?
I atach the Top Level file.
Thank you

採用された回答

Shomit Dutta
Shomit Dutta 2021 年 3 月 16 日
If you want to adjust model behavior using tunable parameters during HDL simulation, please check the usage described in the following page:
Hope, the above meet your requirements. Generics are useful for resuability when you have multiple instantitations of an atomic subystem inside a DUT and HDL Coder generates single resuable HDL module or entity.
  2 件のコメント
Ander Albizu
Ander Albizu 2021 年 3 月 17 日
Thank you for your answer Shomit Dutta, but in your link "myParam" value is set like an input. I need to define it like a generic parameter because I have a model that sometimes will have a CYCLE_MAX value set to 60 and the identical model sometimes is going to work with 40 value. Nowadays I have to generate the code 2 times, when the functionality of the model is the same.
With a generic parameter I will have a model that sometimes will work with 40 and in other cases with 60. My idea is to generic a "configuration" parameter defined as Generic and then set the value of this variable outside.
Shomit Dutta
Shomit Dutta 2021 年 3 月 19 日
If you are using "Generate parameterized HDL code from masked subsystem" option, please note that the HDL code has to be bit true to the original Simulink model for verification usecases. As per design, the generic parameter can be supported only for subsystems inside DUT and not at the top DUT subsystem.
You can manually modify the generic values if it is verifying the functionality different than the original Simulink model.

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by