File : fz_lomul.ads


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