-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnormalize_mult.sv
More file actions
50 lines (43 loc) · 1.15 KB
/
normalize_mult.sv
File metadata and controls
50 lines (43 loc) · 1.15 KB
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
module mult_norm (
input logic [47:0] result_p,
input logic [9:0] exp_sum,
output logic sticky, guard,
output logic [22:0] norm_mant,
output logic [9:0] norm_exp
);
logic MSB;
assign MSB = result_p[47];
always_comb begin
// Normalized Exponent
if(MSB) begin
norm_exp = exp_sum + 1'b1;
end else begin
norm_exp = exp_sum;
end
// Normalized Mantissa
if(MSB) begin
norm_mant = result_p[46:24];
end else begin
norm_mant = result_p[45:23];
end
// Guard Bit
if(MSB) begin
guard = result_p[23];
end else begin
guard = result_p[22];
end
// Sticky Bit
if(MSB) begin
sticky = |result_p[22:0];
end else begin
sticky = |result_p[21:0];
end
// Denormals Handling
if ($signed(norm_exp) < 0) begin
norm_mant = result_p[47] ? result_p[47:25] : result_p[46:24];
norm_mant = (norm_mant >> -(norm_exp));
guard = !($signed(norm_exp) < (-23));
norm_exp = 10'b0;
end
end
endmodule