Chapter 3: Sequential Logic Some Definitions: Dr. Tim Mcguire Sam Houston State University
Chapter 3: Sequential Logic Some Definitions: Dr. Tim Mcguire Sam Houston State University
Chapter 3: Sequential Logic Some Definitions: Dr. Tim Mcguire Sam Houston State University
3-2
Some Definitions
Combinational logic: a digital logic circuit in which logical decisions are made based only on combinations of the inputs (e.g., an adder). Sequential logic: a circuit in which decisions are made based on combinations of the current inputs as well as the past history of inputs (e.g., a memory unit). Finite state machine: a circuit which has an internal state, and whose outputs are functions of both current inputs and its internal state (e.g., a vending machine controller).
3-3
3-4
Sequential Logic
The combinational logic circuits we have been studying so far have no memory. The outputs always follow the inputs. There is a need for circuits with a memory, which behave differently depending upon their previous state. An example is the vending machine, which must remember how many and what kinds of coins have been inserted, and which behave according to not only the current coin inserted, but also upon how many and what kind of coins have been deposited previously. These are referred to as finite state machines, because they can have at most a finite number of states.
in
...
...
i1
f1 fm
3-5
3-6
...
...
A B
State bits
??
A+B
A+B
Q0 D0 s0
?? Timing behavior
...
This delay between input and output is at the basis of the functioning of an important memory element, the flip-flop.
Page 1
3-7
3-8
An R-S Flip-Flop
Qt 0 S Q 0 0 0 1 R Q 1 1 1 St 0 0 1 1 0 0 1 1 Rt 0 1 0 1 0 1 0 1 Q i+1 0 0 1 (disallowed) 1 0 1 (disallowed) Q ?? 2? ? ?? 2? ? Q S R
A Clock Waveform
Amplitude
Timing behavior
3-9
3-10
Q Q
D Symbol C
Q 2? ? Q
?? 2? ?
??
Timing behavior
The clocked D flip-flop, sometimes called a latch, has a potential problem: If D changes while the clock is high, the output will also change. The MasterSlave flip-flop solves this problem.
3-11
3-12
A Master-Slave Flip-Flop
Circuit Master D D QM Slave D QS D CLK QM QS D Symbol Q 3? ? 2? ? Q QS ?? 2? ? 2? ? ??
CLK
C QS
K Circuit
Symbol
Timing behavior
The rising edge of the clock clocks new data into the master, while the slave holds previous data. The falling edge clocks the new master data into the slave.
The J-L flip-flop eliminates the S = R = 1 problem of the S-R flip-flop, because Q enables J while Q' disables K, and vice versa. However there is still a problem. If J goes momentarily to 1 and then back to 0 while the flip-flop is active and in the reset, the flip-flop will catch the 1. This is referred to as 1 s catching. The J-K master-slave flip-flop solves this problem.
Page 2
3-13
3-14
A T Flip-Flop
J Q T K Q Q Symbol Q
Circuit
Symbol
Circuit
The presence of a constant 1 at J and K means that the flipflop will change its state from 0-1 or 1-0 each time it is clocked by the T (toggle) input.
3-15
3-16
Amplitude
A Modulo-4 Counter
Time (t) 4 3 2 1 0 4 3 2 1 0 Time (t) RESET q0 q1 01100 01010 D D s1 CLK Q Q s0 Q Q 00001
CLK
Time
S
Q Main latch
Cycle time = 25 ns
D Stores D
When the clock is high, the two input latches output 0, so the main latch remains in its previous state regardless of changes in D. When the clock goes high-low, values in the two input latches will affect the state of the main latch. While the clock is low, D cannot affect the main latch.
s1
3-17
3-18
Truth Table
r(t) 0 0 0 0 1 1 1 1 s 1 (t)s 0 (t) 00 01 10 11 00 01 10 11 s 1 s 0 (t+1) 01 10 11 00 00 00 00 00 q1 q 0 (t+1) 01 10 11 00 00 00 00 00
Next State RESET 0 1 B/01 A/00 C/10 A/00 D/11 A/00 A/00 A/00 RESET 0 1 01 00 10 00 11 00 00 00
C 0/11
Output 10 state
Output 11 state
The state diagram and state table tell all there is to know about the FSM, and are the basis for a provably correct design.
Develop equations from this truth table for s0(t+1), s1(t+1), q0(t+1), and q1(t+1) from inputs r(t), s0(t) and s1(t)
Page 3
3-19
3-20
Equations
RESET
s 0(t ? 1) ? r (t )s1(t )s 0 (t ) ? r (t )s1( t )s 0(t ) s1(t ? 1) ? r (t )s1(t )s 0(t ) ? r( t )s1(t ) s0 (t ) q 0(t ? 1) ? r (t )s1(t )s 0 (t ) ? r (t )s1( t )s 0(t ) q1(t ? 1) ? r (t )s1(t )s 0(t ) ? r( t )s1(t ) s0 (t )
CLK
D s1
Q q1 Q
D s0
Q q0 Q
Implement these equations There are many simpler techniques for implementing counters.
3-21
3-22
Design a machine that outputs a 1 when exactly 2 of the last 3 inputs are 1. e.g. input sequence of 011011100 produces an output sequence of 001111010 Assume input is a 1-bit serial line. Use D flip-flops and 8-1 multiplexers. Begin by constructing a state transition diagram.
Pres. State
S 2S 1S 0 A=000 B=001 C=010 D=011 E=100 F=101 G=110
X
0 S 2 S 1S 0Z 001/0 011/0 101/0 011/0 101/0 011/0 101/1 1 S 2 S 1S 0Z 010/0 100/0 110/0 100/0 110/1 100/1 110/0
1/1
1/0
3-23
3-24
Acepts nickel, dime, and quarter. When value of money inserted equals or exceeds twenty cents, machine vends item and returns change if any, and waits for next transaction. Implement with PLA and D flip-flops.
CLK
Page 4
3-25
3-26
s1 s0 x1 x0
s1 s0 z2 z1 z 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0 1 0 d 1 1 0 d 1 0 0 d 0 0 0 d
1 0 0 d 0 1 0 d 1 0 0 d 0 0 1 d
0 0 1 d 0 0 1 d 0 1 1 d 1 1 1 d
0 0 1 d 0 0 0 d 0 0 1 d 0 1 1 d
0 0 0 d 0 0 1 d 0 0 1 d 0 0 1 d
3-27
3-28
(a)FSM Circuit, (b)Truth Table, and (c)PLA Realization for Vending Machine Controller
x1 x0 5x5 PLA Q D s0 CLK Q D s1 z2 z z1 0 s1 s0 x1 x0 0 1 2 4
Dispense Return nickel Next Return dime state
(a)
5 6 8 9 10 12 13 14
s1 s0 x1 x0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
s1 s0 z2 z1 z0 0 1 0 d 1 1 0 d 1 0 0 d 0 0 0 d 1 0 0 d 0 1 0 d 1 0 0 d 0 0 1 d 0 0 1 d 0 0 1 d 0 1 1 d 1 1 1 d 0 0 1 d 0 0 0 d 0 0 1 d 0 1 1 d 0 0 0 d 0 0 1 d 0 0 1 d 0 0 1 d
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
5x5 PLA Q D s0
z1 z0
00 01 4-to-1 10 MUX 11
D Q s1 Q
z1
CLK
(c) s1 s0 z2 z1 z0
(b)
Q D s1
CLK
3-29
3-30
Tri-State Buffers
C A 0 0 1 1 0 1 0 1 F C A 0 0 1 1 0 1 0 1 F 0 1
A 4-Bit Register
D3 D2 D Write (WR) CLK Enable (EN) Q D Q D1 D Q D0 D Q
? ?
0 1
? ?
Gate-Level View
Q3
Q2
Q1
Q0
A C
A C
F=AC or F=?
There is a third state: high impedance. This means the gate output is essentially disconnected from the circuit. This state is indicated by ? in the figure.
EN
Page 5
3-31
3-32
Internal Layout and Block Diagram for Left-Right Shift with Parallel Read/Write Capabilities
c1 c0 D3 Left shift out Left shift in D2 D1 D0 Right shift in
Q2
Q1
Q0
D Q
Q0 Q1 Q2 Timing behavior
RESET
Cont rol c1 0 0 1 1 c0 0 1 0 1 No c hange Shift left Shift right Parallel load Function Left shift in Left shift out c0 c1 D3 D2 D1 D0 Q3 Q2 Q 1 Q 0
Q2 Q1 Q0
3-33
3-34
AB
C B A AB
S Q
S ?? R
Rearrange bubbles
Q Q
It is desirable to be able to turn off the flip-flop so it does not respond to such hazards.
?? 2? ? Timing behavior
Page 6