I have a code where I am using recursion,
module mult(a,b,c)
generate
always @(*) begin
/* a few calculations */
if(x < 10)
flag = 1;
else
flag = 0;
end
if( flag == 1)
mult(x,y,z);
else
z = x*y;
endgenerate
endmodule
However, this code returns an error saying that flag is not a constant. I understand that one cannot use an if-else outside the always block, by using registers or wires or integers. However, is there any other way I can implement the code?
Recursion seems to work only in a generate block but outside the always block.