Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Multiple Constant Driver Error

Hi all,

I am trying to implement a full adder with generate-endgenerate approach.

But I got a error message("Error (10028): Can't resolve multiple constant drivers for net "cout" at fulladder.v(33)"), and there seems to be something wrong with my code in line "cout=(a&b)|(a&c[i-1])|(b&c[i-1]);"

Anyone can help me out of this...? Thanks in advance:)


module fulladder# (parameter width=4)
(output reg  sum,
 output reg cout,neg,overflow,
 input  a,b,
 input cin);
 
reg  c;
generate
  genvar i;
  for(i=0;i<=width-1;i=i+1)begin:stage
    case(i)
    0:begin
        always@(*)begin
        sum=a^b^cin;
        c=(a&b)|(a&cin)|(b&cin);
        end
      end
      
    width-1:begin
              always@(*)begin
                sum=a^b^c;
                cout=(a&b)|(a&c)|(b&c);
                neg=sum;
                overflow=cout^c;
              end
            end
     
    default:begin
              always@(*)begin
                sum=a^b^c;
                cout=(a&b)|(a&c)|(b&c);
              end
            end
    endcase
  end
endgenerate
endmodule

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The implementation is incorrect. You would want to assign c[i] instead of cout in case default