Random Number Generator

Background

Random Number generators are commonly used in computers for applications such as:

Common Generation Methods

Common methods of generating random numbers are: In this project I use Route Ring Oscillators. A Route ring Oscillator is essentially an odd number of NOT gates chained together. This is a structure commonly used for chip parametrics and scribe structures and allows process engineers to measure how fast transistors are actually transitioning and how voltage, temperature, process variations and assembly factors affect those transitions.



Since there are variations in the toggle times between individual logic cells and the ways they are routed, each route ring oscillator will toggle at a different rate. So a set of 32 route-ring oscillators could be used to generate one 32-bit random value. As long as the chain of logic does not produce a path considerably longer than the clock cycle time, there is no reason we shouldn't have a new random value on every clock cycle.

Source Code

PYNQ Random Number Generator github

Experience

I was able to proof-of-concept this - the barriers I faced were: I was able to get a basic random number generation working:
root@pynq:/home/xilinx# python3 
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pynq import Overlay
>>> ol = Overlay("PYNQRandomNumberGenerator.bit")
>>> hex(ol.RNGModuleTop_0.read(4))
'0xffffffff'
# Turn on enable 
>>> ol.RNGModuleTop_0.write(0,1)   
>>> hex(ol.RNGModuleTop_0.read(4))
'0xf8f30c01'
>>> hex(ol.RNGModuleTop_0.read(4))
'0xf0cf3ad'


Further Study

I do notice some 'clumping' - f's and 0's, so my next steps would be to review the schematic and make sure I am properly DONT_TOUCHing the cells so they don't get optimized away and then tweaking the chain length (maybe make it 7 or 9 inverters). Making the individual RRO elements longer would increase stability and bit-to-bit variation but would reduce the transition frequency. Making the chain shorter would increase the risk of the inverters entering a race condition.

As a further analysis step, there are plenty of random number analysis techniques that could be applied given time. Most of them involve: