Unformatted text preview:

October 15, 2003 Flip-flops 1Flip-Flops• Last time, we saw how latches can be used as memory in a circuit.• Latches introduce new problems:– We need to know when to enable a latch.– We also need to quickly disable a latch.– In other words, it’s difficult to control the timing of latches in a large circuit.• We solve these problems with two new elements: clocks and flip-flops– Clocks tell us when to write to our memory.– Flip-flops allow us to quickly write the memory at clearly defined times.– Used together, we can create circuits without worrying about thememory timing.October 15, 2003 Flip-flops 2An SR latch with a control input• Here is an SR latch with a control input C.• Notice the hierarchical design!– The dotted blue box is the S’R’ latch.– The additional NAND gates are simply used to generate the correct inputs for the S’R’ latch.• The control input acts just like an enable.C S R S’ R’ Q0 x x 1 1 No change1 0 0 1 1No change1 0 1 1 0 0 (reset)1 1 0 0 1 1 (set)1 1 1 0 0 Avoid!October 15, 2003 Flip-flops 3D latch• Finally, a D latch is based on an S’R’ latch. The additional gates generate the S’ and R’ signals, based on inputs D (“data”) and C (“control”).– When C = 0, S’ and R’ are both 1, so the state Q does not change.– When C = 1, the latch output Q will equal the input D.• No more messing with one input for set and another input for reset!• Also, this latch has no “bad” input combinations to avoid. Any of the four possible assignments to C and D are valid.C D Q0 xNo change1 0 01 1 1October 15, 2003 Flip-flops 4Using latches in real life• We can connect some latches, acting as memory, to an ALU.• Let’s say these latches contain some value that we want to increment.– The ALU should read the current latch value.– It applies the “G = X + 1” operation.– The incremented value is stored back into the latches.• At this point, we have to stop the cycle, so the latch value doesn’t get incremented again by accident.• One convenient way to break the loop is to disable the latches.+1ALUSXGLatchesDQCOctober 15, 2003 Flip-flops 5The problem with latches• The problem is exactly when to disable the latches. You have to wait long enough for the ALU to produce its output, but no longer.– But different ALU operations have different delays. For instance, arithmetic operations might go through an adder, whereas logicaloperations don’t.– Changing the ALU implementation, such as using a carry-lookahead adder instead of a ripple-carry adder, also affects the delay.• In general, it’s very difficult to know how long operations take, and how long latches should be enabled for.+1ALUSXGLatchesDQCOctober 15, 2003 Flip-flops 6Making latches work right• Our example used latches as memory for an ALU.– Let’s say there are four latches initially storing 0000.– We want to use an ALU to increment that value to 0001.• Normally the latches should be disabled, to prevent unwanted data from being accidentally stored.– In our example, the ALU can read the current latch contents, 0000, and compute their increment, 0001.– But the new value cannot be stored back while the latch is disabled. +1ALUSXGLatchesDQC 000000001October 15, 2003 Flip-flops 7Writing to the latches• After the ALU has finished its increment operation, the latch can be enabled, and the updated value is stored. • The latch must be quickly disabled again, before the ALU has a chance to read the new value 0001 and produce a new result 0010.+1ALUSXGLatchesDQC 100010001+1ALUSXGLatchesDQC 000010010October 15, 2003 Flip-flops 8• So to use latches correctly within a circuit, we have to:– Keep the latches disabled until new values are ready to be stored.– Enable the latches just long enough for the update to occur.• There are two main issues we need to address:4 How do we know exactly when the new values are ready?We’ll add another signal to our circuit. When this newsignal becomes 1, the latches will know that the ALUcomputation has completed and data is ready to be stored.4 How can we enable and then quickly disable the latches?This can be done by combining latches together in aspecial way, to form what are called flip-flops.Two main issuesOctober 15, 2003 Flip-flops 9Clocks and synchronization• A clock is a special device that whose output continuously alternates between 0 and 1.• The time it takes the clock to change from 1 to 0 and back to 1 is called the clock period, or clock cycle time.• The clock frequency is the inverse of the clock period. The unit of measurement for frequency is the hertz.• Clocks are often used to synchronize circuits.– They generate a repeating, predictable pattern of 0s and 1s thatcan trigger certain events in a circuit, such as writing to a latch.– If several circuits share a common clock signal, they can coordinate their actions with respect to one another.• This is similar to how humans use real clocks for synchronization.clock periodOctober 15, 2003 Flip-flops 10More about clocks• Clocks are used extensively in computer architecture.• All processors run with an internal clock.– Modern chips run at frequencies up to 3.2 GHz.– This works out to a cycle time as little as 0.31 ns!• Memory modules are often rated by their clock speedstoo—examples include “PC133” and “DDR400” memory.• Be careful...higher frequencies do not always mean faster machines!– You also have to consider how much work is actually being done during each clock cycle.– How much stuff can really get done in just 0.31 ns?– Take CS232.October 15, 2003 Flip-flops 11Synchronizing our example• We can use a clock to synchronize our latches with the ALU.– The clock signal is connected to the latch control input C.– The clock controls the latches. When it becomes 1, the latches will be enabled for writing.• The clock period must be set appropriately for the ALU.– It should not be too short. Otherwise, the latches will start writing before the ALU operation has finished.– It should not be too long either. Otherwise, the ALU might produce a new result that will accidentally get stored, as we saw before.• The faster the ALU runs, the shorter the clock period can be.+1ALUSXGLatchesDQCOctober 15, 2003 Flip-flops 12• The second issue was how to enable a latch for just an instant.• Here is the internal structure of a D flip-flop.– The flip-flop inputs are C and D, and the


View Full Document

U of I CS 231 - Lecture notes

Documents in this Course
Counters

Counters

23 pages

Latches

Latches

22 pages

Lecture

Lecture

33 pages

Lecture

Lecture

16 pages

Lecture

Lecture

4 pages

Datapaths

Datapaths

30 pages

Lecture

Lecture

6 pages

Registers

Registers

17 pages

Datapaths

Datapaths

28 pages

Decoders

Decoders

20 pages

Load more
Download Lecture notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?