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