diff -uNr a/ffa/ffainline/bin/README b/ffa/ffainline/bin/README --- a/ffa/ffainline/bin/README false +++ b/ffa/ffainline/bin/README 86525f2c7086039d79e5bf92869d02934a44716812433ca3a90e18a8d03745785c5ca54fe8c39e681b3b13c00c33a5128884a28c8cbaccbc65d0b401d901ec2e @@ -0,0 +1 @@ +Placeholder. diff -uNr a/ffa/ffainline/exp0.txt b/ffa/ffainline/exp0.txt --- a/ffa/ffainline/exp0.txt false +++ b/ffa/ffainline/exp0.txt b937a56a682d26dc98ebcf6689a7076e480c1b24d008ced2babb44b97a4d954b6ea308aeeeffd10f6d1f5f96eee3ccbfb0957ec4a2a08b65c94ad16e3c3c2529 @@ -0,0 +1 @@ +00000000989680000000000097FDE98000000000976553000000000096CCBC80000000009634260000000000959B8F80000000009502F90000000000946A62800000000093D1CC0000000000933935800000000092A09F00000000009208088000000000916F72000000000090D6DB8000000000903E4500000000008FA5AE80000000008F0D1800000000008E748180000000008DDBEB00000000008D435480000000008CAABE00000000008C122780000000008B799100000000008AE0FA80000000008A4864000000000089AFCD80000000008917370000000000887EA0800000000087E60A0000000000874D73800000000086B4DD0000000000861C4680000000008583B0000000000084EB198000000000845283000000000083B9EC800000000083215600000000008288BF800000000081F0290000000000815792800000000080BEFC000000000080266580000000007F8DCF00000000007EF53880000000007E5CA200000000007DC40B80000000007D2B7500000000007C92DE80000000007BFA4800000000007B61B180000000007AC91B00000000007A308480000000007997EE000000000078FF5780000000007866C1000000000077CE2A80000000007735940000000000769CFD80000000007604670000000000756BD0800000000074D33A0000000000743AA3800000000073A20D000000000073097680000000007270E0000000000071D8498000000000713FB3000000000070A71C8000000000700E8600000000006F75EF80000000006EDD5900000000006E44C280000000006DAC2C00000000006D139580000000006C7AFF00000000006BE26880000000006B49D200000000006AB13B80000000006A18A5000000000069800E800000000068E7780000000000684EE1800000000067B64B0000000000671DB4800000000066851E000000000065EC8780000000006553F1000000000064BB5A80000000006422C40000000000638A2D800000000062F1970000000000625900800000000061C06A00000000006127D38000000000608F3D00000000005FF6A680000000005F5E1000000000005EC57980000000005E2CE300000000005D944C80000000005CFBB600000000005C631F80000000005BCA8900000000005B31F280000000005A995C00000000005A00C5800000000059682F000000000058CF9880000000005837020000000000579E6B80000000005705D50000000000566D3E800000000055D4A80000000000553C11800000000054A37B0000000000540AE4800000000053724E000000000052D9B78000000000524121000000000051A88A8000000000510FF4000000000050775D80000000004FDEC700000000004F463080000000004EAD9A00000000004E150380000000004D7C6D00000000004CE3D680000000004C4B4000000000004BB2A980000000004B1A1300000000004A817C800000000049E8E6000000000049504F800000000048B7B90000000000481F22800000000047868C000000000046EDF5800000000046555F000000000045BCC880000000004524320000000000448B9B800000000043F3050000000000435A6E800000000042C1D8000000000042294180000000004190AB000000000040F8148000000000405F7E00000000003FC6E780000000003F2E5100000000003E95BA80000000003DFD2400000000003D648D80000000003CCBF700000000003C336080000000003B9ACA00000000003B023380000000003A699D000000000039D10680000000003938700000000000389FD980000000003807430000000000376EAC800000000036D6160000000000363D7F800000000035A4E90000000000350C5280000000003473BC000000000033DB25800000000033428F000000000032A9F8800000000032116200000000003178CB800000000030E035000000000030479E80000000002FAF0800000000002F167180000000002E7DDB00000000002DE54480000000002D4CAE00000000002CB41780000000002C1B8100000000002B82EA80000000002AEA5400000000002A51BD800000000029B927000000000029209080000000002887FA000000000027EF6380000000002756CD000000000026BE3680000000002625A00000000000258D09800000000024F4730000000000245BDC800000000023C3460000000000232AAF8000000000229219000000000021F98280000000002160EC000000000020C8558000000000202FBF00000000001F972880000000001EFE9200000000001E65FB80000000001DCD6500000000001D34CE80000000001C9C3800000000001C03A180000000001B6B0B00000000001AD27480000000001A39DE000000000019A14780000000001908B1000000000018701A800000000017D7840000000000173EED800000000016A6570000000000160DC0800000000015752A000000000014DC9380000000001443FD000000000013AB6680000000001312D00000000000127A39800000000011E1A3000000000011490C800000000010B07600000000001017DF80000000000F7F4900000000000EE6B280000000000E4E1C00000000000DB58580000000000D1CEF00000000000C845880000000000BEBC200000000000B532B80000000000ABA9500000000000A21FE8000000000098968000000000008F0D1800000000008583B000000000007BFA4800000000007270E0000000000068E77800000000005F5E10000000000055D4A800000000004C4B40000000000042C1D8000000000039387000000000002FAF0800000000002625A000000000001C9C3800000000001312D000000000000989680 \ No newline at end of file diff -uNr a/ffa/ffainline/ffa_inline.gpr b/ffa/ffainline/ffa_inline.gpr --- a/ffa/ffainline/ffa_inline.gpr false +++ b/ffa/ffainline/ffa_inline.gpr d78cdc965edc9f4ce2b6db81e7b91fa0b029639b3e302674522d9b118e795ffbdb7fab28ff12ce3a277858f232073dd0bfa36e61dde95f4870de6ca7b7df3628 @@ -0,0 +1,67 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 "../libffa/ffa.gpr"; + +project FFA_Inline is + + for Object_Dir use "obj"; + + type Mode_Type is ("debug", "release"); + Mode : Mode_Type := external ("mode", "release"); + + for Languages use ("Ada"); + for Source_Dirs use ("."); + for Exec_Dir use "bin"; + for Main use ("inline_exp1_main.adb", "inline_exp2_main.adb", "inline_exp3_main.adb"); + + + package Compiler is + case Mode is + when "debug" => + for Switches ("Ada") + use ("-g"); + when "release" => + for Switches ("Ada") + use ("-O2", "-fdump-scos", "-gnata", "-fstack-check", + "-fdata-sections", "-ffunction-sections"); + end case; + end Compiler; + + package Binder is + case Mode is + when "debug" => + for Switches ("Ada") + use (); + when "release" => + for Switches ("Ada") + use ("-static"); + end case; + end Binder; + + package Linker is + case Mode is + when "debug" => + for Switches ("Ada") + use (); + when "release" => + for Switches ("Ada") + use ("-L/usr/lib64", "-Wl,--gc-sections", + "-static"); + end case; + end Linker; + +end FFA_Inline; diff -uNr a/ffa/ffainline/ffa_io.adb b/ffa/ffainline/ffa_io.adb --- a/ffa/ffainline/ffa_io.adb false +++ b/ffa/ffainline/ffa_io.adb fcae236bff0cc19d49c75db954293d8cecf1e7cd25c1e34acb955ae270094dc3fbb2fa5524419fa2116f50720e0de5ca38daa627a94c04241e1ae306e4ee3a51 @@ -0,0 +1,58 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 Ada.Text_IO; use Ada.Text_IO; + +with Words; use Words; +with W_Shifts; use W_Shifts; +with FZ_Type; use FZ_Type; + + +package body FFA_IO is + + -- Obtain the WChars corresponding to the given Word + function W_To_WChars(N : Word) return WChars is + H : constant array(0 .. 15) of Character := "0123456789ABCDEF"; + W : Word := N; + Result : WChars; + begin + for b in WChars'Range loop -- From bottom to top: + Result(B) := H(Natural(W and 16#F#)); -- Get current nibble. + W := Shift_Right(W, 4); -- Get the next nibble. + end loop; + return Result; + end W_To_WChars; + + + -- Display a hex representation of W to stdout + procedure Dump(W : in Word) is + T : WChars := W_To_WChars(W); + begin + for i in reverse T'Range loop + Put(T(i)); + end loop; + end Dump; + + + -- Display a hex representation of N to stdout + procedure Dump(N : in FZ) is + begin + for i in reverse N'Range loop + Dump(N(i)); + end loop; + end Dump; + +end FFA_IO; diff -uNr a/ffa/ffainline/ffa_io.ads b/ffa/ffainline/ffa_io.ads --- a/ffa/ffainline/ffa_io.ads false +++ b/ffa/ffainline/ffa_io.ads 980e8fa2021880911e875bed0e7469b898b86d28c140d6c2736d2cb116d9c63a84403b63c08e16094e6cbdff0cbd541647bb0cd0b05e42041d4eb96c2312723c @@ -0,0 +1,34 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 Words; use Words; +with FZ_Type; use FZ_Type; + +package FFA_IO is + + -- Character representation of a Word + type WChars is array(1 .. 2 * Byteness) of Character; + + -- Obtain the WChars corresponding to the given Word + function W_To_WChars(N : Word) return WChars; + + -- Display a hex representation of W to stdout + procedure Dump(W : in Word); + + -- Display a hex representation of N to stdout + procedure Dump(N : in FZ); + +end FFA_IO; diff -uNr a/ffa/ffainline/inline_exp1.adb b/ffa/ffainline/inline_exp1.adb --- a/ffa/ffainline/inline_exp1.adb false +++ b/ffa/ffainline/inline_exp1.adb 146da4e1ad83655aad27ce25c20a7bf4c7ccfd3bd58fabbeb65a48f465a471874a4d5d81229f838fc4e4e33e84bf82b829ed20234f0db7eb410a380a3ddf5bd0 @@ -0,0 +1,60 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 . -- +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ + +-- From Ada: +with Ada.Text_IO; use Ada.Text_IO; + +with FZ_Arith; use FZ_Arith; +with FFA_IO; use FFA_IO; + +package body Inline_Exp1 is + + procedure Mul_By_Sum + (N : in Natural; + X : in FZ; + Z : out FZ; + Overflow : out WBool) + is + + C : WBool := 0; + begin + Z := (others => 0); + for i in 1 .. N loop + FZ_Add (X, Z, Z, C); + end loop; + Overflow := C; + end Mul_By_Sum; + + procedure Inline_Experiment is + X : FZ (1 .. 256) := (others => 0); + Z : FZ (1 .. 256) := (others => 0); + + -- Carry. + C : WBool := 0; + + N : Indices := 256; + begin + for i in 1 .. N loop + X (i) := Word (i); + end loop; + + Mul_By_Sum (10000000, X, Z, C); + + Dump (Z); + + end Inline_Experiment; + +end Inline_Exp1; diff -uNr a/ffa/ffainline/inline_exp1.ads b/ffa/ffainline/inline_exp1.ads --- a/ffa/ffainline/inline_exp1.ads false +++ b/ffa/ffainline/inline_exp1.ads ede8ace23afceae4b2ccd4f78f946642124bf0da7964c46ab2c634c7985f8081c67a44b88aa2fe32e80bb41fa6ba9fe29be2c24edb6e9284e9d3064596d9f25d @@ -0,0 +1,31 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 . -- +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ + +-- From FFA: +with FZ_Type; use FZ_Type; +with Words; use Words; + +package Inline_Exp1 is + + procedure Mul_By_Sum + (N : in Natural; + X : in FZ; + Z : out FZ; + Overflow : out WBool); + + procedure Inline_Experiment; + +end Inline_Exp1; diff -uNr a/ffa/ffainline/inline_exp1_main.adb b/ffa/ffainline/inline_exp1_main.adb --- a/ffa/ffainline/inline_exp1_main.adb false +++ b/ffa/ffainline/inline_exp1_main.adb f9f1dfd6c226be9a25d55a2022138bdd133ac862064e977eeeb1d6598389ff041e42f2f837747fb7b744b0b37ecc8f864034c09f672afbcc685441d9e355101b @@ -0,0 +1,24 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 Inline_Exp1; use Inline_Exp1; + +procedure Inline_Exp1_Main is +begin + + Inline_Experiment; + +end Inline_Exp1_Main; diff -uNr a/ffa/ffainline/inline_exp2.adb b/ffa/ffainline/inline_exp2.adb --- a/ffa/ffainline/inline_exp2.adb false +++ b/ffa/ffainline/inline_exp2.adb 99be2ec895c524096400938f288e9bb3f0eb3cacea7f84f122dfaa3bb5ffd686c5fd6492620226d2f496d307e00191ed47372e8d27e42238d870788b7b013277 @@ -0,0 +1,95 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 . -- +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ + +-- From Ada: +with Ada.Text_IO; use Ada.Text_IO; + +-- From the Demo: +with FFA_IO; use FFA_IO; +with Words; use Words; +with W_Shifts; use W_Shifts; + +package body Inline_Exp2 is + + -- Find the Carry, from an addition where it is known that A + B == S: + function W_Carry2 (A : in Word; B : in Word; S : in Word) return WBool is + begin + return WBool + (Shift_Right ((A and B) or ((A or B) and (not S)), Bitness - 1)); + end W_Carry2; + pragma Inline_Always (W_Carry2); + + -- Sum := X + Y; Overflow := Carry + procedure FZ_Add2 + (X : in FZ; + Y : in FZ; + Sum : out FZ; + Overflow : out WBool) + is + Carry : WBool := 0; + begin + for i in X'Range loop + declare + A : constant Word := X (i); + B : constant Word := Y (i); + S : constant Word := A + B + Carry; + begin + Sum (i) := S; + Carry := W_Carry2 (A, B, S); + end; + end loop; + Overflow := Carry; + end FZ_Add2; + pragma Inline_Always (FZ_Add2); + + procedure Mul_By_Sum + (N : in Natural; + X : in FZ; + Z : out FZ; + Overflow : out WBool) + is + + C : WBool := 0; + begin + Z := (others => 0); + for i in 1 .. N loop + FZ_Add2 (X, Z, Z, C); + end loop; + Overflow := C; + end Mul_By_Sum; + + procedure Inline_Experiment is + + -- We are using 64-bit Words (see iron.ads). + -- We'll begin with an elementary demo, using 256-bit FZ: + X : FZ (1 .. 256) := (others => 0); + Z : FZ (1 .. 256) := (others => 0); + + -- Carry. + C : WBool := 0; + N : Indices := 256; + begin + for i in 1 .. N loop + X (i) := Word (i); + end loop; + + Mul_By_Sum (10000000, X, Z, C); + + Dump (Z); + + end Inline_Experiment; + +end Inline_Exp2; diff -uNr a/ffa/ffainline/inline_exp2.ads b/ffa/ffainline/inline_exp2.ads --- a/ffa/ffainline/inline_exp2.ads false +++ b/ffa/ffainline/inline_exp2.ads 4a43b5917fdaee87e16ecb3ff067dc3958fbf55b8eb61d5e84a84b2adda3e4bead3a794658d0e20125d234950359fe383773b9653ce2ee0d7e70afea1e630cb5 @@ -0,0 +1,31 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 . -- +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ + +-- From FFA: +with FZ_Type; use FZ_Type; +with Words; use Words; + +package Inline_Exp2 is + + procedure Mul_By_Sum + (N : in Natural; + X : in FZ; + Z : out FZ; + Overflow : out WBool); + + procedure Inline_Experiment; + +end Inline_Exp2; diff -uNr a/ffa/ffainline/inline_exp2_main.adb b/ffa/ffainline/inline_exp2_main.adb --- a/ffa/ffainline/inline_exp2_main.adb false +++ b/ffa/ffainline/inline_exp2_main.adb 47648ab008702f5d4e10d3c93c9e5f33f0096fa8f051cecd8a2596090e4c03bee71978336847799c3f29d9ad151a12e888d69c6ae9cd5857b12e77dd319a82e8 @@ -0,0 +1,24 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 Inline_Exp2; use Inline_Exp2; + +procedure Inline_Exp2_Main is +begin + + Inline_Experiment; + +end Inline_Exp2_Main; diff -uNr a/ffa/ffainline/inline_exp3.adb b/ffa/ffainline/inline_exp3.adb --- a/ffa/ffainline/inline_exp3.adb false +++ b/ffa/ffainline/inline_exp3.adb 422fb8705f8228755d671c25d896704961f8220007e3c5286b6ece577ea744db70e87e66b8e87543b0dc3a340c22883989ff16cce150b285c177c5024d1262d2 @@ -0,0 +1,65 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 . -- +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ + +-- From Ada: +with Ada.Text_IO; use Ada.Text_IO; + +with Inline_Exp3_Mod; use Inline_Exp3_Mod; +-- From the Demo: +with FFA_IO; use FFA_IO; +with Words; use Words; +with W_Shifts; use W_Shifts; + +package body Inline_Exp3 is + + procedure Mul_By_Sum + (N : in Natural; + X : in FZ; + Z : out FZ; + Overflow : out WBool) + is + C : WBool := 0; + begin + Z := (others => 0); + for i in 1 .. N loop + FZ_Add3 (X, Z, Z, C); + end loop; + Overflow := C; + end Mul_By_Sum; + + procedure Inline_Experiment is + + -- We are using 64-bit Words (see iron.ads). + -- We'll begin with an elementary demo, using 256-bit FZ: + X : FZ (1 .. 256) := (others => 0); + Z : FZ (1 .. 256) := (others => 0); + + -- Carry. + C : WBool := 0; + N : Indices := 256; + + begin + for i in 1 .. N loop + X (i) := Word (i); + end loop; + + Mul_By_Sum (10000000, X, Z, C); + + Dump (Z); + + end Inline_Experiment; + +end Inline_Exp3; diff -uNr a/ffa/ffainline/inline_exp3.ads b/ffa/ffainline/inline_exp3.ads --- a/ffa/ffainline/inline_exp3.ads false +++ b/ffa/ffainline/inline_exp3.ads 24339d3848a3a5f0992aa2677323ea2d45de1dcc4e98b9fe8ea47feeee3b52f2d3a083f1842c58089a1e413672da774037e54cb6c3244cbbef0c73ff3cf9efb0 @@ -0,0 +1,31 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 . -- +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ + +-- From FFA: +with FZ_Type; use FZ_Type; +with Words; use Words; + +package Inline_Exp3 is + + procedure Mul_By_Sum + (N : in Natural; + X : in FZ; + Z : out FZ; + Overflow : out WBool); + + procedure Inline_Experiment; + +end Inline_Exp3; diff -uNr a/ffa/ffainline/inline_exp3_main.adb b/ffa/ffainline/inline_exp3_main.adb --- a/ffa/ffainline/inline_exp3_main.adb false +++ b/ffa/ffainline/inline_exp3_main.adb 407d7e155677f5c5f8be249088e6c3896c3f731e592b5add36d76d14e675a4480ddef5f5dac9cb5acbba91092d2e867ffcc5bea6cec19ce4e148c8ad207a22a2 @@ -0,0 +1,24 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 Inline_Exp3; use Inline_Exp3; + +procedure Inline_Exp3_Main is +begin + + Inline_Experiment; + +end Inline_Exp3_Main; diff -uNr a/ffa/ffainline/inline_exp3_mod.adb b/ffa/ffainline/inline_exp3_mod.adb --- a/ffa/ffainline/inline_exp3_mod.adb false +++ b/ffa/ffainline/inline_exp3_mod.adb 0b99e4d487955107b4b179a04a64691cb423817cf43ec3180ba2207af347949f52f77ef7410120fe60e037ad09ec113f0f25811929feb692ea2f13e91eb20dcf @@ -0,0 +1,56 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 . -- +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ + +-- From Ada: +with Ada.Text_IO; use Ada.Text_IO; + +-- From the Demo: +with FFA_IO; use FFA_IO; +with Words; use Words; +with W_Shifts; use W_Shifts; + +package body Inline_Exp3_Mod is + + -- Find the Carry, from an addition where it is known that A + B == S: + function W_Carry3 (A : in Word; B : in Word; S : in Word) return WBool is + begin + return WBool + (Shift_Right ((A and B) or ((A or B) and (not S)), Bitness - 1)); + end W_Carry3; + + -- Sum := X + Y; Overflow := Carry + procedure FZ_Add3 + (X : in FZ; + Y : in FZ; + Sum : out FZ; + Overflow : out WBool) + is + Carry : WBool := 0; + begin + for i in X'Range loop + declare + A : constant Word := X (i); + B : constant Word := Y (i); + S : constant Word := A + B + Carry; + begin + Sum (i) := S; + Carry := W_Carry3 (A, B, S); + end; + end loop; + Overflow := Carry; + end FZ_Add3; + +end Inline_Exp3_Mod; diff -uNr a/ffa/ffainline/inline_exp3_mod.ads b/ffa/ffainline/inline_exp3_mod.ads --- a/ffa/ffainline/inline_exp3_mod.ads false +++ b/ffa/ffainline/inline_exp3_mod.ads f1c380acf69fc17bb2be3f20cd960fba9789d268721a78e64d6550b3a7b5e9ca441432f7ae8bedde7dce2b31cd7eade027d423a153d1fe7949a33bc6d940a9c5 @@ -0,0 +1,31 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 . -- +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ + +-- From FFA: +with Words; use Words; +with FZ_Type; use FZ_Type; + +package Inline_Exp3_Mod is + function W_Carry3 (A : in Word; B : in Word; S : in Word) return WBool; + pragma Inline_Always (W_Carry3); + + procedure FZ_Add3 + (X : in FZ; + Y : in FZ; + Sum : out FZ; + Overflow : out WBool); + pragma Inline_Always (FZ_Add3); +end Inline_Exp3_Mod; diff -uNr a/ffa/ffainline/obj/auto.cgpr b/ffa/ffainline/obj/auto.cgpr --- a/ffa/ffainline/obj/auto.cgpr false +++ b/ffa/ffainline/obj/auto.cgpr 82927d47e6e9b5a8d492376f6e8d5e00d524fff588a0a6e681a1205054ff4b7b7b416467d4d15845cee4bd4b9ce987abf5c602ed42f1a227ecf5d95666a6bb8b @@ -0,0 +1,11 @@ +-- This gpr configuration file was generated by gprconfig +-- using this command line: +-- /usr/bin/gprconfig --batch -o /home/vanelteren/ADA/ffa-inline/a/ffa/ffainline/obj/auto.cgpr --target=x86_64-linux -q --config=ada,, + +configuration project Default is + for Target use "x86_64-linux"; + for Archive_Builder use ("ar", "cr"); + for Archive_Builder_Append_Option use ("q"); + for Archive_Indexer use ("ranlib"); + for Archive_Suffix use ".a"; +end Default; diff -uNr a/ffa/ffainline/obj/README b/ffa/ffainline/obj/README --- a/ffa/ffainline/obj/README false +++ b/ffa/ffainline/obj/README 86525f2c7086039d79e5bf92869d02934a44716812433ca3a90e18a8d03745785c5ca54fe8c39e681b3b13c00c33a5128884a28c8cbaccbc65d0b401d901ec2e @@ -0,0 +1 @@ +Placeholder. diff -uNr a/ffa/ffainline/README b/ffa/ffainline/README --- a/ffa/ffainline/README false +++ b/ffa/ffainline/README a4c3ccd08378c9f2cb57da8378df1696b98710d772db4bdd1ed380a4af3d739bb6a58154ff800513ef86f841c62ab625e3a15c6c49dd8b47088eb6edd947fc49 @@ -0,0 +1,39 @@ +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +-- This file is an experiment with 'Finite Field Arithmetic', aka 'FFA'. -- +-- -- +-- 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 . -- +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ + +to clean: +gprclean + +to build: +gprbuild + +to build debug, or on crapple: +gprbuild -Xmode=debug + + +'libffa' will build recursively. + +to run: +time ./bin/inline_exp1_main > exp1.txt + +time ./bin/inline_exp2_main > exp2.txt + +time ./bin/inline_exp3_main > exp3.txt + +ouput should be equal to file: exp0.txt + + + diff -uNr a/ffa/README b/ffa/README --- a/ffa/README c146b4fa50a8c6493c149914f2528fcb7106fc09e5c335d528d6d227fde0577deceb452424f1acd6573f070f262d54427606dce6c6332930de970a82ceb28472 +++ b/ffa/README 3e026dbce439830c452afdc65da949668ed9ce0703f8a42e2fc8134da125a9c2649d3b1385d5f02c11a3938223e38f826dbebbc123b0b0c76417831b985492be @@ -25,3 +25,6 @@ http://webchat.freenode.net/?channels=#trilema&nick=from_ffa Privmsg one of the people speaking and ask politely for 'voice'. + +Added ffainline to experiment with pragma Inline_Always. +