Sign in to follow this  
Sandeep I

Generate if - For construct.

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.

 

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this