I want to design a ripple carry adder which will add n bit A and B number. Before adding I want to check whether any of the input is zero or not. If any value is zero, I want to return another input as output. My script is something similar to below-
module RCA #(parameter n=10) (input [n-1:0] A, input [n-1:0] B,output [n-1:0] R);
wire [n-1:0] r1;
wire [n:0] carry;
assign carry[0]=0;
genvar i;
generate
for (i=0;i<n;i=i+1) begin:ripple_block
FA fa(.a(p[i]),.b(q[i]),.s(r1[i]),.cout(carry[i+1]));
end
endgenerate
if (p==0) begin:a1
assign R=q;
end
if (q==0) begin:a2
assign R=p;
end
else begin:a3
assign R=r1;
end
endmodule
I am getting the error
"Elaboration time unknown or bad value encountered for generate if-statement condition
expression. Please make sure it is elaboration time constant."
Please help me find the error in the script.
Thanks Farhana