Forum Discussion

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

Pseudo-random Number Generator

Hi,

I have looking for a Pseudo-random number generator with some maximum linit. I know the LFSR approach but I dont know how to limit the maximum number generated by the LFSR. For example if I want to use an 8-bit LFSR with maximum limit of 200. How to limit the LFSR so that number must not exceed 200.

Any link, idea or circuit will be highly appreciated

Thanks

Ali Umair

12 Replies

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

    --- Quote Start ---

    If the number is out of range, discard it and request another until you get one in range.

    --- Quote End ---

    This way an undefinite number of cycles is possibly required before you get a valid result.

    If you can't allow this, because you need the random number immediately, you must implement a different solution.

    If you don't bother the indipendence between successive pseudo-random numbers, you can simply feed the LFSR output to a modulo 200 adder: you sum the previous number to the LFSR result, divide by 200 and take the remainder, which is actually a pseudo random number uniformly distributed between 0 and 199.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can't.

    If the number is out of range, discard it and request another until you get one in range.