cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
zwabbit
Explorer
Explorer
696 Views
Registered: ‎12-02-2012

Initialization of typed parameter struct

Jump to solution

So I have something akin to the following.

 

 

typedef struct {
  logic [7:0] cfg_val
} cfg_t;

 

 

And I'm trying to use it for a parameter and initialize it to default values like so.

 

 

parameter cfg_t cfg_param = '{cfg_val:8'hAB};

 

 

All well and good so far. When I attempt to use a constant variable or macro however, like so.

 

 

const logic [7:0] CFG_CONST = 8'hAB;

parameter cfg_t cfg_param = '{cfg_val:CFG_CONST};

 

 

This does not work in Vivado 2019.2 and I get an error claiming that CFG_CONST is not a constant. Am I doing something wrong here, or does Vivado just not support using a non-literal in an initialization list?

0 Kudos
1 Solution

Accepted Solutions
pulim
Xilinx Employee
Xilinx Employee
655 Views
Registered: ‎02-16-2014

Hi @zwabbit 

const is a run-time constant not an elaboration constant.

Use parameter instead const and it should work fine.

parameter logic [7:0] CFG_CONST = 8'hAB;
parameter cfg_t cfg_param1 = '{cfg_val:CFG_CONST};

Thanks,

Manusha

View solution in original post

Tags (1)
0 Kudos
2 Replies
pulim
Xilinx Employee
Xilinx Employee
656 Views
Registered: ‎02-16-2014

Hi @zwabbit 

const is a run-time constant not an elaboration constant.

Use parameter instead const and it should work fine.

parameter logic [7:0] CFG_CONST = 8'hAB;
parameter cfg_t cfg_param1 = '{cfg_val:CFG_CONST};

Thanks,

Manusha

View solution in original post

Tags (1)
0 Kudos
zwabbit
Explorer
Explorer
609 Views
Registered: ‎12-02-2012

Hmm, alright. Probably going to have to put the parameters elsewhere though, since it would defeat the purpose of having a parameter initialize another parameter in the same module in my use case.

0 Kudos