Unit 5 DLD
Unit 5 DLD
Unit 5 DLD
Flip-Flops
Sequential Circuits use flip-flops as storage elements
Flip-Flop is a binary storage device that saves one bit of
information
The outputs can come from flip-flops or combinational logic
Flip-flop inputs come from combinational logic or clock
generators
Latches
Different flip-flops are different based on the number of inputs and how the inputs
affect the binary state.
Basic types of flip-flops operate with signal levels and are called latches.
Example: SR latch
D Latch
Want to get rid of the undesirable SR condition where both S and R are 1.
1
1
0
1
1
1
1
0
D Latch
Want to get rid of the undesirable SR condition where both S and R are 1.
1
1
1
0
1
FLIP-FLOPS
Many flip-flops are edge triggered: They respond to the input only during
transition from 0 to 1 or from 1 to 0.
10
Edge-Triggered D Flip-Flop
The output can change only when clock goes from 1 to 0.
11
Edge-Triggered D Flip-Flop
The output can change only when clock goes from 1 to 0.
12
Graphic Symbols
13
Other Flip-Flops
Each flip-flop is made of interconnection of gates.
The edge-triggered D flip-flop is the most efficient flipflop since it requires the least number of gates.
Other flip-flops are made using the D flip-flop and extra
logic.
Two flip-flops widely used are the JK and T flip-flop.
14
What is a JK Flip-flop?
A flip-flop is a circuit that has two stable states
and can be used to store state information.
The flip-flop can be made to change state by
signals applied to one or more control inputs
and will have one or two outputs.
JK Terminology/Structure
Has 5 inputs named:
J(set),K(reset), PR, CLR, and CLK
Has 2 outputs: Q and Q
PR = Preset
CLR = Clear
CLK = Clock
Outputs
The Q output is the primary output.
This means that the binary bit
stored in the flip-flop, 1 or 0, is
the same as Q.
The Q output is the
opposite binary bit value
that is stored in Q.
Inputs: J and K
The logic states applied to the J and K inputs cause the flipflop to operate 4 different ways.
The way the logic state is applied to J and K is called Mode
of Operation.
The mode of operation refers to the condition of the flipflop as it prepares for the positive clock pulse.
Q(t+1)
Q(t+1)
Mod
e
Hold
Sets
Rese
ts
Togg
le
JK contains an internal
Active Low SR latch.
S set
R
reset
Invalid
Invalid
3 Inputs:
Orig. Q
Orig. Q
Orig. Q
Orig. Q
Orig. Q
Orig. Q
Orig. Q
Orig. Q
Orig. Q
Orig. Q
Characteristic Equation
Q
Q(t + 1)
Characteristic Equation:
Mode
Hold
Sets
Resets
Toggle
SR Latch:
A 0 at the set or the
reset will either set or
reset the value of Q.
JK Flip-Flop
Three flip-flop operations: Set, Reset,
Complement output.
JK performs all three
31
JK Flip-Flop
D = JQ + KQ
if J=1 , K=0 then D=Q+Q=1
if J=0 , K=1 then D=0
if j =1 , K=1 then D = Q
32
T Flip-Flop
T (Toggle) flip-flop is a complementing one.
T flip-flop is obtained from a JK when inputs J and K are tied together.
33
T Flip-Flop
If T=0 ( J=K=0) output does not change.
If T=1 ( J=K=1) output is complemented.
A T flip-flop can also be made of D flip-flop and a XOR.
D = T XOR Q = TQ + TQ
34
Characteristic Tables
JK Flip-flop
J
0
0
1
1
K
0
1
0
1
Q(t+1)
Q(t)
0
1
Q(t)
No change
Reset
Set
Complement
35
Characteristic Tables
D Flip-flop
D
0
1
Q(t+1)
0
Reset
1
Set
T Flip-flop
T
0
1
Q(t+1)
Q(t) No change
Q(t) Complement
36
Introduction: Registers
An n-bit register has a group of n flip-flops and some
logic gates and is capable of storing n bits of
information.
Introduction: Registers
37
Simple Registers
No external gates.
Example: A 4-bit register. A new 4-bit data is loaded
every clock cycle.
A3
A2
A1
A0
I3
I2
I1
I0
CP
CS1104-13
Simple Registers
38
CS1104-13
39
Load'.A0 + Load. I0
D Q
A0
D Q
A1
D Q
A2
D Q
A3
I0
I1
I2
I3
CLK
CLEAR
CS1104-13
40
Clock
Combinational
circuit
Inputs
Outputs
41
Present
state
A1 A2
0
0
0
0
0
1
0
1
1
0
1
0
1
1
1
1
CS1104-13
Input
x
0
1
0
1
0
1
0
1
Next
State
A1+ A2+
0
0
0
1
0
1
0
0
1
0
0
1
1
1
0
0
Output
y
0
0
0
1
0
0
0
1
A1.x' A
1
A2x
x
A2
y
42
Outputs
1
2
3
0
0
0
0
1
0
0
1
0
0
0
1
1
0
0
0
1
0
1
1
0
0
0
1
A1
A2
x
8x3
ROM
y
CS1104-13
43
Shift Registers
Another function of a register, besides storage, is to
provide for data movements.
CS1104-13
Shift Registers
44
Shift Registers
Basic data movement in shift registers (four bits are
used for illustration).
Data in
Data out
Data out
Data in
Data out
Data in
Data out
(e) Parallel in /
parallel out
(f) Rotate right
CS1104-13
45
Serial data
input
D Q
C
Q0
D Q
C
Q1
D Q
Q2
D Q
Q3
Serial data
output
CLK
CS1104-13
46
Shift register A
SO
SI
Shift register B
SO
CP
Shift control
Clock
Shift
control
CP
CS1104-13
Wordtime
T1
T2
T3
T4
47
CS1104-13
Shift register A
1
1
1
0
1
0
1
1
1
0
1
0
1
1
1
1
1
0
1
1
Shift register B
0
1
1
0
1
0
0
1
1
0
1
0
0
1
1
0
1
0
0
1
Serial output of B
0
1
0
0
1
48
D Q
D Q
D Q
D Q
CLK
Q0
Data input
CLK
Q1
Q2
Q3
SRG 4
Logic symbol
C
Q0 Q1 Q2 Q3
CS1104-13
49
D1
D2
D3
SHIFT/LOAD
D Q
C
Q0
D Q
Q1
D Q
C
Q2
Serial
data
D Q
Q3 out
C
CLK
SHIFT.Q0 + SHIFT'.D1
CS1104-13
50
SHIFT/LOAD
CLK
SRG 4
C
Logic symbol
CS1104-13
51
D1
D2
D3
D Q
D Q
D Q
D Q
CLK
Q0
Q1
Q2
Q3
CS1104-13
52
RIGHT.Q0 +
RIGHT'.Q2
D Q
D Q
Q1
D Q
C
Q2
D Q
Q3
Q0
CLK
CS1104-13
53
Clear
A4
A3
A2
A1
CLK
s1
s0
Serial
input for
shift-right
CS1104-13
4x1
MUX
3 2 1 0
I4
4x1
MUX
3 2 1 0
I3
4x1
MUX
3 2 1 0
I2
Parallel inputs
Bidirectional Shift Registers
4x1
MUX
3 2 1 0
I1
Serial
input for
shift-left
54
CS1104-13
0
1
0
1
Register Operation
No change
Shift right
Shift left
Parallel load
55
SO
Shift-right
CP
External input
Shift-register A
x
S
y FA
C
z
SI
Shift-register B
SO
Q D
Clear
CS1104-13
56
CS1104-13
Initial:
A: 0 1 0 0
B: 0 1 1 1
Q: 0
Step 1: 0 + 1 + 0
S = 1, C = 0
A: 1 0 1 0
B: x 0 1 1
Q: 0
Step 2: 0 + 1 + 0
S = 1, C = 0
A: 1 1 0 1
B: x x 0 1
Q: 0
Step 3: 1 + 1 + 0
S = 0, C = 1
A: 0 1 1 0
B: x x x 0
Q: 1
Step 4: 0 + 0 + 1
S = 1, C = 0
A: 1 0 1 1
B: x x x x
Q: 0
57
clk
qb
rst
pr
Clk
qb
Qb
Qbpreviou
s
qb=~q;
end
Rst
Clk
Qb
Previous
state
Qb
No +ve edge -
Previous
state
Edge-Triggered D Flip-Flop
P3
P1
Clock
P2
P4
When Clock = 0
If D = 0 at edge of Clock P4 = 1
regardless of any further D changes
If D = 1 at edge of Clock P2 = P3 = 1
regardless of any further D changes
Preset = 0 Q = 1
Clear = 0 Q = 0
Preset
D
Clock
Preset
Q
D
Q
Q
Clear
Clear
Preset
Preset
Q
D
Clock
Q
Q
Clear
D
Clear
Clear
D
Clock
Terms Reviewed
Latch
Gated latch
Master-slave flip-flop
Edge-triggered flip-flop
T Flip-Flop
Toggle flip-flop
D = T'Q + TQ'
D
T
Clock
Q(t+1)
Q(t)
Q(t)'
Q
Q
JK Flip-Flop
Q(t+1)
Q(t)
D = JQ' + K'Q
Q(t)'
J
D
K
Clock
State Diagrams: D
Q(t+1)
Q(t+1) = D
1
0
characteristic equation
State Diagrams: T
Q(t+1)
Q(t)
Q(t)'
1
1
State Diagrams: SR
Q(t+1)
00
01
11
10
Q(t)
SR
Q
x
Q(t+1) = S + R'Q(t)
0x
1
01
x0
characteristic equation
State Diagrams: JK
Q(t+1)
static hazard!!
00
01
11
10
Q(t)
JK
Q
Q(t)'
Q(t+1) = J Q(t)' + K' Q(t), or
Q(t+1) = J Q(t)' + K' Q(t) + J K'
0x
x0
characteristic equation
x1
Characteristic Equations
Flip-flop
Characteristic Equation
Q(t+1) = D
Q(t+1) = T Q(t)
SR
JK
Excitation Tables
Q(t)
Q(t+1)
SR
JK
0x
0x
10
1x
01
x1
x0
x0
Registers
n flip-flops used
Clock is shared by all so action is synchronous with clock
edge
Simple register
Shift register
Parallel access shift register
Lots of counters: up counter, down counter, BCD counter,
ring counter, Johnson counter
Q
Q
Q2
Q
Q
Q1
Q
Q
Q0
Q
Q
Parallel input
Clock
Q2
Q1
Q0
Parallel input
Clock
Load
In
Clock
Q
Q
Q1
Q
Q
Q2
Q
Q
Q3
Q
Q
Q4
Out
In
Q1
Q2
Q3
Q4 = Out
t0
t1
t2
t3
t4
t5
t6
t7
Shift/Load = 0
Shift right
Shift/Load = 1
Load
Parallel output
Q3
Q
Q
Serial Shift/Load
input
Q2
D
Q1
D
Parallel input
Q
Q
Q0
D
Q
Q
Clock
S1
S0
Function
memory
SHR
SHL
load
Q3
s1
s0
0 1 2 3
Q3
s1
s0
0 1 2 3
Q3
s1
s0
0 1 2 3
SRSI
Q
Q
s1
s0
0 1 2 3
SLSI
Parallel input
Clock
74164 Shifter
74165 Shifter
Asynchronous Counters
1
Clock
Q0
MSB of count
Q1
Q2
Clock
Q0
Q
Q
Q1
Q2
Clock
Q0
Q1
Q2
Count
1
Clock
Q0
Q
Q
Q1
Q2
Clock
Q
Q0
Q
Q
Q1
Q2
Clock
Q0
Q1
Q2
Count
Synchronous Counters
clock cycle
Q2
Q1
Q0
T0 = 1
T1 = Q0
T2 = Q1Q0
T3 = Q2Q1Q0
always toggle
toggle when Q0 = 1
toggle when Q1Q0 = 1
toggle when Q2Q1Q0 = 1
Q0
Clock
Q1
Q
Q2
Q
Q3
Q
Q0
Clock
Q1
T
Q2
Q3
Clock
Q0
Q1
Q2
Q3
Count 0
10 11
12 13
14 15
Enable
Clock
Clear
Q
Q
Q
Q
Q
Q
Q
Q
clock cycle
Q2
Q1
Q0
D0 = 1 Q0
D1 = Q1 Q0
D2 = Q2 Q1Q0
D3 = Q3 Q2Q1Q0
always toggle
toggle when Q0 = 1
toggle when Q1Q0 = 1
toggle when Q2Q1Q0 = 1
4 Bit Up Counter
Enable
D Q
Q0
D Q
Q1
D Q
Q2
D Q
Q3
Q
Clock
Output
carry
Enable
D0
0
1
D1
0
1
DQ
Q0
DQ
Q1
Load = 1 load
D2
Enable = 1 increment
Load = Enable = 0 memory
D3
Load
Clock
0
1
DQ
Q2
0
1
DQ
Q3
Q
Output
carry
Mod 8 counter: k = 3
Enable
D0
Q0
D1
Q1
D2
Q2
Load
Clock
Clock
BCD Counter
Ring Counter
00 01 09 10 11 19 20
Each position is a BCD digit
Johnson Counter
Enable
D0
D1
D2
D3
Q0
Q1
Q2
Q3
BCD 0
Load
Clock
Clock
Clear
0
0
0
0
Enable
D0
D1
D2
D3
Load
Clock
BCD 1
Q1
Qn 1
Start
Clock
asynchronous clear
Johnson Counter
Q0
Q
Q
Reset
Clock
Q1
Q
Q
Qn 1
Q
Q
Verilog Example
x3
x1
x2
Q
D
Clock
x3
x1
x2
Clock
Blocking Assignments
Clock
Q1
D
treated as Q2 = D since Q1 = D
Q2
Non-Blocking Assignments
D
Clock
non-blocking assignment
Q1
D
Q2
Non-Blocking Example
x3
x1
x2
Clock
Synchronous Clear
Q3
Q2
Q1
Q0
D Q
D Q
D Q
D Q
Serial Shift/Load
input
Parallel input
Clock
N-Bit Up Counter
pinB
pinB
Binary Multiplication
Binary Multiplier
ASM Chart
Numerical Example
C ;
[4:0] A, Q, B ;
[2:0] P ;
[1:0] pstate, nstate ;
parameter
// combinational circuit
wire
assign
Z ;
Z = ~|P ;
0;
= 0;
= 0 ;
1; clr = 1;
= 5'b10111 ;
= 5'b10011 ;
0 ;
StateTable
The state table representation of a sequential circuit
consists of three sections labelled
present state,
next state
output.
The present state designates the state of flip-flops before
the occurrence of a clock pulse.
The next state shows the states of flip-flops after the clock
pulse, and
the output section lists the value of the output variables
during the present state.
State Diagram
The binary number inside each
circle identifies the state the
circle represents. The directed
lines are labelled with two
binary numbers separated by a
slash (/).
The input value that causes the
state transition is labelled first.
The number after the slash
symbol / gives the value of the
output.
153
154
155
9/15/09 - L22
Sequential Circuit
156
Continue
Add a state D
State D have detected the 3rd input in the start
of a sequence, a 0, now having 110. From State
D, if the next input is a 1 the sequence has been
detected and a 1 is output.
157
158
160
162
163
0
S0 / 0
S1 / 0
0
0
S3 / 1
S2 / 0
State A B
S0
0 0
S1
0 1
S2
1 0
S3
1 1
1
164
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
x
0
1
0
1
0
1
0
1
Next
State
A
0
0
0
1
0
1
0
1
B
0
1
0
0
0
1
0
1
Output
y
0
0
0
0
0
0
1
1
0
S0 / 0
S1 / 0
0
0
S3 / 1
1
S2 / 0
1
165
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
x
0
1
0
1
0
1
0
1
Next
State
A
0
0
0
1
0
1
0
1
B
0
1
0
0
0
1
0
1
Output
y
0
0
0
0
0
0
1
1
A(t+1) = DA (A, B, x)
= (3, 5, 7)
B(t+1) = DB (A, B, x)
= (1, 5, 7)
y (A, B, x) = (6, 7)
166
DA (A, B, x) = (3, 5, 7)
= Ax + B x
DB (A, B, x) = (1, 5, 7)
= A x + B x
y (A, B, x) = (6, 7)
=AB
0 0 1 0
A 0 1 1 0
x
B
0 1 0 0
A 0 1 1 0
x
0 0 0 0
A 0 0 1 1
x
167
DA = A x + B x
DB = A x + B x
y =AB
Q
y
D
CLK
Eastern Mediterranean University
Q
168
F.F.
Input
Q(t) Q(t+1) D
0
0 0
0
1 1
1
0 0
1
1 1
Present Next
State State
F.F.
Input
Q(t) Q(t+1) J K
0
0 0 x
0
1 1 x
1
0 x 1
1
1 x 0
0 0 (No change)
0 1 (Reset)
1 0 (Set)
1 1 (Toggle)
0 1 (Reset)
1 1 (Toggle)
0 0 (No change)
1 0 (Set)
Q(t) Q(t+1) T
0
0 0
0
1 1
1
0 1
1
1 0
169
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
x
0
1
0
1
0
1
0
1
Next
State
A
0
0
0
1
0
1
0
1
Flip-Flop
Inputs
B JA KA JB KB
0 0 x 0 x
1 0 x 1 x
0 0 x x 1
0 1 x x 1
0 x 1 0 x
1 x 0 1 x
0 x 1 x 1
x University
0
1 xEastern 0Mediterranean
KA = x
KB = A + x
JA = B x
JB = x
CLK
0 0 1 0
x x x x
A 1 0 0 1
x
B
x x 1 1
A x x 0 1
x
A x x x x
x
B
0 1 x x
A 0 1 x x
x
171
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
x
0
1
0
1
0
1
0
1
Next
State
A
0
0
0
1
0
1
0
1
B
0
1
0
0
0
1
0
1
F.F.
Input
TA
0
0
0
1
1
0
1
0
TB
0
1
1
1
0
1
1
0
TA (A, B, x) = (3, 4, 6)
TB (A, B, x) = (1, 2, 3, 5, 6)
172
TA = A x + A B x
TB = A B + B x
B
0 0 1 0
0 1 1 1
A 1 0 0 1
x
A 0 1 0 1
x
CLK
173