forked from IntelLabs/HDFIT.SystolicArray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdder.sv
36 lines (28 loc) · 787 Bytes
/
Adder.sv
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
`include "globals.svh"
// Returns unnormalized sum
module Adder (
input accNormalSigned_t in1,
input accNormalSigned_t in2,
output exponent_t sumExp,
output logic signed [$bits(accMantNormalSigned_t):0] sumMant // larger mantissa
);
accMantNormalSigned_t inMant;
accMantNormalSigned_t inMantShift;
exponent_t shift;
always_comb begin
if(in1.Exp > in2.Exp) begin
sumExp = in1.Exp;
inMant = in1.Mant;
inMantShift = in2.Mant;
shift = sumExp - in2.Exp;
end else begin
sumExp = in2.Exp;
inMant = in2.Mant;
inMantShift = in1.Mant;
shift = sumExp - in1.Exp;
end
end
always_comb sumMant =
{inMant[$bits(accMantNormalSigned_t) - 1], inMant} +
{inMantShift[$bits(accMantNormalSigned_t) - 1], inMantShift >>> shift};
endmodule