Random generation in function

A

ALuPin

Guest
Hi everybody,

I have a process like that


signal l_data : std_logic_vector(2 downto 0);

process(Reset, Clk)
begin
if Reset='1' then
l_data <= (others => '0');
elsif rising_edge(Clk) then

if l_load='1' then
l_data <= xxx;
end if;
end if;
end process;

When l_load is high I want to load data but these data
should be random for example between 0 and 7 (integer).

How can I solve that problem with a function ?

Thank you for your help.

Kind regards

Andre
 
ALuPin wrote:

When l_load is high I want to load data but these data
should be random for example between 0 and 7 (integer).

How can I solve that problem with a function ?
Use a pseudo-random number generator, which is a linear feedback shift
register (LFSR). This is nothing more than a chain of flipflops with
some feedback at special (!) points via XOR-gates.

In number theory it is a primitive and irreducible polynomial over
Galois Field of 2. This polynomial can easily represented by a LFSR.

Polynomials with the same characteristics are used in CRC checksum
generators - so you can take one of these.


Initialize such a LFSR during reset and let it run freely with your main
clock. (That consumes a little bit energy...)

Note: LFSRs provide not a true random signal - only pseudo-random.


Ralf
 

Welcome to EDABoard.com

Sponsor

Back
Top