how to use local parameter in HDL Coder toolbox?
Afficher commentaires plus anciens
Dear MATLAB Support Team,
I am currently working on developing an UART transmitter block in Simulink. Within this block, I require two parameters: CLOCK_FREQ and BAUD_RATE, which are essential for calculating the DIVIDER parameter, given by CLOCK_FREQ / BAUD_RATE.
While I have learned how to generate parameters using HDL Coder, I am facing confusion regarding the generation of the local parameter DIVIDER, which will be utilized within a counter block. I aim to produce Verilog code similar to the following:
- - - - - - - -
parameter BAUD_RATE = 9600;
parameter CLOCK_FREQ = 100000000;
localparam DIVIDER = CLOCK_FREQ / BAUD_RATE;
if (clk_divider == DIVIDER) begin
// Further implementation
end
- - - - - - - - -
However, the generated code I am obtaining differs:
- - - - - - - - - - - -
parameter integer BAUD_RATE = 9600;
parameter integer CLOCK_FREQ = 100000000;
assign DIVIDER_out1 = 32'b00000000000000000010100010110001;
- - - - - - - - - - -
How can I use BAUD_RATE and CLOCK_FREQ within the module to generate other parameters?
The Constant Block setting is as follows:

Réponses (1)
kiyoko
le 7 Mai 2024
0 votes
Unfortunately, HDL Coder does not support the generation of "localparam". "Generate Parameterized HDL Code for Constant and Gain Blocks" is only compatible with "parameter".
As an alternative, if you have custom HDL code, you can use the DocBlock block to integrate that custom HDL code into your design.
1 commentaire
SHIYU SONG
le 7 Mai 2024
Catégories
En savoir plus sur Get Started with HDL Coder dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!