ffa_ch14_barrett.kv 1
ffa_ch14_barrett.kv 2
ffa_ch14_barrett.kv 3
ffa_ch14_barrett.kv 4
ffa_ch15_gcd.kv 5
ffa_ch14_barrett.kv 6
ffa_ch14_barrett.kv 7
ffa_ch14_barrett.kv 8
ffa_ch14_barrett.kv 9
ffa_ch14_barrett.kv 10
ffa_ch14_barrett.kv 11
ffa_ch14_barrett.kv 12
ffa_ch14_barrett.kv 13
ffa_ch14_barrett.kv 14
ffa_ch14_barrett.kv 15
ffa_ch14_barrett.kv 16
ffa_ch14_barrett.kv 17
ffa_ch14_barrett.kv 18
ffa_ch14_barrett.kv 19
ffa_ch14_barrett.kv 20 with Words; use Words;
ffa_ch14_barrett.kv 21 with Word_Ops; use Word_Ops;
ffa_ch14_barrett.kv 22 with W_Mul; use W_Mul;
ffa_ch14_barrett.kv 23 with FZ_Arith; use FZ_Arith;
ffa_ch14_barrett.kv 24 with FZ_Mul; use FZ_Mul;
ffa_ch14_barrett.kv 25
ffa_ch14_barrett.kv 26
ffa_ch14_barrett.kv 27
ffa_ch14_barrett.kv 28
ffa_ch14_barrett.kv 29
ffa_ch14_barrett.kv 30 package body FZ_LoMul is
ffa_ch14_barrett.kv 31
ffa_ch14_barrett.kv 32
ffa_ch14_barrett.kv 33 procedure FZ_Low_Mul_Comba(X : in FZ;
ffa_ch14_barrett.kv 34 Y : in FZ;
ffa_ch14_barrett.kv 35 XY : out FZ) is
ffa_ch14_barrett.kv 36
ffa_ch14_barrett.kv 37
ffa_ch14_barrett.kv 38 L : constant Word_Index := X'Length;
ffa_ch14_barrett.kv 39
ffa_ch14_barrett.kv 40
ffa_ch14_barrett.kv 41 A2, A1, A0 : Word := 0;
ffa_ch14_barrett.kv 42
ffa_ch14_barrett.kv 43 begin
ffa_ch14_barrett.kv 44
ffa_ch14_barrett.kv 45
ffa_ch14_barrett.kv 46 for N in 0 .. L - 1 loop
ffa_ch14_barrett.kv 47
ffa_ch14_barrett.kv 48
ffa_ch14_barrett.kv 49 declare
ffa_ch14_barrett.kv 50
ffa_ch14_barrett.kv 51
ffa_ch14_barrett.kv 52 Lo, Hi : Word;
ffa_ch14_barrett.kv 53
ffa_ch14_barrett.kv 54
ffa_ch14_barrett.kv 55 C : WBool;
ffa_ch14_barrett.kv 56
ffa_ch14_barrett.kv 57
ffa_ch14_barrett.kv 58 Sum : Word;
ffa_ch14_barrett.kv 59
ffa_ch14_barrett.kv 60 begin
ffa_ch14_barrett.kv 61
ffa_ch14_barrett.kv 62
ffa_ch14_barrett.kv 63
ffa_ch14_barrett.kv 64 for j in 0 .. N loop
ffa_ch14_barrett.kv 65
ffa_ch14_barrett.kv 66
ffa_ch14_barrett.kv 67 Mul_Word(X(X'First + j),
ffa_ch14_barrett.kv 68 Y(Y'First - j + N),
ffa_ch14_barrett.kv 69 Lo, Hi);
ffa_ch14_barrett.kv 70
ffa_ch14_barrett.kv 71
ffa_ch14_barrett.kv 72
ffa_ch14_barrett.kv 73
ffa_ch14_barrett.kv 74 Sum := A0 + Lo;
ffa_ch14_barrett.kv 75 C := W_Carry(A0, Lo, Sum);
ffa_ch14_barrett.kv 76 A0 := Sum;
ffa_ch14_barrett.kv 77
ffa_ch14_barrett.kv 78
ffa_ch14_barrett.kv 79 Sum := A1 + Hi + C;
ffa_ch14_barrett.kv 80 C := W_Carry(A1, Hi, Sum);
ffa_ch14_barrett.kv 81 A1 := Sum;
ffa_ch14_barrett.kv 82
ffa_ch14_barrett.kv 83
ffa_ch14_barrett.kv 84 A2 := A2 + C;
ffa_ch14_barrett.kv 85
ffa_ch14_barrett.kv 86 end loop;
ffa_ch14_barrett.kv 87
ffa_ch14_barrett.kv 88
ffa_ch14_barrett.kv 89 XY(XY'First + N) := A0;
ffa_ch14_barrett.kv 90
ffa_ch14_barrett.kv 91
ffa_ch14_barrett.kv 92 A0 := A1;
ffa_ch14_barrett.kv 93 A1 := A2;
ffa_ch14_barrett.kv 94 A2 := 0;
ffa_ch14_barrett.kv 95 end;
ffa_ch14_barrett.kv 96
ffa_ch14_barrett.kv 97 end loop;
ffa_ch14_barrett.kv 98
ffa_ch14_barrett.kv 99 end FZ_Low_Mul_Comba;
ffa_ch14_barrett.kv 100
ffa_ch14_barrett.kv 101
ffa_ch14_barrett.kv 102
ffa_ch14_barrett.kv 103 procedure Low_Mul(X : in FZ;
ffa_ch14_barrett.kv 104 Y : in FZ;
ffa_ch14_barrett.kv 105 XY : out FZ) is
ffa_ch14_barrett.kv 106
ffa_ch14_barrett.kv 107
ffa_ch14_barrett.kv 108 L : constant Word_Count := X'Length;
ffa_ch14_barrett.kv 109
ffa_ch14_barrett.kv 110
ffa_ch14_barrett.kv 111 K : constant Word_Index := L / 2;
ffa_ch14_barrett.kv 112
ffa_ch14_barrett.kv 113
ffa_ch14_barrett.kv 114 subtype KSeg is FZ(1 .. K);
ffa_ch14_barrett.kv 115
ffa_ch14_barrett.kv 116
ffa_ch14_barrett.kv 117 LH, HL : KSeg;
ffa_ch14_barrett.kv 118
ffa_ch14_barrett.kv 119
ffa_ch14_barrett.kv 120 XLo : KSeg renames X( X'First .. X'Last - K );
ffa_ch14_barrett.kv 121 XHi : KSeg renames X( X'First + K .. X'Last );
ffa_ch14_barrett.kv 122
ffa_ch14_barrett.kv 123
ffa_ch14_barrett.kv 124 YLo : KSeg renames Y( Y'First .. Y'Last - K );
ffa_ch14_barrett.kv 125 YHi : KSeg renames Y( Y'First + K .. Y'Last );
ffa_ch14_barrett.kv 126
ffa_ch14_barrett.kv 127
ffa_ch14_barrett.kv 128 XYHi : KSeg renames XY( XY'First + K .. XY'Last );
ffa_ch14_barrett.kv 129
ffa_ch14_barrett.kv 130
ffa_ch14_barrett.kv 131 C : WBool;
ffa_ch14_barrett.kv 132 pragma Unreferenced(C);
ffa_ch14_barrett.kv 133
ffa_ch14_barrett.kv 134 begin
ffa_ch14_barrett.kv 135
ffa_ch14_barrett.kv 136
ffa_ch14_barrett.kv 137 FZ_Multiply_Unbuffered(XLo, YLo, XY);
ffa_ch14_barrett.kv 138
ffa_ch14_barrett.kv 139
ffa_ch14_barrett.kv 140 FZ_Low_Multiply_Unbuffered(XLo, YHi, LH);
ffa_ch14_barrett.kv 141
ffa_ch14_barrett.kv 142
ffa_ch14_barrett.kv 143 FZ_Low_Multiply_Unbuffered(XHi, YLo, HL);
ffa_ch14_barrett.kv 144
ffa_ch14_barrett.kv 145
ffa_ch14_barrett.kv 146 FZ_Add_D(X => XYHi, Y => LH, Overflow => C);
ffa_ch14_barrett.kv 147
ffa_ch14_barrett.kv 148
ffa_ch14_barrett.kv 149 FZ_Add_D(X => XYHi, Y => HL, Overflow => C);
ffa_ch14_barrett.kv 150
ffa_ch14_barrett.kv 151 end Low_Mul;
ffa_ch14_barrett.kv 152
ffa_ch14_barrett.kv 153
ffa_ch14_barrett.kv 154
ffa_ch14_barrett.kv 155
ffa_ch14_barrett.kv 156 procedure FZ_Low_Multiply_Unbuffered(X : in FZ;
ffa_ch14_barrett.kv 157 Y : in FZ;
ffa_ch14_barrett.kv 158 XY : out FZ) is
ffa_ch14_barrett.kv 159
ffa_ch14_barrett.kv 160
ffa_ch14_barrett.kv 161 L : constant Word_Count := X'Length;
ffa_ch14_barrett.kv 162
ffa_ch14_barrett.kv 163 begin
ffa_ch14_barrett.kv 164
ffa_ch14_barrett.kv 165 if L <= Low_Mul_Thresh then
ffa_ch14_barrett.kv 166
ffa_ch14_barrett.kv 167
ffa_ch14_barrett.kv 168 FZ_Low_Mul_Comba(X, Y, XY);
ffa_ch14_barrett.kv 169
ffa_ch14_barrett.kv 170 else
ffa_ch14_barrett.kv 171
ffa_ch14_barrett.kv 172
ffa_ch14_barrett.kv 173 Low_Mul(X, Y, XY);
ffa_ch14_barrett.kv 174
ffa_ch14_barrett.kv 175 end if;
ffa_ch14_barrett.kv 176
ffa_ch14_barrett.kv 177 end FZ_Low_Multiply_Unbuffered;
ffa_ch14_barrett.kv 178
ffa_ch15_gcd.kv 179
ffa_ch15_gcd.kv 180
ffa_ch15_gcd.kv 181 procedure FZ_Low_Multiply_Buffered(X : in FZ;
ffa_ch15_gcd.kv 182 Y : in FZ;
ffa_ch15_gcd.kv 183 XY : out FZ) is
ffa_ch15_gcd.kv 184
ffa_ch15_gcd.kv 185
ffa_ch15_gcd.kv 186 P : FZ(1 .. X'Length);
ffa_ch15_gcd.kv 187
ffa_ch15_gcd.kv 188 begin
ffa_ch15_gcd.kv 189
ffa_ch15_gcd.kv 190 FZ_Low_Multiply_Unbuffered(X, Y, P);
ffa_ch15_gcd.kv 191
ffa_ch15_gcd.kv 192 XY := P;
ffa_ch15_gcd.kv 193
ffa_ch15_gcd.kv 194 end FZ_Low_Multiply_Buffered;
ffa_ch15_gcd.kv 195
ffa_ch14_barrett.kv 196 end FZ_LoMul;