tree checksum vpatch file split hunks

all signers: asciilifeform bvt diana_coman

antecedents:

press order:

ffa_ch1_genesis.kvasciilifeform bvt diana_coman

patch:

-
+ 33552678F5519339C5BEAEC7C62A4F43D2D32FF9620090A6866C056A13C369EE4689263C306102D675622EF9742FA3943698533C3A6407A65EC6036992E8DF96
ffa/README
(0 . 0)(1 . 27)
5 ------------------------------------------------------------------------------
6 ------------------------------------------------------------------------------
7 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
8 -- --
9 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
10 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
11 -- --
12 -- You do not have, nor can you ever acquire the right to use, copy or --
13 -- distribute this software ; Should you use this software for any purpose, --
14 -- or copy and distribute it to anyone or in any manner, you are breaking --
15 -- the laws of whatever soi-disant jurisdiction, and you promise to --
16 -- continue doing so for the indefinite future. In any case, please --
17 -- always : read and understand any software ; verify any PGP signatures --
18 -- that you use - for any purpose. --
19 -- --
20 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
21 ------------------------------------------------------------------------------
22 ------------------------------------------------------------------------------
23
24 See contents of 'demo'.
25
26
27 Questions?
28
29 http://webchat.freenode.net/?channels=#trilema&nick=from_ffa
30
31 Privmsg one of the people speaking and ask politely for 'voice'.
-
+ AD4BCD1C0F26FDAE13316825F8AD112744491727D35D0645BBA892DDE1DCA9CC13FEB756EA2BF673245DAA6E027386E896E5D2975F3A53949EB210571997E9D2
ffa/ffademo/README
(0 . 0)(1 . 47)
36 ------------------------------------------------------------------------------
37 ------------------------------------------------------------------------------
38 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
39 -- --
40 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
41 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
42 -- --
43 -- You do not have, nor can you ever acquire the right to use, copy or --
44 -- distribute this software ; Should you use this software for any purpose, --
45 -- or copy and distribute it to anyone or in any manner, you are breaking --
46 -- the laws of whatever soi-disant jurisdiction, and you promise to --
47 -- continue doing so for the indefinite future. In any case, please --
48 -- always : read and understand any software ; verify any PGP signatures --
49 -- that you use - for any purpose. --
50 -- --
51 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
52 ------------------------------------------------------------------------------
53 ------------------------------------------------------------------------------
54
55 to clean:
56 gprclean
57
58 to build:
59 gprbuild
60
61 to build debug, or on crapple:
62 gprbuild -Xmode=debug
63
64
65 'libffa' will build recursively.
66
67 to run:
68 ./bin/ffa_demo
69
70
71 Chapter 1 demo output should look like this:
72
73 X =
74 0000000000000000000000000000000000000000000000000000000000000000
75 Y =
76 0000000000000000000000000000000000000000000000000000000000005555
77 X + Y =
78 0000000000000000000000000000000000000000000000000000000000005555
79 C = 0
80 X - Y =
81 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAAAB
82 C = 1
-
+ 5FDBAE897EB301A711BF95707F329517DB540E34C182A5BEEC96E93D5D0D856CEC2ED6B01C1191F865E8D1C45709A462C70C3005D4AA3676EB445D1479EDF2E5
ffa/ffademo/bin/README
(0 . 0)(1 . 1)
87 Placeholder.
-
+ 5220F733B82ACDCD95B2806401322ED4657325E6D3D4F1264CFD390C304B900F6A8B1555EB48DDD966ECE7EF91BD120E54972873817A8E8E94B84BD62DD7196A
ffa/ffademo/demo_ch1.adb
(0 . 0)(1 . 69)
92 ------------------------------------------------------------------------------
93 ------------------------------------------------------------------------------
94 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
95 -- --
96 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
97 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
98 -- --
99 -- You do not have, nor can you ever acquire the right to use, copy or --
100 -- distribute this software ; Should you use this software for any purpose, --
101 -- or copy and distribute it to anyone or in any manner, you are breaking --
102 -- the laws of whatever soi-disant jurisdiction, and you promise to --
103 -- continue doing so for the indefinite future. In any case, please --
104 -- always : read and understand any software ; verify any PGP signatures --
105 -- that you use - for any purpose. --
106 -- --
107 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
108 ------------------------------------------------------------------------------
109 ------------------------------------------------------------------------------
110
111 -- From Ada:
112 with Ada.Text_IO; use Ada.Text_IO;
113
114 -- From FFA:
115 with Words; use Words;
116 with FZ_Type; use FZ_Type;
117 with FZ_Arith; use FZ_Arith;
118
119 -- From the Demo:
120 with FFA_IO; use FFA_IO;
121
122
123 package body Demo_Ch1 is
124
125 procedure Demo_Add_Sub is
126
127 -- We are using 64-bit Words (see iron.ads).
128 -- We'll begin with an elementary demo, using 256-bit FZ:
129 X : FZ(1 .. 4) := (0, 0, 0, 0);
130 Y : FZ(1 .. 4) := (16#5555#, 0, 0, 0);
131 Z : FZ(1 .. 4) := (0, 0, 0, 0);
132
133 -- Carry.
134 C : WBool := 0;
135
136 begin
137
138 Put_Line("X =");
139 Dump(X);
140 New_Line;
141
142 Put_Line("Y =");
143 Dump(Y);
144 New_Line;
145
146 FZ_Add(X, Y, Z, C);
147 Put_Line("X + Y =");
148 Dump(Z);
149 New_Line;
150 Put_Line("C = " & WBool'Image(C));
151
152 FZ_Sub(X, Y, Z, C);
153 Put_Line("X - Y =");
154 Dump(Z);
155 New_Line;
156 Put_Line("C = " & WBool'Image(C));
157
158 end Demo_Add_Sub;
159
160 end Demo_Ch1;
-
+ 1959CDA0F5A15B35A1E5B050978162E9522F3885881F98EAFF4BBDA4B314E49A6CECD3E938F4C894E1E18C64CCE7E704C63BC867FF8D5E0AC37161365B6B4B31
ffa/ffademo/demo_ch1.ads
(0 . 0)(1 . 24)
165 ------------------------------------------------------------------------------
166 ------------------------------------------------------------------------------
167 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
168 -- --
169 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
170 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
171 -- --
172 -- You do not have, nor can you ever acquire the right to use, copy or --
173 -- distribute this software ; Should you use this software for any purpose, --
174 -- or copy and distribute it to anyone or in any manner, you are breaking --
175 -- the laws of whatever soi-disant jurisdiction, and you promise to --
176 -- continue doing so for the indefinite future. In any case, please --
177 -- always : read and understand any software ; verify any PGP signatures --
178 -- that you use - for any purpose. --
179 -- --
180 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
181 ------------------------------------------------------------------------------
182 ------------------------------------------------------------------------------
183
184 package Demo_Ch1 is
185
186 procedure Demo_Add_Sub;
187
188 end Demo_Ch1;
-
+ 1E4B961E54FBFCEA9605A60C667B7F88BFA5C81481A765E9D256592542BF7E7C4F9A831A4702E4A8CF324DDB04B1ED106E76BE33FCC6D6CC05BD5238150184E2
ffa/ffademo/ffa_demo.adb
(0 . 0)(1 . 27)
193 ------------------------------------------------------------------------------
194 ------------------------------------------------------------------------------
195 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
196 -- --
197 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
198 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
199 -- --
200 -- You do not have, nor can you ever acquire the right to use, copy or --
201 -- distribute this software ; Should you use this software for any purpose, --
202 -- or copy and distribute it to anyone or in any manner, you are breaking --
203 -- the laws of whatever soi-disant jurisdiction, and you promise to --
204 -- continue doing so for the indefinite future. In any case, please --
205 -- always : read and understand any software ; verify any PGP signatures --
206 -- that you use - for any purpose. --
207 -- --
208 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
209 ------------------------------------------------------------------------------
210 ------------------------------------------------------------------------------
211
212 with Demo_Ch1; use Demo_Ch1;
213
214 procedure FFA_Demo is
215 begin
216
217 Demo_Add_Sub;
218
219 end FFA_Demo;
-
+ D6E5FAEE35C92B829D83F16C74EC7BCBFE66214AEB7A4AD914C5ACB84B561DCF0D311D7FBDDC4A9EDF4D5FEBA462B5BFB709AA42ADB9B75B40C515275B1454BD
ffa/ffademo/ffa_demo.gpr
(0 . 0)(1 . 69)
224 ------------------------------------------------------------------------------
225 ------------------------------------------------------------------------------
226 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
227 -- --
228 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
229 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
230 -- --
231 -- You do not have, nor can you ever acquire the right to use, copy or --
232 -- distribute this software ; Should you use this software for any purpose, --
233 -- or copy and distribute it to anyone or in any manner, you are breaking --
234 -- the laws of whatever soi-disant jurisdiction, and you promise to --
235 -- continue doing so for the indefinite future. In any case, please --
236 -- always : read and understand any software ; verify any PGP signatures --
237 -- that you use - for any purpose. --
238 -- --
239 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
240 ------------------------------------------------------------------------------
241 ------------------------------------------------------------------------------
242
243 with "../libffa/ffa.gpr";
244
245 project FFA_Demo is
246
247 for Object_Dir use "obj";
248
249 type Mode_Type is ("debug", "release");
250 Mode : Mode_Type := external ("mode", "release");
251
252 for Languages use ("Ada");
253 for Source_Dirs use (".");
254 for Exec_Dir use "bin";
255 for Main use ("ffa_demo.adb");
256
257 package Compiler is
258 case Mode is
259 when "debug" =>
260 for Switches ("Ada")
261 use ("-g");
262 when "release" =>
263 for Switches ("Ada")
264 use ("-O2", "-fdump-scos", "-gnata", "-fstack-check",
265 "-fdata-sections", "-ffunction-sections");
266 end case;
267 end Compiler;
268
269 package Binder is
270 case Mode is
271 when "debug" =>
272 for Switches ("Ada")
273 use ();
274 when "release" =>
275 for Switches ("Ada")
276 use ("-static");
277 end case;
278 end Binder;
279
280 package Linker is
281 case Mode is
282 when "debug" =>
283 for Switches ("Ada")
284 use ();
285 when "release" =>
286 for Switches ("Ada")
287 use ("-Wl,--gc-sections",
288 "-static");
289 end case;
290 end Linker;
291
292 end FFA_Demo;
-
+ 408328BDCB8543BFF0E7ADFD454105C5B1876C7EE71EF41337622BD95D269188F6643FD8BF9EA6076692AEFC59E63A9A02B986B7C4C697B76A3EA0B69A4FFB87
ffa/ffademo/ffa_io.adb
(0 . 0)(1 . 61)
297 ------------------------------------------------------------------------------
298 ------------------------------------------------------------------------------
299 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
300 -- --
301 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
302 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
303 -- --
304 -- You do not have, nor can you ever acquire the right to use, copy or --
305 -- distribute this software ; Should you use this software for any purpose, --
306 -- or copy and distribute it to anyone or in any manner, you are breaking --
307 -- the laws of whatever soi-disant jurisdiction, and you promise to --
308 -- continue doing so for the indefinite future. In any case, please --
309 -- always : read and understand any software ; verify any PGP signatures --
310 -- that you use - for any purpose. --
311 -- --
312 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
313 ------------------------------------------------------------------------------
314 ------------------------------------------------------------------------------
315
316 with Ada.Text_IO; use Ada.Text_IO;
317
318 with Words; use Words;
319 with W_Shifts; use W_Shifts;
320 with FZ_Type; use FZ_Type;
321
322
323 package body FFA_IO is
324
325 -- Obtain the WChars corresponding to the given Word
326 function W_To_WChars(N : Word) return WChars is
327 H : constant array(0 .. 15) of Character := "0123456789ABCDEF";
328 W : Word := N;
329 Result : WChars;
330 begin
331 for b in WChars'Range loop -- From bottom to top:
332 Result(B) := H(Natural(W and 16#F#)); -- Get current nibble.
333 W := Shift_Right(W, 4); -- Get the next nibble.
334 end loop;
335 return Result;
336 end W_To_WChars;
337
338
339 -- Display a hex representation of W to stdout
340 procedure Dump(W : in Word) is
341 T : WChars := W_To_WChars(W);
342 begin
343 for i in reverse T'Range loop
344 Put(T(i));
345 end loop;
346 end Dump;
347
348
349 -- Display a hex representation of N to stdout
350 procedure Dump(N : in FZ) is
351 begin
352 for i in reverse N'Range loop
353 Dump(N(i));
354 end loop;
355 end Dump;
356
357 end FFA_IO;
-
+ DE4FF4DFC81DF4A4FEBC2B5A1C359DF912969821FB3790D51D78EED6352FA52D03EB70A9226EF896CEE16DCFC40AB2FACB9FD49D54110FB86F3FEBD8CAF29E64
ffa/ffademo/ffa_io.ads
(0 . 0)(1 . 37)
362 ------------------------------------------------------------------------------
363 ------------------------------------------------------------------------------
364 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
365 -- --
366 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
367 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
368 -- --
369 -- You do not have, nor can you ever acquire the right to use, copy or --
370 -- distribute this software ; Should you use this software for any purpose, --
371 -- or copy and distribute it to anyone or in any manner, you are breaking --
372 -- the laws of whatever soi-disant jurisdiction, and you promise to --
373 -- continue doing so for the indefinite future. In any case, please --
374 -- always : read and understand any software ; verify any PGP signatures --
375 -- that you use - for any purpose. --
376 -- --
377 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
378 ------------------------------------------------------------------------------
379 ------------------------------------------------------------------------------
380
381 with Words; use Words;
382 with FZ_Type; use FZ_Type;
383
384 package FFA_IO is
385
386 -- Character representation of a Word
387 type WChars is array(1 .. 2 * Byteness) of Character;
388
389 -- Obtain the WChars corresponding to the given Word
390 function W_To_WChars(N : Word) return WChars;
391
392 -- Display a hex representation of W to stdout
393 procedure Dump(W : in Word);
394
395 -- Display a hex representation of N to stdout
396 procedure Dump(N : in FZ);
397
398 end FFA_IO;
-
+ 5FDBAE897EB301A711BF95707F329517DB540E34C182A5BEEC96E93D5D0D856CEC2ED6B01C1191F865E8D1C45709A462C70C3005D4AA3676EB445D1479EDF2E5
ffa/ffademo/obj/README
(0 . 0)(1 . 1)
403 Placeholder.
-
+ B8DBE89A3D907943ED0A96EF2EB23550A00FE344C5396BECC747BA8D64E1BA2D45BAF32E4DCA24630D4A2B75297FD1B79402592C07DD2949666F4A72C14406C9
ffa/libffa/README
(0 . 0)(1 . 27)
408 ------------------------------------------------------------------------------
409 ------------------------------------------------------------------------------
410 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
411 -- --
412 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
413 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
414 -- --
415 -- You do not have, nor can you ever acquire the right to use, copy or --
416 -- distribute this software ; Should you use this software for any purpose, --
417 -- or copy and distribute it to anyone or in any manner, you are breaking --
418 -- the laws of whatever soi-disant jurisdiction, and you promise to --
419 -- continue doing so for the indefinite future. In any case, please --
420 -- always : read and understand any software ; verify any PGP signatures --
421 -- that you use - for any purpose. --
422 -- --
423 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
424 ------------------------------------------------------------------------------
425 ------------------------------------------------------------------------------
426
427 to clean:
428 gprclean
429
430 to build:
431 gprbuild
432
433 to build debug, or on crapple:
434 gprbuild -Xmode=debug
-
+ 92D0220A48F6753FB699220DB8EBA867B4F4354291C3E4EBD6B3048982524E93F82356D40B8BF2371F7C6768545FE2EE0E531EBD70144CBD8213A6D8C84E727E
ffa/libffa/ffa.gpr
(0 . 0)(1 . 62)
439 ------------------------------------------------------------------------------
440 ------------------------------------------------------------------------------
441 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
442 -- --
443 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
444 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
445 -- --
446 -- You do not have, nor can you ever acquire the right to use, copy or --
447 -- distribute this software ; Should you use this software for any purpose, --
448 -- or copy and distribute it to anyone or in any manner, you are breaking --
449 -- the laws of whatever soi-disant jurisdiction, and you promise to --
450 -- continue doing so for the indefinite future. In any case, please --
451 -- always : read and understand any software ; verify any PGP signatures --
452 -- that you use - for any purpose. --
453 -- --
454 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
455 ------------------------------------------------------------------------------
456 ------------------------------------------------------------------------------
457
458 project FFA is
459
460 for Object_Dir use "obj";
461
462 type Mode_Type is ("debug", "release");
463 Mode : Mode_Type := external ("mode", "release");
464
465 for Languages use ("Ada");
466 for Source_Dirs use (".");
467 for Library_Dir use "lib";
468 for Library_Name use "FFA";
469 for Library_Kind use "static";
470
471 package Binder is
472 case Mode is
473 when "debug" =>
474 for Switches ("Ada")
475 use ();
476 when "release" =>
477 for Switches ("Ada")
478 use ("-static", "-r");
479 end case;
480 end Binder;
481
482 package Builder is
483 for Switches ("Ada")
484 use ("-nostdlib");
485 end Builder;
486
487 package Compiler is
488 case Mode is
489 when "debug" =>
490 for Switches ("Ada")
491 use ("-g");
492 when "release" =>
493 for Switches ("Ada")
494 use ("-O2", "-fdump-scos", "-gnata", "-fstack-check",
495 "-fdata-sections", "-ffunction-sections",
496 "-gnatec=" & FFA'Project_Dir & "restrict.adc");
497 end case;
498 end Compiler;
499
500 end FFA;
-
+ EE90484DC801B605DDC2DB7B3DCE4C95A6B99F59577253D40E437F94EA6E89534137102A68DAB20B46D0EA1F8C7BA625258E7073102859AD764020989B95FA7C
ffa/libffa/fz_arith.adb
(0 . 0)(1 . 68)
505 ------------------------------------------------------------------------------
506 ------------------------------------------------------------------------------
507 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
508 -- --
509 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
510 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
511 -- --
512 -- You do not have, nor can you ever acquire the right to use, copy or --
513 -- distribute this software ; Should you use this software for any purpose, --
514 -- or copy and distribute it to anyone or in any manner, you are breaking --
515 -- the laws of whatever soi-disant jurisdiction, and you promise to --
516 -- continue doing so for the indefinite future. In any case, please --
517 -- always : read and understand any software ; verify any PGP signatures --
518 -- that you use - for any purpose. --
519 -- --
520 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
521 ------------------------------------------------------------------------------
522 ------------------------------------------------------------------------------
523
524 with Word_Ops; use Word_Ops;
525
526 -- Fundamental Arithmetic operators on FZ:
527 package body FZ_Arith is
528
529 -- Sum := X + Y; Overflow := Carry
530 procedure FZ_Add(X : in FZ;
531 Y : in FZ;
532 Sum : out FZ;
533 Overflow : out WBool) is
534 Carry : WBool := 0;
535 begin
536 for i in X'Range loop
537 declare
538 A : constant Word := X(I);
539 B : constant Word := Y(I);
540 S : constant Word := A + B + Carry;
541 begin
542 Sum(i) := S;
543 Carry := W_Carry(A, B, S);
544 end;
545 end loop;
546 Overflow := Carry;
547 end FZ_Add;
548 pragma Inline_Always(FZ_Add);
549
550
551 -- Difference := X - Y; Underflow := Borrow
552 procedure FZ_Sub(X : in FZ;
553 Y : in FZ;
554 Difference : out FZ;
555 Underflow : out WBool) is
556 Borrow : WBool := 0;
557 begin
558 for i in 0 .. Word_Index(X'Length - 1) loop
559 declare
560 A : constant Word := X(X'First + i);
561 B : constant Word := Y(Y'First + i);
562 S : constant Word := A - B - Borrow;
563 begin
564 Difference(Difference'First + i) := S;
565 Borrow := W_Borrow(A, B, S);
566 end;
567 end loop;
568 Underflow := Borrow;
569 end FZ_Sub;
570 pragma Inline_Always(FZ_Sub);
571
572 end FZ_Arith;
-
+ 614AD5186CB1FE04E3019AF0E9EC9AE3F70B82EEE7F2D7436BE2C23A256677C76E2EDC91F6DF9E50A443EF03AEAA78FF86A2B83C8F0BF5326427AF3C9BA2E9B5
ffa/libffa/fz_arith.ads
(0 . 0)(1 . 42)
577 ------------------------------------------------------------------------------
578 ------------------------------------------------------------------------------
579 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
580 -- --
581 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
582 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
583 -- --
584 -- You do not have, nor can you ever acquire the right to use, copy or --
585 -- distribute this software ; Should you use this software for any purpose, --
586 -- or copy and distribute it to anyone or in any manner, you are breaking --
587 -- the laws of whatever soi-disant jurisdiction, and you promise to --
588 -- continue doing so for the indefinite future. In any case, please --
589 -- always : read and understand any software ; verify any PGP signatures --
590 -- that you use - for any purpose. --
591 -- --
592 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
593 ------------------------------------------------------------------------------
594 ------------------------------------------------------------------------------
595
596 with Words; use Words;
597 with FZ_Type; use FZ_Type;
598
599 -- Fundamental Arithmetic operators on FZ:
600 package FZ_Arith is
601
602 pragma Pure;
603
604 -- Sum := X + Y; Overflow := Carry
605 procedure FZ_Add(X : in FZ;
606 Y : in FZ;
607 Sum : out FZ;
608 Overflow : out WBool);
609 pragma Precondition(X'Length = Y'Length and X'Length = Sum'Length);
610
611 -- Difference := X - Y; Underflow := Borrow
612 procedure FZ_Sub(X : in FZ;
613 Y : in FZ;
614 Difference : out FZ;
615 Underflow : out WBool);
616 pragma Precondition(X'Length = Y'Length and X'Length = Difference'Length);
617
618 end FZ_Arith;
-
+ C53D7E85E48B1C7BA062AEC40E7D95C2230EE1D09F70DC19681B7759EE1F07F2AA599764AE2742FD3AF4FB6CBDD599EAC0E0C4E1F4F07C11B0F843EFB73B02E5
ffa/libffa/fz_type.ads
(0 . 0)(1 . 47)
623 ------------------------------------------------------------------------------
624 ------------------------------------------------------------------------------
625 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
626 -- --
627 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
628 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
629 -- --
630 -- You do not have, nor can you ever acquire the right to use, copy or --
631 -- distribute this software ; Should you use this software for any purpose, --
632 -- or copy and distribute it to anyone or in any manner, you are breaking --
633 -- the laws of whatever soi-disant jurisdiction, and you promise to --
634 -- continue doing so for the indefinite future. In any case, please --
635 -- always : read and understand any software ; verify any PGP signatures --
636 -- that you use - for any purpose. --
637 -- --
638 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
639 ------------------------------------------------------------------------------
640 ------------------------------------------------------------------------------
641
642 -- FZ -- the fundamental FZ type: an unsigned integer of fixed width,
643 -- i.e. a contiguous array of machine words. There is no 'meta'-anything:
644 -- in particular, there is no normalization nor will there ever be any
645 -- normalization, nor any provisions for resizing, nor any such thing.
646 -- Note that endianness is irrelevant, here and elsewhere in FFA.
647
648 with Words; use Words;
649
650 package FZ_Type is
651
652 pragma Pure;
653
654 -- Indices of all indexable items:
655 type Indices is new Natural;
656
657 -- Index of a particular Word in an FZ:
658 subtype Word_Index is Indices;
659
660 -- The FZ, in person! I.e. a bignum of permanently fixed bitness.
661 type FZ is array(Word_Index range <>) of Word;
662
663 -- A count of Words in an FZ (cannot be 0):
664 subtype Word_Count is Indices range 1 .. Indices'Last;
665
666 -- An index of a particular ~bit~ in an FZ:
667 subtype FZBit_Index is Indices;
668
669 end FZ_Type;
-
+ 9BE8930649F097919664873A6F502D6C0A2E67BB36DF1F61DB80B291162B2DE3644837694290FF253E045499F9EBD138D84CC7D127A3B7C91838E550DC01836D
ffa/libffa/iron.ads
(0 . 0)(1 . 41)
674 ------------------------------------------------------------------------------
675 ------------------------------------------------------------------------------
676 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
677 -- --
678 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
679 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
680 -- --
681 -- You do not have, nor can you ever acquire the right to use, copy or --
682 -- distribute this software ; Should you use this software for any purpose, --
683 -- or copy and distribute it to anyone or in any manner, you are breaking --
684 -- the laws of whatever soi-disant jurisdiction, and you promise to --
685 -- continue doing so for the indefinite future. In any case, please --
686 -- always : read and understand any software ; verify any PGP signatures --
687 -- that you use - for any purpose. --
688 -- --
689 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
690 ------------------------------------------------------------------------------
691 ------------------------------------------------------------------------------
692
693 package Iron is
694
695 pragma Pure;
696
697 --------------------------------------
698 -------- For a 64-bit system: --------
699 --------------------------------------
700 MachineBitness : constant Positive := 64;
701 MachineBitnessLog2 : constant Positive := 6; -- log2(64)
702 --------------------------------------
703
704 --------------------------------------
705 -------- For a 32-bit system: --------
706 --------------------------------------
707 -- MachineBitness : constant Positive := 32;
708 -- MachineBitnessLog2 : constant Positive := 5; -- log2(32)
709 --------------------------------------
710
711 -- Bits per Byte
712 ByteBits : constant Positive := 8;
713
714 end Iron;
-
+ 5FDBAE897EB301A711BF95707F329517DB540E34C182A5BEEC96E93D5D0D856CEC2ED6B01C1191F865E8D1C45709A462C70C3005D4AA3676EB445D1479EDF2E5
ffa/libffa/lib/README
(0 . 0)(1 . 1)
719 Placeholder.
-
+ 5FDBAE897EB301A711BF95707F329517DB540E34C182A5BEEC96E93D5D0D856CEC2ED6B01C1191F865E8D1C45709A462C70C3005D4AA3676EB445D1479EDF2E5
ffa/libffa/obj/README
(0 . 0)(1 . 1)
724 Placeholder.
-
+ 8040F67337558BA8EBDE821CA4EDD6264A8164AA9D0CF5A44F5F270C43FCAC6D0033421B94D3BD5379B75B85A06300A271237D391ADA11B9360865AC22BC5C5B
ffa/libffa/restrict.adc
(0 . 0)(1 . 84)
729 ------------------------------------------------------------------------------
730 ------------------------------------------------------------------------------
731 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
732 -- --
733 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
734 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
735 -- --
736 -- You do not have, nor can you ever acquire the right to use, copy or --
737 -- distribute this software ; Should you use this software for any purpose, --
738 -- or copy and distribute it to anyone or in any manner, you are breaking --
739 -- the laws of whatever soi-disant jurisdiction, and you promise to --
740 -- continue doing so for the indefinite future. In any case, please --
741 -- always : read and understand any software ; verify any PGP signatures --
742 -- that you use - for any purpose. --
743 -- --
744 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
745 ------------------------------------------------------------------------------
746 ------------------------------------------------------------------------------
747
748 pragma Restrictions(Immediate_Reclamation);
749 pragma Restrictions(Max_Asynchronous_Select_Nesting => 0);
750 pragma Restrictions(Max_Protected_Entries => 0);
751 pragma Restrictions(Max_Select_Alternatives => 0);
752 pragma Restrictions(Max_Task_Entries => 0);
753 pragma Restrictions(Max_Tasks => 0);
754 pragma Restrictions(No_Abort_Statements);
755 pragma Restrictions(No_Access_Parameter_Allocators);
756 pragma Restrictions(No_Allocators);
757 pragma Restrictions(No_Asynchronous_Control);
758 pragma Restrictions(No_Calendar);
759 pragma Restrictions(No_Coextensions);
760 pragma Restrictions(No_Default_Stream_Attributes);
761 pragma Restrictions(No_Delay);
762 pragma Restrictions(No_Dispatch);
763 pragma Restrictions(No_Dispatching_Calls);
764 pragma Restrictions(No_Dynamic_Attachment);
765 pragma Restrictions(No_Dynamic_Priorities);
766 pragma Restrictions(No_Entry_Calls_In_Elaboration_Code);
767 pragma Restrictions(No_Entry_Queue);
768 pragma Restrictions(No_Enumeration_Maps);
769 pragma Restrictions(No_Exception_Propagation);
770 pragma Restrictions(No_Exception_Registration);
771 pragma Restrictions(No_Finalization);
772 pragma Restrictions(No_Fixed_Io);
773 pragma Restrictions(No_Floating_Point);
774 pragma Restrictions(No_Implementation_Aspect_Specifications);
775 pragma Restrictions(No_Implementation_Units);
776 pragma Restrictions(No_Implicit_Aliasing);
777 pragma Restrictions(No_Implicit_Conditionals);
778 pragma Restrictions(No_Implicit_Dynamic_Code);
779 pragma Restrictions(No_Implicit_Heap_Allocations);
780 pragma Restrictions(No_Implicit_Protected_Object_Allocations);
781 pragma Restrictions(No_Implicit_Task_Allocations);
782 pragma Restrictions(No_Initialize_Scalars);
783 pragma Restrictions(No_Local_Protected_Objects);
784 pragma Restrictions(No_Local_Timing_Events);
785 pragma Restrictions(No_Multiple_Elaboration);
786 pragma Restrictions(No_Nested_Finalization);
787 pragma Restrictions(No_Protected_Type_Allocators);
788 pragma Restrictions(No_Protected_Types);
789 pragma Restrictions(No_Relative_Delay);
790 pragma Restrictions(No_Requeue_Statements);
791 pragma Restrictions(No_Secondary_Stack);
792 pragma Restrictions(No_Select_Statements);
793 pragma Restrictions(No_Specific_Termination_Handlers);
794 pragma Restrictions(No_Standard_Allocators_After_Elaboration);
795 pragma Restrictions(No_Stream_Optimizations);
796 pragma Restrictions(No_Streams);
797 pragma Restrictions(No_Task_Allocators);
798 pragma Restrictions(No_Task_At_Interrupt_Priority);
799 pragma Restrictions(No_Task_Attributes_Package);
800 pragma Restrictions(No_Task_Hierarchy);
801 pragma Restrictions(No_Tasking);
802 pragma Restrictions(No_Task_Termination);
803 pragma Restrictions(No_Terminate_Alternatives);
804 pragma Restrictions(No_Unchecked_Access);
805 pragma Restrictions(No_Unchecked_Conversion);
806 pragma Restrictions(No_Unchecked_Deallocation);
807 pragma Restrictions(No_Wide_Characters);
808 pragma Restrictions(Pure_Barriers);
809 pragma Restrictions(Simple_Barriers);
810 pragma Restrictions(Static_Priorities);
811 pragma Restrictions(Static_Storage_Size);
812 pragma Validity_Checks(ALL_CHECKS);
-
+ 531BBAA56146A75CF0632ABD688C4FB260DE0F3BCBA9C841A6F4868D3B8A3769FE05C42C5E290A1C573425F5583647EE2C41F6FE24E428B66C745ED52467DCE6
ffa/libffa/w_shifts.ads
(0 . 0)(1 . 58)
817 ------------------------------------------------------------------------------
818 ------------------------------------------------------------------------------
819 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
820 -- --
821 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
822 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
823 -- --
824 -- You do not have, nor can you ever acquire the right to use, copy or --
825 -- distribute this software ; Should you use this software for any purpose, --
826 -- or copy and distribute it to anyone or in any manner, you are breaking --
827 -- the laws of whatever soi-disant jurisdiction, and you promise to --
828 -- continue doing so for the indefinite future. In any case, please --
829 -- always : read and understand any software ; verify any PGP signatures --
830 -- that you use - for any purpose. --
831 -- --
832 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
833 ------------------------------------------------------------------------------
834 ------------------------------------------------------------------------------
835
836 with Words; use Words;
837
838 -- For some peculiar reason, the Ada standards group made
839 -- the fundamental Shift and Rotate bitwise ops into ~optional~ components!
840
841 -- However on GNAT we can force them to exist, as described in:
842 -- https://gcc.gnu.org/onlinedocs/gnat_rm/Shifts-and-Rotates.html
843
844 -- On a non-GNAT compiler, you're own your own.
845
846 package W_Shifts is
847
848 pragma Pure;
849
850 function Shift_Left
851 (Value : Word;
852 Amount : Natural)
853 return Word;
854 pragma Import(Intrinsic, Shift_Left);
855
856 function Shift_Right
857 (Value : Word;
858 Amount : Natural)
859 return Word;
860 pragma Import(Intrinsic, Shift_Right);
861
862 function Rotate_Left
863 (Value : Word;
864 Amount : Natural)
865 return Word;
866 pragma Import(Intrinsic, Rotate_Left);
867
868 function Rotate_Right
869 (Value : Word;
870 Amount : Natural)
871 return Word;
872 pragma Import(Intrinsic, Rotate_Right);
873
874 end W_Shifts;
-
+ 7CA5191747D159092841AF1D29A5779075AB1C74F3CCAA94B187DC135D76819034CA9666AE01ABC3212D47A2BDDF06A56DAD178591646225B17E11801CDEEBAC
ffa/libffa/word_ops.adb
(0 . 0)(1 . 101)
879 ------------------------------------------------------------------------------
880 ------------------------------------------------------------------------------
881 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
882 -- --
883 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
884 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
885 -- --
886 -- You do not have, nor can you ever acquire the right to use, copy or --
887 -- distribute this software ; Should you use this software for any purpose, --
888 -- or copy and distribute it to anyone or in any manner, you are breaking --
889 -- the laws of whatever soi-disant jurisdiction, and you promise to --
890 -- continue doing so for the indefinite future. In any case, please --
891 -- always : read and understand any software ; verify any PGP signatures --
892 -- that you use - for any purpose. --
893 -- --
894 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
895 ------------------------------------------------------------------------------
896 ------------------------------------------------------------------------------
897
898 with W_Shifts; use W_Shifts;
899
900 -- Fundamental Operations on Words:
901 package body Word_Ops is
902
903 -- Ada (like C) does not (portably) tell us over/underflow from arithmetic.
904 -- And there existed in the past, and apparently exist today, CPUs made
905 -- by idiots and wreckers (e.g. 'RISC-V') that do not have flags at all!
906
907 -- However, for multi-word addition, subtraction, the inner loop of
908 -- Comba's multiplication, and for a handful of other ops, we need it!
909
910 -- So we derive the Carry or Borrow at the 'eldest' binary position.
911 -- See the elementary proof (base case: 1 bit) further below:
912
913 -- Find the Carry, from an addition where it is known that A + B == S:
914 function W_Carry(A : in Word; B : in Word; S : in Word)
915 return WBool is
916 begin
917 return WBool(Shift_Right((A and B) or ((A or B) and (not S)),
918 Bitness - 1));
919 end W_Carry;
920 pragma Inline_Always(W_Carry);
921
922
923 -- Find the Borrow, from a subtraction where it is known that A - B == D:
924 function W_Borrow(A : in Word; B : in Word; D : in Word)
925 return WBool is
926 begin
927 return WBool(Shift_Right(((not A) and B) or (((not A) or B) and D),
928 Bitness - 1));
929 end W_Borrow;
930 pragma Inline_Always(W_Borrow);
931
932 -- A+B+C is the output bit of 1-bit adder; C is carry-in;
933 -- A-B-C is the output bit of 1-bit subber; C is borrow-in.
934 -- Observe that A+B+C is equal to A-B-C for all A,B,C !
935 -- +-+-+-+-----+--------------+-----+----------------+
936 -- | | 'Carry' out: | | 'Borrow' out: |
937 -- +-+-+-+-----+--------------+-----+----------------+
938 -- | | | | |(a and b) or | |(~a and b) or |
939 -- |A|B|C|A+B+C| ((a or b) and|A-B-C| ((~a or b) and |
940 -- | | | | | ~(A+B+C)) | | (A-B-C)) |
941 -- +-+-+-+-----+--------------+-----+----------------+
942 -- |0|0|0| 0 | 0 | 0 | 0 |
943 -- +-+-+-+-----+--------------+-----+----------------+
944 -- |1|0|0| 1 | 0 | 1 | 0 |
945 -- +-+-+-+-----+--------------+-----+----------------+
946 -- |0|1|0| 1 | 0 | 1 | 1 |
947 -- +-+-+-+-----+--------------+-----+----------------+
948 -- |1|1|0| 0 | 1 | 0 | 0 |
949 -- +-+-+-+-----+--------------+-----+----------------+
950 -- |0|0|1| 1 | 0 | 1 | 1 |
951 -- +-+-+-+-----+--------------+-----+----------------+
952 -- |1|0|1| 0 | 1 | 0 | 0 |
953 -- +-+-+-+-----+--------------+-----+----------------+
954 -- |0|1|1| 0 | 1 | 0 | 1 |
955 -- +-+-+-+-----+--------------+-----+----------------+
956 -- |1|1|1| 1 | 1 | 1 | 1 |
957 -- +-+-+-+-----+--------------+-----+----------------+
958 -- This base case extends to any N bit register, since
959 -- both equations depend ~strictly~ on A, B, and C.
960
961
962 -- Without any branching: if Sel == 0, return A; if Sel == 1, return B.
963 function W_Mux(A : in Word; B : in Word; Sel : in WBool) return Word is
964 begin
965 return B xor ((Sel - 1) and (A xor B));
966 end W_Mux;
967 pragma Inline_Always(W_Mux);
968
969
970 -- Exchange A and B.
971 procedure W_Swap(A : in out Word; B : in out Word) is
972 begin
973 A := A xor B;
974 B := A xor B;
975 A := A xor B;
976 end W_Swap;
977 pragma Inline_Always(W_Swap);
978
979 end Word_Ops;
-
+ 991563401E923B6D1448644D1AD8FE238E79F5154F98D7317D38227C5856D6CFB55FCEE27C5DDA316E70464A3F234831358B58D9B409CF2D5DB90AA1F38D9E92
ffa/libffa/word_ops.ads
(0 . 0)(1 . 42)
984 ------------------------------------------------------------------------------
985 ------------------------------------------------------------------------------
986 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
987 -- --
988 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
989 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
990 -- --
991 -- You do not have, nor can you ever acquire the right to use, copy or --
992 -- distribute this software ; Should you use this software for any purpose, --
993 -- or copy and distribute it to anyone or in any manner, you are breaking --
994 -- the laws of whatever soi-disant jurisdiction, and you promise to --
995 -- continue doing so for the indefinite future. In any case, please --
996 -- always : read and understand any software ; verify any PGP signatures --
997 -- that you use - for any purpose. --
998 -- --
999 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
1000 ------------------------------------------------------------------------------
1001 ------------------------------------------------------------------------------
1002
1003 with Words; use Words;
1004
1005 -- Fundamental Operations on Words:
1006 package Word_Ops is
1007
1008 pragma Pure;
1009
1010 -- Branch-free calculation of 'carry' from a machine-word addition.
1011 function W_Carry(A : in Word; B : in Word; S : in Word)
1012 return WBool;
1013
1014 -- Branch-free calculation of 'borrow' from a machine-word subtraction.
1015 function W_Borrow(A : in Word; B : in Word; D : in Word)
1016 return WBool;
1017
1018 -- Without any branching: if Sel == 0, return A; if Sel == 1, return B.
1019 function W_Mux(A : in Word; B : in Word; Sel : in WBool)
1020 return Word;
1021
1022 -- Exchange A and B.
1023 procedure W_Swap(A : in out Word; B : in out Word);
1024
1025 end Word_Ops;
-
+ 81A4BF46ABD4B92F58B791872C94193606E9847F7C232AA604F91B71412F0B9732D23BE295810596355B68B8111EF5102BB7778DCB2FE987C948490A95B49CCD
ffa/libffa/words.ads
(0 . 0)(1 . 46)
1030 ------------------------------------------------------------------------------
1031 ------------------------------------------------------------------------------
1032 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
1033 -- --
1034 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
1035 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
1036 -- --
1037 -- You do not have, nor can you ever acquire the right to use, copy or --
1038 -- distribute this software ; Should you use this software for any purpose, --
1039 -- or copy and distribute it to anyone or in any manner, you are breaking --
1040 -- the laws of whatever soi-disant jurisdiction, and you promise to --
1041 -- continue doing so for the indefinite future. In any case, please --
1042 -- always : read and understand any software ; verify any PGP signatures --
1043 -- that you use - for any purpose. --
1044 -- --
1045 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
1046 ------------------------------------------------------------------------------
1047 ------------------------------------------------------------------------------
1048
1049 with Iron;
1050
1051 package Words is
1052
1053 pragma Pure;
1054
1055 -- The most fundamental fact about Word: width.
1056 Bitness : constant Positive := Iron.MachineBitness;
1057
1058 -- It is possible to calculate BitnessLog2 at elaboration time,
1059 -- but we will avoid having ~any~ elaboration at all in FFA.
1060 BitnessLog2 : constant Positive := Iron.MachineBitnessLog2;
1061
1062 -- The Word width, expressed in ~bytes~:
1063 Byteness : constant Positive := Bitness / Iron.ByteBits;
1064
1065 -- What kind of words to use. Must be machine-word or smaller.
1066 type Word is mod 2**Bitness;
1067 for Word'Size use Bitness;
1068
1069 -- The very same Word, but its only legal values are 0 and 1.
1070 subtype WBool is Word range 0 .. 1;
1071
1072 -- When we must refer to individual bit positions of a machine word:
1073 subtype WBit_Index is Natural range 0 .. Bitness - 1;
1074
1075 end Words;