These 9 Digital Components Rule Our World

Digital Logic Design Basics

The three men in the photo above are perhaps some of the most important men in human history. No they are not engineers but physicists. They are William Shockley, Walter Houser Brattain and John Bardeen. They are the inventors of the transistor.

With the invention of the transistor we were able to make electronic devices smaller, cheaper and much more versatile than ever before.

Before the transistor, you would need large glass vacuum tubes to implement logical operations in a circuit. To achieve the same computing power we have today in our smartphones, we would need a huge amount of space to even create a fraction of it.

The transistor paved the way for allowing us to create smaller and more versatile digital components. As an engineer myself, I help design systems that use the digital components that the transistor has made possible.

While working as an engineer, I realized that most of the digital systems that I have seen can be broken down into just 9 different digital components. 9 digital building blocks that help to create the systems that we use, and the systems that ultimately control our entire world.

We will start our discussion with the super basic building block to all digital systems, the logic gate.

Logic Gates

Logic gates are circuits that perform a specific logic function from discrete math.

The basic logic functions that logic gates perform are listed below.

  • AND function
  • OR function
  • NOT function

There are other logic functions out there like NAND and XOR but the logic functions AND, OR and NOT are the most basic.

They are called logic gates because they act like doorways that allow voltage to pass through the circuit or stop voltage from passing through the circuit. Just like how a gate allows people to enter into an area or keep people out of an area.

How does a logic gate work?

Logic gates are made up of transistors. Depending on how you arrange the transistors, you will get a different logic function, thus different logic gates. When you apply a digital signal to the inputs of the logic gate, the signal activates (or deactivates) the transistors inside and the transistors create the appropriate output.

Below is a NOT logic gate. To the left is the circuit symbol for a NOT gate and to the right is the transistor circuit diagram that creates that gate.

Below is a AND logic gate and the transistor circuit diagram that creates that gate.

Now that we have a very basic understanding of a logic gate we can understand that the 9 digital components that control our world are nothing more than just a very specific arrangement of these logic gates.

1. Multiplexer

The multiplexer is probably the most versatile digital component used today. You can practically make every other digital logic component and logic function on this list with multiplexers except for a flip-flop, counter, register or shift register.

Multiplexers are used to make look-up-tables in FPGAs and many more things. These lookup tables are responsible for creating any digital logic function you can think of.

Multiplexers are the hardware equivalent to a case statement in programming.

Multiplexers have multiple data inputs and one data output. The multiplexer connects one of its data inputs to the output at any one time. You will never have more than one data input connected to an output at the same time. How do you choose which data input gets routed to the output? There are select signals connected to the multiplexer that determine what input should be connected to the output.

I practically use multiplexers all the time at work when designing digital systems.

Anytime you can think of a case statement type of a situation you are probably going to be using a multiplexer.

Below is a high-level design of a communication bus. Different digital devices are connected to the bus via multiplexers. The digital devices are the master and slave devices.

One of the multiplexers chooses which master gets to talk to the slaves. The other multiplexer chooses which slave gets to talk to the masters. The multiplexers make sure that only one device communication port is connected to the bus at any one time.

If two devices were to talk on the bus at the same time the data would be corrupted. It’s like when two people are trying to talk over one another at the same time…you can’t really understand what either one of them was trying to say. Same thing happens when two devices try to talk on the same bus at the same time.

2. Decoder

The next most versatile digital component we have is the decoder. Decoders have multiple data inputs and multiple data outputs. Unlike the multiplexer which has multiple data inputs, but only one data output.

A decoder takes a coded input and generates a non-coded output. This is where the name decoder comes from. We have the ability to make really robust decoders that can be used for all sorts of different things.

Decoders are the hardware equivalent of an IF-ELSE conditional statement in programming.

The simplest decoder out there is the binary decoder. It takes a binary number on its input and then activates the output that corresponds to that binary number. If the binary number on the input is a 2, then the output that gets activated is the one associated with the number 2. If the binary number on the input is a 4, then the output that gets activated is the one associated with the number 4.

How does the decoder know to select the correct output for each input? It’s in how the logic gates of the decoder are set up.

Below is an image of the logic gate implementation of a binary decoder.

Decoders can be used in so many different ways. I could not possibly list all of them out here. One application of a decoder is an address decoder. When there are multiple digital devices in a digital system there needs to be a way to choose which device you want to talk to. Just like how you have a specific way that you address your parents or your elders, there is a specific address that each device has in the system.

In a bus-based communication system, an address decoder will get signals from a master device. The master device sends the appropriate slave address to the decoder. The decoder then sends out control signals to a multiplexer which will route the correct slave to the master. As we know from the previous section the multiplexer is what connects the correct digital device onto the bus.

There are more details, signals and wires to bus-based communication architectures but for simplicity I have left those out.

Below is a picture of the same communication architecture from the previous section but with the address decoder in there.

Another use of decoders are as instruction decoders. You can have a memory address get applied to the inputs of the decoder, and then have the corresponding output fetch the current instruction. So many applications I literally cannot list all possible use cases for them.

3. Encoder

An encoder is another really great and versatile digital component that engineers use. It is kind of the opposite of the decoder. It has multiple inputs and outputs like the decoder. But the encoder generally has more inputs than outputs.

The most basic encoder is a binary encoder. It works in the exact reverse of the decoder. It will take whatever input is active and produce the correct binary output.

The image at the beginning of this section shows a 4-to-1 binary encoder.

Before I started working as an engineer, I never really knew of any use cases for an encoder. But on my very first design I used a particular type of encoder called a priority encoder. The priority encoder was the key to creating the whole system.

Below we have a use case for an encoder. We are sticking with the example of the bus-based communication architecture. The box labeled Priority Arbiter is implemented with a priority encoder.

Only one master can issue commands over the bus at one time. What happens when you have two masters trying to issue commands over the bus at one time? Like we said early it’s like having two people talk over each other at the same time. You won’t understand what either of them are saying. To solve this we use what’s called an arbiter. An arbiter determines what master can talk on the bus if more than one master device requests to talk on the bus at the same time.

So where does an encoder come into play here? Well we can use a priority encoder to create what’s called a static priority arbitration scheme. This arbitration scheme is one of the simpler ones out there. Arbitration schemes can get more complex than this. Each master device is given a priority level. When two masters request to talk on the bus at the same time, the master with the higher priority will be granted access.

Encoders can be used for more than just arbitration in a communication architecture. But for now I will leave it at just that example.

4. Full-Adder

Adders are the next most utilized component in digital design. Engineers use adders in digital systems for so many different situations. Obviously an adder is a digital component that can add numbers together. They are pretty self explanatory so I will not go in too deep into how they are designed. Just know that by understanding how to add binary numbers, and how to make a truth table, you can figure out the logic circuit for implementing a full adder.

When you do math in a digital system the first thing you should think about is “is there a way I can simplify this complex math operation to a series of multiple additions?

Say you wanted to do convolution in your digital system because you are designing an LTI filter. Well we know that the convolution formula can be broken down into a series of additions.

Because we can break it down into a series of additions we now have a path forward to implementing the LTI filter.

There’s more to the story of how LTI filters are implemented in digital systems. But the main point is that we can reduce complex mathematical equations down to summations.

So how do summations come into play of controlling the world? Well all of our cell phones, fighter jets, WiFi and pretty much everything else that uses signals must go through signal processing. Signal processing algorithms are needed to process the signals. Signal processing algorithms are complex math equations. Those equations get reduced to summations.

5. Comparator

The next digital component we will look at is the comparator. What does the comparator do? Well it takes two different digital input signals and determines if they are equal or not. Not only can we make our comparator determine if two signals are equal, we can also see which signal is greater than the other, or less than the other.

In programming, whenever you use an IF statement you are evaluating a true or false expression. In order to determine if an expression is true or false, you need to compare the expression that you have to the value of true. The comparator is the hardware equivalent to the comparison expression in a programming IF statement.

Without the ability to compare two signals together we wouldn’t be very far in terms of digital design and technology.

One application of a comparator is to use it in an ALU (arithmetic logic unit). An ALU is a logic unit that performs additions, subtractions, shift operations, comparisons and much more inside of a processor. It’s a very simple application but an application nonetheless.

6. D Flip Flop

Here it is. The D Flip Flop. This is a big turning point in this list. The D flip flop is what we call a sequential logic element. The thing about sequential logic elements is that they have the ability to store memory. We call this memory a state. With this new addition to our digital repertoire we can engineer so many more digital systems.

All flip flops work off a clock signal. The clock signal lets the flip flop element know when to check its input, to change its output state. When the clock signal is low or high, it does not matter what value is on the input. The output state of the flip flop will not change. When the clock signal is changing from a low to a high state (called a rising edge), then the flip flop will check its input and change its output state.

One good application of flip flops is to introduce a time delay in systems that have devices that have multiple devices operating at different speeds.

Say we have a clock signal that has a period of 25 ns. A flip flop that is working on this 25 ns clock signal will delay all signals that go through it by 25 ns. This relates to a bigger concept known as register pipelining.

Flip flops work best together. When we have multiple flip flops used together they are known as a register.

7. Register

Each flip flop can only hold 1 bit. But if you get 32 flip flops together you can store 32 bits. When you have multiple flip flops together they are known as a register. Registers are used to store data that will be used in the near future.

In programming we use a concept called variables. Variables hold specific types of data. But where in actual hardware does this data reside? It most likely resides in a register. Based on the type of data that the variable will store you will use different sized registers (32 bit register vs a 64 bit register).

Registers are also used when doing multiplication. Why do we use them in multiplication? Because we need to store our multiplication result somewhere!

Have you ever done a FOR loop in programming? Well if you have, the iteration variable is stored in a register. If it was not stored in a register, then you would never be able to execute the (i = i + 1) operation correctly. The value of (i) would always stay in whatever initial state it started in.

The use of registers is everywhere in digital design and our world. We simply just would not have the technology we have today without it.

8. Counter

Counters are also very widely used by embedded systems and hardware engineers.

A counter keeps track of the number of times a signal pulses. Or more generally, the number of times an event occurs.

Counters that keep track of whenever a new period of a clock cycle occurs can be used as timers. Say the clock period is 25 ns and you want to wait for 100 ns before you execute some command or an event. How would you do this? Well you just count the clock period 4 times and then you know that it would have been 100 ns (25 ns * 4 = 100 ns).

Whenever you want to keep track of time in a digital system you will use a counter that counts the clock period. Whenever you want to keep track of how many times something happens in a digital system you will use a counter.

Now the interesting thing about counters is that they make use of registers! In order to know that four clock periods have passed, there needs to be a way to store that data. So when the next time a clock period roles around, the counter can look at what the current count value is from the register, and then increment from there.

Also, in order for a counter to work it must be able to increment the value that is in the register. We do this through using an adder. Adding the value of 1 to the stored result in the register.

We also must use a comparator to see when our current count value reaches the max count value that we have assigned.

Below is a diagram of a counter that counts four clock pulses.

There are more signals and components involved then what is shown above, but it is meant to give you a basic idea of how it is put together.

Counters can also be used for other things like a switch debounce on physical push button switches. I won’t go into that here since this post is starting to get a little long.

9. Shift Register

Lastly we have a shift register. A shift register is the same as a normal register, except the output of one flip flop is connected to the input of the next flip flop. This way, when the clock signal comes by for all the flip flops in the register, the result of the first flip flop will shift into the next flip flop and become that one’s result.

Shift registers are used to buffer data and transfer data. They can also be used to delay data by a certain period of time. They can also be used to generate a constant stream of random data.

The one area where you will see shift registers is in JTAG testing of digital hardware. I won’t go deep into what JTAG is or how it works (that would require another post). JTAG uses a shift register to shift data into one device but it can also shift the data out of one device and into another. The data that gets shifted through are usually test vectors for the I/O of a chip.

Below is a design of a pseudo-random number generator using a shift register. Between the register outputs we take the result and running through some XOR logic. The 3 logic gates you see at the top of the diagram are XOR gates. The XOR gates help to generate the pseudo-random numbers. If we looked at the outputs of each flip flop (or the output of the register) we would see that the values would change randomly.

Conclusion

There it is. Those are the 9 digital components that rule our world. Almost all digital systems that I can think of are just fancy designs, arrangements and applications of these 9 digital components. They literally form the backbone of our digital processing systems.

If you skipped to the end here (like I normally do) here is the list of the components.

  1. Multiplexer
  2. Decoder
  3. Encoder
  4. Full adder
  5. Comparator
  6. D Flip Flop
  7. Register
  8. Counter
  9. Shift Register

I hoped you enjoyed the post! Until next time!

“Always have a map and a destination. Or else you will just wander the seas. — Tyler George