mrflibble
Advanced Member level 5
- Joined
- Apr 19, 2010
- Messages
- 2,720
- Helped
- 679
- Reputation
- 1,360
- Reaction score
- 652
- Trophy points
- 1,393
- Activity points
- 19,551
I'll try to keep it short and simple (loads of math crap on request).
I need 16-bits random numbers of reasonable quality (*), and the budget is only 1 flipflop and a xor gate. Okay, maybe a bit more but that's really pushing it.
*) Doesn't have to be crypto grade, but no dodgy spectral content.
The distribution has to be normal. Also, not uniform. So a LFSR would be nice and simple, except it generates a uniform distribution...
Broadly two methods I could come up with that seem reasonable:
- run several independent LFSRs in parallel, and sum them. Wave central limit theorem wand et presto, normal distribution.
- use a lookup table to map LFSR output onto the wanted distribution
I did a few checks, and for lets say 4 summed LFSRs the distribution was not good enough. At about 8 the distribution got to be "normal enough". So that would mean running 8 LFSRs, and sum them. And obviously those LFSRs would each have a different seed.
A random number is required at 1/16th clock rate, so summing the LFSRs can be done by a single accumulator. For full rate something else would be needed, as in pipelined adders.
This is for synthesizable hardware. The simulation side was almost too easy in systemverilog. Oh and for today I think I'll stick with determinism, so no toasty warm ring oscillators.
Anyways, I was wondering if someone had this same problem (no doubt) and how they solved it.
PS: I realize I didn't give hard specs for the "non-dodgy spectral content" and "distribution is normal enough". That is 100% totally on purpose, since I'm looking for several solutions for several small projects in parallel all with somewhat different requirements. But they all want random numbers for breakfast.
I need 16-bits random numbers of reasonable quality (*), and the budget is only 1 flipflop and a xor gate. Okay, maybe a bit more but that's really pushing it.
*) Doesn't have to be crypto grade, but no dodgy spectral content.
The distribution has to be normal. Also, not uniform. So a LFSR would be nice and simple, except it generates a uniform distribution...
Broadly two methods I could come up with that seem reasonable:
- run several independent LFSRs in parallel, and sum them. Wave central limit theorem wand et presto, normal distribution.
- use a lookup table to map LFSR output onto the wanted distribution
I did a few checks, and for lets say 4 summed LFSRs the distribution was not good enough. At about 8 the distribution got to be "normal enough". So that would mean running 8 LFSRs, and sum them. And obviously those LFSRs would each have a different seed.
A random number is required at 1/16th clock rate, so summing the LFSRs can be done by a single accumulator. For full rate something else would be needed, as in pipelined adders.
This is for synthesizable hardware. The simulation side was almost too easy in systemverilog. Oh and for today I think I'll stick with determinism, so no toasty warm ring oscillators.
Anyways, I was wondering if someone had this same problem (no doubt) and how they solved it.
PS: I realize I didn't give hard specs for the "non-dodgy spectral content" and "distribution is normal enough". That is 100% totally on purpose, since I'm looking for several solutions for several small projects in parallel all with somewhat different requirements. But they all want random numbers for breakfast.