Andrew Warren wrote: > > Richard Ottosen wrote: > > > > the original question asked for an 8-bit pseudo-random number > > > generator. "RANDOM" is only 8 bits wide, so the routine produces > > > a 255-step sequence. > > > Would it be better to take a few bits out of a longer sequence? As an > > example, you could use 8 bits from a 24 bit random number generator. > > Richard: > > It would be DIFFERENT... But "better" would depend on the intended > application. If, for example, the application required that the > generator never return the same value twice in a row, taking 8 bits > out of a longer shift-register WOULDN'T be better. > > Also, the original question asked for code that used as few registers > as possible. An "8 out of 24" solution would require at least 3 or 4 > times as many registers as the one-register 8-bit solution. > > -Andy > > === Andrew Warren - fastfwd@ix.netcom.com > === Fast Forward Engineering - San Diego, California > === http://www.geocities.com/SiliconValley/2499 Andy: You are right. "Better" was a very bad choice of words. No *one* pseudo random generator is best for every application. These shift register/XOR feedback PRNG's work well for making what sounds like noise to the ears. If you feed the bits to a digital to analog convertor and look at the result on a scope, the waveform looks like a bunch of exponential curves. To the eyes this appears very non-random. Even random pulses from nuclear decay is not the right random for all uses. If you want to use the values for a test, make changes, and test again then you don't want true random numbers! It makes it hard to tell whether your change or the different random sequence made the the difference when retesting. I forgot the requirement of only a few registers available. Oops, if all else fails read the instructions :-) The original letter letter also asked about hardware solutions. The first idea that comes to my mind is to implement the hardware of shift registers and XOR gates to do the equivalent of the software that has been suggested for the PIC.