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_ch15_gcd.kv 5 -- (C) 2019 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 -- From Ada:
ffa_ch2_logicals.kv 21 with Ada.Text_IO; use Ada.Text_IO;
ffa_ch2_logicals.kv 22
ffa_ch2_logicals.kv 23 -- From FFA:
ffa_ch2_logicals.kv 24 with Words; use Words;
ffa_ch2_logicals.kv 25 with FZ_Type; use FZ_Type;
ffa_ch2_logicals.kv 26 with FZ_Arith; use FZ_Arith;
ffa_ch2_logicals.kv 27
ffa_ch2_logicals.kv 28 -- FFA Ch. 2
ffa_ch2_logicals.kv 29 with W_Pred; use W_Pred;
ffa_ch2_logicals.kv 30 with FZ_Basic; use FZ_Basic;
ffa_ch2_logicals.kv 31 with FZ_Pred; use FZ_Pred;
ffa_ch2_logicals.kv 32 with FZ_BitOp; use FZ_BitOp;
ffa_ch2_logicals.kv 33 with FZ_Cmp; use FZ_Cmp;
ffa_ch2_logicals.kv 34
ffa_ch2_logicals.kv 35 -- From the Demo:
ffa_ch2_logicals.kv 36 with FFA_IO; use FFA_IO;
ffa_ch2_logicals.kv 37
ffa_ch2_logicals.kv 38
ffa_ch2_logicals.kv 39 package body Demo_Ch2 is
ffa_ch2_logicals.kv 40
ffa_ch2_logicals.kv 41 procedure Demo_Word_Preds is
ffa_ch2_logicals.kv 42
ffa_ch2_logicals.kv 43 begin
ffa_ch2_logicals.kv 44
ffa_ch2_logicals.kv 45 Put_Line("~~~ Ch. 2 : Word Predicates ~~~");
ffa_ch2_logicals.kv 46 New_Line;
ffa_ch2_logicals.kv 47
ffa_ch2_logicals.kv 48 Put_Line("W_ZeroP(0) :");
ffa_ch2_logicals.kv 49 Dump(W_ZeroP(0));
ffa_ch2_logicals.kv 50 New_Line;
ffa_ch2_logicals.kv 51 New_Line;
ffa_ch2_logicals.kv 52
ffa_ch2_logicals.kv 53 Put_Line("W_ZeroP(1) :");
ffa_ch2_logicals.kv 54 Dump(W_ZeroP(1));
ffa_ch2_logicals.kv 55 New_Line;
ffa_ch2_logicals.kv 56 New_Line;
ffa_ch2_logicals.kv 57
ffa_ch2_logicals.kv 58 Put_Line("W_NZeroP(1) :");
ffa_ch2_logicals.kv 59 Dump(W_NZeroP(1));
ffa_ch2_logicals.kv 60 New_Line;
ffa_ch2_logicals.kv 61 New_Line;
ffa_ch2_logicals.kv 62
ffa_ch2_logicals.kv 63 Put_Line("W_OddP(3) :");
ffa_ch2_logicals.kv 64 Dump(W_OddP(3));
ffa_ch2_logicals.kv 65 New_Line;
ffa_ch2_logicals.kv 66 New_Line;
ffa_ch2_logicals.kv 67
ffa_ch2_logicals.kv 68 Put_Line("W_EqP(1, 1) :");
ffa_ch2_logicals.kv 69 Dump(W_EqP(1, 1));
ffa_ch2_logicals.kv 70 New_Line;
ffa_ch2_logicals.kv 71 New_Line;
ffa_ch2_logicals.kv 72
ffa_ch2_logicals.kv 73 Put_Line("W_EqP(1, 0) :");
ffa_ch2_logicals.kv 74 Dump(W_EqP(1, 0));
ffa_ch2_logicals.kv 75 New_Line;
ffa_ch2_logicals.kv 76 New_Line;
ffa_ch2_logicals.kv 77
ffa_ch2_logicals.kv 78 end Demo_Word_Preds;
ffa_ch2_logicals.kv 79
ffa_ch2_logicals.kv 80
ffa_ch2_logicals.kv 81 procedure Demo_FZ_Basics is
ffa_ch2_logicals.kv 82
ffa_ch2_logicals.kv 83 X : FZ(1 .. 4) := ( 0, 0, 0, 0);
ffa_ch2_logicals.kv 84
ffa_ch2_logicals.kv 85 -- Shorthand for 'maxint'
ffa_ch2_logicals.kv 86 Y : FZ(1 .. 4) := (-1, -1, -1, -1);
ffa_ch2_logicals.kv 87
ffa_ch2_logicals.kv 88 Z : FZ(1 .. 4) := ( 0, 0, 0, 0);
ffa_ch2_logicals.kv 89
ffa_ch2_logicals.kv 90 -- Flag.
ffa_ch2_logicals.kv 91 F : WBool := 0;
ffa_ch2_logicals.kv 92
ffa_ch2_logicals.kv 93 begin
ffa_ch2_logicals.kv 94
ffa_ch2_logicals.kv 95 Put_Line("~~~ Ch. 2 : FZ Basics ~~~");
ffa_ch2_logicals.kv 96 New_Line;
ffa_ch2_logicals.kv 97
ffa_ch2_logicals.kv 98 Put_Line("X =");
ffa_ch2_logicals.kv 99 Dump(X);
ffa_ch2_logicals.kv 100 New_Line;
ffa_ch2_logicals.kv 101 New_Line;
ffa_ch2_logicals.kv 102
ffa_ch2_logicals.kv 103 Put_Line("Y =");
ffa_ch2_logicals.kv 104 Dump(Y);
ffa_ch2_logicals.kv 105 New_Line;
ffa_ch2_logicals.kv 106 New_Line;
ffa_ch2_logicals.kv 107
ffa_ch2_logicals.kv 108 Put_Line("FZ_ZeroP(X) :");
ffa_ch2_logicals.kv 109 Dump(FZ_ZeroP(X));
ffa_ch2_logicals.kv 110 New_Line;
ffa_ch2_logicals.kv 111 New_Line;
ffa_ch2_logicals.kv 112
ffa_ch2_logicals.kv 113 Put_Line("FZ_ZeroP(Y) :");
ffa_ch2_logicals.kv 114 Dump(FZ_ZeroP(Y));
ffa_ch2_logicals.kv 115 New_Line;
ffa_ch2_logicals.kv 116 New_Line;
ffa_ch2_logicals.kv 117
ffa_ch2_logicals.kv 118 FZ_Swap(X, Y);
ffa_ch2_logicals.kv 119 Put_Line("After FZ_Swap(X, Y) :");
ffa_ch2_logicals.kv 120 Put_Line("X =");
ffa_ch2_logicals.kv 121 Dump(X);
ffa_ch2_logicals.kv 122 New_Line;
ffa_ch2_logicals.kv 123 New_Line;
ffa_ch2_logicals.kv 124
ffa_ch2_logicals.kv 125 Put_Line("Y =");
ffa_ch2_logicals.kv 126 Dump(Y);
ffa_ch2_logicals.kv 127 New_Line;
ffa_ch2_logicals.kv 128 New_Line;
ffa_ch2_logicals.kv 129
ffa_ch2_logicals.kv 130 F := 0;
ffa_ch2_logicals.kv 131 FZ_Mux(X, Y, Z, F);
ffa_ch2_logicals.kv 132 Put_Line("After F := 0 , FZ_Mux(X, Y, Z, F) : ");
ffa_ch2_logicals.kv 133 Put_Line("Z =");
ffa_ch2_logicals.kv 134 Dump(Z);
ffa_ch2_logicals.kv 135 New_Line;
ffa_ch2_logicals.kv 136 New_Line;
ffa_ch2_logicals.kv 137
ffa_ch2_logicals.kv 138 F := 1;
ffa_ch2_logicals.kv 139 FZ_Mux(X, Y, Z, F);
ffa_ch2_logicals.kv 140 Put_Line("After F := 1 , FZ_Mux(X, Y, Z, F) : ");
ffa_ch2_logicals.kv 141 Put_Line("Z =");
ffa_ch2_logicals.kv 142 Dump(Z);
ffa_ch2_logicals.kv 143 New_Line;
ffa_ch2_logicals.kv 144 New_Line;
ffa_ch2_logicals.kv 145
ffa_ch2_logicals.kv 146 end Demo_FZ_Basics;
ffa_ch2_logicals.kv 147
ffa_ch2_logicals.kv 148
ffa_ch2_logicals.kv 149 procedure Demo_FZ_Various_Ops is
ffa_ch2_logicals.kv 150
ffa_ch2_logicals.kv 151 X : FZ(1 .. 4) := ( 16#083e16f27091f65f#, 16#74c01a9c3ce54f80#,
ffa_ch2_logicals.kv 152 16#9fd0913737c3fcbe#, 16#fa55f3f5459a9e79# );
ffa_ch2_logicals.kv 153
ffa_ch2_logicals.kv 154 Y : FZ(1 .. 4) := ( 16#d16b9d65bf3991d0#, 16#8a509a858786b366#,
ffa_ch2_logicals.kv 155 16#d39d23682728f4f8#, 16#6c571dbc646bf513# );
ffa_ch2_logicals.kv 156
ffa_ch2_logicals.kv 157 Z : FZ(1 .. 4) := ( 0, 0, 0, 0 );
ffa_ch2_logicals.kv 158
ffa_ch2_logicals.kv 159 begin
ffa_ch2_logicals.kv 160
ffa_ch2_logicals.kv 161 Put_Line("~~~ Ch. 2 : FZ Bit Ops ~~~");
ffa_ch2_logicals.kv 162 New_Line;
ffa_ch2_logicals.kv 163 New_Line;
ffa_ch2_logicals.kv 164
ffa_ch2_logicals.kv 165 Put_Line("X =");
ffa_ch2_logicals.kv 166 Dump(X);
ffa_ch2_logicals.kv 167 New_Line;
ffa_ch2_logicals.kv 168 New_Line;
ffa_ch2_logicals.kv 169
ffa_ch2_logicals.kv 170 Put_Line("Y =");
ffa_ch2_logicals.kv 171 Dump(Y);
ffa_ch2_logicals.kv 172 New_Line;
ffa_ch2_logicals.kv 173 New_Line;
ffa_ch2_logicals.kv 174
ffa_ch3_shifts.kv 175 FZ_Not(X, Z);
ffa_ch3_shifts.kv 176 Put_Line("After FZ_Not(X, Z):");
ffa_ch2_logicals.kv 177 Put_Line("Z =");
ffa_ch2_logicals.kv 178 Dump(Z);
ffa_ch2_logicals.kv 179 New_Line;
ffa_ch2_logicals.kv 180 New_Line;
ffa_ch2_logicals.kv 181
ffa_ch2_logicals.kv 182 FZ_And(X, Y, Z);
ffa_ch2_logicals.kv 183 Put_Line("After FZ_And(X, Y, Z) :");
ffa_ch2_logicals.kv 184 Put_Line("Z =");
ffa_ch2_logicals.kv 185 Dump(Z);
ffa_ch2_logicals.kv 186 New_Line;
ffa_ch2_logicals.kv 187 New_Line;
ffa_ch2_logicals.kv 188
ffa_ch2_logicals.kv 189 FZ_Or(X, Y, Z);
ffa_ch2_logicals.kv 190 Put_Line("After FZ_Or(X, Y, Z) :");
ffa_ch2_logicals.kv 191 Put_Line("Z =");
ffa_ch2_logicals.kv 192 Dump(Z);
ffa_ch2_logicals.kv 193 New_Line;
ffa_ch2_logicals.kv 194 New_Line;
ffa_ch2_logicals.kv 195
ffa_ch2_logicals.kv 196 FZ_Xor(X, Y, Z);
ffa_ch2_logicals.kv 197 Put_Line("After FZ_Xor(X, Y, Z) :");
ffa_ch2_logicals.kv 198 Put_Line("Z =");
ffa_ch2_logicals.kv 199 Dump(Z);
ffa_ch2_logicals.kv 200 New_Line;
ffa_ch2_logicals.kv 201 New_Line;
ffa_ch2_logicals.kv 202
ffa_ch2_logicals.kv 203 Put_Line("FZ_EqP(X, X) :");
ffa_ch2_logicals.kv 204 Dump(FZ_EqP(X, X));
ffa_ch2_logicals.kv 205 New_Line;
ffa_ch2_logicals.kv 206 New_Line;
ffa_ch2_logicals.kv 207
ffa_ch2_logicals.kv 208 Put_Line("FZ_EqP(X, Y) :");
ffa_ch2_logicals.kv 209 Dump(FZ_EqP(X, Y));
ffa_ch2_logicals.kv 210 New_Line;
ffa_ch2_logicals.kv 211 New_Line;
ffa_ch2_logicals.kv 212
ffa_ch2_logicals.kv 213 Put_Line("FZ_LessThanP(X, Y) :");
ffa_ch2_logicals.kv 214 Dump(FZ_LessThanP(X, Y));
ffa_ch2_logicals.kv 215 New_Line;
ffa_ch2_logicals.kv 216 New_Line;
ffa_ch2_logicals.kv 217
ffa_ch2_logicals.kv 218 Put_Line("FZ_LessThanP(Y, X) :");
ffa_ch2_logicals.kv 219 Dump(FZ_LessThanP(Y, X));
ffa_ch2_logicals.kv 220 New_Line;
ffa_ch2_logicals.kv 221 New_Line;
ffa_ch2_logicals.kv 222
ffa_ch2_logicals.kv 223 Put_Line("FZ_GreaterThanP(X, Y) :");
ffa_ch2_logicals.kv 224 Dump(FZ_GreaterThanP(X, Y));
ffa_ch2_logicals.kv 225 New_Line;
ffa_ch2_logicals.kv 226 New_Line;
ffa_ch2_logicals.kv 227
ffa_ch2_logicals.kv 228 Put_Line("FZ_GreaterThanP(Y, X) :");
ffa_ch2_logicals.kv 229 Dump(FZ_GreaterThanP(Y, X));
ffa_ch2_logicals.kv 230 New_Line;
ffa_ch2_logicals.kv 231 New_Line;
ffa_ch2_logicals.kv 232
ffa_ch2_logicals.kv 233 end Demo_FZ_Various_Ops;
ffa_ch2_logicals.kv 234
ffa_ch2_logicals.kv 235
ffa_ch2_logicals.kv 236 end Demo_Ch2;