George Suarez
Guest
|
Hi,
Here is a code that I wrote for random numbers between A and minus A.
architecture random of random_num is
constant K : real := 1.3806503e-23; signal Vth_op: real := 0.0; signal rand: real := 0.0; signal clk : bit :='0';
entity ... is... end entity;
architecture ideal of .... is
signal rand1,rand2: real := 0.0; signal clk : bit :='0';
begin clk <= not clk after Tshrn; process variable unf : real; variable seed1:integer := 2; variable seed2:integer := 123123123; begin wait on clk; Uniform(seed1,seed2,unf); rand1 <= ROUND(unf*10.0); --Multiply unf by 10 to obtain integer end process; break on rand1; process variable unf : real; variable seed1:integer := 2; variable seed2:integer := 123123123; begin wait on clk; Uniform(seed1,seed2,unf); rand2 <= unf; end process; break on rand2;
between_A_n_minusA == ((-1.0)**rand1)*rand2*A end random;
This code may be freely distributed, I create it for a course project. Hope it helps.
gEoRgiE
|