Tuesday, April 29, 2014

Techy Tuesday - Digital Design Primer - part I

At work, I think people would tell you that if you're learning digital design from me, you're asking the wrong person.  I stopped doing most of the digital design tasks that come up years ago.  I interface circuits, connect things up, and help architect the analog/digital dividing line in our products, but what a friend once called "gate-slinging" is not my field. 

But back up a minute.  What am I talking about?  I spoke about analog and digital electronics in my "Least You Should Know" series a couple of years ago.  Briefly, analog systems deal with continuously, smoothing changing voltages or currents.  Digital systems deal with discrete levels; the logical "yes or no", "high or low", or "one or zero" you've heard of.  The exact voltages depend on the type of circuit and what it's built of: early logic (Transistor Transistor Logic, TTL) ran off of 5V and ground (anything below about 0.8 volt was low enough to be considered ground).  Some types of circuits ran on 15V.  As circuits have become more dense and more sophisticated with time, the voltages have lowered to where current processors have cores running at 1.8V or even lower.  That actually isn't very important to this discussion about the generalities of digital logic. 

Logic circuits are called that because they obey the laws of symbolic logic codified into Boolean Algebra. The individual elements of a logic circuit are called gates and there's a limited number of possible Boolean operations.  While the vast majority of parts sold as gates have only two inputs, most of them are available with more inputs.  A signal can be Inverted; that is, high turned to low or low to high and an inverter is the most basic gate (these, by the way, are only available as single input/single output parts).  Two signals can be combined in a logical OR, where the output is high if one of the inputs is high, or they can be combined in a logical AND, where the output is high only if both of the inputs are high.  Beginners are frequently confused that the output of an OR is high when both inputs are high, but think of the output as answering the question "is one of the inputs high?", and you'll realize that when both of the inputs are high, the answer is yes, one is high.  There is a logic function that is only true when one of the inputs is true and not for the AND condition, called an Exclusive OR or XOR.  All of these can be made with the output inverted, forming NOR (Not-OR), NAND (Not-AND) and XNOR (Exclusive Not Or).  A NAND gate, for example will have its output low only when both of the inputs are high (HIGH and HIGH is true; the NOT makes it low).   

These gates can be combined into one of the most fundamental building blocks of digital electronics, the flip-flop.  Flip-flops in turn combine into registers, also essential building blocks. 

You might find it interesting that gates existed conceptually long before electronics existed - as did Boolean Algebra; they're not an invention from the 1970s or even 1940s.  In 1881, for example, Charles Sanders Pierce determined that all functions of logic could be implemented in NOR or NAND gates, making these two the "universal gates".  George Boole introduced his mathematics of symbolic logic in 1854. 

Logic circuits made from discrete gates (usually packaged a few to the integrated circuit "chip") are called Small Scale Integration, and are rarely seen today.  Yes, single and low counts of gates are still sold, but they are not used much in industry.  Sometimes they need to be used, though, and it's not uncommon to have several SSI parts in a board full of more highly integrated parts to shift logic levels between, say, circuits that run on 3.3V and others on 1.8V or do other miscellaneous functions.  This is usually referred to as "glue logic".   In the old days, processor boards looked like this:
(from a project log of someone building a DIY computer using 1970s logic)

Some readers will find this overwhelming; some will say, "so what?" and some will wonder where this is going.  Next, we'll look at more modern digital design.  While I might have needed shift registers, gates and switches to generate SPI bus programming for an RF circuit in the 1980s, today I'd probably reach for a microcontroller and write software to do the job, if it was for a low number of pieces used around the lab or something.  If I was going to want to produce a minimum cost device for production, I'd reach for tools to create a custom logic part.   That's where we're going.
EDIT 4/30 2038 EDT : minor typo correction

1 comment:

  1. Yep, it's amazing what you can do with a PIC microcontroller.