raw
ffa_ch14_barrett.kv     1 ------------------------------------------------------------------------------
ffa_ch14_barrett.kv 2 ------------------------------------------------------------------------------
ffa_ch14_barrett.kv 3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
ffa_ch14_barrett.kv 4 -- --
ffa_ch15_gcd.kv 5 -- (C) 2019 Stanislav Datskovskiy ( www.loper-os.org ) --
ffa_ch14_barrett.kv 6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
ffa_ch14_barrett.kv 7 -- --
ffa_ch14_barrett.kv 8 -- You do not have, nor can you ever acquire the right to use, copy or --
ffa_ch14_barrett.kv 9 -- distribute this software ; Should you use this software for any purpose, --
ffa_ch14_barrett.kv 10 -- or copy and distribute it to anyone or in any manner, you are breaking --
ffa_ch14_barrett.kv 11 -- the laws of whatever soi-disant jurisdiction, and you promise to --
ffa_ch14_barrett.kv 12 -- continue doing so for the indefinite future. In any case, please --
ffa_ch14_barrett.kv 13 -- always : read and understand any software ; verify any PGP signatures --
ffa_ch14_barrett.kv 14 -- that you use - for any purpose. --
ffa_ch14_barrett.kv 15 -- --
ffa_ch14_barrett.kv 16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
ffa_ch14_barrett.kv 17 ------------------------------------------------------------------------------
ffa_ch14_barrett.kv 18 ------------------------------------------------------------------------------
ffa_ch14_barrett.kv 19
ffa_ch14_barrett.kv 20 with FZ_Type; use FZ_Type;
ffa_ch14_barrett.kv 21
ffa_ch14_barrett.kv 22
ffa_ch14_barrett.kv 23 -- "Low Multiplication" computes only the bottom half of the product XY.
ffa_ch14_barrett.kv 24 -- Presently, it is used solely in Barrett's Modular Reduction.
ffa_ch14_barrett.kv 25
ffa_ch14_barrett.kv 26 package FZ_LoMul is
ffa_ch14_barrett.kv 27
ffa_ch14_barrett.kv 28 pragma Pure;
ffa_ch14_barrett.kv 29
ffa_ch14_barrett.kv 30 -- Threshhold for Low Mul - at or below this many Words, we use Comba mult.
ffa_ch14_barrett.kv 31 Low_Mul_Thresh : constant Indices := 8;
ffa_ch14_barrett.kv 32
ffa_ch14_barrett.kv 33 -- Multiply. (CAUTION: UNBUFFERED)
ffa_ch14_barrett.kv 34 procedure FZ_Low_Multiply_Unbuffered(X : in FZ;
ffa_ch14_barrett.kv 35 Y : in FZ;
ffa_ch14_barrett.kv 36 XY : out FZ);
ffa_ch14_barrett.kv 37 pragma Inline_Always(FZ_Low_Multiply_Unbuffered);
ffa_ch14_barrett.kv 38
ffa_ch14_barrett.kv 39 -- Comba's multiplier. (CAUTION: UNBUFFERED)
ffa_ch14_barrett.kv 40 procedure FZ_Low_Mul_Comba(X : in FZ;
ffa_ch14_barrett.kv 41 Y : in FZ;
ffa_ch14_barrett.kv 42 XY : out FZ);
ffa_ch14_barrett.kv 43 pragma Inline_Always(FZ_Low_Mul_Comba);
ffa_ch14_barrett.kv 44
ffa_ch14_barrett.kv 45 -- Low Multiplier. (CAUTION: UNBUFFERED)
ffa_ch14_barrett.kv 46 procedure Low_Mul(X : in FZ;
ffa_ch14_barrett.kv 47 Y : in FZ;
ffa_ch14_barrett.kv 48 XY : out FZ)
ffa_ch14_barrett.kv 49 with Pre => X'Length = Y'Length and
ffa_ch14_barrett.kv 50 XY'Length = X'Length and
ffa_ch14_barrett.kv 51 X'Length mod 2 = 0;
ffa_ch14_barrett.kv 52 -- CAUTION: Inlining prohibited for Low_Mul !
ffa_ch14_barrett.kv 53
ffa_ch15_gcd.kv 54 -- Low-Only Multiplier. Preserves the inputs.
ffa_ch15_gcd.kv 55 procedure FZ_Low_Multiply_Buffered(X : in FZ;
ffa_ch15_gcd.kv 56 Y : in FZ;
ffa_ch15_gcd.kv 57 XY : out FZ)
ffa_ch15_gcd.kv 58 with Pre => X'Length = Y'Length and
ffa_ch15_gcd.kv 59 XY'Length = X'Length and
ffa_ch15_gcd.kv 60 X'Length mod 2 = 0;
ffa_ch15_gcd.kv 61
ffa_ch14_barrett.kv 62 end FZ_LoMul;