Reformat glibc_random

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
pull/64/head
Anton Blanchard 5 years ago committed by Anton Blanchard
parent 1d5e8c2eb4
commit 06392e7eaa

@ -6,33 +6,33 @@ library work;
use work.glibc_random_helpers.all; use work.glibc_random_helpers.all;


package glibc_random is package glibc_random is
function pseudorand(a: integer) return std_ulogic_vector; function pseudorand(a: integer) return std_ulogic_vector;
function pseudorand1 return std_ulogic; function pseudorand1 return std_ulogic;
end package glibc_random; end package glibc_random;


package body glibc_random is package body glibc_random is
function pseudorand(a: integer) return std_ulogic_vector is function pseudorand(a: integer) return std_ulogic_vector is
variable tmp1, tmp2, tmp3, tmp4: std_ulogic_vector(31 downto 0); variable tmp1, tmp2, tmp3, tmp4: std_ulogic_vector(31 downto 0);
variable ret: std_ulogic_vector(63 downto 0); variable ret: std_ulogic_vector(63 downto 0);
begin begin
tmp1 := std_ulogic_vector(to_unsigned(random, 32)); tmp1 := std_ulogic_vector(to_unsigned(random, 32));
tmp2 := std_ulogic_vector(to_unsigned(random, 32)); tmp2 := std_ulogic_vector(to_unsigned(random, 32));
if a <= 32 then if a <= 32 then
ret := tmp1 & tmp2; ret := tmp1 & tmp2;
else else
tmp3 := std_ulogic_vector(to_unsigned(random, 32)); tmp3 := std_ulogic_vector(to_unsigned(random, 32));
tmp4 := std_ulogic_vector(to_unsigned(random, 32)); tmp4 := std_ulogic_vector(to_unsigned(random, 32));


ret := tmp1(15 downto 0) & tmp2(15 downto 0) & tmp3(15 downto 0) & tmp4(15 downto 0); ret := tmp1(15 downto 0) & tmp2(15 downto 0) & tmp3(15 downto 0) & tmp4(15 downto 0);
end if; end if;


return ret((a-1) downto 0); return ret((a-1) downto 0);
end; end;


function pseudorand1 return std_ulogic is function pseudorand1 return std_ulogic is
variable tmp: std_ulogic_vector(31 downto 0); variable tmp: std_ulogic_vector(31 downto 0);
begin begin
tmp := std_ulogic_vector(to_unsigned(random, 32)); tmp := std_ulogic_vector(to_unsigned(random, 32));
return tmp(0); return tmp(0);
end; end;
end package body glibc_random; end package body glibc_random;

@ -1,19 +1,19 @@
package glibc_random_helpers is package glibc_random_helpers is
procedure srand (v : integer); procedure srand (v : integer);
attribute foreign of srand : procedure is "VHPIDIRECT srand"; attribute foreign of srand : procedure is "VHPIDIRECT srand";


function random return integer; function random return integer;
attribute foreign of random : function is "VHPIDIRECT random"; attribute foreign of random : function is "VHPIDIRECT random";
end glibc_random_helpers; end glibc_random_helpers;


package body glibc_random_helpers is package body glibc_random_helpers is
procedure srand (v : integer) is procedure srand (v : integer) is
begin begin
assert false severity failure; assert false severity failure;
end srand; end srand;


function random return integer is function random return integer is
begin begin
assert false severity failure; assert false severity failure;
end random; end random;
end glibc_random_helpers; end glibc_random_helpers;

Loading…
Cancel
Save