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_ch5_egypt.kv 22 with FZ_Basic; use FZ_Basic;
ffa_ch5_egypt.kv 23 with FZ_Arith; use FZ_Arith;
ffa_ch5_egypt.kv 24 with FZ_BitOp; use FZ_BitOp;
ffa_ch5_egypt.kv 25 with FZ_Shift; use FZ_Shift;
ffa_ch5_egypt.kv 26
ffa_ch5_egypt.kv 27
ffa_ch5_egypt.kv 28 package body FZ_Divis is
ffa_ch5_egypt.kv 29
ffa_ch5_egypt.kv 30
ffa_ch5_egypt.kv 31
ffa_ch5_egypt.kv 32 procedure FZ_IDiv(Dividend : in FZ;
ffa_ch5_egypt.kv 33 Divisor : in FZ;
ffa_ch5_egypt.kv 34 Quotient : out FZ;
ffa_ch5_egypt.kv 35 Remainder : out FZ) is
ffa_ch5_egypt.kv 36
ffa_ch5_egypt.kv 37
ffa_ch5_egypt.kv 38 QR : FZ(1 .. Dividend'Length + Divisor'Length);
ffa_ch5_egypt.kv 39
ffa_ch5_egypt.kv 40
ffa_ch5_egypt.kv 41 Q : FZ renames QR(1 .. Dividend'Length);
ffa_ch5_egypt.kv 42 R : FZ renames QR(Dividend'Length + 1 .. QR'Last);
ffa_ch5_egypt.kv 43
ffa_ch5_egypt.kv 44 C : WBool := 0;
ffa_ch5_egypt.kv 45 begin
ffa_ch5_egypt.kv 46 Q := Dividend;
ffa_ch5_egypt.kv 47 FZ_Clear(R);
ffa_ch5_egypt.kv 48
ffa_ch5_egypt.kv 49
ffa_ch5_egypt.kv 50 for i in 1 .. FZ_Bitness(Dividend) loop
ffa_ch5_egypt.kv 51
ffa_ch5_egypt.kv 52
ffa_ch5_egypt.kv 53 FZ_ShiftLeft(QR, QR, 1);
ffa_ch5_egypt.kv 54
ffa_ch5_egypt.kv 55
ffa_ch5_egypt.kv 56 FZ_Sub(X => R, Y => Divisor, Difference => R, Underflow => C);
ffa_ch5_egypt.kv 57
ffa_ch5_egypt.kv 58
ffa_ch5_egypt.kv 59 FZ_Add_Gated(X => R, Y => Divisor, Gate => C, Sum => R);
ffa_ch5_egypt.kv 60
ffa_ch5_egypt.kv 61
ffa_ch5_egypt.kv 62 FZ_Or_W(Q, W_Not(C));
ffa_ch5_egypt.kv 63
ffa_ch5_egypt.kv 64 end loop;
ffa_ch5_egypt.kv 65
ffa_ch5_egypt.kv 66 Quotient := Q;
ffa_ch5_egypt.kv 67 Remainder := R;
ffa_ch5_egypt.kv 68
ffa_ch5_egypt.kv 69 end FZ_IDiv;
ffa_ch5_egypt.kv 70 pragma Inline_Always(FZ_IDiv);
ffa_ch5_egypt.kv 71
ffa_ch5_egypt.kv 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 pragma Inline_Always(FZ_Div);
ffa_ch5_egypt.kv 83
ffa_ch5_egypt.kv 84
ffa_ch5_egypt.kv 85
ffa_ch5_egypt.kv 86 procedure FZ_Mod(Dividend : in FZ;
ffa_ch5_egypt.kv 87 Divisor : in FZ;
ffa_ch5_egypt.kv 88 Remainder : out FZ) is
ffa_ch5_egypt.kv 89 Quotient : FZ(Dividend'Range);
ffa_ch5_egypt.kv 90 pragma Unreferenced(Quotient);
ffa_ch5_egypt.kv 91 begin
ffa_ch5_egypt.kv 92 FZ_IDiv(Dividend, Divisor, Quotient, Remainder);
ffa_ch5_egypt.kv 93 end FZ_Mod;
ffa_ch5_egypt.kv 94 pragma Inline_Always(FZ_Mod);
ffa_ch5_egypt.kv 95
ffa_ch5_egypt.kv 96 end FZ_Divis;