Finite Field Arithmetic

fz_shift.ads


   1 ------------------------------------------------------------------------------
   2 ------------------------------------------------------------------------------
   3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'.               --
   4 --                                                                          --
   5 -- (C) 2019 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 Words;   use Words;
  21 with FZ_Type; use FZ_Type;
  22 
  23 
  24 package FZ_Shift is
  25    
  26    pragma Pure;
  27    
  28    --------------------------------------------------------------
  29    -- WARNING: These ops are not precondition-shielded, and
  30    -- must never be directly exposed via the user API ( ffa.ads )
  31    --------------------------------------------------------------
  32    
  33    --------------------------------------------------------------
  34    -- Shift Right
  35    --------------------------------------------------------------
  36    
  37    -- ShiftedN := N >> Count (with Overflow Input and Output)
  38    -- WARNING: OF_in MUST be of valid bit-width for the shift!
  39    procedure FZ_ShiftRight_O_I(N        : in  FZ;
  40                                ShiftedN : out FZ;
  41                                Count    : in  WBit_Index;
  42                                Overflow : out Word;
  43                                OF_in    : in  Word);
  44    pragma Inline_Always(FZ_ShiftRight_O_I);
  45    
  46    -- ShiftedN := N >> Count (with Overflow Output only)
  47    procedure FZ_ShiftRight_O(N        : in  FZ;
  48                              ShiftedN : out FZ;
  49                              Count    : in  WBit_Index;
  50                              Overflow : out Word);
  51    pragma Inline_Always(FZ_ShiftRight_O);
  52    
  53    -- ShiftedN := N >> Count (no Overflow output or input)
  54    procedure FZ_ShiftRight(N        : in  FZ;
  55                            ShiftedN : out FZ;
  56                            Count    : in  WBit_Index);
  57    pragma Inline_Always(FZ_ShiftRight);
  58    
  59    --------------------------------------------------------------
  60    -- Shift Left
  61    --------------------------------------------------------------
  62 
  63    -- ShiftedN := N << Count (with Overflow Input and Output)
  64    -- WARNING: OF_in MUST be of valid bit-width for the shift!
  65    procedure FZ_ShiftLeft_O_I(N        : in  FZ;
  66                               ShiftedN : out FZ;
  67                               Count    : in  WBit_Index;
  68                               Overflow : out Word;
  69                               OF_in    : in  Word);
  70    pragma Inline_Always(FZ_ShiftLeft_O_I);
  71    
  72    -- ShiftedN := N << Count (with Overflow Output only)
  73    procedure FZ_ShiftLeft_O(N        : in  FZ;
  74                             ShiftedN : out FZ;
  75                             Count    : in  WBit_Index;
  76                             Overflow : out Word);
  77    pragma Inline_Always(FZ_ShiftLeft_O);
  78    
  79    -- ShiftedN := N << Count (no Overflow output or input)
  80    procedure FZ_ShiftLeft(N        : in  FZ;
  81                           ShiftedN : out FZ;
  82                           Count    : in  WBit_Index);
  83    pragma Inline_Always(FZ_ShiftLeft);
  84    
  85 end FZ_Shift;