Generate block and Macro combination

In reply to mitesh.patel:

Hello,
i want to pass an argument to macro from generate block but getting an error. please find the code
define DATA_CHECK(intf,num,rem)\ MY_ASSERTION(data_intfo,ennumi,cntrremi)
generate
for(genvar i = 0; i< 31; i++)
begin
`MY_ASSERTION(i,(i/4),(i%4))
end
endgenerate
but getting compilation error as 'en
/4_o’ is not defined. but i want for i = 2 en_0_i and cntr_2_i. as MY_ASSERTION Macro
Is there any solution for above issue.
Thanks in advance.
Mitesh N Patel

I don’t think that you can use macro for this purpose. The macro will replace ‘num’ by exactly string ‘i/4’ (instead of i/4 value), therefore you will get error because ‘en_i/4_o’ is not defined. If you want to use this macro, you have to call `DATA_CHECK for every value of i:


`DATA_CHECK(0, 0, 0);
`DATA_CHECK(1, 0, 1);
`DATA_CHECK(2, 0, 2);
...

otherwise please find other ways.