[SOLVED] System Verilog conditional parameter

Status
Not open for further replies.

shparekh

Newbie
Joined
Mar 5, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
Hi,

I have a following statement in my code -

Code:
genvar sliteIfIter_grp1
generate for (  sliteIfIter_grp1=0;
                  sliteIfIter_grp1<MAX_SLITE_GRP1;
                  sliteIfIter_grp1+=1)

The psuedo code to assign MAX_SLITE_GRP1 is

Code:
 if (SLITE_NUM > 4)
   localparam MAX_SLITE_GRP1 = 4
 else
   localparam MAX_SLITE_GRP1 = SLITE_NUM

SLITE_NUM is a parameter which can be overridden at the time instantiating the block.

Can you please suggest how I can write this in system verilog?

Thanks.
Best regards,
SP
 

Code:
localparam MAX_SLITE_GRP1 = (SLITE_NUM>4)? 4 : SLITE_NUM;
and the same generate block, or
Code:
genvar sliteIfIter_grp1;
for (  sliteIfIter_grp1=0;
                  sliteIfIter_grp1<( (SLITE_NUM>4)? 4 : SLITE_NUM);
                  sliteIfIter_grp1++)
 

Super. I knew there had to be a way.
Thx.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…