------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. -- -- -- -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) -- -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html -- -- -- -- You do not have, nor can you ever acquire the right to use, copy or -- -- distribute this software ; Should you use this software for any purpose, -- -- or copy and distribute it to anyone or in any manner, you are breaking -- -- the laws of whatever soi-disant jurisdiction, and you promise to -- -- continue doing so for the indefinite future. In any case, please -- -- always : read and understand any software ; verify any PGP signatures -- -- that you use - for any purpose. -- -- -- -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Word_Ops; use Word_Ops; -- Elementary Predicates on Words: package body W_Pred is -- Return 1 if N is equal to 0; otherwise return 0. function W_ZeroP(N : in Word) return WBool is begin return W_Borrow(N, 1, N - 1); end W_ZeroP; pragma Inline_Always(W_ZeroP); -- Return 1 if N is unequal to 0; otherwise return 0. function W_NZeroP(N : in Word) return WBool is begin return 1 xor W_ZeroP(N); end W_NZeroP; pragma Inline_Always(W_NZeroP); -- Return WBool-complement of N. function W_Not(N : in WBool) return WBool is begin return 1 xor N; end W_Not; pragma Inline_Always(W_Not); -- Return 1 if N is odd; otherwise return 0. function W_OddP(N : in Word) return WBool is begin return 1 and N; end W_OddP; pragma Inline_Always(W_OddP); -- Return 1 if A is equal to B ; otherwise return 0. function W_EqP(A : in Word; B : in Word) return WBool is begin return W_ZeroP(A xor B); end W_EqP; pragma Inline_Always(W_EqP); end W_Pred;