New version page

ILLINOIS CS 231 - Counters

Documents in this Course
Load more
Upgrade to remove ads
Upgrade to remove ads
Unformatted text preview:

Counters 1Counters• Next, we’ll look at different kinds of counters and discuss how to build them.• These are not only examples of sequential analysis and design, but also real devices used in larger circuits, as we’ll see in the coming weeks.Counters 2Introducing counters• Counters are a specific type of sequential circuit.• The state, or the flip-flop values themselves, serves as the “output.”• The output value increases by one on each clock cycle.• After the largest value, the output “wraps around” back to 0.• Using two bits, we’d get something like this:• We’ll soon look at some extensions to this basic idea.Present State Next State A B A B 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 000110111111Counters 3What good are counters?• Counters can act as simple clocks to keep track of “time.”• You may need to record how many times something has happened.– How many bits have been sent or received?– How many steps have been performed in some computation?• All processors contain a program counter, or PC.– Programs consist of a list of instructions that are to be executed one after another (for the most part).– The PC keeps track of the instruction currently being executed.– The PC increments once on each clock cycle, and the next programinstruction is then executed.Counters 4A slightly fancier counter• Let’s try to design a slightly different two-bit counter:– Again, the counter outputs will be 00, 01, 10 and 11.– Now, there is a single input, X. When X=0, the counter value should incrementon each clock cycle. But when X=1, the value should decrement on successive cycles.• We’ll need two flip-flops again. Here are the four possible states:00011011Counters 5The complete state diagram and table0001101100010 111Present State Inputs Next StateQ1Q0X Q1Q00 0 0 0 10 0 1 1 10 1 0 1 00 1 1 0 01 0 0 1 11 0 1 0 11 1 0 0 01 1 1 1 0• Here’s the complete state diagram and state table for this circuit.– Make sure you know how to come up with these – this is a typical sequential design problem!Counters 6D flip-flop inputs• If we use D flip-flops, then the D inputs will just be the same as the desired next states.• K-maps for the D flip-flop inputs are shown at the right.Present State Inputs Next StateQ1Q0X Q1Q00 0 0 0 10 0 1 1 10 1 0 1 00 1 1 0 01 0 0 1 11 0 1 0 11 1 0 0 01 1 1 1 0Q00 1 0 1Q11 0 1 0XQ01 1 0 0Q11 1 0 0XD1=D0=Counters 7D flip-flop inputs• If we use D flip-flops, then the D inputs will just be the same as the desired next states.• Equations for the D flip-flop inputs are shown at the right.• Why does D0= Q0’ make sense? Present State Inputs Next StateQ1Q0X Q1Q00 0 0 0 10 0 1 1 10 1 0 1 00 1 1 0 01 0 0 1 11 0 1 0 11 1 0 0 01 1 1 1 0Q00 1 0 1Q11 0 1 0XQ01 1 0 0Q11 1 0 0XD1= Q1⊕ Q0⊕ XD0= Q0’Counters 8The counter in LogicWorks• Here are some D Flip Flopdevices from LogicWorks.• They have both normal and complemented outputs, so we can access Q0’ directly without using an inverter. (Q1’ is not needed in this example.)• This circuit counts normally when Reset = 1. But when Reset is 0, the flip-flop outputs are cleared to 00 immediately. • There is no three-input XOR gate in LogicWorks so we’ve used a four-input version instead, with one of the inputs connected to 0.Counters 9JK flip-flop inputs• If we use JK flip-flops instead, then we have to compute the JK inputs for each flip-flop.• Look at the present and desired next state, and use the excitation table on the right.Present State Inputs Next State Flip flop inputs Q1 Q0 X Q1 Q0 J1 K1 J0 K0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 0 Q(t) Q(t+1) J K0 0 0 x0 1 1 x1 0 x 11 1 x 0Counters 10JK flip-flop input equations• J1= • K1= • J0= • K0= Present State Inputs Next State Flip flop inputs Q1 Q0 X Q1 Q0 J1 K1 J0 K0 0 0 0 0 1 0 x 1 x 0 0 1 1 1 1 x 1 x 0 1 0 1 0 1 x x 1 0 1 1 0 0 0 x x 1 1 0 0 1 1 x 0 1 x 1 0 1 0 1 x 1 1 x 1 1 0 0 0 x 1 x 1 1 1 1 1 0 x 0 x 1Counters 11JK flip-flop input equations• We can then find equations for all four flip-flop inputs, in terms of the present state and inputs. Here, it turns out J1= K1and J0= K0.J1= K1= Q0’ X + Q0X’ = Q0⊕ XJ0= K0= 1• Why does J0= K0= 1 make sense?Present State Inputs Next State Flip flop inputsQ1Q0X Q1Q0J1K1J0K00 0 0 0 1 0 x 1 x0 0 1 1 1 1 x 1 x0 1 0 1 0 1 x x 10 1 1 0 0 0 x x 11 0 0 1 1 x 0 1 x1 0 1 0 1 x 1 1 x1 1 0 0 0 x 1 x 11 1 1 1 0 x 0 x 1Counters 12The counter in LogicWorks again• Here is the counter again, but using JK Flip Flop n.i. RS devices instead.• The “n.i. RS” part means that the direct inputs R and S are non-inverted, or active-high.• So this version of the circuit counts normally when Reset = 0, but initializes to 00 when Reset is 1.Counters 13Unused states• The examples shown so far have all had 2nstates, and used n flip-flops. But sometimes you may have unused, leftover states.• For example, here is a state table and diagram for a counter that repeatedly counts from 0 (000) to 5 (101).• What should we put in the table for the two unused states?Present State Next StateQ2Q1Q0Q2Q1Q00 0 0 0 0 10 0 1 0 1 00 1 0 0 1 10 1 1 1 0 01 0 0 1 0 11 0 1 0 0 01 1 0 ? ? ?1 1 1 ? ? ?001010011100101000Counters 14Unused states can be don’t cares…• To get the simplestpossible circuit, you can fill in don’t cares for the next states. This will also result in don’t cares for the flip-flop inputs, which can simplify the hardware.• If the circuit somehow ends up in one of the unused states (110 or 111), its behavior will depend on exactly what the don’t cares were filled in with.Present State Next StateQ2Q1Q0Q2Q1Q00 0 0 0 0 10 0 1 0 1 00 1 0 0 1 10 1 1 1 0 01 0 0 1 0 11 0 1 0 0 01 1 0 x x x1 1 1 x x …


View Full Document
Download Counters
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 Counters 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 Counters 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?