// normalize_mult.sv
// This module normalizes a 48-bit mantissa product and adjusts the exponent accordingly.
// It also extracts the guard and sticky bits for IEEE-754 rounding.

module normalize_mult (
    input  logic [47:0] mantissa_in,     // Input mantissa (product of 24-bit x 24-bit)
    input  logic [9:0]  exponent_in,     // Input exponent (after bias adjustment)
    output logic [22:0] mantissa_out,    // Normalized 23-bit mantissa
    output logic [9:0]  exponent_out,    // Adjusted exponent after normalization
    output logic        guard_bit,       // Guard bit for rounding
    output logic        sticky_bit       // Sticky bit for rounding
);

    logic [47:0] mant_shifted;
    logic [5:0]  shift_amount;
    logic [9:0]  exponent_adj;
    logic sticky;


    always_comb begin
        if (mantissa_in[47] == 1'b1) begin
            exponent_out = exponent_in + 1;
            mantissa_out = mantissa_in[46:24];
            guard_bit    = mantissa_in[23];
            sticky_bit   = | mantissa_in[22:0];
        end
        else begin
            exponent_out = exponent_in;
            mantissa_out = mantissa_in[45:23];
            guard_bit    = mantissa_in[22];
            sticky_bit   = | mantissa_in[21:0];
        end
    end
endmodule

