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_ch8_randomism.kv 5 -- (C) 2017 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_ch8_randomism.kv 20 with OS; use OS;
ffa_ch8_randomism.kv 21
ffa_ch8_randomism.kv 22 with FZ_Type; use FZ_Type;
ffa_ch8_randomism.kv 23
ffa_ch8_randomism.kv 24
ffa_ch8_randomism.kv 25 package body FFA_RNG is
ffa_ch8_randomism.kv 26
ffa_ch8_randomism.kv 27 -- Prepare an RNG for use; at given path, or will use default
ffa_ch8_randomism.kv 28 procedure Init_RNG(RNG : out RNG_Device;
ffa_ch8_randomism.kv 29 RNG_Unix_Path : in String := Default_RNG_Path) is
ffa_ch8_randomism.kv 30 begin
ffa_ch8_randomism.kv 31 begin
ffa_ch8_randomism.kv 32 -- Open the RNG at the offered path:
ffa_ch8_randomism.kv 33 Word_IO.Open(File => RNG.F,
ffa_ch8_randomism.kv 34 Mode => Word_IO.In_File,
ffa_ch8_randomism.kv 35 Name => RNG_Unix_Path);
ffa_ch8_randomism.kv 36 exception
ffa_ch8_randomism.kv 37 when others =>
ffa_ch8_randomism.kv 38 Eggog("Could not open RNG at : " & RNG_Unix_Path & "!");
ffa_ch8_randomism.kv 39 end;
ffa_ch8_randomism.kv 40 end Init_RNG;
ffa_ch8_randomism.kv 41
ffa_ch8_randomism.kv 42
ffa_ch8_randomism.kv 43 -- Fill a FZ from RNG
ffa_ch8_randomism.kv 44 procedure FZ_Random(RNG : in RNG_Device;
ffa_ch8_randomism.kv 45 N : out FZ) is
ffa_ch8_randomism.kv 46 begin
ffa_ch8_randomism.kv 47 begin
ffa_ch8_randomism.kv 48 -- Fill the destination FZ from this RNG:
ffa_ch8_randomism.kv 49 for i in N'Range loop
ffa_ch8_randomism.kv 50 Word_IO.Read(RNG.F, N(i));
ffa_ch8_randomism.kv 51 end loop;
ffa_ch8_randomism.kv 52 exception
ffa_ch8_randomism.kv 53 when others =>
ffa_ch8_randomism.kv 54 Eggog("Could not read from RNG!");
ffa_ch8_randomism.kv 55 end;
ffa_ch8_randomism.kv 56 end FZ_Random;
ffa_ch8_randomism.kv 57
ffa_ch8_randomism.kv 58 end FFA_RNG;