Finite Field Arithmetic

word_ops.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 
  22 -- Fundamental Operations on Words:
  23 package Word_Ops is
  24    
  25    pragma Pure;
  26    
  27    -- Branch-free calculation of 'carry' from a machine-word addition.
  28    function W_Carry(A : in Word; B : in Word; S : in Word)
  29                    return WBool;
  30    pragma Inline_Always(W_Carry);
  31    
  32    -- Branch-free calculation of 'borrow' from a machine-word subtraction.
  33    function W_Borrow(A : in Word; B : in Word; D : in Word)
  34                     return WBool;
  35    pragma Inline_Always(W_Borrow);
  36    
  37    -- Without any branching: if Sel == 0, return A; if Sel == 1, return B.
  38    function W_Mux(A : in Word; B : in Word; Sel : in WBool)
  39                  return Word;
  40    pragma Inline_Always(W_Mux);
  41    
  42 end Word_Ops;