module M65C02_BIN(
    input   En,                 // ALU Enable

    input   [7:0] A,            // Adder Input A
    input   [7:0] B,            // Adder Input B
    input   Ci,                 // Adder Carry In
    
    output  reg [8:0] Out,      // Adder Sum <= A + B + Ci
    output  reg OV,             // Adder Overflow
    output  reg Valid           // Adder Outputs Valid
);

///////////////////////////////////////////////////////////////////////////////
//
//  Declarations
//

reg     [7:0] S;        // Intermediate Binary Sum: S <= A + B + Ci
reg     C6, C7;         // Sum Carry Out from Bitx 

///////////////////////////////////////////////////////////////////////////////
//
//  Implementation
//

//  Adder First Stage - Combinatorial; Binary Sums and Carries

always @(*)
begin
    // Binary Addition and Generate C6 and C7 Carries
    {C6, S[6:0]} <= ({1'b0, A[6:0]} + {1'b0, B[6:0]} + {7'b0, Ci});
    {C7,   S[7]} <= ({1'b0,   A[7]} + {1'b0,   B[7]} + {1'b0, C6});
end

always @(*)
begin
    Out   <= ((En) ? {C7, S}   : 0);
    OV    <= ((En) ? (C7 ^ C6) : 0);
    Valid <= En;
end

endmodule