ffa_ch5_egypt.kv 1
ffa_ch5_egypt.kv 2
ffa_ch5_egypt.kv 3
ffa_ch5_egypt.kv 4
ffa_ch15_gcd.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
ffa_ch5_egypt.kv 72
ffa_ch5_egypt.kv 73 procedure FZ_Div(Dividend : in FZ;
ffa_ch5_egypt.kv 74 Divisor : in FZ;
ffa_ch5_egypt.kv 75 Quotient : out FZ) is
ffa_ch5_egypt.kv 76 Remainder : FZ(Divisor'Range);
ffa_ch5_egypt.kv 77 pragma Unreferenced(Remainder);
ffa_ch5_egypt.kv 78 begin
ffa_ch5_egypt.kv 79 FZ_IDiv(Dividend, Divisor, Quotient, Remainder);
ffa_ch5_egypt.kv 80 end FZ_Div;
ffa_ch5_egypt.kv 81
ffa_ch7_turbo_egy... 82
ffa_ch5_egypt.kv 83 procedure FZ_Mod(Dividend : in FZ;
ffa_ch5_egypt.kv 84 Divisor : in FZ;
ffa_ch5_egypt.kv 85 Remainder : out FZ) is
ffa_ch7_turbo_egy... 86
ffa_ch7_turbo_egy... 87
ffa_ch7_turbo_egy... 88 L : constant Indices := Divisor'Length;
ffa_ch7_turbo_egy... 89
ffa_ch7_turbo_egy... 90
ffa_ch7_turbo_egy... 91 R : FZ(1 .. L) := (others => 0);
ffa_ch7_turbo_egy... 92
ffa_ch7_turbo_egy... 93
ffa_ch7_turbo_egy... 94 subtype Dividend_Index is Word_Index range Dividend'Range;
ffa_ch7_turbo_egy... 95
ffa_ch7_turbo_egy... 96
ffa_ch7_turbo_egy... 97 subtype Divisor_Cuts is Word_Index range 2 .. Divisor'Length;
ffa_ch7_turbo_egy... 98
ffa_ch7_turbo_egy... 99
ffa_ch7_turbo_egy... 100 procedure Slice(Index : Dividend_Index;
ffa_ch7_turbo_egy... 101 Cut : Divisor_Cuts) is
ffa_ch7_turbo_egy... 102 begin
ffa_ch7_turbo_egy... 103
ffa_ch7_turbo_egy... 104 declare
ffa_ch7_turbo_egy... 105
ffa_ch7_turbo_egy... 106
ffa_ch7_turbo_egy... 107 C : WBool;
ffa_ch7_turbo_egy... 108
ffa_ch7_turbo_egy... 109
ffa_ch7_turbo_egy... 110 LsO : WBool;
ffa_ch7_turbo_egy... 111
ffa_ch7_turbo_egy... 112
ffa_ch7_turbo_egy... 113 Rs : FZ renames R(1 .. Cut);
ffa_ch7_turbo_egy... 114
ffa_ch7_turbo_egy... 115
ffa_ch7_turbo_egy... 116 Ds : FZ renames Divisor(1 .. Cut);
ffa_ch7_turbo_egy... 117
ffa_ch7_turbo_egy... 118
ffa_ch7_turbo_egy... 119 W : Word := Dividend(Dividend'Last + 1 - Index);
ffa_ch7_turbo_egy... 120
ffa_ch7_turbo_egy... 121 begin
ffa_ch7_turbo_egy... 122
ffa_ch7_turbo_egy... 123
ffa_ch7_turbo_egy... 124 for b in 1 .. Bitness loop
ffa_ch7_turbo_egy... 125
ffa_ch7_turbo_egy... 126
ffa_ch7_turbo_egy... 127 W := Rotate_Left(W, 1);
ffa_ch7_turbo_egy... 128
ffa_ch7_turbo_egy... 129
ffa_ch7_turbo_egy... 130 FZ_ShiftLeft_O_I(N => Rs, ShiftedN => Rs, Count => 1,
ffa_ch7_turbo_egy... 131 OF_In => W and 1,
ffa_ch7_turbo_egy... 132 Overflow => LsO);
ffa_ch7_turbo_egy... 133
ffa_ch7_turbo_egy... 134
ffa_ch7_turbo_egy... 135 FZ_Sub(X => Rs, Y => Ds, Difference => Rs, Underflow => C);
ffa_ch7_turbo_egy... 136
ffa_ch7_turbo_egy... 137
ffa_ch7_turbo_egy... 138 FZ_Add_Gated(X => Rs, Y => Ds, Sum => Rs,
ffa_ch7_turbo_egy... 139 Gate => C and W_Not(LsO));
ffa_ch7_turbo_egy... 140
ffa_ch7_turbo_egy... 141 end loop;
ffa_ch7_turbo_egy... 142
ffa_ch7_turbo_egy... 143 end;
ffa_ch7_turbo_egy... 144
ffa_ch7_turbo_egy... 145 end Slice;
ffa_ch7_turbo_egy... 146
ffa_ch5_egypt.kv 147 begin
ffa_ch7_turbo_egy... 148
ffa_ch7_turbo_egy... 149
ffa_ch7_turbo_egy... 150 for i in 1 .. L - 1 loop
ffa_ch7_turbo_egy... 151
ffa_ch7_turbo_egy... 152 Slice(i, i + 1);
ffa_ch7_turbo_egy... 153
ffa_ch7_turbo_egy... 154 end loop;
ffa_ch7_turbo_egy... 155
ffa_ch7_turbo_egy... 156
ffa_ch7_turbo_egy... 157 for i in L .. Dividend'Length loop
ffa_ch7_turbo_egy... 158
ffa_ch7_turbo_egy... 159 Slice(i, L);
ffa_ch7_turbo_egy... 160
ffa_ch7_turbo_egy... 161 end loop;
ffa_ch7_turbo_egy... 162
ffa_ch7_turbo_egy... 163
ffa_ch7_turbo_egy... 164 Remainder := R;
ffa_ch7_turbo_egy... 165
ffa_ch5_egypt.kv 166 end FZ_Mod;
ffa_ch7_turbo_egy... 167
ffa_ch5_egypt.kv 168 end FZ_Divis;