As said in one of the first entries on this blog Flip-Flops are logic devices that “hold” data. Also said in that entry, I could not come up with a particularly compelling reason to use these devices other than “you can”. Well, I was sadly mistaken, flip-flops are incredibly useful.

For instance, if you were building a clock or counter, it would be incredibly useful to remember where you were last. A calculator would also be a good place so that you could “enter” each number and operation. Both applications require vastly different approaches. We’ll start with the calculator, since it’s easier.

To build a calculator, let’s use our imaginations for a second. On a traditional digital calculator you enter your first number then the operation then the next number, repeating the process over and over until you get to your final answer. Alright, let’s imagine a canal, each number is held in a dike and pushed forward through the canal one at a time. Then let us imagine that our operations are each a path this water can go through. Now, the problem is how to do we hold the number so we can continue to add/subtract as long as we see fit. Basically input-operation-hold-more input-operation-etc.

So we need a method of holding since we already created an adder/subtractor that works perfectly well. A “D” flip-flop does the trick very well, actually by definition. A D flip-flop takes in an entry at an instant (defined by a periodic clock usually) and only changes that input when the clock hits again. Usually you’d just program a regular frequency for a clock, but in this case, the clock operation is going to be the add or subtract queue. Like when you press + on a simple digital calculator and the screen changes, the “clock pulse” will be the + button.

Once we understand the underlying problem and solution, the design is exceedingly simple. We just need to plug the parts together, see the diagram:

Image source

With the following diagram it’s a matter of plug-and-chug to create the circuit. The user input (switches for binary numbers) is tied to one input of the full adder (see lab 3) while the output is fed into a D flip flop. The D’s output (read as D^{+}) is sent both to the Y input of the full adder (so initially it’s user’s input + 0, then all further operations are “previous number” + “user input”) and to the ROM we designed in lab 5/6. Same use, same setup. The ROM translates the final output to normal decimal.

Some important things to make note of:

-the number of flip flops depends on number of inputs. You would arrange them to cover all possible outcomes. So, if there are 2^{n} combinations, then you’d need N flip flops.

-There are many types of flip flops with their own usages. I will cover them further in another post.

-The XOR thing in the full schematic is to handle subtraction. This was covered in Lab 3-part b.

Full sized schematic can be found [HERE]