raw
ffa_ch2_logicals.kv     1 ------------------------------------------------------------------------------
ffa_ch2_logicals.kv 2 ------------------------------------------------------------------------------
ffa_ch2_logicals.kv 3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
ffa_ch2_logicals.kv 4 -- --
ffa_ch2_logicals.kv 5 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
ffa_ch2_logicals.kv 6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
ffa_ch2_logicals.kv 7 -- --
ffa_ch2_logicals.kv 8 -- You do not have, nor can you ever acquire the right to use, copy or --
ffa_ch2_logicals.kv 9 -- distribute this software ; Should you use this software for any purpose, --
ffa_ch2_logicals.kv 10 -- or copy and distribute it to anyone or in any manner, you are breaking --
ffa_ch2_logicals.kv 11 -- the laws of whatever soi-disant jurisdiction, and you promise to --
ffa_ch2_logicals.kv 12 -- continue doing so for the indefinite future. In any case, please --
ffa_ch2_logicals.kv 13 -- always : read and understand any software ; verify any PGP signatures --
ffa_ch2_logicals.kv 14 -- that you use - for any purpose. --
ffa_ch2_logicals.kv 15 -- --
ffa_ch2_logicals.kv 16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
ffa_ch2_logicals.kv 17 ------------------------------------------------------------------------------
ffa_ch2_logicals.kv 18 ------------------------------------------------------------------------------
ffa_ch2_logicals.kv 19
ffa_ch2_logicals.kv 20 with Word_Ops; use Word_Ops;
ffa_ch2_logicals.kv 21
ffa_ch2_logicals.kv 22 -- Elementary Predicates on Words:
ffa_ch2_logicals.kv 23 package body W_Pred is
ffa_ch2_logicals.kv 24
ffa_ch2_logicals.kv 25 -- Return 1 if N is equal to 0; otherwise return 0.
ffa_ch2_logicals.kv 26 function W_ZeroP(N : in Word) return WBool is
ffa_ch2_logicals.kv 27 begin
ffa_ch2_logicals.kv 28 return W_Borrow(N, 1, N - 1);
ffa_ch2_logicals.kv 29 end W_ZeroP;
ffa_ch2_logicals.kv 30 pragma Inline_Always(W_ZeroP);
ffa_ch2_logicals.kv 31
ffa_ch2_logicals.kv 32
ffa_ch2_logicals.kv 33 -- Return 1 if N is unequal to 0; otherwise return 0.
ffa_ch2_logicals.kv 34 function W_NZeroP(N : in Word) return WBool is
ffa_ch2_logicals.kv 35 begin
ffa_ch2_logicals.kv 36 return 1 xor W_ZeroP(N);
ffa_ch2_logicals.kv 37 end W_NZeroP;
ffa_ch2_logicals.kv 38 pragma Inline_Always(W_NZeroP);
ffa_ch2_logicals.kv 39
ffa_ch2_logicals.kv 40
ffa_ch5_egypt.kv 41 -- Return WBool-complement of N.
ffa_ch5_egypt.kv 42 function W_Not(N : in WBool) return WBool is
ffa_ch5_egypt.kv 43 begin
ffa_ch5_egypt.kv 44 return 1 xor N;
ffa_ch5_egypt.kv 45 end W_Not;
ffa_ch5_egypt.kv 46 pragma Inline_Always(W_Not);
ffa_ch5_egypt.kv 47
ffa_ch5_egypt.kv 48
ffa_ch2_logicals.kv 49 -- Return 1 if N is odd; otherwise return 0.
ffa_ch2_logicals.kv 50 function W_OddP(N : in Word) return WBool is
ffa_ch2_logicals.kv 51 begin
ffa_ch2_logicals.kv 52 return 1 and N;
ffa_ch2_logicals.kv 53 end W_OddP;
ffa_ch2_logicals.kv 54 pragma Inline_Always(W_OddP);
ffa_ch2_logicals.kv 55
ffa_ch2_logicals.kv 56
ffa_ch2_logicals.kv 57 -- Return 1 if A is equal to B ; otherwise return 0.
ffa_ch2_logicals.kv 58 function W_EqP(A : in Word; B : in Word) return WBool is
ffa_ch2_logicals.kv 59 begin
ffa_ch2_logicals.kv 60 return W_ZeroP(A xor B);
ffa_ch2_logicals.kv 61 end W_EqP;
ffa_ch2_logicals.kv 62 pragma Inline_Always(W_EqP);
ffa_ch2_logicals.kv 63
ffa_ch2_logicals.kv 64 end W_Pred;