Ece341 Lecture03
Ece341 Lecture03
Lecture # 3
Instructor: Zeshan Chishti
[email protected]
October 6, 2014
D Q D Q D Q
……………………
Clk
1 x x x x
0 1 x x x
0 0 1 x x
1 0 0 1 x
1 0 0 1
Assume
:Shift / Load 1
Behavior:
Parallel Access
0 1` 0 1 0 1 0 1
Parallel Access Shift Register
Assume
:Shift / Load 0
Behavior:
Serial Access
1 0 1 0 1 0 1 0
Counters
• Counters are arithmetic circuits used for the purpose of counting
– Can increment or decrement by 1 each cycle
• Counters often implemented with T flip-flops
– Toggle feature naturally suited for counting operation
• Applications of counters
– Count occurrences of certain events, for example, no. of add instructions
– Track elapsed time between events
– Generate control and timing signals, for example, to produce signals whose
frequencies are multiples of original clock frequency
A 3-bit Up-counter
Counter x2 x1 x0
Consider a 3-bit counter Value
x2x1x0 shown in table. 0 0 0 0
•The least significant bit x0 1 0 0 1
toggles at every increment
of counter 2 0 1 0
• x1 toggles on 1->0 3 0 1 1
transitions of x0 (half the
4 1 0 0
rate of toggling of x0)
• x2 toggles on 1->0 5 1 0 1
transitions of x1 (half the 6 1 1 0
rate of toggling of x1)
7 1 1 1
A 3-bit Up-counter
Practice Exercise
• Design a 3-bit down counter with T flip-flops. How does
the down counter circuit differ from the up-counter
circuit?
A 3-bit Down-counter
Counter x2 x1 x0
•The least significant bit x0 Value
toggles at every decrement 7 1 1 1
of counter 6 1 1 0
• x1 toggles on 0->1
transitions of x0 5 1 0 1
• x2 toggles on 0->1 4 1 0 0
transitions of x1
3 0 1 1
2 0 1 0
1 0 0 1
0 0 0 0
Practice Exercise Solution
• Design a 3-bit down counter with T flip-flops. How
does the down counter circuit differ from the up-
counter circuit?
• Solution:
– Two ways to convert the up-counter to a down-counter:
1. Either, replace the +ve edge-triggered T flip-flops with –ve edge-
triggered T flip-flops
2. Or, connect the Q outputs (instead of NOT(Q) outputs) from previous
flip-flops to clock inputs of next flip-flops
Asynchronous Counters
• The previous counter is an example of asynchronous counters.
Also called ripple counters
– Input clock only connected to one flip flop
– Clocks for other flip-flops are derived from outputs of previous flip-flops
• Asynchronous counters are slow because of cascaded clocking
– The input clock pulse ripples from stage to stage
– Propagation delay of individual flip-flops limit speed of operation
• Solution: Synchronous sequential circuits (finite state machines)
Finite State Machines
• Recall that in a sequential circuit:
– Outputs depend both on present inputs and the sequence of previous inputs
• The state of a sequential circuit determines its behavior when various
input patterns are applied
• A finite state machine model formally describes a sequential circuit
Inputs Outputs
Combinational
Logic
Present Next
State State
Delay Elements
(Flip-flops)
Synthesis of Finite State Machines
Synthesis of FSM involves the following steps:
• Step 1: Develop a state diagram or state table
– Depict how state transitions occur in response to input patterns
• Step 2: Determine # and types of needed flip flops
• Step 3: Determine state assignment (flip-flop values for each state)
• Step 4: Determine the state-assigned state table
• Step 5: Derive the logic expressions for next-state logic and outputs
• Step 6: Use the derived expressions to implement the circuit
Example: Up/Down Counter with D flip-flops
Problem Statement: Design a mod-4 counter which counts up or down
depending on an input and has an output of 1 if the count is equal to 2
x=0
S0/0 S1/0
x=1
x=1
S3/0 S2/1
x=0
State Table
x=0 x=1
S0 S1 S3 0
S1 S2 S0 0
S2 S3 S1 1
S3 S0 S2 0
Next state Y 2 y 2 y1 x Y1 y1
Logic
Expressions Output z y 2y1
Logic Circuit
Y 2 y 2 y1 x Y1 y1
Logic Next state
Expressions Output z y 2y1