Define global constant for HDL Coder

3 views (last 30 days)
Pham Dang
Pham Dang on 18 Nov 2015
Answered: Kiran Kintali on 1 Nov 2020
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 ?

Answers (1)

Kiran Kintali
Kiran Kintali on 1 Nov 2020
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

Products

Community Treasure Hunt

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

Start Hunting!