raw
ffa_ch8_randomism.kv    1 ------------------------------------------------------------------------------
ffa_ch8_randomism.kv 2 ------------------------------------------------------------------------------
ffa_ch8_randomism.kv 3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
ffa_ch8_randomism.kv 4 -- --
ffa_ch15_gcd.kv 5 -- (C) 2019 Stanislav Datskovskiy ( www.loper-os.org ) --
ffa_ch8_randomism.kv 6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
ffa_ch8_randomism.kv 7 -- --
ffa_ch8_randomism.kv 8 -- You do not have, nor can you ever acquire the right to use, copy or --
ffa_ch8_randomism.kv 9 -- distribute this software ; Should you use this software for any purpose, --
ffa_ch8_randomism.kv 10 -- or copy and distribute it to anyone or in any manner, you are breaking --
ffa_ch8_randomism.kv 11 -- the laws of whatever soi-disant jurisdiction, and you promise to --
ffa_ch8_randomism.kv 12 -- continue doing so for the indefinite future. In any case, please --
ffa_ch8_randomism.kv 13 -- always : read and understand any software ; verify any PGP signatures --
ffa_ch8_randomism.kv 14 -- that you use - for any purpose. --
ffa_ch8_randomism.kv 15 -- --
ffa_ch8_randomism.kv 16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
ffa_ch8_randomism.kv 17 ------------------------------------------------------------------------------
ffa_ch8_randomism.kv 18 ------------------------------------------------------------------------------
ffa_ch8_randomism.kv 19
ffa_ch11_tuning_a... 20 with OS; use OS;
ffa_ch11_tuning_a... 21 with FFA; use FFA;
ffa_ch8_randomism.kv 22
ffa_ch8_randomism.kv 23
ffa_ch8_randomism.kv 24 package body FFA_RNG is
ffa_ch8_randomism.kv 25
ffa_ch8_randomism.kv 26 -- Prepare an RNG for use; at given path, or will use default
ffa_ch8_randomism.kv 27 procedure Init_RNG(RNG : out RNG_Device;
ffa_ch8_randomism.kv 28 RNG_Unix_Path : in String := Default_RNG_Path) is
ffa_ch8_randomism.kv 29 begin
ffa_ch8_randomism.kv 30 begin
ffa_ch8_randomism.kv 31 -- Open the RNG at the offered path:
ffa_ch8_randomism.kv 32 Word_IO.Open(File => RNG.F,
ffa_ch8_randomism.kv 33 Mode => Word_IO.In_File,
ffa_ch8_randomism.kv 34 Name => RNG_Unix_Path);
ffa_ch8_randomism.kv 35 exception
ffa_ch8_randomism.kv 36 when others =>
ffa_ch8_randomism.kv 37 Eggog("Could not open RNG at : " & RNG_Unix_Path & "!");
ffa_ch8_randomism.kv 38 end;
ffa_ch8_randomism.kv 39 end Init_RNG;
ffa_ch8_randomism.kv 40
ffa_ch8_randomism.kv 41
ffa_ch8_randomism.kv 42 -- Fill a FZ from RNG
ffa_ch8_randomism.kv 43 procedure FZ_Random(RNG : in RNG_Device;
ffa_ch8_randomism.kv 44 N : out FZ) is
ffa_ch8_randomism.kv 45 begin
ffa_ch8_randomism.kv 46 begin
ffa_ch8_randomism.kv 47 -- Fill the destination FZ from this RNG:
ffa_ch8_randomism.kv 48 for i in N'Range loop
ffa_ch8_randomism.kv 49 Word_IO.Read(RNG.F, N(i));
ffa_ch8_randomism.kv 50 end loop;
ffa_ch8_randomism.kv 51 exception
ffa_ch8_randomism.kv 52 when others =>
ffa_ch8_randomism.kv 53 Eggog("Could not read from RNG!");
ffa_ch8_randomism.kv 54 end;
ffa_ch8_randomism.kv 55 end FZ_Random;
ffa_ch8_randomism.kv 56
ffa_ch8_randomism.kv 57 end FFA_RNG;