Jump to content

Generate if - For construct.


Sandeep I

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...