Top Banner
CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling Timing Behavior Glitches/hazards and how to avoid them FSM Partitioning What to do when the state machine doesn’t fit! State Machine Signaling Introducing Idle States (synchronous model) Four Cycle Signaling (asynchronous model) Dealing with Asynchronous Inputs Metastability and synchronization
32

CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 1

State Machine Signaling Timing Behavior

Glitches/hazards and how to avoid them

FSM Partitioning What to do when the state machine doesn’t fit!

State Machine Signaling Introducing Idle States (synchronous model) Four Cycle Signaling (asynchronous model)

Dealing with Asynchronous Inputs Metastability and synchronization

Page 2: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 2

Midterm #1 ResultsMidterm 1

0

5

10

15

20

25

38 39 40 41 42 43 44 45 46 47 48 49 50

Score

Nu

mb

er

Mean

Page 3: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 3

Midterm #2 ResultsMid2 Results

0

1

2

3

4

5

6

7

8

10 15 20 25 30 35 40 45

Score

Number

Mean +1 SD-1 SD-2 SD +2 SD

Page 4: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 4

Combined Midterm ResultsMidterms

0

1

2

3

4

5

6

7

8

9

50 55 60 65 70 75 80 85 90 95

Total Score

Number

Mean +1 SD-1 SD-2 SD +2 SD

Page 5: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 5

F is not always 0pulse 3 gate-delays wide

D remains high forthree gate delays after

A changes from low to high

FA B C D

Momentary Changes in Outputs Can be useful—pulse shaping circuits Can be a problem—incorrect circuit

operation (glitches/hazards) Example: pulse shaping circuit

A' • A = 0 delays matter

in function

Page 6: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 6

initially undefined

close switch

open switch

+

open switch

resistor

A B

CD

Oscillatory Behavior

Another pulse shaping circuit

Page 7: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 7

Hazards/Glitches Hazards/glitches: unwanted switching at the outputs

Occur when different paths through circuit have different propagation delays

As in pulse shaping circuits we just analyzed Dangerous if logic causes an action while output is unstable

May need to guarantee absence of glitches

Usual solutions1) Wait until signals are stable (by using a clock): preferable

(easiest to design when there is a clock – synchronous design)

2) Design hazard-free circuits: sometimes necessary (clock not used – asynchronous design)

Page 8: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 8

10 0

1 10 0

1 10 0

01 1

Types of Hazards Static 1-hazard

Input change causes output to go from 1 to 0 to 1

Static 0-hazard Input change causes output to go from 0 to 1 to 0

Dynamic hazards Input change causes a double change

from 0 to 1 to 0 to 1 OR from 1 to 0 to 1 to 0

Page 9: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 9

F

static-0 hazard static-1 hazard

A

B

S

S'

F

hazard

AS

B

S'

Static Hazards Due to a literal and its complement momentarily

taking on the same value Thru different paths with different delays and

reconverging

May cause an output that should have stayed at the same value to momentarily take on the wrong value

Example:

Page 10: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 10

B2

A

C

B1

F

hazarddynamic hazards

B3

A

C

B

F

1

23

Dynamic Hazards Due to the same versions of a literal taking on

opposite values Thru different paths with different delays and

reconverging

May cause an output that was to change value to change 3 times instead of once

Example:

Page 11: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 11

Eliminating Static Hazards Following 2-level logic function has a hazard, e.g.,

when inputs change from ABCD = 0101 to 1101A

AB 00 01 11 10

0 0 1 1

1 1 1 1

1 1 0 0

0 0 0 0

00

01

11

10 C

CD

D

B

G1

G2

G3

A\C

\AD

F

G1

G2

G3

A\C

\AD

F

1

1

1

1

0

0

0

1

1

1

1

0

0

0

ABCD = 1100 ABCD = 1101

No Glitch in this case

G1

G2

G3

A\C

\AD

F

G1

G2

G3

A\C

\AD

F

0

1

0

0

1

0

0

1

1

1

1

1

0

0

ABCD = 1101 ABCD = 0101 (A is still 0)

G1

G2

G3

A\C

\AD

F

0

1

0

1

1

1

1

ABCD = 0101 (A is 1)

Glitch in this case

This is the fix

Page 12: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 12

Eliminating Dynamic Hazards Very difficult! A circuit that is static

hazard free can still have dynamic hazards

Best approach: Design critical

circuits to be two level and eliminate all static hazards

OR, use good clocked synchronous design style

G1

G2

G3

G5

G4

\A B

\B

\B \C

F

A

0 1

1

1 0

1

0 1

1 0

1 0 1

1 0 0

1 0

1 0 1 0

Slow

V ery slow

Page 13: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 13

FSM Partitioning Why Partition?

What if programmable logic is limited in number of inputs and outputs that can be used in a particular device?

For PLAs, the number of product terms are limited, thus limiting the complexity of the next state and output functions

Page 14: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 14

Partitioning the State Machine Suppose that FSM is

partitioned so that states at the right are in one partition and states at the left are in the other

How do you support intersignaling between the state machine partitions?

It is usually a good idea to partition the machine so there are as few cross links as possible (min cut set in graph theoretic terms)

Page 15: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 15

Partitioning the State Machine Solution: introduce idle states SA and SB

Machine at left enters SA allowing machine at right to exit SB

When machine at right returns to SB, machine at left exits SA

Page 16: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 16

Rules for Introducing Idle States

Page 17: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 17

Example: Partitioning the Up/Down Counter

Page 18: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 18

Example Partitioning: Traffic Light Controller Main Controller vs. Counter/Timer

ST triggers transfer of control TS or TL triggers return of

control

Reset

TS'

TS / ST

(TL•C)'

TL•C / ST

TS'

TS / ST

(TL+C')'

TL+C' / ST

HG

FG

FYHY

T00

T01

T02

T03

T04[TS]

T05

T09

T08

T07

T06

T10

T11

T12

T13

T19[TL]

T18

T17

T16

T15

T14

ST

(a) Main controller(b) Counter/timer

Page 19: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 19

Partitioned FSM Block Diagram

Interface between the two partitions are the signals ST, TS, TL

NOTE: Main Controller and Timer use the same clock and are operating in a synchronous mode

traffic light controller

timer

TLTSST

resetC

HRHYHGFRFYFG

Page 20: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 20

Generalized Inter-FSM Signaling Interlocked Synchronized Signaling

Page 21: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 21

Asynchronous Signaling

Also known as “speed-independent” signaling Requester/client/master vs. Provider/Server/Slave

Communications Signals Clocked

SubsystemClocked

Subsystem

S1

requester client master

S2

provider server slave

Request

Data Flow

Acknowledgement

Page 22: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 22

Asynchronous Signaling First consider the common clock case (synchronous)

Master asserts Request Slave recognizes request, processes request, indicates

completion by asserting Acknowledgement Master accepts results, removes Request Slave see Request removed, removes Acknowledge

Req

Data

Ack

Clk

Page 23: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 23

Asynchronous Signaling What if Slave can’t respond in single cycle? Solution: Wait

signaling

Slave inhibits master by asserting wait

When slave unasserts wait, master knows request has been processed, and can latch results

Req

Data

W ait

Clk

Page 24: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 24

Req

Data

Ack

True Asynchronous Signaling Now remove the assumption of a single common clock How do we make sure that receiver has seen the sender’s

signal? Solution: Interlocked signaling Four cycle signaling: assert Req, process request, assert

ack, latch result, remove Req, remove Ack and start again Sometimes called “Return to Zero” signaling

1

2

3

4

Page 25: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 25

True Asynchronous Signaling

Alternative scheme: Two-Cycle Signaling Non-return-to-zero signaling Transaction start by Req lo-to-hi, finishes Ack lo-to-hi Next transaction starts by Req hi-to-lo, finishes Ack hi-to-

lo Requires EXTRA state to keep track of the current sense

of the transitions—faster than 4 cycle case, but usually involves more hardware

Ack

Data

Req 1

2

1

2

Page 26: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 26

True Asynchronous Timing Self-Timed Circuits

Uses Req/Ack signaling as described

Components can be constructed with NO internal clocks

Determines on its own when the request has been processed

Concept of the delay line simply slows down the pass through of the Req to the Ack—usually matched to the worst case delay path

Becoming MORE important for large scale VLSI chips were global clock distribution is a challenge

Input

Req

Output

Ack

Combinational logic

Delay

Page 27: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 27

Metastability and Asynchronous inputs Clocked synchronous circuits

Inputs, state, and outputs sampled or changed in relation to acommon reference signal (called the clock)

E.g., master/slave, edge-triggered

Asynchronous circuits Inputs, state, and outputs sampled or changed independently

of a common reference signal (glitches/hazards a major concern)

E.g., R-S latch

Asynchronous inputs to synchronous circuits 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)

Page 28: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 28

small, but non-zero probability that the FF output will get stuck

in an in-between state

oscilloscope traces demonstratingsynchronizer failure and eventual

decay to steady state

logic 0 logic 1logic 0

logic 1

Synchronization Failure Occurs when FF input changes close to clock edge

FF may enter a metastable state – neither a logic 0 nor 1 – May stay in this state an indefinite amount of time Is not likely in practice but has some probability

Page 29: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 29

D DQ Qasynchronous

inputsynchronized

input

synchronous system

Clk

Dealing with Synchronization Failure Probability of failure can never be reduced to 0,

but it can be reduced(1) slow down the system clock: this gives the

synchronizer more time to decay into a steady state; synchronizer failure becomes a big problem for very high speed systems

(2) use fastest possible logic technology in the synchronizer:this makes for a very sharp "peak" upon which to balance

(3) cascade two synchronizers: this effectively synchronizes twice (both would have to fail)

Page 30: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 30

D Q

D Q

Q0

Clock

Clock

Q1

Async Input

D Q

D Q

Q0

Clock

Clock

Q1

Async Input D Q

Clocked Synchronous

System

Synchronizer

Handling Asynchronous Inputs Never allow asynchronous inputs to fan-out to

more than one flip-flop Synchronize as soon as possible and then treat as

synchronous signal

Page 31: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 31

In is asynchronous and fans out to D0 and D1

one FF catches the signal, one does not

inconsistent state may be reached!

In

Q0

Q1

CLK

Handling Asynchronous Inputs (cont’d)

What can go wrong? Input changes too close to clock edge (violating setup

time constraint)

Page 32: CS 150 - Spring 2004 – Lec #22 – Signaling - 1 State Machine Signaling zTiming Behavior yGlitches/hazards and how to avoid them zFSM Partitioning yWhat.

CS 150 - Spring 2004 – Lec #22 – Signaling - 32

Signaling Summary Glitches/Hazards

Introduce redundant logic terms to avoid them OR use synchronous design!

FSM Partitioning Replacing monolithic State Machine with simpler

communicating state machine Technique of introducing idle states

Machine-to-machine Signaling Synchronous vs. asynchronous Four vs. Two Cycle Signaling

Asynchronous inputs and their dangers Synchronizer failure: what it is and how to minimize its impact