ffa_ch5_egypt.kv 1
ffa_ch5_egypt.kv 2
ffa_ch5_egypt.kv 3
ffa_ch5_egypt.kv 4
ffa_ch5_egypt.kv 5
ffa_ch5_egypt.kv 6
ffa_ch5_egypt.kv 7
ffa_ch5_egypt.kv 8
ffa_ch5_egypt.kv 9
ffa_ch5_egypt.kv 10
ffa_ch5_egypt.kv 11
ffa_ch5_egypt.kv 12
ffa_ch5_egypt.kv 13
ffa_ch5_egypt.kv 14
ffa_ch5_egypt.kv 15
ffa_ch5_egypt.kv 16
ffa_ch5_egypt.kv 17
ffa_ch5_egypt.kv 18
ffa_ch5_egypt.kv 19
ffa_ch5_egypt.kv 20 with Words; use Words;
ffa_ch5_egypt.kv 21 with W_Pred; use W_Pred;
ffa_ch7_turbo_egy... 22 with W_Shifts; use W_Shifts;
ffa_ch5_egypt.kv 23 with FZ_Basic; use FZ_Basic;
ffa_ch5_egypt.kv 24 with FZ_Arith; use FZ_Arith;
ffa_ch5_egypt.kv 25 with FZ_BitOp; use FZ_BitOp;
ffa_ch5_egypt.kv 26 with FZ_Shift; use FZ_Shift;
ffa_ch5_egypt.kv 27
ffa_ch5_egypt.kv 28
ffa_ch5_egypt.kv 29 package body FZ_Divis is
ffa_ch5_egypt.kv 30
ffa_ch5_egypt.kv 31
ffa_ch5_egypt.kv 32
ffa_ch5_egypt.kv 33 procedure FZ_IDiv(Dividend : in FZ;
ffa_ch5_egypt.kv 34 Divisor : in FZ;
ffa_ch5_egypt.kv 35 Quotient : out FZ;
ffa_ch5_egypt.kv 36 Remainder : out FZ) is
ffa_ch5_egypt.kv 37
ffa_ch5_egypt.kv 38
ffa_ch5_egypt.kv 39 QR : FZ(1 .. Dividend'Length + Divisor'Length);
ffa_ch5_egypt.kv 40
ffa_ch5_egypt.kv 41
ffa_ch5_egypt.kv 42 Q : FZ renames QR(1 .. Dividend'Length);
ffa_ch5_egypt.kv 43 R : FZ renames QR(Dividend'Length + 1 .. QR'Last);
ffa_ch5_egypt.kv 44
ffa_ch5_egypt.kv 45 C : WBool := 0;
ffa_ch5_egypt.kv 46 begin
ffa_ch5_egypt.kv 47 Q := Dividend;
ffa_ch5_egypt.kv 48 FZ_Clear(R);
ffa_ch5_egypt.kv 49
ffa_ch5_egypt.kv 50
ffa_ch5_egypt.kv 51 for i in 1 .. FZ_Bitness(Dividend) loop
ffa_ch5_egypt.kv 52
ffa_ch5_egypt.kv 53
ffa_ch5_egypt.kv 54 FZ_ShiftLeft(QR, QR, 1);
ffa_ch5_egypt.kv 55
ffa_ch5_egypt.kv 56
ffa_ch5_egypt.kv 57 FZ_Sub(X => R, Y => Divisor, Difference => R, Underflow => C);
ffa_ch5_egypt.kv 58
ffa_ch5_egypt.kv 59
ffa_ch5_egypt.kv 60 FZ_Add_Gated(X => R, Y => Divisor, Gate => C, Sum => R);
ffa_ch5_egypt.kv 61
ffa_ch5_egypt.kv 62
ffa_ch5_egypt.kv 63 FZ_Or_W(Q, W_Not(C));
ffa_ch5_egypt.kv 64
ffa_ch5_egypt.kv 65 end loop;
ffa_ch5_egypt.kv 66
ffa_ch5_egypt.kv 67 Quotient := Q;
ffa_ch5_egypt.kv 68 Remainder := R;
ffa_ch5_egypt.kv 69
ffa_ch5_egypt.kv 70 end FZ_IDiv;
ffa_ch5_egypt.kv 71 pragma Inline_Always(FZ_IDiv);
ffa_ch5_egypt.kv 72
ffa_ch5_egypt.kv 73
ffa_ch5_egypt.kv 74
ffa_ch5_egypt.kv 75 procedure FZ_Div(Dividend : in FZ;
ffa_ch5_egypt.kv 76 Divisor : in FZ;
ffa_ch5_egypt.kv 77 Quotient : out FZ) is
ffa_ch5_egypt.kv 78 Remainder : FZ(Divisor'Range);
ffa_ch5_egypt.kv 79 pragma Unreferenced(Remainder);
ffa_ch5_egypt.kv 80 begin
ffa_ch5_egypt.kv 81 FZ_IDiv(Dividend, Divisor, Quotient, Remainder);
ffa_ch5_egypt.kv 82 end FZ_Div;
ffa_ch5_egypt.kv 83 pragma Inline_Always(FZ_Div);
ffa_ch5_egypt.kv 84
ffa_ch5_egypt.kv 85
ffa_ch7_turbo_egy... 86
ffa_ch5_egypt.kv 87 procedure FZ_Mod(Dividend : in FZ;
ffa_ch5_egypt.kv 88 Divisor : in FZ;
ffa_ch5_egypt.kv 89 Remainder : out FZ) is
ffa_ch7_turbo_egy... 90
ffa_ch7_turbo_egy... 91
ffa_ch7_turbo_egy... 92 L : constant Indices := Divisor'Length;
ffa_ch7_turbo_egy... 93
ffa_ch7_turbo_egy... 94
ffa_ch7_turbo_egy... 95 R : FZ(1 .. L) := (others => 0);
ffa_ch7_turbo_egy... 96
ffa_ch7_turbo_egy... 97
ffa_ch7_turbo_egy... 98 subtype Dividend_Index is Word_Index range Dividend'Range;
ffa_ch7_turbo_egy... 99
ffa_ch7_turbo_egy... 100
ffa_ch7_turbo_egy... 101 subtype Divisor_Cuts is Word_Index range 2 .. Divisor'Length;
ffa_ch7_turbo_egy... 102
ffa_ch7_turbo_egy... 103
ffa_ch7_turbo_egy... 104 procedure Slice(Index : Dividend_Index;
ffa_ch7_turbo_egy... 105 Cut : Divisor_Cuts) is
ffa_ch7_turbo_egy... 106 begin
ffa_ch7_turbo_egy... 107
ffa_ch7_turbo_egy... 108 declare
ffa_ch7_turbo_egy... 109
ffa_ch7_turbo_egy... 110
ffa_ch7_turbo_egy... 111 C : WBool;
ffa_ch7_turbo_egy... 112
ffa_ch7_turbo_egy... 113
ffa_ch7_turbo_egy... 114 LsO : WBool;
ffa_ch7_turbo_egy... 115
ffa_ch7_turbo_egy... 116
ffa_ch7_turbo_egy... 117 Rs : FZ renames R(1 .. Cut);
ffa_ch7_turbo_egy... 118
ffa_ch7_turbo_egy... 119
ffa_ch7_turbo_egy... 120 Ds : FZ renames Divisor(1 .. Cut);
ffa_ch7_turbo_egy... 121
ffa_ch7_turbo_egy... 122
ffa_ch7_turbo_egy... 123 W : Word := Dividend(Dividend'Last + 1 - Index);
ffa_ch7_turbo_egy... 124
ffa_ch7_turbo_egy... 125 begin
ffa_ch7_turbo_egy... 126
ffa_ch7_turbo_egy... 127
ffa_ch7_turbo_egy... 128 for b in 1 .. Bitness loop
ffa_ch7_turbo_egy... 129
ffa_ch7_turbo_egy... 130
ffa_ch7_turbo_egy... 131 W := Rotate_Left(W, 1);
ffa_ch7_turbo_egy... 132
ffa_ch7_turbo_egy... 133
ffa_ch7_turbo_egy... 134 FZ_ShiftLeft_O_I(N => Rs, ShiftedN => Rs, Count => 1,
ffa_ch7_turbo_egy... 135 OF_In => W and 1,
ffa_ch7_turbo_egy... 136 Overflow => LsO);
ffa_ch7_turbo_egy... 137
ffa_ch7_turbo_egy... 138
ffa_ch7_turbo_egy... 139 FZ_Sub(X => Rs, Y => Ds, Difference => Rs, Underflow => C);
ffa_ch7_turbo_egy... 140
ffa_ch7_turbo_egy... 141
ffa_ch7_turbo_egy... 142 FZ_Add_Gated(X => Rs, Y => Ds, Sum => Rs,
ffa_ch7_turbo_egy... 143 Gate => C and W_Not(LsO));
ffa_ch7_turbo_egy... 144
ffa_ch7_turbo_egy... 145 end loop;
ffa_ch7_turbo_egy... 146
ffa_ch7_turbo_egy... 147 end;
ffa_ch7_turbo_egy... 148
ffa_ch7_turbo_egy... 149 end Slice;
ffa_ch7_turbo_egy... 150
ffa_ch5_egypt.kv 151 begin
ffa_ch7_turbo_egy... 152
ffa_ch7_turbo_egy... 153
ffa_ch7_turbo_egy... 154 for i in 1 .. L - 1 loop
ffa_ch7_turbo_egy... 155
ffa_ch7_turbo_egy... 156 Slice(i, i + 1);
ffa_ch7_turbo_egy... 157
ffa_ch7_turbo_egy... 158 end loop;
ffa_ch7_turbo_egy... 159
ffa_ch7_turbo_egy... 160
ffa_ch7_turbo_egy... 161 for i in L .. Dividend'Length loop
ffa_ch7_turbo_egy... 162
ffa_ch7_turbo_egy... 163 Slice(i, L);
ffa_ch7_turbo_egy... 164
ffa_ch7_turbo_egy... 165 end loop;
ffa_ch7_turbo_egy... 166
ffa_ch7_turbo_egy... 167
ffa_ch7_turbo_egy... 168 Remainder := R;
ffa_ch7_turbo_egy... 169
ffa_ch5_egypt.kv 170 end FZ_Mod;
ffa_ch5_egypt.kv 171 pragma Inline_Always(FZ_Mod);
ffa_ch5_egypt.kv 172
ffa_ch7_turbo_egy... 173
ffa_ch5_egypt.kv 174 end FZ_Divis;