# Random Number Generation

808

## Generating Random Numbers

For this design, we need a random number to set the time interval between the start button being pressed and the LED illuminating. Random numbers and random number generation algorithms are frequently used in security, encryption, and gaming applications. But creating truly random numbers within a closed digital system is very difficult, if not impossible. Certain well known algorithms (or circuits) can produce a sequence of pseudo-random numbers, where the sequence of numbers is based on a staring or seed value. For any given seed value, a unique sequence of numbers is produced, and the numbers appear random at first glance. But since the numbers are produced according to an algorithm, they are not truly random, and anyone who knows the algorithm and seed value can always compute the next random number in sequence.

A truly random number can only be produced from a truly random seed value, and a random seed value is typically sourced by measuring some physical phenomenon that is outside of the system in which it is used. For example, a random environmental variable like thermal noise, radioactive decay, or oscillatory patterns might be measured and converted into a binary number at some given time, and then that number could be used as a seed. See http://rijndael.ece.vt.edu/schaum//teaching/ddii/lecture6.pdf for a good presentation on generating random numbers from Verilog source files.

In our case, we need a somewhat random number to drive a simple game-style application. Since there are no security or privacy concerns, we can be somewhat less formal in how we generate a random number to create a time interval between pressing the start button and illuminating the LED. You could certainly create a circuit like those described in the link above, but with a little thought, you may be able to come up with a suitable solution with less work. (Hint: You have a 100MHz clock source on your board that can cause a free-running counter to increment once every 10ns. If such a free running counter is started when you first program your board, what will its value be when someone hits the start button?)