Week 5 - Lectures
Week 5 - Lectures
1 SEQUENTIAL CIRCUITS
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
5 .1
Motivation
Most digital system specifications cannot be implemented by combinational circuits because
the value of an output signal could be a function of
(not only) the value of the input signals at the same time,
(but also) the value of the input signals at preceding times.
5
5 .1
1. Sequential systems
Digital circuits with memory: HOW?
6
5 .1
1. Sequential systems: Concept of STATE
CURRENT
STATE NEXT
STATE
7
5 .1
1. Sequential systems
SEQUENTIAL CIRCUIT
EXTERNAL EXTERNAL
INPUTS OUTPUTS
CURRENT
STATE NEXT
STATE
8
5 .1
2. Synchronization: Synchronous sequential circuits
What does mean t, t-1, t-2,… etc.? If t is the current time, does t-1 mean t minus 1 second, t
minus 1 minute, ··· ?
Clock
1
0
time
9
5 .1
2. Synchronization: Synchronous sequential circuits
What does mean t, t-1, t-2,… etc.? If t is the current time, does t-1 mean t minus 1 second, t
minus 1 minute, ··· ?
Clock
1
0
time
10
5 .1
2. Synchronization: Synchronous sequential circuits
What does mean t, t-1, t-2,… etc.? If t is the current time, does t-1 mean t minus 1 second, t
minus 1 minute, ··· ?
Clock
1
0
time
Positive edge
cycle Positive pulse
11
5 .1
2. Synchronization: Synchronous sequential circuits
Period Frequency
1 msec (milisecond) = 10-3 sec. 1Hz = 1 cycle/sec
1 mseg (microsecond) = 10-6 sec. 1 KHz (kiloHertz) = 103 Hz.
1 nsec (nanosecond) = 10-9 sec. 1 MHz (megaHertz) = 106 Hz.
1 psec (picosecond) = 10-12 sec. 1 GHz (gigaHertz) = 109 Hz.
… 1 THz (teraHertz) = 1012 Hz.
…
Positive edge
cycle Positive pulse
12
Quiz
What is the period of a clock signal of 20 GHz?
1. 20 msec
2. 50 msec
3. 20 microsec
4. 50 microsec
5. 20 psec
6. 50 psec
13
5 .1
3. Sequential circuit
SEQUENTIAL CIRCUIT
EXTERNAL EXTERNAL
INPUTS OUTPUTS
CURRENT
STATE NEXT
STATE
CK
14
5 .1
SUMMARY
1. Need of other types of circuits (apart from the combinational circuits)
2. Sequential circuits.
3. Concept of circuit internal state (memory).
4. Concept of synchronization. Clock signal CK.
15
5 .1
16
5 .2 EXPLICIT FUNCTIONAL DESCRIPTION OF
SEQUENTIAL CIRCUITS
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
5 .2
1. State transition graph
Set of vertices and directed edges.
Vertices: correspond to the states.
Edges: state transitions .
18
5 .2
1. State transition graph
Set of vertices and directed edges.
Vertices: correspond to the states.
Edges: state transitions.
X=1
Q0
X=1, X=2 o X=3
X=3
X=2
Q1
Q2 X=1 o X=2
X=0
19
5 .2
2. Moore and Mealy machines
What about the circuit outputs?: Two possibilities…
X=1
Q0
Y=1
X=1, X=2 o X=3
X=3
X=2 Q1
Y=0
Q2
Y=1 X=1 o X=2
X=0
20
5 .2
Example
OBJECTIVE: define a circuit that controls a robot vacuum cleaner.
22
5 .2
Example
23
5 .2
Example
24
5 .2
Example
OB=0
SAR
RR=RL=00
OB=1 OB=1 OB=0 OB=1
SRL SRR
RR,RL=01 RR,RL=10
OB=0
OB=1
SAL
OB=0 RR=RL=00
25
5 .2
(EXERCISE)
ODD PARITY DETECTION:
Define the state transition graph of a sequential circuit with one binary input X and one
binary output Y. It generates Y = 1 if the input sequence received up to the current time
includes an odd number of 1’s.
26
5 .2
(SOLUTION)
ODD PARITY DETECTION:
Define the state transition graph of a sequential circuit with one binary input X and one
binary output Y. It generates Y = 1 if the input sequence received up to the current time
includes an odd number of 1’s.
27
5 .2
3. Next state table and output table
28
5 .2
3. Next state table and output table
29
5 .2
3. Next state table and output table
NEXT STATE TABLE
OUTPUT TABLE
30
5 .2
Question
1. The state transition graph defines a circuit with 3 states, 1 input and 1 output
2. The state transition graph defines a circuit with 3 states, 2 inputs and 2 outputs
3. The state transition graph defines a Moore machine
4. The state transition graph defines a Mealy machine
31
5 .2
(EXERCISE)
Define the next state table and the output table, and check the correct assertions:
32
5 .2
(SOLUTION)
Define the next state table and the output table, and check the correct assertions:
33
5 .2
SUMMARY
1. Exhaustive functional definition of sequential machines.
2. State transition graph.
3. Moore and Mealy machines.
4. Next state table and output table.
34
5 .2
35
5 .3 COMPONENTS : BISTABLES
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
5 .3
1. Library components
Components that store 1 bit
Generic names : Bistable, Memory element
37
5 .3
1. Library components
Components that store 1 bit
Generic names : Bistable, Memory element
0 1
1
1 0
2
STATE_0 STATE_1
38
5 .3
1. Library components
0 1
1
1 0
2
STATE_0 STATE_1
D b1 1 Q
b2 2
Load Q
39
5 .3
1.a Type D bistable
D b1 1 Q D Q
b2 2
Load Q
Load Q
LATCH D
40
5 .3
1.a Type D bistable
D b1 1 Q D Q
b2 2
Load Q
Load Q
LATCH D
Load D Q Q Equation:
Next state when Load=1
0 x x Q
1 0 x 0 Q f (Q, D ) D
1 1 x 1
41
5 .3
1.b Other bistables
Bistable Equation
42
5 .3
2. Latches and flip-flops
Type D bistables: LATCHES and FLIP-FLOPS.
Latch: the state can change at any time when the synchronization input signal
Load = 1.
Flip-flop: the state can only change on a positive edge (0 to 1 transition) of the
synchronization signal.
LATCH
D Q D Q
FF
Load Load
Q Q
43
5 .3
2. Latches and flip-flops
LATCH
D Q D Q
FF
Load Load
Q Q
Load
44
5 .3
2. Latches and flip-flops
LATCH
D Q D Q
FF
Load Load
Q Q
Load
45
5 .3
2. Latches and flip-flops
LATCH
D Q D Q
FF
Load Load
Q Q
Load Load
46
5 .3
2. Latches and flip-flops
LATCH
D Q D Q
FF
Load Load
Q Q
Load Load
47
5 .3
2. Latches and flip-flops
LATCH
D Q D Q
FF
Load Load
Q Q
Load Load
48
5 .3
Question
1. Q = 0
2. ENABLE = 0 D D Q
ENABLE
3. D = 0 Q
49
5 .3
3. Asynchronous Set and Reset inputs
Inputs that can modify the bistable state, independently of the synchronization input :
Reset : makes state = 0
Set : makes state = 1
Set
D Q T Q J Q
K
CK CK
CK CK
Q Q Q
D
Reset Reset Reset
Q
50
5 .3
3. Asynchronous Set and Reset inputs
Inputs that can modify the bistable state, independently of the synchronization input :
Reset : makes state = 0
Set : makes state = 1
Set
D Q T Q J Q
K
CK CK
CK CK
Q Q Q
D
Reset Reset Reset
Q
51
5 .3
4. Time diagram
Describes the circuit behavior in function of the time.
52
5 .3
(Exercise)
Complete the following time diagram:
53
5 .3
(Exercise: solution)
Complete the following time diagram:
x = 1: Q0 = Not(Q0);
x = 0: Q0 = 1;
Q0 = 0: Q1 = Not(Q1);
Q0 = 1: Q1 = 1;
54
5 .3
SUMMARY
1. Bistables. Type D bistables.
2. Latches and flip-flops: behavior of latches and flip-flops.
3. Time diagrams.
55
5 .4 SYNTHESIS FROM TABLES
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
5 .4
Summing up …
57
5 .4
1. Flip-flops or latches?
Latches: smaller circuits (rougly: half the number of transistors of a flip-flop)
Flip-flops: more reliable circuits (flip-flops: inputs are sampled on an edge of CK; latches:
transparent while CK=1)
Equation:
D Q T Q
Next state when JKCK= Q
CK CK CK
Q Q
Q f (Q, D ) DQ
Reset Reset Reset
58
5 .4
2. Problem statement
60
5 .4
3.1 Synthesis: STATE ASSIGNMENT
state q1 q0
SAR 0 0
SRR 0 1
SAL 1 0
SRL 1 1
61
5 .4
3.2 Synthesis: tables with encoded internal states
TABLA DE SALIDAS
q1 q0 RR RL
SAR 0 0 0 0 𝑅𝑅 = 𝑞1 . 𝑞0
SRR 0 1 1 0
SAL 1 0 0 0 𝑅𝐿 = 𝑞1 . 𝑞0
SRL 1 1 0 1
63
5 .4
3.3 Synthesis: circuit design
𝐷1 = 𝑞1 . 𝑞0 . 𝑂𝐵 + 𝑞1 . 𝑂𝐵 + 𝑞1 . 𝑞0
𝐷0 = 𝑂𝐵
𝑅𝑅 = 𝑞1 . 𝑞0
𝑅𝐿 = 𝑞1 . 𝑞0
64
5 .4
4. Mealy
Next state table and output table can be merged. Example:
a=0 / z=0
S0 Estado
State a State
Estado z
S0 0 S0 0
a=1 / z=0
S0 1 S1 0
a=1 / z=1
S1 S1 0 S2 1
S1 1 S2 1
a=x / z=1
S2 0 S2 0
S2 S2 1 S0 1
65
5 .4
5. Comment
In most cases a reset signal is necessary to put the circuit in a known initial state.
66
5 .4
Question 1
1. 1
2. 2
3. 4
4. It depends on the values of A and B
67
5 .4
Question 2
1. 1
2. 2
3. Both
4. None
68
5 .4
SUMMARY
Steps that must be followed to synthesize a sequential circuit from its next state table and
its output table:
a) Compute the number of flip-flops.
b) Encode the states with 0’s and 1’s.
c) Compute 𝑞𝑖 Δ = 𝑓 𝑖𝑛𝑝𝑢𝑡𝑠, 𝑠𝑡𝑎𝑡𝑒𝑠 from the next state tables.
d) Compute 𝐷𝑖 in function of 𝑞𝑖 Δ (in the case of type D flip-flops: 𝐷𝑖 = 𝑞𝑖 Δ).
e) Compute 𝑜𝑢𝑡𝑖 = 𝑓 𝑖𝑛𝑝𝑢𝑡𝑠, 𝑠𝑡𝑎𝑡𝑒𝑠 (Mealy), or 𝑜𝑢𝑡𝑖 = 𝑓 𝑠𝑡𝑎𝑡𝑒𝑠 (Moore).
f) Design the circuit (don’t forget CK and Reset).
69
5 .5 AN EXAMPLE OF SYNTHESIS
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
5 .5
Specification
Design a Serial Adder: it adds two n-bit numbers A and B that are serially inputted (inputs
inA and inB, one bit per clock cycle):
∀𝑛
0, an-1, an-2, …, a1, a0 inA
0, bn-1, bn-2, …, b1, b0 inB
Serial Adder S sn, sn-1, …, s1, s0
CK >
(initial most significant bits 0's are added to A and B as the sum of two
n-bit numbers is an (n+1)-bit number)
71
5 .5
Question 1
What information should be internally stored within the circuit in order to perform the
desired operation?
o The value of n.
o The latest computed 1-bit sum
ai+bi .
o The carry generated by the latest
computed 1-bit sum ai+bi .
o None; the serial adder can be
implemented by a combinational
circuit.
an-1, an-2, …, a1, a0 inA
bn-1, bn-2, …, b1, b0 inB
Serial Adder S sn, sn-1, …, s1, s0
CK >
72
5 .5
Question 2
The correct answer is “The carry generated by the latest computed 1-bit sum ai+bi .”
So, which are the minimum number of internal states and the minimum number of flip-
flops necessary to implement the circuit?:
73
5 .5
Question 3
The correct answer is “2 states, 1 flip flop “. Assume that state C0 corresponds to a latest
generated carry = 0, and C1 to a latest generated carry = 1. What state transition graph(s)
describe(s) the circuit?
1. 2. 3.
(inA,inB)=00, S=0 (inA,inB)=00, S=1 (inA,inB)=11, S=0
(inA,inB)=01 or 10, S=1 (inA,inB)=01 or 10, S=0 (inA,inB)=01 or 10, S=1
C0 C0 C0
(inA,inB)=00, S=1 (inA,inB)=11, S=0 (inA,inB)=00, S=0 (inA,inB)=11, S=1 (inA,inB)=00, S=1 (inA,inB)=11, S=0
C1 C1 C1
74
5 .5
Question 4
o Moore
o Mealy
75
5 .5
Question 5
Consider the following graph and assign 0 to state C0 and 1 to state C1. Which of the
following tables correspond to the graph? (q is the flip-flop state)
76
5 .5
Question 6
Synthesize the Boolean functions D (next state) and S (output) that correspond to the
preceding tables. Check which of them is correct:
77
5 .5
Question 7
1. 3.
2.
78
5 .5
SUMMARY
A Serial Adder has been implemented.
79