8-Bit Computer Flip-Flop Design

D flip flop
Share:

About

In this post, we’ll take a look at the flip-flop which is one of the most common and essential logic blocks used in digital logic design. It can be used used for lots of different things. If you take a look at my 8-bit computer build you will see that flip-flops are used all over the place. 

You can use premade flip-flops provided in Quartus. However, I wanted to build my own from scratch to truly understand how they work.

NAND Gate SR Latch

But before building a flip-flop let’s look at the most essential element required to make one: the SR latch.

SR latches are most commonly made from NAND or NOR gates. It doesn’t really matter what you use but I will stick with using NAND gates. 

NAND Gate

NAND Gate Truth Table

ABC
001
011
101
110

Now assuming you know the behavior/truth table of NAND gates we can explore how they can form a latching circuit that can store state. This is achieved by connecting the outputs of each gate one of the inputs of the other gate. 

SR Latch

SR Latch Truth Table

SRQNQ
00//
0101
1010
1100

The S(set) input can be toggled to set Q to high or the R(reset) can be toggled to set Q low. 

Below you can play around with the circuit yourself to see how it works. I think that this will be way more intuitive and easy to understand compared to me describing it with words.

Clocked SR Flip Flop

The SR latch will change state whenever the inputs change. But we want the state to change only on a certain condition like when the clock signal is present. To accomplish this we add a NAND gate to the S and R inputs. Then we tie together the inputs of those gates and use that as an input for the clock signal. While the other two outputs now become the S and R. Now the set/reset will only be possible while the clock signal is present.

D Flip Flop

The SR flip-flop still has two inputs(S,R) that require to be toggled separately to change the latched value from 0 to 1 or vice versa. We wouldn’t be able to store the value from a single dateline this way. What we want is a single input to which we can connect our data line. Then when the clock signal is present the value from the data line(0 or 1) gets stored in the latch.

This can simply be done by connecting the S input to the R input through a NOT gate.

Master Slave D Flip Flop

After making our D flip-flop we now stumble upon another problem. We only want the data to be read into our flip flop on the rising edge of the clock. If the signal changes after the rising edge of the clock we don’t want the change to be registered. To do that we can attach two D flip-flops one after another in a master-slave configuration(see below).

Edge Triggered D Flip Flop with Asynchronus Set and Reset

Ok, almost done now. The last thing we need to add is an asynchronous set/reset. This will be useful when resetting our computer as we can simply apply a 1 to the reset/clear input and the flip-flop Q output will reset to 0 without having to wait for the clock hence why it’s called asynchronous.

The design is a bit different here, you can see three latches. One to latch the set signal, one to latch the reset signal, and the final latch that stores the state. The NAND gates used here have three inputs so we can feed in the additional set/reset signal. 

Here is a simulation of the final circuit for better understanding(but without the set and reset functionality).

Conclusion

This is how I made the flip-flops I used in my 8-bit computer build. The simpler alternative would be to use the premade D flip-flop provided by Quartus and save yourself some time. 🙂 But hopefully, now you at least somewhat understand the inner workings of a flip-flop.

Quartus DFF
Premade DFF provided in Quartus
Share:

Leave a Reply

Your email address will not be published.

The following GDPR rules must be read and accepted:
This form collects your name, email and content so that we can keep track of the comments placed on the website. For more info check our privacy policy where you will get more info on where, how and why we store your data.

Advertisment ad adsense adlogger