Random generation in function

A

ALuPin

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
 
R

Ralf Hildebrandt

ALuPin said:
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
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top