`timescale 1ns/1ps

module normalize_mult_tb;

    logic [47:0] mantissa_in;
    logic [9:0]  exponent_in;
    logic [22:0] mantissa_out;
    logic [9:0]  exponent_out;
    logic guard_bit, sticky_bit;

    normalize_mult dut (
        .mantissa_in(mantissa_in),
        .exponent_in(exponent_in),
        .mantissa_out(mantissa_out),
        .exponent_out(exponent_out),
        .guard_bit(guard_bit),
        .sticky_bit(sticky_bit)
    );

    initial begin

        integer i;
        logic [47:0] mantissa_inputs [13];
        logic [9:0]  exponent_inputs [13];
        logic [22:0] exp_mantissas [13];
        logic [9:0]  exp_exponents [13];
        string       exp_grs [13];

        $display("Starting normalize_mult test...\n");

        mantissa_inputs[0] = 48'h800000000000; exponent_inputs[0] = 130; exp_mantissas[0] = 23'h400000; exp_exponents[0] = 131; exp_grs[0] = "0,0";
        mantissa_inputs[1] = 48'h400000000000; exponent_inputs[1] = 130; exp_mantissas[1] = 23'h400000; exp_exponents[1] = 130; exp_grs[1] = "0,0";
        mantissa_inputs[2] = 48'h200000000000; exponent_inputs[2] = 130; exp_mantissas[2] = 23'h400000; exp_exponents[2] = 129; exp_grs[2] = "0,0";
        mantissa_inputs[3] = 48'h000040000000; exponent_inputs[3] = 130; exp_mantissas[3] = 23'h400000; exp_exponents[3] = 114; exp_grs[3] = "0,0";
        mantissa_inputs[4] = 48'h000000000F00; exponent_inputs[4] = 130; exp_mantissas[4] = 23'h780000; exp_exponents[4] =  95; exp_grs[4] = "0,0";
        mantissa_inputs[5] = 48'h000000000000; exponent_inputs[5] = 130; exp_mantissas[5] = 23'h000000; exp_exponents[5] = 130; exp_grs[5] = "0,0";
        mantissa_inputs[6] = 48'h400000000080; exponent_inputs[6] = 130; exp_mantissas[6] = 23'h400000; exp_exponents[6] = 130; exp_grs[6] = "0,1";
        mantissa_inputs[7] = 48'h4000000000C0; exponent_inputs[7] = 130; exp_mantissas[7] = 23'h400000; exp_exponents[7] = 130; exp_grs[7] = "0,1";
        mantissa_inputs[8] = 48'h400000000089; exponent_inputs[8] = 130; exp_mantissas[8] = 23'h400000; exp_exponents[8] = 130; exp_grs[8] = "0,1";
        mantissa_inputs[9] = 48'h4000000000FF; exponent_inputs[9] = 130; exp_mantissas[9] = 23'h400000; exp_exponents[9] = 130; exp_grs[9] = "0,1";
        mantissa_inputs[10]= 48'h400000800000; exponent_inputs[10]= 130; exp_mantissas[10]=23'h400000; exp_exponents[10]=130; exp_grs[10]= "1,0";
        mantissa_inputs[11]= 48'h400000C00000; exponent_inputs[11]= 130; exp_mantissas[11]=23'h400000; exp_exponents[11]=130; exp_grs[11]= "1,1";
        mantissa_inputs[12]= 48'h800000000001; exponent_inputs[12]= 130; exp_mantissas[12]=23'h400000; exp_exponents[12]=131; exp_grs[12]= "0,1";

        for (i = 0; i < 13; i++) begin
            mantissa_in = mantissa_inputs[i];
            exponent_in = exponent_inputs[i];

            #10;
            $display("[%0d] IN=%h | EXPECTED: OUT=%h EXP=%0d (G,S)=(%s) | OUT=%h EXP=%0d  (G,S)=(%b,%b)",
                     i+1,
                     mantissa_in,
                     exp_mantissas[i],
                     exp_exponents[i],
                     exp_grs[i],
                     mantissa_out,
                     exponent_out,
                     guard_bit, sticky_bit
            );
        end

        $display("\nFinished normalize_mult test.");
        $stop;
    end

endmodule

