Beginning Logic Design – Part 1

I have a passion for learning about technology. My desire to understand more about how things work has driven me to dive into lower and lower levels of computing systems. For the last couple years I’ve been trying to go all the way down to working with the basic digital components. I did not find many resources to help learning these low level basics, so today I am kicking off a series to teach others how easy it can be to get started with digital logic design.

How We’ll Be Learning

There are not a lot of tools I’ve found that are modern, useful or stable enough to use to get started with learning basic digital design. Most legit hardware design tools are based on using a Hardware Description Language such as VHDL or SystemVerilog. I think the early digital knowledge you need is best solidified with schematic design and simulation; by working with the most basic logic gates to understand how larger and more complex designs can be made from very simple components.

The best tool I’ve found so far for digital logic design and simulation is logic.ly, an educational piece of software that has a clean and usable interface along with a good set of features around managing subcomponents. It is not free software, a full license runs around $60, but there is a free trial that you can use for up to 30 days. It is also only supported for Windows and OSX, though I have had good luck running it via Wine on my Ubuntu box.

The best free (and open source!) alternative to this I found was BOOLR, which is a fairly impressive simulator but as of this writing is not stable enough to recommend. I’ll be keeping an eye on that project to see where it goes.

As far as prerequisite knowledge requirements, I recommend some familiarity with binary and hexadecimal numbers. Outside of that, some determination is all you need!



Getting Started

To get started, download Logicly and get it installed. Activate your 30-day trial and fire it up!

Logicly running via Wine on Ubuntu 16.04

To get the lay of the land, let’s look at some of the most basic components Logicly has to offer.

Input and Output devices in Logicly

I have Logicly’s 5 input devices on the left and its 2 output devices on the right.

Starting from the top of the inputs, Logicly has a toggle switch that operates very similar to a light switch, it outputs 0 when the switch is off and 1 when the switch is on. Below that is a button, or momentary switch, that normally outputs 0, but while it is held down will output 1. The next input devices is a clock signal, it automatically flips its output after a configurable time, one second by default. The last two inputs are constants, always 1 or always 0.

On the right side we have the outputs. The light bulb is lit or unlit depending on the signal being driven to it. The second output device is a digit display, which will show a 0-F hexadecimal value based on its 4 input bits. We’ll only be using the light bulb for this lesson.

Feel free to dabble with these components if you’d like, we’ll use them to explore the logic gates in the next section.

Basic Logic Gates

Logicly has 9 components in it’s Logic Gates category, we’ll explore them each here.

The first row has the Buffer and the NOT gate. These are the simplest gates. The Buffer simply outputs an identical signal to its input, in Logicly this is generally only useful for adding a bit of delay to signal propagation. We won’t be using the Buffer component very much, if at all. The NOT gate will output the opposite of its input.

A buffer and a NOT gate in parallel

As you can see above, when the switch is on, the light behind the buffer is also on, while the NOT gate inverts the signal and the light behind it stays off. Notice the similarity of the component symbols, in digital design you’ll often see a small circle that indicates the inversion of a signal from low to high or high to low.

The next row of components is the AND gate and the NAND (NOT-AND) gate. The AND gate will output 1 only if all inputs provided to it are 1.

AND gate in various input configurations

The NAND gate has the opposite output of the AND gate, similar to what you’d see if you used a NOT gate to invert the output of an AND gate.

NAND gate in various input configurations

The next two gates are OR and NOR. The OR gate will output 1 if any input is 1, and 0 if all inputs are 0.

OR gate in various input configurations

As you may expect, the NOR gate is very similar to the OR gate, but with inverted outputs.

The next couple gates are XOR and XNOR. The XOR gate, short for exclusive-or, is a little bit trickier. In a 2-input configuration it will output 1 if the two inputs differ, and 0 if the two inputs are the same.

XOR gate in various input configurations

This symbol for XOR is very similar to OR, but has an extra curved line on its input side to stand apart. Just like with the other N* gates the XNOR has the opposite outputs of XOR.

The last basic logic gate Logicly gives us is a Tri-State Gate. It is very similar to the Buffer with the addition of a signal to control if the output of the buffer is enabled. If the Tri-State is enabled, the output will match the input, if disabled it will not emit an output which leaves the connection unset, or floating, allowing something else to control the output line its connected to. Don’t worry about this gate for now, we won’t use it for a bit.

It can take a while to get used to these symbols and their outputs, here’s a diagram that shows the truth tables, and boolean algebraic expressions for these gates.

These gates are each fairly simple but all digital electronics are composed of just these gates in various arrangements! It may take a while to understand how things like RAM, CPUs and entire computers can be built from such simple components, but as you practice building incrementally more complex circuits it will begin to make sense.

Functionally Complete Gates

Two of these logic gates (NAND and NOR) have a very special feature, they are functionally complete. This means that any other gate, and therefore any digital machine, can be made of just NAND gates or just NOR gates. This has some significant benefits for manufacturing electronics, but since we’re not fabs we’ll just explore this property to get a bit of practice building some simple circuits. NAND logic is a bit more popular for various reasons, so let’s explore how we can make some of other other basic gates by using just NAND gates.

To start off with, here’s a NAND gate setup to work just like a NOT gate, I have these gates in parallel so they share the same input to allow for easy comparison.

NOT gate next to NOT implemented with a NAND gate

By simply wiring the switch to both NAND inputs, we get the exact same behavior as a NOT gate.

We can use this same concept to implement an AND gate. Since NAND has the opposite output of AND, we can use the previous NOT-like configuration to flip the output of NAND to match AND. NNAND?

AND gate next to AND implemented with NAND gates

For some solo practice, try your hand at replicating the function of OR and XOR gates using only NAND gates. If you get stuck (I did), reference Wikipedia’s page on NAND Logic for the solution and look at the wire states in Logicly as you toggle the inputs and think about why it works.

 

This is a whopper of a first lesson, but I hope it’s useful for folks just starting out. If you have any questions or feedback please leave a note in the comments and I’d be glad to help you out. In the next post we’ll be exploring some of the interesting things you can do by combining these basic logic gates. Keep tinkering!

Save

Save

Save

Leave a Reply

Your email address will not be published. Required fields are marked *