Professional Documents
Culture Documents
Synchronization in Digital
Digital Abstraction depends on all
Logic Circuits signals in a system having a valid logic
state
Ryan Donohue Therefore, Digital Abstraction depends
Rdonohue@yahoo.com on reliable synchronization of external
events
system clock 0
Vin Q
D 1 Vout
CLK
'0' state Vin
1
Quick Metastability Review Mean Time Between Failures
'0' state '1' state '0' state '1' state For a FF we can compute its MTBF,
which is a figure of merit related to
metastability.
FF in 'normal' states FF in metastable state
Once a FF goes metastable (due to a setup tr resolution time (time since clock edge)
time violation, say) we can_t say when it will (tr/t)
MTBF(tr) = e
f sampling clock frequency
assume a valid logic level or what level it Tofa
a asynchronous event frequency
t and To FF parameters
might eventually assume
The only thing we know is that the probability For a typical .25um
of a FF coming out of a metastable state ASIC library FF
For f = 100MHz, MTBF = 20.1 days
increases exponentially with time tr = 2.3ns
t = 0.31ns
a = 1MHz
To = 9.6as
CLK SIG1
2
Single Synchronizer analysis Flip Flop design is important?
MTBF of this system is roughly: Dynamic FFs not suitable for synchronizers
(tr/t) (t /t) For a typical .25um
since they have no regeneration
MTBF(tr) = e x e r
ASIC library FF
Tofa Tof CLK CLK f
tr = 2.3ns For f = 100MHz, D Q
MTBF = 9.57x1010 years t = 0.31ns a = 1MHz f f
Age of Earth = 5x109 years To = 9.6as
D Q
f
SIG
D Q
META
D Q
SIG1
D Q
SIG2
Special _SYNC_ FFs should be used for the
primary synchronizer if available
CLK
SYNC
Vout VTC of
'1' state
SYNC FF
series inverters
CLK
SIG META SIG1 VTC of SIG
D Q D Q regular FF
SYNC series inverters SIG2
D Q D Q
SYNC
CLK
3
Bus Synchronization Handshaking is the Answer
Need a single point of synchronization for the
Obvious approach is to use single signal entire bus
synchronizers on each bit CLK
WRONG! SIG[1:0]
REQ
SIG[0] SIG1[0]
D Q D Q ACK
SYNC
CLK
SIG 2
CLK
SIG[0]
REQ
SIG[1] DQ DQ
SIG[1] SIG1[1] Hand Hand
SIG1[0] CLK2
D Q D Q shaking shaking
SYNC FSM
SIG1[1] ACK FSM
Q D Q D
CLK1
CLK
CLK1 CLK2
4
High Bandwidth solutions Abstract FIFO design
Handshaking works great, but reduces Ideal dual port FIFO writes with one
bandwidth at the clock crossing clock, reads with another
interface because each piece of data FIFO storage provides buffering to help
has many cycles of series handshaking. rate match load/unload frequency
Correctly designed FIFOs can increase Flow control needed in case FIFO gets
bandwidth across the interface and still totally full or totally empty
maintain reliable communication DATA_IN DATA_OUT
FULL EMPTY
CLK1 CLK2
an on-chip SRAM
SRAM
circular buffer using FEh
pointers.
PORT1 PORT 2
5
FIFO pointers and flow control FIFO in detail
Generation of FULL and EMPTY signals. We have a problem!
$ FIFO is FULL when write pointer catches read
pointer Dual Port
SRAM
always @(posedge clk1)
FULL <= (WR_PNTR == RD_PNTR) && ((OLD_WR_PNTR + 1 == RD_PNTR) || FULL) PORT1 PORT 2
$ Write passing read overwrites unread data To generate FULL/EMPTY conditions the write
$ Read passing write re-reads invalid data logic needs to see the read pointer and the read
logic needs to see the write pointer!
(when they change, they increment by 1) A standard single bit input [SIZE-1:0] bin;
output [SIZE-1:0] gray;
$ Gray coding the pointer value means at most one We can still do binary math to module gray2bin (gray,bin);
bit will change per cycle _ we can only be _off by increment the pointer. parameter SIZE = 4;
6
Pointer Synchronizer pitfall Answer to pitfall
PTR_IN PTR_OUT
Write and read pointers need to be registered bin2gray
D
SYNC
Q D Q gray2bin
$ Typically EMPTY = 1 when READ catches WRITE. Works for any phase/frequency relationship
We need EMPTY = 1 when READ catches WRITE-1. between CLK1 and CLK2
7
Mesosynchronous Designs Mesosynchronous Tradeoffs
When two systems of bounded frequency Benefits to mesosynchronous designs
need communicate, open loop $ Less synchronization circuitry
synchronization circuits can be used (no ACK) $ Synchronizer might have lower latency vs. full 4-
CLK phase handshaking
SIG[1:0]
Costs of mesosynchronous designs
REQ
$ Synchronizer only works at certain frequency
2
ratios (may hamper bringup/debug)
SIG
REQ
Hand CLK2
DQ DQ
Hand Assume:
$ Intolerant of spec mistakes (maybe that unload
shaking
FSM
shaking
FSM CLK2 = CLK1 +- 5% frequency was supposed to be +- 50%!)
CLK1 CLK2