Define global constant for HDL Coder

5 次查看(过去 30 天)
Hi, I use the HDL Coder Toolbox to generate Verilog code from my Matlab code.
I would like to use a global constant variable in my Matlab code in order to hardcode some values some specific global parameters. I know Verilog has a `define directive for global constant definition but the HDL Coder Toolbox does not allow the use of global statement in Matlab code.
Let's say my Matlab source code is :
global NROW_MATLAB_CODE ;
NROW_MATLAB_CODE = 31 ;
for kRow=1:NROW_MATLAB_CODE
% Process
end
Any idea of how to tell HDL Coder to insert a specific code line like `define NROW 5'd31 and make it use the string NROW wherever the variable NROW_MATLAB_CODE is used ?

回答(1 个)

Kiran Kintali
Kiran Kintali 2020-11-1
Globals are not currently supported in HDL Coder. Use persistent variables instead.
Also see this example on how to
>> mlhdlc_demo_setup('comms_data_packet')
% Key design pattern covered in this example:
  1. Design illustrates the us of binary operands, such as bitxor
  2. Shows how to properly segment persistent variables for register an BRAM access
  3. Illustrates the use of fi math
  4. Shows how to properly format and store ROM data, e.g., padData
  5. Loading external data in the test bench

类别

Help CenterFile Exchange 中查找有关 Code Generation 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by