`timescale 1us/1ns
`include "fpu_2.v"
module fpu_bench;
reg[63:0] float1, float2, float_out;
reg[31:0] input1, input2;
reg add = 1'b0;
wire[31:0] fpu_output;
fpu_2 fpu0 (add,input1, input2, fpu_output);
initial begin
input1=32'b01000011000111001100110011001101; // 2.45
input2=32'b00111001001001100110011001100110; //.65
#5;
float1={input1[31],input1[30],{3{~input1[30]}},input1[29:23],input1[22:0], {29{1'b0}}};
float2={input2[31],input2[30],{3{~input2[30]}},input2[29:23],input2[22:0], {29{1'b0}}};
float_out={fpu_output[31],fpu_output[30],{3{~fpu_output[30]}},fpu_output[29:23],fpu_output[22:0], {29{1'b0}}};
$display("\nSum: %f + %f = %f", $bitstoreal(float1),$bitstoreal(float2), $bitstoreal(float_out));
input1=32'b01000100000111001110111011001101; // 2.45
input2=32'b10111111001000100110011001100110; //.65
#5;
float1={input1[31],input1[30],{3{~input1[30]}},input1[29:23],input1[22:0], {29{1'b0}}};
float2={input2[31],input2[30],{3{~input2[30]}},input2[29:23],input2[22:0], {29{1'b0}}};
float_out={fpu_output[31],fpu_output[30],{3{~fpu_output[30]}},fpu_output[29:23],fpu_output[22:0], {29{1'b0}}};
$display("\nSum: %f + %f = %f", $bitstoreal(float1),$bitstoreal(float2), $bitstoreal(float_out));
input1=32'b11000110000111001100110110001101; // 2.45
input2=32'b00111111001001100110011001100110; //.65
#5;
float1={input1[31],input1[30],{3{~input1[30]}},input1[29:23],input1[22:0], {29{1'b0}}};
float2={input2[31],input2[30],{3{~input2[30]}},input2[29:23],input2[22:0], {29{1'b0}}};
float_out={fpu_output[31],fpu_output[30],{3{~fpu_output[30]}},fpu_output[29:23],fpu_output[22:0], {29{1'b0}}};
$display("\nSum: %f + %f = %f", $bitstoreal(float1),$bitstoreal(float2), $bitstoreal(float_out));
input1=32'b10111111000111001100110011001101; // 2.45
input2=32'b11000011001001100110001001100110; //.65
#5;
float1={input1[31],input1[30],{3{~input1[30]}},input1[29:23],input1[22:0], {29{1'b0}}};
float2={input2[31],input2[30],{3{~input2[30]}},input2[29:23],input2[22:0], {29{1'b0}}};
float_out={fpu_output[31],fpu_output[30],{3{~fpu_output[30]}},fpu_output[29:23],fpu_output[22:0], {29{1'b0}}};
$display("\nSum: %f + %f = %f", $bitstoreal(float1),$bitstoreal(float2), $bitstoreal(float_out));
add = 1'b1;
input1=32'b01000011000111001100110011001101; // 2.45
input2=32'b00111001001001100110011001100110; //.65
#5;
float1={input1[31],input1[30],{3{~input1[30]}},input1[29:23],input1[22:0], {29{1'b0}}};
float2={input2[31],input2[30],{3{~input2[30]}},input2[29:23],input2[22:0], {29{1'b0}}};
float_out={fpu_output[31],fpu_output[30],{3{~fpu_output[30]}},fpu_output[29:23],fpu_output[22:0], {29{1'b0}}};
$display("\nSum: %f - %f = %f", $bitstoreal(float1),$bitstoreal(float2), $bitstoreal(float_out));
input1=32'b01000100000111001110111011001101; // 2.45
input2=32'b10111111001000100110011001100110; //.65
#5;
float1={input1[31],input1[30],{3{~input1[30]}},input1[29:23],input1[22:0], {29{1'b0}}};
float2={input2[31],input2[30],{3{~input2[30]}},input2[29:23],input2[22:0], {29{1'b0}}};
float_out={fpu_output[31],fpu_output[30],{3{~fpu_output[30]}},fpu_output[29:23],fpu_output[22:0], {29{1'b0}}};
$display("\nSum: %f - %f = %f", $bitstoreal(float1),$bitstoreal(float2), $bitstoreal(float_out));
input1=32'b11000110000111001100110110001101; // 2.45
input2=32'b00111111001001100110011001100110; //.65
#5;
float1={input1[31],input1[30],{3{~input1[30]}},input1[29:23],input1[22:0], {29{1'b0}}};
float2={input2[31],input2[30],{3{~input2[30]}},input2[29:23],input2[22:0], {29{1'b0}}};
float_out={fpu_output[31],fpu_output[30],{3{~fpu_output[30]}},fpu_output[29:23],fpu_output[22:0], {29{1'b0}}};
$display("\nSum: %f - %f = %f", $bitstoreal(float1),$bitstoreal(float2), $bitstoreal(float_out));
input1=32'b10111111000111001100110011001101; // 2.45
input2=32'b11000011001001100110001001100110; //.65
#5;
float1={input1[31],input1[30],{3{~input1[30]}},input1[29:23],input1[22:0], {29{1'b0}}};
float2={input2[31],input2[30],{3{~input2[30]}},input2[29:23],input2[22:0], {29{1'b0}}};
float_out={fpu_output[31],fpu_output[30],{3{~fpu_output[30]}},fpu_output[29:23],fpu_output[22:0], {29{1'b0}}};
$display("\nSum: %f - %f = %f", $bitstoreal(float1),$bitstoreal(float2), $bitstoreal(float_out));
$finish;
end
endmodule