URL
https://opencores.org/ocsvn/lxp32/lxp32/trunk
[/] [lxp32/] [trunk/] [verify/] [common_pkg/] [common_pkg_body.vhd] - Diff between revs 2 and 6
Go to most recent revision |
Show entire file |
Details |
Blame |
View Log
Rev 2 |
Rev 6 |
Line 4... |
Line 4... |
-- Part of the LXP32 verification environment
|
-- Part of the LXP32 verification environment
|
--
|
--
|
-- Copyright (c) 2016 by Alex I. Kuznetsov
|
-- Copyright (c) 2016 by Alex I. Kuznetsov
|
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
|
|
use std.textio.all;
|
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.numeric_std.all;
|
use ieee.numeric_std.all;
|
|
use ieee.math_real.all;
|
|
|
package body common_pkg is
|
package body common_pkg is
|
impure function rand return integer is
|
procedure rand(variable st: inout rng_state_type; a,b: integer; variable x: out integer) is
|
variable r: unsigned(63 downto 0);
|
variable r: real;
|
begin
|
|
r:=rand_state*to_unsigned(1103515245,32)+12345;
|
|
rand_state:=r(rand_state'range);
|
|
return to_integer(rand_state(30 downto 16));
|
|
end function;
|
|
|
|
impure function rand(a: integer; b: integer) return integer is
|
|
begin
|
begin
|
assert a<=b report "Invalid range" severity failure;
|
assert a<=b report "Invalid range" severity failure;
|
return (rand mod (b-a+1))+a;
|
uniform(st.seed1,st.seed2,r);
|
end function;
|
r:=r*real(b-a+1);
|
|
x:=a+integer(floor(r));
|
|
end procedure;
|
|
|
function hex_string(x: std_logic_vector) return string is
|
function hex_string(x: std_logic_vector) return string is
|
variable xx: std_logic_vector(x'length-1 downto 0);
|
variable xx: std_logic_vector(x'length-1 downto 0);
|
variable i: integer:=0;
|
variable i: integer:=0;
|
variable ii: integer;
|
variable ii: integer;
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.