1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
`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
|