- EE90484DC801B605DDC2DB7B3DCE4C95A6B99F59577253D40E437F94EA6E89534137102A68DAB20B46D0EA1F8C7BA625258E7073102859AD764020989B95FA7C
+ 27A59F78F058FCD385EC1B2E7EDEF7D2A8936EE3BF81338A64C786BC5B208BEFA8FB424EABD630F4042E4B32FFC5D6222778837BD04EAD9BFF096BA12BC32EA1
ffa/libffa/fz_arith.adb
(44 . 6)(44 . 44)
77 pragma Inline_Always(FZ_Add);
78
79
80 -- Gate = 1: Sum := X + Y; Overflow := Carry
81 -- Gate = 0: Sum := X; Overflow := 0
82 procedure FZ_Add_Gated_O(X : in FZ;
83 Y : in FZ;
84 Gate : in WBool;
85 Sum : out FZ;
86 Overflow : out WBool) is
87 Carry : WBool := 0;
88 Mask : constant Word := 0 - Gate;
89 begin
90 for i in 0 .. Word_Index(X'Length - 1) loop
91 declare
92 A : constant Word := X(X'First + i);
93 B : constant Word := Y(Y'First + i) and Mask;
94 S : constant Word := A + B + Carry;
95 begin
96 Sum(Sum'First + i) := S;
97 Carry := W_Carry(A, B, S);
98 end;
99 end loop;
100 Overflow := Carry;
101 end FZ_Add_Gated_O;
102 pragma Inline_Always(FZ_Add_Gated_O);
103
104
105 -- Same as FZ_Add_Gated_O, but without Overflow output
106 procedure FZ_Add_Gated(X : in FZ;
107 Y : in FZ;
108 Gate : in WBool;
109 Sum : out FZ) is
110 Overflow : Word;
111 pragma Unreferenced(Overflow);
112 begin
113 FZ_Add_Gated_O(X, Y, Gate, Sum, Overflow);
114 end FZ_Add_Gated;
115 pragma Inline_Always(FZ_Add_Gated);
116
117
118 -- Difference := X - Y; Underflow := Borrow
119 procedure FZ_Sub(X : in FZ;
120 Y : in FZ;