Lecture 4
Lecture 4
(WBCS010-05)
Lecture 4: Sequential Logic
Reza Hassanpour
[email protected]
Introduction
› The output from combinational logic circuits
depends only on their inputs.
› Digital computers need to store data/state, and
decide the output based on inputs and stored
data/state.
› Sequential logic circuits the output depends upon
present as well as past input.
2-bit decoder
3
Multiplexer (Mux) (recap)
› A mux has 2n data inputs, n select inputs, and one output
› The select bits are used to "choose" one of the data inputs to flow
through to the output
4-to-1 mux
4 input bits,
2 select bits
4
Full Adder (1-bit binary addition) (recap)
5
Decoder (more)
00 /A /B A
A
01 /A B B 3:8
2:4 C
B 10 A /B
11 A B
A B X Y
A 0 0 0 0
2:4 X
B 0 1 1 0
Y
1 0 1 0
› What are X and Y? 1 1 0 1
› What if we name X = S (sum) and Y = Cout?
› This is a combinational circuit called half-adder
› Can we also make a full-adder with a decoder?
6
Multiplexer (Mux) (more)
4:1 X
AB
7
Sequential Logic Circuit: Finite State Machine
8
What is State?
9
Example: A Combination Lock
› Four States:
› A: The lock is not open, and no relevant operations have been performed
› B: The lock is not open, and the user has completed the R-13 operation
› C: The lock is not open, and the user has completed R-13, followed by L-22
› D: The lock is open. (The user completed R-13, L-22, and R-3)
10
State Diagram
11
Finite State Machine: Definition
› A finite state machine (FSM) is a description of a system with the
following elements:
1. A finite set of states
2. A finite number of external inputs
3. A finite number of external outputs
4. An explicit specification of all state transitions
5. An explicit specification of what determines each output value
nickel = 5c
dime = 10c
14
FSM Example: Danger Sign (US)
15
Danger Sign: State Diagram
16
Danger Sign: Implementation
Given current state,
what should outputs be?
17
Danger Sign: Truth Tables
› Two truth tables: one for each combinational logic circuit.
› On left, translate state S[1:0] to output signals:
W = lights 1 & 2, X = lights 3 & 4, V = light 5
› On right, translate input (Switch) and state S[1:0] to next
state: S'[1:0]
Switch S[1:0] S'[1:0]
S[1:0] W X V
0 00 00
00 0 0 0 0 01 00
01 1 0 0 0 10 00
10 1 1 0 0 11 00
1 00 01
11 1 1 1
1 01 10
› All information can be 1 10 11
read from the state diagram 1 11 00
18
Danger Sign: Combinational Logic
19
FSM Summary
00 0 0 0 0 00 00
0 01 00
01 1 0 0
0 10 00
10 1 1 0
0 11 00
11 1 1 1
1 00 01
1 01 10
1 10 11
1 11 00
20
Synchronous versus Asynchronous
T (period) [s]
f(frequency) [Hz]
T=1/f
2 ns ➙ 500MHz
22
Storage Elements: D-Latch?
› Problem:
› As long as WE = 1, the new data will change the stored data.
› Solution: flip-flop!
23
Signal Propagation Delay
› Propagation delay is the amount of time required after
an input signal is applied until the output of the circuit
has stabilized to the correct output signal.
26
Storage Elements: Flip-flop
When Clock = 0 (write phase), new data (D) When Clock = 1 (read phase), data from
is stored in the Master latch, but output (Q) Master is stored into the Slave and the output
does not change. (Q) changes to the new value.
27
Timing Diagram
Transistors (logic gates, latches) and wires are not ideal. It
takes time for the electrons to do the work or travel.
› As long as worst-case propagation delay through the logic is less than half of the
clock cycle, state will properly change each clock cycle.
› Because of this behavior, flip-flop is considered an edge-triggered storage
element: its state changes on the clock edge. A latch is level-triggered, because it
changes as long as the WE signal is enabled.
28
Clock Frequency
› Critical path
0
Combinational
circuit
0
0 T
clock
How fast can the clock be?
FYI: T= 1/f
where T is period [s] and f is frequency [Hz]
The period of 1GHz clock signal is 1 ns
29
Registers
› Registers are a type of computer memory used by the
CPU.
› It acts like an N-bit memory
› They can be built out of latches/flip flops
Registers with Load Control
› The input to the memory cells (flip-flops) of a
register may change with changes in the outputs of
the combinational circuits.