Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17252 Discussions

question regarding random number generator

Altera_Forum
Honored Contributor II
2,177 Views

hii.. 

 

i would like to ask if there is any library that have a function to generate numbers randomly within certain range..??? 

 

i wanna make a component that takes an input once add to its value 15 and subtract from it 15 and gives output within this range randomly 

i.e --> output= rand[input+15, input-15] 

i've no problem with the design except of the part of random value generation 

i did some work arround to do so that i'm not satisfied with.. 

here is what i did --> xoring 2 bits putting the result in another place.. 

 

 

any idea how can i do this.. 

 

all your helps highly appreciated.. 

 

thanks, 

Niveen..
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
1,431 Views

Questions: 

1. Should this block be synthesisable? 

2. How "random" does it need to be? 

 

I ask these questions because: 

1. VHDL has a random number generator, but it is not synthesisable and only meant for testbenches 

2. Have you looked into a LFSR? http://en.wikipedia.org/wiki/lfs with this you can create a pseudo random sequence. This would be the easiest logic solution. I have heard of others before but they often involve rlocs and require good knowledge on oscilators. One solution (i havent done it, but had it described) is to route a clock though some logic as far apart as possible. Then sample the clock at a given rate, to try and give a random bit (it was described to me a long time ago, so I may have some details wrong).
0 Kudos
Altera_Forum
Honored Contributor II
1,431 Views

 

--- Quote Start ---  

Questions: 

1. Should this block be synthesisable? 

 

--- Quote End ---  

 

no just testing 

 

 

--- Quote Start ---  

Questions: 

2. How "random" does it need to be? 

 

--- Quote End ---  

 

i want to generate 36 output values with only 1 input 

 

 

--- Quote Start ---  

Questions: 

I ask these questions because: 

1. VHDL has a random number generator, but it is not synthesisable and only meant for testbenches 

 

--- Quote End ---  

 

would plz tell me about it, and if it take range or not?? 

 

 

--- Quote Start ---  

Questions: 

2. Have you looked into a LFSR? http://en.wikipedia.org/wiki/lfs with this you can create a pseudo random sequence. This would be the easiest logic solution. I have heard of others before but they often involve rlocs and require good knowledge on oscilators. One solution (i havent done it, but had it described) is to route a clock though some logic as far apart as possible. Then sample the clock at a given rate, to try and give a random bit (it was described to me a long time ago, so I may have some details wrong). 

--- Quote End ---  

 

the work arround i did was similar to LFSR.. 

execuse me, i couldn't get the rest of this.. 

 

 

 

thanks, 

Niveen
0 Kudos
Altera_Forum
Honored Contributor II
1,431 Views

Per Tricky's comments, if an LFSR is sufficient, there is a tutorial and code here: 

 

http://www.ovro.caltech.edu/~dwh/correlator/pdf/lfsr_tutorial.pdf 

http://www.ovro.caltech.edu/~dwh/correlator/pdf/lfsr_tutorial_src.zip 

 

You would need to decide whether you want uniform or Gaussian(-like) noise, and then just scale it to the numeric range you describe above. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,431 Views

There's a synthesizable random number generator using an inverter chain in the Altera cookbook: http://www.altera.com/literature/manual/stx_cookbook.pdf 

See chapter 14
0 Kudos
Altera_Forum
Honored Contributor II
1,431 Views

Thanks alot Dave for the tutorial.. :) 

 

whenever i try to post any "reply with quote" it dissapear once i click "post".. any idea why does this happen 

 

thanks, 

Niveen..
0 Kudos
Altera_Forum
Honored Contributor II
1,431 Views

Thanks alot jederrick for the cookbook link.. :)

0 Kudos
Altera_Forum
Honored Contributor II
1,431 Views

 

--- Quote Start ---  

 

whenever i try to post any "reply with quote" it dissapear once i click "post".. any idea why does this happen 

 

--- Quote End ---  

 

 

Works fine for me - WinXP + Firefox. 

 

Cheers, 

Dave
0 Kudos
Reply