1 |
6 |
davidklun |
|
2 |
|
|
`timescale 1ps / 1ps
|
3 |
8 |
davidklun |
module fpu_addsub_tb;
|
4 |
6 |
davidklun |
|
5 |
|
|
reg clk;
|
6 |
|
|
reg rst;
|
7 |
|
|
reg enable;
|
8 |
|
|
reg fpu_op;
|
9 |
8 |
davidklun |
reg [1:0]rmode;
|
10 |
6 |
davidklun |
reg [63:0]opa;
|
11 |
|
|
reg [63:0]opb;
|
12 |
|
|
wire [63:0]out;
|
13 |
8 |
davidklun |
wire ready;
|
14 |
6 |
davidklun |
|
15 |
|
|
|
16 |
8 |
davidklun |
fpu_addsub UUT (
|
17 |
6 |
davidklun |
.clk(clk),
|
18 |
|
|
.rst(rst),
|
19 |
|
|
.enable(enable),
|
20 |
|
|
.fpu_op(fpu_op),
|
21 |
8 |
davidklun |
.rmode(rmode),
|
22 |
6 |
davidklun |
.opa(opa),
|
23 |
|
|
.opb(opb),
|
24 |
|
|
.out(out),
|
25 |
|
|
.ready(ready));
|
26 |
|
|
|
27 |
|
|
initial
|
28 |
|
|
begin : STIMUL
|
29 |
8 |
davidklun |
#0
|
30 |
6 |
davidklun |
enable = 1'b0;
|
31 |
|
|
rst = 1'b1;
|
32 |
8 |
davidklun |
#10000;
|
33 |
|
|
enable = 1'b1;
|
34 |
|
|
rst = 1'b0;
|
35 |
|
|
opa = 64'b0100000000010001010110010001011010000111001010110000001000001100;
|
36 |
|
|
opb = 64'b0000110000000110111010010011111101011101101000101000001001001100;
|
37 |
|
|
fpu_op = 1'b0;
|
38 |
|
|
rmode = 2'b10;
|
39 |
|
|
#10000;
|
40 |
|
|
//inputA:1.6000000000e+001
|
41 |
|
|
//inputB:1.0000000000e-208
|
42 |
|
|
opa = 64'b0100000000110000000000000000000000000000000000000000000000000000;
|
43 |
|
|
opb = 64'b0001010011000000011100000001101111010101001001111011010010011000;
|
44 |
6 |
davidklun |
fpu_op = 1'b1;
|
45 |
8 |
davidklun |
rmode = 2'b10;
|
46 |
|
|
#10000;
|
47 |
|
|
//inputA:9.9999999996e-314
|
48 |
|
|
//inputB:4.6770000000e+000
|
49 |
|
|
opa = 64'b0000000000000000000000000000010010110110011010010101010000110010;
|
50 |
|
|
opb = 64'b0100000000010010101101010011111101111100111011011001000101101000;
|
51 |
|
|
fpu_op = 1'b1;
|
52 |
|
|
rmode = 2'b11;
|
53 |
|
|
#10000;
|
54 |
|
|
//inputA:5.3620000000e+003
|
55 |
|
|
//inputB:1.9999999999e-314
|
56 |
|
|
opa = 64'b0100000010110100111100100000000000000000000000000000000000000000;
|
57 |
|
|
opb = 64'b0000000000000000000000000000000011110001010010000100010000001010;
|
58 |
|
|
fpu_op = 1'b0;
|
59 |
|
|
rmode = 2'b10;
|
60 |
|
|
#10000;
|
61 |
|
|
//inputA:5.8000000000e+000
|
62 |
|
|
//inputB:5.7900000000e+000
|
63 |
|
|
opa = 64'b0100000000010111001100110011001100110011001100110011001100110011;
|
64 |
|
|
opb = 64'b0100000000010111001010001111010111000010100011110101110000101001;
|
65 |
|
|
fpu_op = 1'b1;
|
66 |
|
|
rmode = 2'b10;
|
67 |
|
|
#10000;
|
68 |
|
|
opa = 64'b0100000000010001010110010001011010000111001010110000001000001100;
|
69 |
|
|
opb = 64'b0000110000000110111010010011111101011101101000101000001001001100;
|
70 |
|
|
fpu_op = 1'b0;
|
71 |
|
|
rmode = 2'b00;
|
72 |
|
|
#10000;
|
73 |
|
|
//inputA:-9.4000000000e+035
|
74 |
|
|
//inputB:9.4770000000e+035
|
75 |
|
|
opa = 64'b1100011101100110101000010011001010000000011101101111101100010011;
|
76 |
|
|
opb = 64'b0100011101100110110100001010011011110101101100101001000000100011;
|
77 |
|
|
fpu_op = 1'b0;
|
78 |
|
|
rmode = 2'b10;
|
79 |
|
|
#10000;
|
80 |
|
|
//inputA:-3.6680000000e+000
|
81 |
|
|
//inputB:9.0007340000e+003
|
82 |
|
|
opa = 64'b1100000000001101010110000001000001100010010011011101001011110010;
|
83 |
|
|
opb = 64'b0100000011000001100101000101110111110011101101100100010110100010;
|
84 |
|
|
fpu_op = 1'b1;
|
85 |
|
|
rmode = 2'b11;
|
86 |
|
|
#10000;
|
87 |
|
|
//inputA:4.7700000000e+000
|
88 |
|
|
//inputB:-2.5000000000e-003
|
89 |
|
|
opa = 64'b0100000000010011000101000111101011100001010001111010111000010100;
|
90 |
|
|
opb = 64'b1011111101100100011110101110000101000111101011100001010001111011;
|
91 |
|
|
fpu_op = 1'b0;
|
92 |
|
|
rmode = 2'b10;
|
93 |
|
|
#10000;
|
94 |
|
|
//inputA:7.9500000000e+000
|
95 |
|
|
//inputB:-7.9433210000e+000
|
96 |
|
|
opa = 64'b0100000000011111110011001100110011001100110011001100110011001101;
|
97 |
|
|
opb = 64'b1100000000011111110001011111010111110000101100101000010100100011;
|
98 |
|
|
fpu_op = 1'b1;
|
99 |
|
|
rmode = 2'b00;
|
100 |
|
|
#10000;
|
101 |
|
|
//inputA:8.0260000000e+000
|
102 |
|
|
//inputB:1.0000000000e-106
|
103 |
|
|
opa = 64'b0100000000100000000011010100111111011111001110110110010001011010;
|
104 |
|
|
opb = 64'b0010100111101101010110110101011000010101011101000111011001011011;
|
105 |
|
|
fpu_op = 1'b0;
|
106 |
|
|
rmode = 2'b10;
|
107 |
|
|
#10000;
|
108 |
|
|
//inputA:9.9230000000e+001
|
109 |
|
|
//inputB:2.5370000000e-003
|
110 |
|
|
opa = 64'b0100000001011000110011101011100001010001111010111000010100011111;
|
111 |
|
|
opb = 64'b0011111101100100110010000111100110000000111101010101110111100110;
|
112 |
|
|
fpu_op = 1'b1;
|
113 |
|
|
rmode = 2'b11;
|
114 |
|
|
#10000;
|
115 |
|
|
//inputA:1.7179869184e+010
|
116 |
|
|
//inputB:4.0000000000e-176
|
117 |
|
|
opa = 64'b0100001000001111111111111111111111111111111111111111111111111111;
|
118 |
|
|
opb = 64'b0001101110000100010000101110010011111011011001110001100101100000;
|
119 |
|
|
fpu_op = 1'b0;
|
120 |
|
|
rmode = 2'b10;
|
121 |
|
|
#10000;
|
122 |
|
|
//inputA:-2.6800000000e-005
|
123 |
|
|
//inputB:-8.5400000000e-013
|
124 |
|
|
opa = 64'b1011111011111100000110100001000111111001111111011000011110000000;
|
125 |
|
|
opb = 64'b1011110101101110000011000010010111101110000010111101110010010110;
|
126 |
|
|
fpu_op = 1'b0;
|
127 |
|
|
rmode = 2'b00;
|
128 |
|
|
#10000;
|
129 |
|
|
//inputA:-8.5400000000e-013
|
130 |
|
|
//inputB:INF
|
131 |
|
|
opa = 64'b1011110101101110000011000010010111101110000010111101110010010110;
|
132 |
|
|
opb = 64'b0111111111110000000000000000000000000000000000000000000000000000;
|
133 |
|
|
fpu_op = 1'b0;
|
134 |
|
|
rmode = 2'b00;
|
135 |
|
|
#10000;
|
136 |
|
|
//inputA:-5.6555650000e+006
|
137 |
|
|
//inputB:-2.3665000000e-001
|
138 |
|
|
opa = 64'b1100000101010101100100110000001101000000000000000000000000000000;
|
139 |
|
|
opb = 64'b1011111111001110010010101000110000010101010011001001100001011111;
|
140 |
|
|
fpu_op = 1'b1;
|
141 |
|
|
rmode = 2'b11;
|
142 |
|
|
#90000;
|
143 |
|
|
//Output:4.337000000000001e+000
|
144 |
|
|
if (out==64'h40115916872B020D)
|
145 |
|
|
$display($time,"ps Answer is correct %h", out);
|
146 |
|
|
else
|
147 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
148 |
|
|
#10000;
|
149 |
|
|
//Output:1.600000000000000e+001
|
150 |
|
|
if (out==64'h4030000000000000)
|
151 |
|
|
$display($time,"ps Answer is correct %h", out);
|
152 |
|
|
else
|
153 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
154 |
|
|
#10000;
|
155 |
|
|
//Output:-4.677000000000000e+000
|
156 |
|
|
if (out==64'hC012B53F7CED9168)
|
157 |
|
|
$display($time,"ps Answer is correct %h", out);
|
158 |
|
|
else
|
159 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
160 |
|
|
#10000;
|
161 |
|
|
//Output:5.362000000000001e+003
|
162 |
|
|
if (out==64'h40B4F20000000000)
|
163 |
|
|
$display($time,"ps Answer is correct %h", out);
|
164 |
|
|
else
|
165 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
166 |
|
|
#10000;
|
167 |
|
|
//Output:9.999999999999787e-003
|
168 |
|
|
if (out==64'h3F847AE147AE1400)
|
169 |
|
|
$display($time,"ps Answer is correct %h", out);
|
170 |
|
|
else
|
171 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
172 |
|
|
#10000;
|
173 |
|
|
//Output:4.337000000000001e+000
|
174 |
|
|
if (out==64'h40115916872B020C)
|
175 |
|
|
$display($time,"ps Answer is correct %h", out);
|
176 |
|
|
else
|
177 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
178 |
|
|
#10000;
|
179 |
|
|
//Output:7.699999999999867e+033
|
180 |
|
|
if (out==64'h46F7BA3A9DCA8800)
|
181 |
|
|
$display($time,"ps Answer is correct %h", out);
|
182 |
|
|
else
|
183 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
184 |
|
|
#10000;
|
185 |
|
|
//Output:-9.004402000000000e+003
|
186 |
|
|
if (out==64'hC0C1963374BC6A80)
|
187 |
|
|
$display($time,"ps Answer is correct %h", out);
|
188 |
|
|
else
|
189 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
190 |
|
|
#10000;
|
191 |
|
|
//Output:4.767500000000000e+000
|
192 |
|
|
if (out==64'h401311EB851EB852)
|
193 |
|
|
$display($time,"ps Answer is correct %h", out);
|
194 |
|
|
else
|
195 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
196 |
|
|
#10000;
|
197 |
|
|
//Output:1.589332100000000e+001
|
198 |
|
|
if (out==64'h402FC9615EBFA8F8)
|
199 |
|
|
$display($time,"ps Answer is correct %h", out);
|
200 |
|
|
else
|
201 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
202 |
|
|
#10000;
|
203 |
|
|
//Output:8.026000000000002e+000
|
204 |
|
|
if (out==64'h40200D4FDF3B645B)
|
205 |
|
|
$display($time,"ps Answer is correct %h", out);
|
206 |
|
|
else
|
207 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
208 |
|
|
#10000;
|
209 |
|
|
//Output:9.922746300000000e+001
|
210 |
|
|
if (out==64'h4058CE8EC0F88334)
|
211 |
|
|
$display($time,"ps Answer is correct %h", out);
|
212 |
|
|
else
|
213 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
214 |
|
|
#10000;
|
215 |
|
|
//Output:1.717986918400000e+010
|
216 |
|
|
if (out==64'h4210000000000000)
|
217 |
|
|
$display($time,"ps Answer is correct %h", out);
|
218 |
|
|
else
|
219 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
220 |
|
|
#10000;
|
221 |
|
|
//Output:-2.680000085400000e-005
|
222 |
|
|
if (out==64'hBEFC1A1209039A77)
|
223 |
|
|
$display($time,"ps Answer is correct %h", out);
|
224 |
|
|
else
|
225 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
226 |
|
|
#10000;
|
227 |
|
|
//Output:INF
|
228 |
|
|
if (out==64'h7FF0000000000000)
|
229 |
|
|
$display($time,"ps Answer is correct %h", out);
|
230 |
|
|
else
|
231 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
232 |
|
|
#10000;
|
233 |
|
|
//Output:-5.655564763350001e+006
|
234 |
|
|
if (out==64'hC155930330DAB9F6)
|
235 |
|
|
$display($time,"ps Answer is correct %h", out);
|
236 |
|
|
else
|
237 |
|
|
$display($time,"ps Error! out is incorrect %h", out);
|
238 |
|
|
#390000;
|
239 |
|
|
$finish;
|
240 |
|
|
end
|
241 |
6 |
davidklun |
|
242 |
8 |
davidklun |
always
|
243 |
|
|
begin : CLOCK_clk
|
244 |
|
|
clk = 1'b0;
|
245 |
|
|
#5000;
|
246 |
|
|
clk = 1'b1;
|
247 |
|
|
#5000;
|
248 |
|
|
end
|
249 |
6 |
davidklun |
|
250 |
8 |
davidklun |
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
endmodule
|
254 |
|
|
|