Multi Clock Design
Multi Clock Design
Contents
Product in
Mind
Introduction
Clock Domain Crossing Issues
Synchronous clock domain crossings
examples
Exercise Dual clock FIFO design
(2)
INTRODUCTION
Introduction
Product in
Mind
cpu_clock
CPU_core
MEM_
CONTROLLER
bus_clock
timer_clock
uart_clock
UART
TIMER
Product in
Mind
A
FA
C1
FB
C2
Product in
Mind
clock edge
D
CLK
Q
DFF
tsu
setup time
CLK
th
hold time
7
(7)
Product in
Mind
C1
A
C2
B
A sampled by C2
Clock signal is
initially metastable
(8)
Metastability effect
Vdd
on
Product in
Mind
Ileakage
Imax
on
NOT gate
(9)
Metastable solution
Product in
Mind
FA
FB
Bsync
D
FB
C1
C2
(10)
Data Loss
A generated by C1
Product in
Mind
C1
A
C2
B
Data capture in 2nd
clock cycle
Product in
Mind
Product in
Mind
C1
A
C2
B
Data Incoherency
Product in
Mind
C1
X[0]
X[1]
Invalid data
C2
Y[0]
Y[1]
Valid data
Product in
Mind
B[0]
D
FB
FA
C1
0
A[1]
D
B[1]
D
FB
FA
C1
EN
D
FA
FB
Bsync
D
FB
C1
C2
(15)
Bin [3:0]
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Gray [3:0]
0000
0001
0011
0010
0110
0111
0101
0100
1100
1101
1111
1110
1010
1011
1001
1000
Product in
Mind
(16)
req
(Transit active)
Product in
Mind
req_sync
D
FB
FB
C2
Clock
Domain
C1
ack_sync
ack
QD
QD
FA
FA
(transit_done)
Clock
Domain
C2
C1
Data bus
(17)
Synchornizer
Clock
Domain
C1
Product in
Mind
Clock
Domain
C2
req_sync
C2
Idle
Idle
ack_sync
Synchornizer
Start
req
Done
ack_sync
go
Wait
req
ack
(transit_done)
C1
!ack_sync
req_sync
Done
Start
Process
ack
Data bus
(18)
Product in
Mind
Dual clock
FIFO
Clock
Domain
C1
C1
C2
Clock
Domain
C2
Dual clock
FIFO
SYNCHRONOUS CLOCK
DOMAIN CROSSINGS
EXAMPLES
Product in
Mind
C1
A
C2
B
Product in
Mind
C1
A
C2
3/4 clock
cycle
These are the clocks having the same time period but a
constant phase difference. A typical example is the use of a
clock and its inverted clock.
Another example is a clock which is phase shifted from its
parent clock, for example by T/4 where T is the time period
of the clocks.
(22)
Product in
Mind
C1
C2
T
2T
3T
Questions and
Discussion
(24)
Product in
Mind
clk
rst_n
rd
data_out[7:0]
status signals
data_in[7:0]
wr
26
(26)
Product in
Mind
wclk domain
wdata
wdata
waddr
FIFO
wptr
and
full
flag
wq2_rptr
wclk
wrst_n
rdata
rdata
wenable
wfull
winc
rclk domain
waddr
raddr
raddr
FIFO
rptr and
empty
flag
rempty
rinc
rq2_rptr
rclk
rrst_n
(27)
Problem
Product in
Mind
(28)
Product in
Mind
(29)
Binary-to-Gray
b[n-1]
b[n-2]
Product in
Mind
b[n-3]
b[1]
b[0]
Binary to Gray
converter
(MSB)
g[n-1]
gray[0]
gray[1]
gray[2]
gray[3]
=
=
=
=
g[n-2]
bin[0]
bin[1]
bin[2]
bin[3]
g[n-3]
g[0]
^ bin[1];
^ bin[2];
^ bin[3];
^ 1'b0 ; // same as gray[3] = bin[3];
(30)
Product in
Mind
(31)
Product in
Mind
(32)
Product in
Mind
(33)
Product in
Mind
(34)
Product in
Mind
only use n-1 bits to address the FIFO memory
rbin [ASIZE:0]
rbnext
rinc
binary
reg
rempty
Binary to
Gray
converter
rgnext
rptr [ASIZE:0]
gray
reg
rclk
rrst_n
=?
rempty
rq2_wptr
wptr [ASIZE:0]
rq1_wptr
Product in
Mind
only use n-1 bits to address the FIFO memory
wbin [ASIZE:0]
wbnext
winc
binary
reg
wfull
Binary to
Gray
converter
wgnext
wptr [ASIZE:0]
gray
reg
wclk
{~wptr [ASIZE:ASIZE-1],
wptr [ASIZE-2:0]
=?
wrst_n
wfull
wq2_rptr
rptr [ASIZE:0]
wq1_rptr