Escolar Documentos
Profissional Documentos
Cultura Documentos
Sequential circuits
q
q
q
q
q
n
n
state is memory
state is an "output" and an "input" to combinational logic
combination storage elements are also memory
new
C1
C2
multiplexer
shift registers
simple counters
reset
C3
mux
control
comb. logic
state
comparator
clock
VI - Sequential Logic
equal
value
Basic registers
q
Asynchronous inputs
q
Timing methodologies
q
Sequential circuits
open/closed
2
VI - Sequential Logic
X1
X2
Xn
"stored value"
switching
network
Z1
Z2
Zn
"0"
"remember"
"data"
VI - Sequential Logic
VI - Sequential Logic
"load"
"stored value"
4
Q'
R
S
Timing behavior
Reset
S'
Q'
Set
Reset
Q'
R'
\Q
5
VI - Sequential Logic
Q'
Q
hold
0
1
unstable
SR=00
SR=01
Q Q'
1 0
SR=01
Q Q'
0 1
SR=01
Q'
Q Q'
0 0
SR=00
SR=10
SR=10
State diagram
q
SR=11
SR=01
Q Q'
1 1
Q Q'
1 0
SR=11
VI - Sequential Logic
SR=10
Q Q'
0 1
R
0
1
0
1
Race
100
S
0
0
1
1
Set
R'
VI - Sequential Logic
Hold
possible oscillation
between states 00 and 11
7
VI - Sequential Logic
Q Q'
0 0
SR=11
SR=00
SR=11
SR=00
SR=10
Q Q'
1 1
Q'
q
q
SR=01
Q Q'
0 1
SR=01
Q Q'
1 0
SR=00
SR=10
S
0
0
0
0
1
1
1
1
SR=10
SR=11
Q Q'
0 0
SR=11
SR=11
SR=00
VI - Sequential Logic
SR=00
9
Q'
S
0
0
0
0
1
1
1
1
R
0
0
1
1
0
0
1
1
S
1
1
1
1
0
0
0
0
VI - Sequential Logic
R
1
1
0
0
1
1
0
0
Q(t)
0
1
0
1
0
1
0
1
Q(t+)
0
1
0
0
1
1
X
X
Q(t)
Q(t+)
hold
Q(t)
set
not allowed
Q(t)
R
characteristic equation
Q(t+) = S + R Q(t)
10
otherwise, the
slightest glitch on R
or S while enable is
low could cause
change in value
stored
R'
enable'
Q'
S'
Set
100
Reset
S'
R'
enable'
characteristic equation
Q(t+) = S + R Q(t)
Q(t+)
0
hold
1
0
reset
0
1
set
1
X not allowed
X
R
S
reset
Q(t)
0
1
0
1
0
1
0
1
Q(t)
Q'
R
0
0
1
1
0
0
1
1
VI - Sequential Logic
SR=10
SR=00
SR=01
Q
Q'
11
VI - Sequential Logic
12
Clocks
n
Clocks (contd)
n
clock
S
stable changing stable changing stable
R and S
period
clock
VI - Sequential Logic
13
Cascading latches
n
n
q
q
need to be able to control flow of data from one latch to the next
move one latch per clock period
have to worry about logic between latches (arrows) that is too fast
R
S
Q
Q
R
S
14
Master-slave structure
VI - Sequential Logic
master-slave flip-flop
twice as much logic
output changes a few gate delays after the falling edge of clock
but does not affect any cascaded flip-flops
slave stage
master stage
Q
Q
clock
CLK
VI - Sequential Logic
15
VI - Sequential Logic
16
D flip-flop
Set
Reset
1s
catch
q
q
slave stage
master stage
R
P
P
q
q
CLK
P
P
Q
Q
slave stage
master stage
CLK
S
R
Master
Outputs
CLK
Slave
Outputs
VI - Sequential Logic
10 gates
17
Edge-triggered flip-flops
n
holds D when
clock goes low
0
R
Clk=1
Q
Step-by-step analysis
D
sensitive to inputs only near edge of clock signal (not while high)
18
VI - Sequential Logic
negative edge-triggered D
flip-flop (D-FF)
D
R
Clk=0
Clk=0
S
S
D
0
holds D when
clock goes low
D
VI - Sequential Logic
D
Copyright 2004, Gaetano Borriello and Randy H. Katz
D
characteristic equation
Q(t+1) = D
19
new D
new D old D
data
VI - Sequential Logic
20
Positive edge-triggered
q
Timing methodologies
n
100
D
CLK
Qpos
positive edge-triggered FF
Qneg
negative edge-triggered FF
Qneg
VI - Sequential Logic
21
D Q
CLK
positive
edge-triggered
flip-flop
D Q
G
clock
clock
22
D
CLK
Qedge
D Q
input
VI - Sequential Logic
VI - Sequential Logic
D Q
clock:
Tsu Th
(1) correct inputs, with respect to time, are provided to the flipflops
(2) no flip-flop changes state more than once per clocking event
Definition of terms
q
Qpos
Qlatch
CLK
stable changing
transparent
(level-sensitive)
latch
data
clock
23
VI - Sequential Logic
24
Type
unclocked
latch
always
level-sensitive
latch
clock high
(Tsu/Th around falling
edge of clock)
master-slave
flip-flop
clock high
(Tsu/Th around falling
edge of clock)
negative
edge-triggered
flip-flop
Clk
q
q
Th
1.8
ns
0.5
ns
Tsu
Th
1.8
ns
0.5
ns
Tw
3.3
ns
Tw
3.3
ns
Tpd
3.6 ns
1.1 ns
Tpd
3.6 ns
1.1 ns
all measurements are made from the clocking event (the rising edge of the clock)
VI - Sequential Logic
25
q
q
IN
Q0
D Q
Q1
q
q
100
Tsu
1.8ns
Tsu
1.8ns
Tp
1.1-3.6ns
Tp
1.1-3.6ns
Q0
CLK
Q1
CLK
Copyright 2004, Gaetano Borriello and Randy H. Katz
timing constraints
guarantee proper
operation of
cascaded components
Q1
IN
VI - Sequential Logic
26
OUT
CLK
Shift register
q
VI - Sequential Logic
Th
0.5ns
27
VI - Sequential Logic
Th
0.5ns
Copyright 2004, Gaetano Borriello and Randy H. Katz
28
Clock skew
n
The problem
q
q
q
q
CLK0
CLK1
CLK1 is a delayed
version of CLK0
Q0
Q1
100
In
Development of D-FF
q
similar to R-S but with 1-1 being used to toggle output (complement state)
good in days of TTL/SSI (more complex input function: D = J Q + K Q
not a good choice for PALs/PLAs as it requires 2 inputs
can always be implemented using D-FF
original state: IN = 0, Q0 = 1, Q1 = 1
due to skew, next state becomes: Q0 = 0, Q1 = 0, and not Q0 = 0, Q1 = 1
VI - Sequential Logic
29
30
Asynchronous circuits
q
Synchronization failure
VI - Sequential Logic
logic 1
inputs can change at any time, will not meet setup/hold times
dangerous, synchronous inputs are greatly preferred
cannot be avoided (e.g., reset signal, memory wait, user input)
VI - Sequential Logic
logic 0
31
logic 1
VI - Sequential Logic
logic 0
oscilloscope traces demonstrating
synchronizer failure and eventual
decay to steady state
32
Clocked
Synchronous
System
Async
Input
Synchronizer
Q0
D Q
Async
Input
D Q
Clock
Clock
asynchronous
input
Q1
D Q
synchronized
input
Q1
D Q
Clock
Clock
Clk
Q0
D Q
synchronous system
VI - Sequential Logic
33
Q1
In is asynchronous and
fans out to D0 and D1
VI - Sequential Logic
35
(set-dominant)
(reset-dominant)
CLK
Q0
34
In
Flip-flop features
VI - Sequential Logic
VI - Sequential Logic
36
Registers
n
Shift register
n
Examples
q
q
OUT1
shift registers
counters
OUT1
OUT2
OUT3
OUT4
IN
"0"
D Q
D Q
OUT2
OUT3
D Q
OUT4
D Q
CLK
R S
R S
R S
R S
D Q
D Q
D Q
D Q
CLK
IN1
VI - Sequential Logic
IN2
IN3
IN4
37
q
q
q
right_out
right_in
clock
input
VI - Sequential Logic
clear
1
0
0
0
0
s0
0
0
1
1
s1
0
1
0
1
new value
0
output
output value of FF to left (shift right)
output value of FF to right (shift left)
input
Nth cell
output
left_in
left_out
clear
s0
s1
38
Holds 4 values
q
VI - Sequential Logic
to N-1th
cell
to N+1th
cell
Q
D
CLK
s1
0
1
0
1
function
hold state
shift right
shift left
load new input
CLEAR
0 1 2 3 s0 and s1
control mux
Q[N-1]
(left)
39
VI - Sequential Logic
Input[N]
Q[N+1]
(right)
40
10
Pattern recognizer
parallel outputs
OUT1
OUT2
OUT3
OUT4
parallel inputs
D Q
IN
serial transmission
VI - Sequential Logic
41
Counters
n
VI - Sequential Logic
D Q
42
OUT1
IN
OUT1
IN
D Q
Activity
D Q
CLK
D Q
D Q
OUT2
OUT3
D Q
D Q
D Q
OUT2
D Q
OUT3
OUT4
D Q
CLK
OUT4
D Q
Counts through the sequence: 1000, 1100, 1110, 1111, 0111, 0011, 0001, 0000
CLK
VI - Sequential Logic
43
VI - Sequential Logic
44
11
Binary counter
n
OUT2
D Q
OUT3
D Q
OUT4
D Q
CLK
D
C
B
A
RCO
QD
QC
LOAD QB
QA
CLK
CLR
"1"
VI - Sequential Logic
45
Offset counters
n
"1"
"0"
"1"
"1"
"0"
"0"
46
EN
RCO
QD
D
QC
C
QB
B
QA
A
LOAD
CLK
CLR
Flip-flops
q
q
n
n
Shift registers
Simple counters
VI - Sequential Logic
VI - Sequential Logic
"1"
EN
"0"
"0"
"0"
"0"
D
C
B
A
LOAD
CLK
CLR
RCO
QD
QC
QB
QA
47
VI - Sequential Logic
48
12
Flip-flop in Verilog
n
More Flip-flops
Synchronous/asynchronous reset/set
single thread that waits for the clock
three parallel threads only one of which waits for the clock
q
q
Synchronous
input clk, d;
output q;
reg
q;
module dff
input
output
reg
(clk, s, r, d, q);
clk, s, r, d;
q;
q;
Asynchronous
module dff
input
output
reg
endmodule
(clk, s, r, d, q);
clk, s, r, d;
q;
q;
always @(posedge r)
q = 1'b0;
always @(posedge s)
q = 1'b1;
always @(posedge clk)
q = d;
endmodule
endmodule
VI - Sequential Logic
49
VI - Sequential Logic
always @(clk)
q = d;
Example: swap
always @(posedge CLK)
begin
temp = B;
B = A;
A = temp;
end
endmodule
VI - Sequential Logic
50
input clk, d;
output q;
reg
q;
51
VI - Sequential Logic
52
13
VI - Sequential Logic
1b0;
1b0;
1b0;
1b0;
53
VI - Sequential Logic
input clk;
output c8, c4, c2, c1;
input clk;
output c8, c4, c2, c1, rco;
=
=
=
=
endmodule
VI - Sequential Logic
count[3];
count[2];
count[1];
count[0];
Basic registers
q
q
use of clocks
cascaded FFs work because propagation delays exceed hold times
beware of clock skew
c8 = count[3];
c4 = count[2];
c2 = count[1];
c1 = count[0];
rco = (count == 4b1111);
Timing methodologies
initial begin
count = 0;
end
assign
assign
assign
assign
54
shift registers
counters
endmodule
Copyright 2004, Gaetano Borriello and Randy H. Katz
55
VI - Sequential Logic
56
14