I need to include a rather complex computation in a verilog macro. Can I use for loop in Macro definition? Below is given the example of my code
`define CLOGB2(depth) \
integer width \
for(width=0;depth>0;width=width+1) \
depth = depth >> 1; \
return width
module test #(parameter MEMDEPTH = 16)
(
// Input-output port declaration
);
parameter MEMWIDTH = `CLOGB2(MEMDEPTH);
$display("Calculated width : %d\n",MEMWIDTH);
...
...
endmodule
Will it work?