Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

question regarding random number generator

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..

7 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- 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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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..
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- 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