Random Bit Generator

Oct 20, 2010 107 Replies

It will click when you see it. The key idea is Finite State Machine. With N flip-flops, the best you can do is 2^N states. A counter gets them all, but it's not random.

A LFSR with the right taps gets 2^N-1, and they happen to be a "nice" random pattern. They are widely used in gear for testing communication links.

Horowitz and Hill, Art of Electronics, has a nice section starting on page 655. It's only 3 pages, no hairy math.

The Wikipedia article on LFSRs is good:

formatting link

These are my opinions, not necessarily my employer's. I hate spam.

OK. Got it working. Repeats at 255.

What was confusing me was the double-talk about numbering the shift-register stages. Must be Physics majors who still have their direction of current reversed ;-)

Thanks again, David! ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I can see November from my house :-)

Yep, That's a good one. Thanks! ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I can see November from my house :-)

rs,

That's just thinking SMALL. Get an analog TV tuner card, set it to some station that doesn't exist (UHF channel eleventy-three), and record a few gigabytes of static. Discard the high bits of each byte.

A 1-transistor superregen receiver, with no input, makes tons of noise. Interesting circuit.

John

Strange. Those taps are supposed to yield a maximal length sequence (2^n-1), and the pulse-stuffer is supposed to force the sequence to include the lockup state, yielding 2^n states between repeats. I'll get on it tomorrow and, hopefully, find where the problem lies. In the meantime, I apologize for the inconvenience.

No problem. "Breadboarded" instantly in PSpice ;-)

I'm currently running with taps at 8,4,3,2 and getting a 255-long sequence. ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I can see November from my house :-)

Nah - it's a digital nerd thing - Typically, for a binary output, Q0, Q1, ... Qn, the bit position corresponds to that power of two. As far as which way you shift, there's a holy war between little-endian and big-endian, but ssentially, it's a coin toss. :-)

Cheers! Rich

[ASCIImatic snipped]

Do I dare mention Don Lancaster's TTL Cookbook? He's got schematics up to some fairly long length - I don't recall off the top of my head how long, but it's definitely more than 16.

Cheers! Rich

That's there in case some random glitch inserts or removes a bit, accidentally leading to the stuck state.

Cheers! Rich

XOR some of Sloman's messages. ;-)

Politicians should only get paid if the budget is balanced, and there is enough left over to pay them.

Aaargh!

Sorry about that...

Normally the counter jumps over the all-zeroes lockup state and runs at a length of 2^n - 1.

The error here (egg on face) was that by forcing the counter into the all-zeroes state, once every cycle, a lot (all?) of the states which would have existed on the other side of the jump are killed off.

The right way, if starting up in (or accidentally falling into) the all zeroes state is a concern, is to NOR all the Q's and feed the NOR output to the XOR, as shown.

That way, the counter runs at maximal length normally, but forces a 1 into the shift register's serial input if its outputs all go to 0, for whatever reason.

JF

Why? The reset forces the counter into a known state on startup, but if that's unnecessary then I agree; the RESET\ pin should be connected to Vcc.

The way it was done in old analog synthesizers was to take something like a 2N3904, cut off the collector leg and reverse bias the emitter base junction through a 1 Meg resistor. Capacitor couple to an an opamp with a gain of about 100.

detectors,

Clocked bits? ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I can see November from my house :-)

Just sample the resulting value with 2 or 3 flops in series to reduce metastability and you get your clocked bits. Beware that, obviously, this doesn't give you any reproducibility.

Muzaffer Kal DSPIA INC. ASIC/FPGA Design Services http://www.dspia.com

Ken S. Tucker:

No, it was the getting in and out of an Hartmann node.

I like better Wiener bridges. But also Frankfurters are not bad. ;-)

Saluti

What I have now...

Newsgroups: alt.binaries.schematics.electronic Subject: Random Bit Generator (from SED) - DevelopRandomBits.pdf Date: Fri, 22 Oct 2010 11:20:37 -0700 Message-ID: ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I can see November from my house :-)

2**31 but some of the tap sequences longer than 2^20 are not maximal (pgs 280 - 281)

So everybody is suggesting the LSFR. LSFRs are trivial; zero state problem has to be dealt with. I try doing something different just for the sake ot it.

Take two binary counters. One counts to 2^N, the other one counts to some odd number. Compute parity function of both counters. Here you go.

Take a binary adder and a register. Add some odd number at every cycle. Tale a bit somewhere from the middle of the register.

Take a binary adder and a register. Multiply by (2^N - 1), i.e. leftshift and subtract. Set the LSB to 1 to avoid all zero state.

There is approximately a zillion of ways of making quazi random (or true random) generator from whatever stuff you got in the drawers. BTW, some

25 years ago I made random generator from relays. However, that was LSFR :-)

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required