Sandeep I Posted July 12, 2018 Share Posted July 12, 2018 Can we declare Generate if-for statement? module prac#(parameter m=3) (input x, input[2:0]a,b,output[2:0]c); wire [2:0]f[0:3]; genvar i; generate if(!x) begin : d2 for(i=0;i<=m;i=i+1) begin:dd assign f=(a & b); end end endgenerate endmodule It is saying that 'x' is not a constant. Thanks in advance. Link to comment Share on other sites More sharing options...
D@n Posted July 12, 2018 Share Posted July 12, 2018 @Sandeep I, Try reversing the if and the for. See this article for a description of the realities of generate statements. The statements you are creating while using them are not like software if and for statements, Dan Link to comment Share on other sites More sharing options...
xc6lx45 Posted July 12, 2018 Share Posted July 12, 2018 I guess the question was already answered...anyway, here's a quick example that works correctly in Vivado, within a module...endmodule context: genvar j; generate for (j = 2; j <= NWRDELAY; j = j + 1) begin always @(posedge i_clk) begin wa[j] <= wa[j-1]; wd[j] <= wd[j-1]; we[j] <= we[j-1]; end end endgenerate Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.