6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 10:15 am

All times are UTC




Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: Tue Feb 08, 2011 1:25 pm 
Offline
User avatar

Joined: Mon Dec 08, 2008 6:32 pm
Posts: 143
Location: Brighton, England
It occurs that a noise source feeding an ADC would not be a good random number generator. WHite noise does not have an even spread of amplitude vs probability, it is actually a gausian curve - with the probability of a specific amplitude being greatest when the desired amplitude is zero and reducing in a bell-shaped curve as the desired amplitude gets further away from zero.

If you amplify this noise, it gets limited at the ends of the ADC range, increasing the probability of these two values comming out of the ADC at the expense of all the other values.

Either way, a noise source feeding an ADC is unlikely to create a good random number generator.

Squaring off the noise and then either counting it or feeding it into a shift register gives better randomness, since then it is only the frequency of the noise that matters, not its amplitude. As long as you don't try and read the squared signal at too high a frequency, the result is a fairly good random number generator.

_________________
Shift to the left,
Shift to the right,
Mask in, Mask Out,
BYTE! BYTE! BYTE!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Feb 08, 2011 5:47 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
Were this true, wouldn't we expect a TV tuned to a channel with no transmitter to produce a predominantly black screen instead of snow?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 10, 2011 3:39 am 
Offline

Joined: Fri Aug 30, 2002 2:05 pm
Posts: 347
Location: UK
No because the TV signal uses negative modulation. Peak signal is almost half again darker than black.

Also AGC.

Lee.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 10, 2011 7:42 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
I'm sorry; I'm a licensed ham radio operator, and that explanation still doesn't make any sense to me. Can you explain it again more clearly?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 10, 2011 5:27 pm 
Offline
User avatar

Joined: Mon Dec 08, 2008 6:32 pm
Posts: 143
Location: Brighton, England
Leeeeee said that TV uses negative modulation, with no signal being white and peak signal being sync, which is "blacker than black." Thus, the noise tends to produce more white than black.

I suspect the effect comes about because of the biasing of the stages that follow the video detector - in the absence of a signal these stages arn't biased to black but to a partially lit screen. Thus the most common noise voltages produce a lit screen with brighter areas and dark areas (the noise peaks) being less common.

_________________
Shift to the left,
Shift to the right,
Mask in, Mask Out,
BYTE! BYTE! BYTE!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Feb 11, 2011 7:59 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
PaulF wrote:
Leeeeee said that TV uses negative modulation, with no signal being white and peak signal being sync, which is "blacker than black." Thus, the noise tends to produce more white than black.


OK, your translation allowed me to reconstruct the sentence Leeee had written. It was written in a style of English that I just didn't expect, and it threw me clean off.


Top
 Profile  
Reply with quote  
 Post subject: Re:
PostPosted: Tue Aug 27, 2013 2:22 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
PaulF wrote:
I've built a random number generator using this method.

Diode noise (from the reverse-biased base-emitter junction of a BC548) was amplified by an op-amp and then fed into a schmitt-trigger inverter. This fed into a shift register clocked at a constant rate. I then read random numbers from the shift register.

As long as the interval at which the random numbers are read is long enough for the entire shift register to shift through, the numbers that come out appear to be truely random.

Paul, can you share your RNG circuit?
I would like to incorporate it into the next version of my video project.
Currently, the pseudo-RNG I am using is too predictable and also taking up some resources in the FPGA.
An internal shifter register would be all I need, at the cost of a few external components which I'm willing to add for a closer shot at true randomness.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 30, 2013 5:38 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
As a collage project I've built a random generator circuit of my own, and implemented it in tsmc 0.18 um topology, and made simulations in LT spice(which took forever on my pc).
I even built a prototype using only 4000 series IC, and it works.
The idea was using a pair of oscillators made out of inverters, but with extra xor gates that could invert the oscillators phase at any moment, and what I did is to take the output of one oscillator and use it to invert the phase of the next, and then I made such a ring of four of those, and had two such pairs. The end result got xor-ed, and fed into a sorta LFSR for a few cycles, and the output then is latched to a 8 bit latch. The 4000 series prototype could generate 12000 bytes per sec @5V and 24k @12V. The chip simulation was much faster.
I've made a schematic in Eagle later, but it is hopeless to try to fit the circuit on the board, even the auto router can't figure it out.
I've included the original documentation(you will need to use google translate if you want to read it, I didn't translate it yet) and the eagle files.
I did get a good grade for this project, but I've never tested the thing properly with the random testing algorithms, but I see no reason why it shouldn't pass them.

Edit: I've made the circuit interface so that it would nicely fit on the 68/65xx bus(or any other cpu bus). :D


Attachments:
rndgen_col_project.zip [2.75 MiB]
Downloaded 72 times
Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 30, 2013 5:52 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Is there any way it could get stuck at all-zeros or all-ones, or some short repeating pattern? Did you check that the output is 50/50 between 0 and 1? That's the simplest possible test!
Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 30, 2013 7:03 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
Quote:
even the auto router can't figure it out.

Autorouters save time, but they're not very smart.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 31, 2013 5:56 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
BigEd wrote:
Is there any way it could get stuck at all-zeros or all-ones, or some short repeating pattern? Did you check that the output is 50/50 between 0 and 1? That's the simplest possible test!
Cheers
Ed

It can't get stuck, I've tested it quite a while. I hooked up the 4000 version to a speaker, and I left it to play noise for hours, and I just got noise. I also tried jamming the oscillators with a screwdriver, and only then I got a repeating pattern. As for the 50/50 test, the circular shift register takes care of even out the odds. When looking at the output of both the simulated and real device I get a decently even distribution of values(there are some pictures in the documents). Later on I was planing to solder a proper interface connector, so that I can insert the module in my 6502 system, and get decent data for tests.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 31, 2013 8:43 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Certainly sounds good enough for hobby purposes!
Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 31, 2013 3:01 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
It's curious that, after a solid 3 minutes on Google, there isn't a dedicated RNG chip out there. Apparently many chips, CPUs notably, have RNGs embedded on them, but there doesn't seem to be any standalone ones. You'd think they'd be able to put one in a 8 pin chip. I guess the demand isn't there, or they bury them for security purposes (doesn't help if your RNG can be replaced with a trace cut and fed what you want to it).


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 31, 2013 3:51 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
A cryptographically secure random number generator is very hard to get right, especially in a stand alone chip.

For non-cryptographic purposes, a simple pseudo random generator usually doesn't need a stand alone chip.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 31, 2013 3:57 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
I think perhaps the SID and indeed the Beeb's sound chip contain PRNGs but they are no use to the CPU. A CPLD would be big enough.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: