1 |
11 |
constantin |
`timescale 1ns / 1ps
|
2 |
|
|
//////////////////////////////////////////////////////////////////////////////////
|
3 |
19 |
constantin |
// Company: UPT
|
4 |
|
|
// Engineer: Constantina-Elena Gavriliu
|
5 |
11 |
constantin |
//
|
6 |
|
|
// Create Date: 00:31:28 12/19/2013
|
7 |
|
|
// Design Name:
|
8 |
|
|
// Module Name: DualPathAdderConversion
|
9 |
|
|
// Project Name:
|
10 |
|
|
// Target Devices:
|
11 |
|
|
// Tool versions:
|
12 |
|
|
// Description: A ± B with mapped conversions
|
13 |
19 |
constantin |
// //do not take into consideration cases for which the operation generates a NaN or Infinity exception (with corresponding sign) when initial "special cases" are not such exceptions
|
14 |
11 |
constantin |
//
|
15 |
19 |
constantin |
// Dependencies: effective_op.v
|
16 |
|
|
// leading_zeros.v
|
17 |
|
|
// shifter.v
|
18 |
|
|
// rounding.v
|
19 |
|
|
// special_cases.v
|
20 |
11 |
constantin |
//
|
21 |
|
|
// Revision:
|
22 |
|
|
// Revision 0.01 - File Created
|
23 |
|
|
// Additional Comments:
|
24 |
|
|
//
|
25 |
|
|
//////////////////////////////////////////////////////////////////////////////////
|
26 |
|
|
module DualPathAdderConversion #( parameter size_mantissa = 24, //1.M
|
27 |
|
|
parameter size_exponent = 8,
|
28 |
|
|
parameter size_exception_field = 2,
|
29 |
|
|
parameter size_counter = 5,//log2(size_mantissa) + 1 = 5)
|
30 |
|
|
parameter [size_exception_field - 1 : 0] zero = 0, //00
|
31 |
|
|
parameter [size_exception_field - 1 : 0] normal_number = 1, //01
|
32 |
|
|
parameter [size_exception_field - 1 : 0] infinity = 2, //10
|
33 |
|
|
parameter [size_exception_field - 1 : 0] NaN = 3, //11
|
34 |
|
|
parameter size_integer = 32,
|
35 |
|
|
parameter counter_integer = 6,//log2(size_integer) + 1 = 6)
|
36 |
|
|
parameter [1 : 0] FP_operation = 0, //00
|
37 |
|
|
parameter [1 : 0] FP_to_int = 1, //01 - mapped on FarPath
|
38 |
|
|
parameter [1 : 0] int_to_FP = 2, //10 - mapped on ClosePath
|
39 |
|
|
|
40 |
|
|
parameter pipeline = 0,
|
41 |
|
|
parameter pipeline_pos = 0, // 8 bits
|
42 |
|
|
parameter size = size_mantissa + size_exponent + size_exception_field
|
43 |
|
|
)
|
44 |
|
|
( input [1:0] conversion,
|
45 |
|
|
input sub,
|
46 |
|
|
input [size - 1 : 0] a_number_i,
|
47 |
|
|
input [size - 1 : 0] b_number_i,
|
48 |
|
|
output[size - 1 : 0] resulted_number_o);
|
49 |
|
|
|
50 |
|
|
parameter double_size_mantissa = size_mantissa + size_mantissa;
|
51 |
|
|
parameter double_size_counter = size_counter + 1;
|
52 |
|
|
parameter max_size = (size_integer > size_mantissa)? size_integer : size_mantissa;
|
53 |
|
|
parameter max_counter = (counter_integer > size_counter)? counter_integer : size_counter;
|
54 |
|
|
parameter size_diff_i_m = (size_integer > size_mantissa)? (size_integer - size_mantissa) : (size_mantissa - size_integer);
|
55 |
|
|
parameter bias = {1'b0,{(size_exponent-1){1'b1}}};
|
56 |
|
|
parameter exp_biasedCP = bias + size_mantissa;
|
57 |
|
|
parameter exponentCP = exp_biasedCP - 1'b1;
|
58 |
|
|
|
59 |
|
|
wire [size_exception_field - 1 : 0] sp_case_a_number, sp_case_b_number;
|
60 |
|
|
wire [size_mantissa - 1 : 0] m_a_number, m_b_number;
|
61 |
|
|
wire [size_exponent - 1 : 0] e_a_number, e_b_number;
|
62 |
|
|
wire s_a_number, s_b_number;
|
63 |
|
|
|
64 |
|
|
wire [size_exponent : 0] a_greater_exponent, b_greater_exponent;
|
65 |
|
|
|
66 |
|
|
wire [size_exponent - 1 : 0] exp_difference;
|
67 |
|
|
wire [size_exponent : 0] exp_inter;
|
68 |
|
|
wire eff_op;
|
69 |
|
|
|
70 |
19 |
constantin |
wire [size_exception_field - 1 : 0] set_b_sp_case, resulted_exception_field;
|
71 |
11 |
constantin |
wire resulted_sign;
|
72 |
|
|
wire swap;
|
73 |
|
|
|
74 |
|
|
wire zero_flag;
|
75 |
|
|
|
76 |
|
|
wire [max_size - 1 : 0] max_entityFP;
|
77 |
|
|
wire [size_exponent - 1 : 0] resulted_e_oFP;
|
78 |
|
|
wire [size_exponent - 1 : 0] adjust_mantissaFP;
|
79 |
|
|
wire [size_exponent - 1 : 0] unadjusted_exponentFP;
|
80 |
|
|
wire [size_mantissa - 1 : 0] mantissa_to_shiftFP, shifted_m_bFP, convert_neg_mantissaFP;
|
81 |
19 |
constantin |
wire [size_mantissa + 2 : 0] adder_mantissaFP;
|
82 |
11 |
constantin |
wire [size_mantissa - 1 : 0] resulted_inter_m_oFP, resulted_m_oFP;
|
83 |
19 |
constantin |
wire [size_mantissa - 1 : 0] initial_rounding_bitsFP;
|
84 |
|
|
wire [size_mantissa - 2 : 0] inter_rounding_bitsFP;
|
85 |
11 |
constantin |
wire [double_size_mantissa:0] normalized_mantissaFP;
|
86 |
19 |
constantin |
wire [size_mantissa + 1 : 0] unnormalized_mantissaFP, conversion_dummiesFP;
|
87 |
11 |
constantin |
wire [size_exponent : 0] shift_value_when_positive_exponentFP, shift_value_when_negative_exponentFP;
|
88 |
|
|
wire [size_exponent - 1 : 0] shift_valueFP, shft_valFP;
|
89 |
19 |
constantin |
wire [size_mantissa - 1 : 0] entity_to_roundFP;
|
90 |
|
|
wire [size_mantissa : 0] dummy_entityFP;
|
91 |
11 |
constantin |
wire [size_exponent : 0] exponentFP;
|
92 |
|
|
wire dummy_bitFP;
|
93 |
|
|
|
94 |
|
|
wire [max_size - 1 : 0] max_entityCP;
|
95 |
|
|
wire [size_mantissa - 1 : 0] shifted_m_bCP;
|
96 |
19 |
constantin |
wire [size_mantissa + 2 : 0] adder_mantissaCP;
|
97 |
|
|
wire [size_mantissa + 1 : 0] unnormalized_mantissaCP;
|
98 |
11 |
constantin |
wire [size_mantissa : 0] rounded_mantissaCP;
|
99 |
|
|
wire [size_mantissa - 1 : 0] r_mantissaCP;
|
100 |
|
|
wire [size_exponent - 1 : 0] resulted_e_oCP;
|
101 |
|
|
wire [size_mantissa - 1 : 0] resulted_m_oCP;
|
102 |
|
|
wire [size_exponent - 1 : 0] unadjusted_exponentCP, adjust_exponentCP;
|
103 |
|
|
wire [size_exponent - 1 : 0] exp_selectionCP;
|
104 |
19 |
constantin |
wire [max_size - size_mantissa : 0] dummy_bitsCP, dummy_entityCP;
|
105 |
11 |
constantin |
wire [max_counter - 1 : 0] lzsCP;
|
106 |
|
|
wire init_shft_bitCP, shft_bitCP;
|
107 |
|
|
wire lsb_shft_bitCP;
|
108 |
19 |
constantin |
wire [4:0] sign_cases;
|
109 |
|
|
reg intermediar_sign;
|
110 |
11 |
constantin |
|
111 |
|
|
wire do_conversion;
|
112 |
|
|
|
113 |
|
|
assign do_conversion = |conversion; //let me know if there is a conversion
|
114 |
|
|
|
115 |
|
|
assign e_a_number = a_number_i[size_mantissa + size_exponent - 1 : size_mantissa - 1]; //exponent for a_number_i
|
116 |
|
|
assign e_b_number = b_number_i[size_mantissa + size_exponent - 1 : size_mantissa - 1]; //exponent for b_number_i
|
117 |
|
|
assign s_a_number = a_number_i[size - size_exception_field - 1]; //sign for a_number_i
|
118 |
|
|
assign s_b_number = b_number_i[size - size_exception_field - 1]; //sign for b_number_i
|
119 |
|
|
assign sp_case_a_number = a_number_i[size - 1 : size - size_exception_field]; //special_case for a_number_i
|
120 |
|
|
assign sp_case_b_number = b_number_i[size - 1 : size - size_exception_field]; //special_case for b_number_i
|
121 |
|
|
|
122 |
|
|
//find the greater exponent
|
123 |
|
|
assign a_greater_exponent = e_a_number - e_b_number;
|
124 |
|
|
assign b_greater_exponent = e_b_number - e_a_number;
|
125 |
|
|
|
126 |
|
|
//find the difference between exponents
|
127 |
|
|
assign exp_difference = (a_greater_exponent[size_exponent])? b_greater_exponent[size_exponent - 1 : 0] : a_greater_exponent[size_exponent - 1 : 0];
|
128 |
|
|
assign exp_inter = (b_greater_exponent[size_exponent])? {1'b0, e_a_number} : {1'b0, e_b_number};
|
129 |
|
|
|
130 |
|
|
//set shifter always on m_b_number
|
131 |
19 |
constantin |
assign {m_a_number, m_b_number} = (b_greater_exponent[size_exponent])?
|
132 |
|
|
{{1'b1, a_number_i[size_mantissa - 2 :0]}, {1'b1, b_number_i[size_mantissa - 2 :0]}} :
|
133 |
|
|
{{1'b1, b_number_i[size_mantissa - 2 :0]}, {1'b1, a_number_i[size_mantissa - 2 :0]}};
|
134 |
11 |
constantin |
|
135 |
|
|
effective_op effective_op_instance( .a_sign(s_a_number), .b_sign(s_b_number), .sub(sub), .eff_op(eff_op));
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
//------------------------------------------------------- start ClosePath addition and conversion
|
139 |
19 |
constantin |
assign {shifted_m_bCP, init_shft_bitCP} = (exp_difference)? {1'b0, m_b_number[size_mantissa-1:0]} : {m_b_number, 1'b0};
|
140 |
11 |
constantin |
|
141 |
|
|
//compute unnormalized_mantissa
|
142 |
19 |
constantin |
assign adder_mantissaCP = {1'b0, m_a_number, 1'b0} - {1'b0, shifted_m_bCP, init_shft_bitCP};
|
143 |
11 |
constantin |
assign {unnormalized_mantissaCP, shft_bitCP} =
|
144 |
19 |
constantin |
(adder_mantissaCP[size_mantissa + 2])? ({~adder_mantissaCP[size_mantissa + 1 : 0], ~init_shft_bitCP}) :
|
145 |
|
|
({adder_mantissaCP[size_mantissa + 1 : 0], init_shft_bitCP});
|
146 |
11 |
constantin |
|
147 |
19 |
constantin |
assign max_entityCP = do_conversion? (a_number_i[size_integer-1]? (~a_number_i[max_size-1 : 0]) : a_number_i[max_size-1 : 0]) :
|
148 |
|
|
{{(max_size-size_mantissa-2){1'b0}}, unnormalized_mantissaCP[size_mantissa + 1 : 0]};
|
149 |
|
|
assign lsb_shft_bitCP = (do_conversion)? a_number_i[size_integer-1] : adder_mantissaCP[size_mantissa+2];//sign?
|
150 |
11 |
constantin |
|
151 |
19 |
constantin |
assign max_ovfCP = do_conversion? 1'b0 : unnormalized_mantissaCP[size_mantissa + 1];
|
152 |
11 |
constantin |
|
153 |
|
|
//compute leading_zeros over unnormalized mantissa
|
154 |
|
|
leading_zeros #(.SIZE_INT(max_size), .SIZE_COUNTER(max_counter), .PIPELINE(pipeline))
|
155 |
|
|
leading_zeros_CP_instance ( .a(max_entityCP),
|
156 |
|
|
.ovf(max_ovfCP),
|
157 |
|
|
.lz(lzsCP));
|
158 |
|
|
|
159 |
|
|
//compute shifting over unnormalized_mantissa
|
160 |
|
|
shifter #( .INPUT_SIZE(max_size),
|
161 |
|
|
.SHIFT_SIZE(max_counter),
|
162 |
|
|
.OUTPUT_SIZE(max_size + 1),
|
163 |
|
|
.DIRECTION(1'b1), //0=right, 1=left
|
164 |
|
|
.PIPELINE(pipeline),
|
165 |
|
|
.POSITION(pipeline_pos))
|
166 |
|
|
shifter_CP_instance( .a(max_entityCP),//mantissa
|
167 |
|
|
.arith(lsb_shft_bitCP),
|
168 |
|
|
.shft(lzsCP),
|
169 |
|
|
.shifted_a({r_mantissaCP, dummy_bitsCP}));
|
170 |
19 |
constantin |
|
171 |
|
|
assign dummy_entityCP = (conversion[1] & (&dummy_bitsCP[max_size - size_mantissa - 1:0]) & (~dummy_bitsCP[max_size - size_mantissa]))? (a_number_i[size_integer-1]? ~dummy_bitsCP : dummy_bitsCP) : dummy_bitsCP;
|
172 |
11 |
constantin |
|
173 |
19 |
constantin |
assign rounded_mantissaCP = (dummy_entityCP[max_size - size_mantissa] && (r_mantissaCP[0] | (|dummy_entityCP[max_size - size_mantissa - 1 : 0 ])))?
|
174 |
11 |
constantin |
r_mantissaCP + 1'b1 : r_mantissaCP;
|
175 |
|
|
assign resulted_m_oCP = (rounded_mantissaCP[size_mantissa])? rounded_mantissaCP[size_mantissa : 1] :
|
176 |
|
|
rounded_mantissaCP[size_mantissa-1:0];
|
177 |
|
|
|
178 |
|
|
assign ovfCP = do_conversion? s_a_number : adder_mantissaCP[size_mantissa+1];
|
179 |
|
|
|
180 |
19 |
constantin |
assign exp_selectionCP = do_conversion? exponentCP : exp_inter - 1'b1;
|
181 |
11 |
constantin |
assign adjust_exponentCP = exp_selectionCP - lzsCP;
|
182 |
|
|
assign unadjusted_exponentCP = adjust_exponentCP + size_diff_i_m;
|
183 |
|
|
|
184 |
|
|
assign resulted_e_oCP = (do_conversion & ~(|max_entityCP))? bias : unadjusted_exponentCP + rounded_mantissaCP[size_mantissa];
|
185 |
|
|
//------------------------------------------------------- end ClosePath addition and conversion
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
//--------------------------------------------- start FarPath addition and conversion
|
189 |
|
|
assign exponentFP = e_a_number - bias;
|
190 |
|
|
assign shift_value_when_positive_exponentFP = max_size - 2'd2 - exponentFP[size_exponent-1 : 0];
|
191 |
|
|
assign shift_value_when_negative_exponentFP = max_size + (~exponentFP[size_exponent-1 : 0]);
|
192 |
|
|
assign shift_valueFP = (exponentFP[size_exponent])? shift_value_when_negative_exponentFP[size_exponent - 1 : 0] :
|
193 |
|
|
(shift_value_when_positive_exponentFP[size_exponent])? (~shift_value_when_positive_exponentFP[size_exponent - 1 : 0]):
|
194 |
|
|
shift_value_when_positive_exponentFP[size_exponent - 1 : 0];
|
195 |
|
|
assign shft_valFP = do_conversion? shift_valueFP : exp_difference;
|
196 |
|
|
|
197 |
|
|
assign convert_neg_mantissaFP = {1'b0, ~a_number_i[size_mantissa-2 : 0]};
|
198 |
|
|
assign conversion_dummiesFP = {(size_mantissa+1){1'b1}};
|
199 |
|
|
|
200 |
|
|
assign mantissa_to_shiftFP = do_conversion? (s_a_number? convert_neg_mantissaFP + 1'b1 : {1'b1, a_number_i[size_mantissa-2 : 0]}) : m_b_number;
|
201 |
|
|
assign arith_shiftFP = do_conversion? s_a_number : 1'b0;
|
202 |
|
|
|
203 |
|
|
//shift m_b_number
|
204 |
|
|
shifter #( .INPUT_SIZE(size_mantissa),
|
205 |
|
|
.SHIFT_SIZE(size_exponent),
|
206 |
|
|
.OUTPUT_SIZE(double_size_mantissa),
|
207 |
|
|
.DIRECTION(1'b0), //0=right, 1=left
|
208 |
|
|
.PIPELINE(pipeline),
|
209 |
|
|
.POSITION(pipeline_pos))
|
210 |
|
|
m_b_shifter_FP_instance( .a(mantissa_to_shiftFP),
|
211 |
|
|
.arith(arith_shiftFP),
|
212 |
|
|
.shft(shft_valFP),
|
213 |
|
|
.shifted_a({shifted_m_bFP, initial_rounding_bitsFP}));
|
214 |
|
|
|
215 |
|
|
assign max_entityFP = {s_a_number, shifted_m_bFP[size_mantissa-1 : 0], initial_rounding_bitsFP[size_mantissa-1 : size_mantissa - size_diff_i_m + 1]};
|
216 |
|
|
|
217 |
|
|
//compute unnormalized_mantissa
|
218 |
19 |
constantin |
assign adder_mantissaFP = (eff_op)? ({1'b0, m_a_number, 1'b0} - {1'b0, shifted_m_bFP, initial_rounding_bitsFP[size_mantissa - 1]}) : ({1'b0, m_a_number, 1'b0} + {1'b0, shifted_m_bFP, initial_rounding_bitsFP[size_mantissa - 1]});
|
219 |
|
|
|
220 |
|
|
//compute unnormalized_mantissa
|
221 |
|
|
assign unnormalized_mantissaFP = (adder_mantissaFP[size_mantissa + 2])? ~adder_mantissaFP[size_mantissa + 1 : 0] : adder_mantissaFP[size_mantissa + 1 : 0];
|
222 |
11 |
constantin |
|
223 |
19 |
constantin |
assign inter_rounding_bitsFP = ((eff_op)? ((|initial_rounding_bitsFP[size_mantissa - 2 : 0])?~initial_rounding_bitsFP[size_mantissa - 2 : 0] : initial_rounding_bitsFP[size_mantissa - 2 : 0]) : initial_rounding_bitsFP[size_mantissa - 2 : 0]);
|
224 |
|
|
|
225 |
|
|
assign adjust_mantissaFP = unnormalized_mantissaFP[size_mantissa + 1]? 2'd0 :
|
226 |
|
|
unnormalized_mantissaFP[size_mantissa]? 2'd1 : 2'd2;
|
227 |
11 |
constantin |
|
228 |
|
|
//compute shifting over unnormalized_mantissa
|
229 |
|
|
shifter #( .INPUT_SIZE(double_size_mantissa+1),
|
230 |
|
|
.SHIFT_SIZE(size_exponent),
|
231 |
|
|
.OUTPUT_SIZE(double_size_mantissa+2),
|
232 |
|
|
.DIRECTION(1'b1),
|
233 |
|
|
.PIPELINE(pipeline),
|
234 |
|
|
.POSITION(pipeline_pos))
|
235 |
|
|
unnormalized_no_shifter_FP_instance(.a({unnormalized_mantissaFP, inter_rounding_bitsFP}),
|
236 |
19 |
constantin |
.arith(inter_rounding_bitsFP[0]),
|
237 |
11 |
constantin |
.shft(adjust_mantissaFP),
|
238 |
|
|
.shifted_a({normalized_mantissaFP, dummy_bitFP}));
|
239 |
|
|
|
240 |
19 |
constantin |
assign correction = do_conversion? 1'b0 :
|
241 |
|
|
eff_op? ((|initial_rounding_bitsFP[size_mantissa - 2 : 0])?
|
242 |
|
|
((adder_mantissaFP[0] | ((~adder_mantissaFP[0]) & (~adder_mantissaFP[size_mantissa]) & (~initial_rounding_bitsFP[size_mantissa - 1])
|
243 |
|
|
& (~(&{normalized_mantissaFP[size_mantissa-1 : 0],dummy_bitFP}))))? 1'b1 : 1'b0) : 1'b0) : 1'b0;
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
assign entity_to_roundFP = do_conversion? max_entityFP[size_mantissa-1 : 0] : normalized_mantissaFP[double_size_mantissa : double_size_mantissa - size_mantissa + 1];
|
247 |
|
|
assign dummy_entityFP = do_conversion? {initial_rounding_bitsFP[size_mantissa - size_diff_i_m : 0], {size_diff_i_m{1'b0}}} : normalized_mantissaFP[double_size_mantissa - size_mantissa: 0];
|
248 |
|
|
|
249 |
11 |
constantin |
//instantiate rounding_component
|
250 |
|
|
rounding #( .SIZE_MOST_S_MANTISSA(size_mantissa),
|
251 |
|
|
.SIZE_LEAST_S_MANTISSA(size_mantissa + 2'd1))
|
252 |
19 |
constantin |
rounding_FP_instance( .unrounded_mantissa(entity_to_roundFP),
|
253 |
|
|
.dummy_bits(dummy_entityFP),
|
254 |
|
|
.correction(correction),
|
255 |
11 |
constantin |
.rounded_mantissa(resulted_inter_m_oFP));
|
256 |
|
|
|
257 |
19 |
constantin |
assign resulted_m_oFP = resulted_inter_m_oFP;
|
258 |
11 |
constantin |
assign unadjusted_exponentFP = exp_inter - adjust_mantissaFP;
|
259 |
|
|
assign resulted_e_oFP = do_conversion? max_entityFP[size_mantissa+size_exponent-2 : size_mantissa-1] : unadjusted_exponentFP + 1'b1;
|
260 |
|
|
//-------------------------------------------------------- end FarPath addition and conversion
|
261 |
|
|
|
262 |
|
|
|
263 |
19 |
constantin |
assign set_b_sp_case = do_conversion? zero : sp_case_b_number;
|
264 |
|
|
|
265 |
11 |
constantin |
//compute exception_field
|
266 |
|
|
special_cases #( .size_exception_field(size_exception_field),
|
267 |
|
|
.zero(zero),
|
268 |
|
|
.normal_number(normal_number),
|
269 |
|
|
.infinity(infinity),
|
270 |
|
|
.NaN(NaN))
|
271 |
|
|
special_cases_instance( .sp_case_a_number(sp_case_a_number),
|
272 |
19 |
constantin |
.sp_case_b_number(set_b_sp_case),
|
273 |
|
|
.sp_case_result_o(resulted_exception_field));
|
274 |
|
|
|
275 |
|
|
//set zero_flag in case of equal numbers
|
276 |
|
|
assign zero_flag = ((exp_difference > 1 | !eff_op) & conversion != int_to_FP)? ~(|resulted_m_oFP) : ~(|resulted_m_oCP);
|
277 |
17 |
constantin |
|
278 |
19 |
constantin |
assign sign_cases = {eff_op, s_a_number, s_b_number, a_greater_exponent[size_exponent], b_greater_exponent[size_exponent]};
|
279 |
17 |
constantin |
|
280 |
19 |
constantin |
always
|
281 |
|
|
@(*)
|
282 |
|
|
begin
|
283 |
|
|
case (sign_cases)
|
284 |
|
|
5'b00000: intermediar_sign = 1'b0;
|
285 |
|
|
5'b00001: intermediar_sign = 1'b0;
|
286 |
|
|
5'b00010: intermediar_sign = 1'b0;
|
287 |
|
|
|
288 |
|
|
5'b10000: intermediar_sign = ~max_ovfCP;
|
289 |
|
|
5'b10001: intermediar_sign = 1'b0;
|
290 |
|
|
5'b10010: intermediar_sign = 1'b1;
|
291 |
|
|
|
292 |
|
|
5'b10100: intermediar_sign = ~max_ovfCP;
|
293 |
|
|
5'b10101: intermediar_sign = 1'b0;
|
294 |
|
|
5'b10110: intermediar_sign = 1'b1;
|
295 |
|
|
|
296 |
|
|
5'b00100: intermediar_sign = 1'b0;
|
297 |
|
|
5'b00101: intermediar_sign = 1'b0;
|
298 |
|
|
5'b00110: intermediar_sign = 1'b0;
|
299 |
|
|
|
300 |
|
|
5'b11000: intermediar_sign = max_ovfCP;
|
301 |
|
|
5'b11001: intermediar_sign = 1'b1;
|
302 |
|
|
5'b11010: intermediar_sign = 1'b0;
|
303 |
|
|
|
304 |
|
|
5'b01000: intermediar_sign = 1'b1;
|
305 |
|
|
5'b01001: intermediar_sign = 1'b1;
|
306 |
|
|
5'b01010: intermediar_sign = 1'b1;
|
307 |
|
|
|
308 |
|
|
5'b01100: intermediar_sign = 1'b1;
|
309 |
|
|
5'b01101: intermediar_sign = 1'b1;
|
310 |
|
|
5'b01110: intermediar_sign = 1'b1;
|
311 |
|
|
|
312 |
|
|
5'b11100: intermediar_sign = max_ovfCP;
|
313 |
|
|
5'b11101: intermediar_sign = 1'b1;
|
314 |
|
|
5'b11110: intermediar_sign = 1'b0;
|
315 |
|
|
|
316 |
|
|
default: intermediar_sign = 1'b1;
|
317 |
|
|
endcase
|
318 |
|
|
end
|
319 |
11 |
constantin |
|
320 |
19 |
constantin |
assign resulted_sign = do_conversion? s_a_number : intermediar_sign;
|
321 |
11 |
constantin |
|
322 |
19 |
constantin |
assign resulted_number_o = conversion[0]? {3'd0, resulted_e_oFP, resulted_m_oFP[size_mantissa-2 : 0]} :
|
323 |
|
|
conversion[1]? {normal_number, a_number_i[size_integer - 1],resulted_e_oCP, resulted_m_oCP[size_mantissa-2 : 0]} :
|
324 |
|
|
(zero_flag)? {size{1'b0}} :
|
325 |
|
|
(!sp_case_a_number)? {b_number_i[size-1 : size-size_exception_field], eff_op ^ s_b_number, b_number_i[size-1-size_exception_field-1 : 0]} :
|
326 |
|
|
(!sp_case_b_number)? {a_number_i[size-1 : 0]} :
|
327 |
|
|
((exp_difference > 1 | !eff_op) & conversion != int_to_FP)?
|
328 |
11 |
constantin |
{resulted_exception_field, resulted_sign, resulted_e_oFP, resulted_m_oFP[size_mantissa-2 : 0]}:
|
329 |
|
|
{resulted_exception_field, resulted_sign, resulted_e_oCP, resulted_m_oCP[size_mantissa-2 : 0]};
|
330 |
|
|
endmodule
|