function random_std_logic_vector (vector_size : integer)
return std_logic_vector is
variable seed1, seed2: positive;
variable rand: real;
variable int_rand: integer;
variable stim: std_logic_vector(vector_size-1 downto 0);
begin
-- loop
UNIFORM(seed1, seed2, rand);
-- get a random value of size vector_size
rand := rand * real(vector_size);
int_rand := integer(floor(rand));
-- 2. convert to std_logic_vector
stim := std_logic_vector(to_unsigned(int_rand, stim'LENGTH));
seed1 := integer(real(seed1) * rand);
-- end loop;
return stim;
end;
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.