My desired functionality will be to add A, B, and cin (where A and B are 64 bits, and cin is one bit). So the actual sum (the actual result) can either be 64 bits or even 65 bits, right? So I want the output "sum" to be 64 bits, and then the carryout output "cout" would hold the most significant bit of the result. Tried doing this by an assign
statement, but I guess that's not how you do it as it gives an error. Any other way?
module addsub(A, B, cin, sum, cout);
input [63:0] A, B;
input cin;
output reg [63:0] sum;
output cout;
reg [64:0] actualsum; // the actual result of the addition, which I want to then "split" into cout & sum
always @(A or B or cin) begin
actualsum = A + B + cin;
sum <= actualsum[63:0];
cout <= actualsum[64];
end
endmodule