CODE
The Hidden Language of Computer Hardware and Software
2nd Edition

Chapter 17. Feedback and Flip-Flops

This chapter explores feedback of various sorts, and particularly its use in flip-flops.

Oscillating Relay (pages 213)

Begin with a simple oscillator built from a relay. Turn the switch on with your mouse or finger to see the relay oscillate.

Your browser does not support the canvas element.

First Flip-Flop (pages 217)

The first flip-flop uses two NOR gates wired so that the output of each becomes one of the inputs of the other.

To turn on the lightbulb, toggle the top switch on and then off. The lightbulb remains on even though the switch is now off.

To turn off the lightbulb, toggle the bottom switch on and then off. The lightbulb remains off.

Your browser does not support the canvas element.

Reset-Set Flip-Flop (pages 220)

Here is that same flip-flop but rearranged to show its symmetry and with an additional output.

In real life use of this flip-flop, only one of the two inputs is 1 at any time. For that reason, they have been changed to momentary switches: The switch is on only when it's pressed.

Press the bottom switch to set the Q output to 1. Any further taps of that button do nothing. Press the top switch to reset the Q output to 0. Again, any further taps of that button do nothing.

Your browser does not support the canvas element.

Hold Flip-Flop (page 222)

In this variation, the Set and Reset signals work similarly, but only when the Hold input is set to 1. The Set input is essentially saving the output of that Hold input to the Q output.

Your browser does not support the canvas element.

Level-Triggered D-Type Flip-Flop (page 224)

That flip-flop can easily be modified to create the standard level-triggered D-type flip-flop shown below. When Clock is 1, the Data input is transferred to the Q output.

The term “level-triggered” means that when Clock is 1, any changes to the Data input are reflected in the Q output.

Your browser does not support the canvas element.

Edge-Triggered D-Type Flip-Flop (page 229)

In the following “edge-triggered” flip-flop, the Q output is set from the Data input only when the Clock input transitions from 0 to 1. Any further changes to the Data input do not affect the Q output.

Your browser does not support the canvas element.

Eight-Bit Accumulating Adder (page 231)

In the following circuit, an eight-bit adder is combined with an edge-triggered flip-flop to create an accumulating adder.

To use this adder, enter a binary number on the switches at the top. When you press the Add button, that value is stored in the flip-flops and displayed on the bottom. But the value is also routed back to the adder below the switches. You can enter a second number on the switches at the top and press Add again. Now the result is the sum of the first two numbers.

You can continue as long as you want, but be aware that only eight bits are retained and the final Carry bit is discarded.

Your browser does not support the canvas element.

Eight-Bit Ripple Counter (page 235)

Edge-triggered flip-flops can be cascaded and combined with an oscillator to create a counter. The oscillator is at the upper-left and has a period of about one second. That provides a Clock input to the rightmost flip-flop, which then provides a Clock input to the next most-significant flip-flop.

The value at the bottom shows the number of seconds that have elapsed, but it’s based on JavaScript animation facilities and might be imprecise.

Your browser does not support the canvas element.

Level-Triggered D-Type Flip-Flop with Clear (page 238)

A Clear signal is often convenient to set the output of a flip-flop to 0 regardless of the other inputs.

Your browser does not support the canvas element.

Edge-Triggered D-Type Flip-Flop with Clear and Preset (page 238)

Here's an edge-triggered flip-flop decked out with both Clear and Preset inputs.

Your browser does not support the canvas element.