37
EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Embed Size (px)

Citation preview

Page 1: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

EE365Adv. Digital Circuit Design

Clarkson University

Lecture #13

Clock Skew & Synchronization

Page 2: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Topics

Rissacher EE365Lect #13

• More Serial

• Clock Skew

• Synchronization

Page 3: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Serial data systems (e.g., TPC)

Rissacher EE365Lect #13

Page 4: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Serial data in the phone system (E-1) • 2.048 Mb/s links between phone switches and

subscribers– partitioned into 32 64 Kb/s channels

• Each channel gets a timeslot in a “frame” where it can send 8 bits every 125 sec.– 8000 frames/sec

Rissacher EE365Lect #13

Page 5: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Timeslot details

count = 255

Rissacher EE365Lect #13

Page 6: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Parallel-to-serial conversion

256

LSBs are bit number

Assert shift-registerLOAD input during bit 7

Timeslot number canbe decoded and usedto select source ofparallel data

Serial data todestination

count = 255

Rissacher EE365Lect #13

Page 7: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Serial-to-parallel

conversion

Synchronize destination’s counter to source’s

Shift in serial data

Detect that acomplete bytehas beenreceived

Holding registerfor completebyte

Note:loads0…0

Rissacher EE365Lect #13

Page 8: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Destination timing

Serial-in, parallel-outshift register outputs

Holding-register outputsGrab complete byte when available

Rissacher EE365Lect #13

Page 9: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Serial communication on ONE wire• Serial communication requires three signals:

CLOCK, SYNC, and DATA. Yet only one “wire” is used. How?

• One solution: Manchester code.

• Or use a phase-locked loop (analog circuit)to extract clock from the data:

Rissacher EE365Lect #13

Page 10: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Still a couple of problems• Framing -- SYNC signal

– Solution: Use a unique data pattern for SYNC

• PLL clock recovery -- what if too many zeroes are transmitted? PLL can’t stay in sync.– Solution: Use a code that guarantees a minimum

number of ones– Phone system: Map 00000000 --> 00000010

(creating slight voice distortion)

• Gigabit Ethernet: Uses 8B10B code, solving both problems– Map each byte into 8 bits– Use only a “good” subset of 210 code words– Use another code word for synchronization

Rissacher EE365Lect #13

Page 11: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Synchronous System Structure

Everything is clocked by the same, common clock

Rissacher EE365Lect #13

Page 12: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Typical synchronous-system timing

• Outputs have one complete clock period to propagate to inputs.

• Must take into account flip-flop setup times at next clock period.

Rissacher EE365Lect #13

Page 13: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Clock Skew– Clock signal may not reach all flip-flops simultaneously.– Output changes of flip-flops receiving “early” clock may

reach D inputs of flip-flops with “late” clock too soon.

Reasons for slowness:(a) wiring delays(b) capacitance(c) incorrect design

Rissacher EE365Lect #13

Page 14: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Clock-skew calculation

• tffpd(min) + tcomb(min) thold tskew(max) > 0

• First two terms are minimum time after clock edge that a D input changes

• Hold time is earliest time that the input may change

• Clock skew subtracts from the available hold-time margin

• Compensating for clock skew:– Longer flip-flop propagation delay– Explicit combinational delays– Shorter (even negative) flip-flop hold times

Rissacher EE365Lect #13

Page 15: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

In-Class Practice Problem

Rissacher EE365Lect #13

tffpd(min) = 5 ns

tcomb(min) = 20 ns

thold = 20 ns

tskew(max) = 10 ns

Comb Logic(Excitation Eqns)

CLKDelay

Calculate whether clock-skew is an issue for the indicated Flip-Flop

Page 16: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

In-Class Practice Problem

Rissacher EE365Lect #13

tffpd(min) = 5 ns

tcomb(min) = 20 ns

thold = 20 ns

tskew(max) = 10 ns

tffpd(min) + tcomb(min) thold tskew(max) = -5 ns

Calculate whether clock-skew is an issue for the indicated Flip-Flop

Page 17: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

In-Class Practice Problem

Rissacher EE365Lect #13

tffpd(min) = 5 ns

tcomb(min) = 20 ns

thold = 20 ns

tskew(max) = 10 ns

Comb Logic(Excitation Eqns)

CLKDelay

Now add a delay to the circuit to fix the issue.

Page 18: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

In-Class Practice Problem

Rissacher EE365Lect #13

tffpd(min) = 5 ns

tcomb(min) = 20 ns

thold = 20 ns

tskew(max) = 10 ns

Comb Logic(Excitation Eqns)

CLKDelay

> 5 ns

Page 19: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Example of bad clock distribution

Rissacher EE365Lect #13

Page 20: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Clock distribution in ASICs

• This is what a typical ASIC router will do if you don’t lay out the clock by hand.

Rissacher EE365Lect #13

Page 21: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

“Clock-tree” solution

• Often laid out by hand• Wide,fast metal (low R ==> fast RC time constant)

Rissacher EE365Lect #13

Page 22: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Gating the

clock

• Definitely a no-no– Glitches possible if control signal (CLKEN) is

generated by the same clock– Excessive clock skew in any case.

Rissacher EE365Lect #13

Page 23: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

If you really must gate the

clock...

Rissacher EE365Lect #13

Page 24: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Asynchronous inputs

• Not all inputs are synchronized with the clock• Examples:

– Keystrokes– Sensor inputs– Data received from a network (transmitter has its

own clock)

• Inputs must be synchronized with the system clock before being applied to a synchronous system.

Rissacher EE365Lect #13

Page 25: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

A simple synchronizer

Rissacher EE365Lect #13

Page 26: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Only one synchronizer per input

Rissacher EE365Lect #13

Page 27: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Even worse

• Combinational delays to the two synchronizers are likely to be different.

Rissacher EE365Lect #13

Page 28: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

The way to do it

• One synchronizer per input• Carefully locate the synchronization points in

a system.• But still a problem -- the synchronizer output

may become metastable when setup and hold time are not met.

Rissacher EE365Lect #13

Page 29: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Recommended synchronizer design

• Hope that FF1 settles down before “META” is sampled.– In this case, “SYNCIN” is valid for almost a full

clock period.– Can calculate the probability of “synchronizer failure”

(FF1 still metastable when META sampled)

Rissacher EE365Lect #13

Page 30: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Metastability decision window

Rissacher EE365Lect #13

Page 31: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Metastability resolution time

Rissacher EE365Lect #13

Page 32: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Flip-flop metastable behavior• Probability of flip-flop output being in the

metastable state is an exponentially decreasing function of tr (time since clock edge, a.k.a.

“resolution time”).

• Stated another way,

MTBF(tr) = exp(tr /) / [T0 f a] , where

and T0 are parameters for a particular flip-flop,

f is the clock frequency, anda is the number of asynchronous transitions / sec

Rissacher EE365Lect #13

Page 33: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Typical flip-flop metastability parameters

exp(tr /)________ [T0 f a]

MTBF =

MTBF = 1000 yrs.F = 25 MHza = 100 KHz

tr = ?

Rissacher EE365Lect #13

Page 34: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Is 1000 years enough?

• If MTBF = 1000 years and you ship 52,000 copies of the product, then some system experiences a mysterious failure every week.

• Real-world MTBFs must be much higher.• How to get better MTBFs?

– Use faster flip-flops• But clock speeds keep getting faster, thwarting this approach.

– Wait for multiple clock ticks to get a longer metastabilty resolution time

• Waiting longer usually doesn’t hurt performance• …unless there is a critical “round-trip” handshake.

Rissacher EE365Lect #13

Page 35: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Multiple-cycle synchronizer

• Clock-skew problem

Rissacher EE365Lect #13

Page 36: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

De-skewed multiple-cycle synchronizer

• Necessary in really high-speed systems• DSYNCIN is valid for almost an entire clock

period.

Rissacher EE365Lect #13

Page 37: EE365 Adv. Digital Circuit Design Clarkson University Lecture #13 Clock Skew & Synchronization

Next time

• CPLDs

• FPGAs

Rissacher EE365Lect #13