17
SystemVerilog Assertions for Clock-Domain-Crossing Data Paths Don Mills Microchip Technology Inc.

SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

  • Upload
    others

  • View
    24

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

SystemVerilog Assertions for

Clock-Domain-Crossing

Data Paths

Don Mills

Microchip Technology Inc.

Page 2: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

Outline

• Brief Review of CDC Concepts and Issues

• Basics of SystemVerilog Assertions

• Modeling Techniques and Issues using SVA for CDC

• SVA Model for both RTL and GLS

22/26/2015 Don Mills, Microchip Technology Inc.

Page 3: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

What is

Clock Domain Crossing?

• What is a Clock Domain?

– flip-flops with same clock (clock tree)

• Clock Domain Crossing

– Data from one clock domain is captured (sampled) in

another clock domain

A_inA1 B1

Clk_A

Clk_B

B_in B_out

32/26/2015 Don Mills, Microchip Technology Inc.

Page 4: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

Clock Domain Crossing

Issue - Metastability

Violating “setup” or “hold” time of flip-

flop B1 can cause metastability

B_in

Clk_B

Setup time window

B_in

Clk_B

Hold time windowA_inA1 B1

Clk_A

Clk_B

B_in B_out

• A signal settling from

metastability settles to

• the old state

• or the new stateScreen shot from Philip Freidin – www.fpga-faq.com

http://www.fpga-faq.com/FAQ_Pages/0017_Tell_me_about_metastables.htm

42/26/2015 Don Mills, Microchip Technology Inc.

Page 5: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

A_in

sampled

by A_clk

Asynchronous Clocks &

Metastability Scenario 1

Original Slide from Cliff Cummings Boston SNUG 2008 (Used by permission) – Modifications made to match this presentation.

B_in

sampled

by B_clk

B_in

A_clk

A_in

A_inA1 B1

Clk_A

Clk_B

B_in B_out ??

??

??

?? "1"

"0"

??

B_clk

Clocked B_in signal is

initially metastable –

settles to either 0 or 1B_out

52/26/2015 Don Mills, Microchip Technology Inc.

All outputs are

known in this cycle

Page 6: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

Asynchronous Clocks &

Metastability Scenario 2

Original Slide from Cliff Cummings Boston SNUG 2008 (Used by permission) – Modifications made to match this presentation.

B_in

A_inA1 B1

Clk_

AClk_B

B1_in B_out

B2

B2_in

A_in

sampled by

A_clk

A_clk

A_in

B2_in

B_out

B1_in

sampled

by B_clkB_clk

"1"

"1"

"1"

"1" "0"

"0"

"0"

62/26/2015 Don Mills, Microchip Technology Inc.

B2 filters the metastable state of B1 from propagating

– assumes B1 settles within one clock cycle

Page 7: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

An Assertion Property for

CDC

property CDC_prop1;

logic v_temp;

@(posedge Clk_A) ($changed(A_in), v_temp = A_in) |=>

($changed(B1_in) && (B1_in === v_temp))

##1

@(posedge Clk_B) ($changed(B1_in) && (B1_in === v_temp))

##[2:3] ($changed(B_out) && (B_out === v_temp));

endproperty:CDC_prop1

A_inA1 B1

Clk_A

Clk_B

B1_inB_out

B2

B2_in

Transition to Clk_B

72/26/2015 Don Mills, Microchip Technology Inc.

Page 8: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

@(posedge Clk_B)($changed(B1_in) &&

(B1_in === v_temp))##[2:3]($changed(B1_out) &&

(B1_out === v_temp));

##1 //switch clk domains

Map Assertion to Wave –

view 1 (passes)

Test B1_in at

output of A1 in

A_clk domain

82/26/2015 Don Mills, Microchip Technology Inc.

@(posedge Clk_A)($changed(A_in),

v_temp = A_in)|=> (($changed(B1_in) &&

(B1_in === v_temp))

Page 9: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

Map Assertion to Wave –

view 2 (fails)

92/26/2015 Don Mills, Microchip Technology Inc.

@(posedge Clk_B)($changed(B1_in) &&

(B1_in === v_temp))##[2:3]($changed(B1_out) &&

(B1_out === v_temp));

##1 //switch clk domains

Testing $changed of input to B1 in

B_clk domain is a cycle late

@(posedge Clk_A)($changed(A_in),

v_temp = A_in)|=> (($changed(B1_in) &&

(B1_in === v_temp))

Test B1_in at

output of A1 in

A_clk domain

Page 10: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

property CDC_prop1;

logic v_temp;

@(posedge Clk_A) ($changed(A_in), v_temp = A_in) |=>

($changed(B1_in) && (B1_in === v_temp))

##1

@(posedge Clk_B) ($changed(B1_in) && (B1_in === v_temp))

##[2:3] ($changed(B_out) && (B_out === v_temp));

endproperty:CDC_prop1

Why does this Property fail

for CDC?A_in

A1 B1Clk_A

Clk_B

B1_inB_out

B2

B2_in

Cannot remain testing in Clk_A domain while actual

data has moved onto the next clock domain

102/26/2015 Don Mills, Microchip Technology Inc.

Page 11: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

A correct (RTL)

Assertion Property for CDC

property CDC_prop1;

logic v_temp;

@(posedge Clk_A) ($changed(A_in), v_temp = A_in) |->

@(posedge Clk_B) ($changed(B1_in) && (B1_in === v_temp))

##[2:3] ($changed(B_out) && (B_out === v_temp));

endproperty:CDC_prop1

A_inA1 B1

Clk_A

Clk_B

B1_inB_out

B2

B2_in

Changes to Property

1. overlapping implication operator

2. no test after implication operator3. use |-> for clock transition

112/26/2015 Don Mills, Microchip Technology Inc.

Page 12: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

Correctly working CDC Assertion

@(posedge Clk_A)($changed(A_in),

v_temp = A_in)|->

@(posedge Clk_B)($changed(B1_in) &&(B1_in === v_temp))

##[2:3]

($changed(B1_out) &&(B1_out === v_temp));

122/26/2015 Don Mills, Microchip Technology Inc.

Page 13: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

Full RTL test results – rising

and falling, 2 and 3 clk delay

11 22 33

33

11 22 33

11 22 44 3311 22 44

All conditions passed All conditions passed

NOTE: Final $changed is tested

one cycle after last transition

132/26/2015 Don Mills, Microchip Technology Inc.

Page 14: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

Exaggerated Clk to Q GLS delay

Gate Level Sim (GLS)

can fail with RTL assertion

142/26/2015 Don Mills, Microchip Technology Inc.

A_inA1 B1

Clk_A

Clk_B

B1_inB_out

B2

B2_in

Assertion sampling

does not account for

GLS propagation

@(posedge Clk_B)($changed(B1_in) &&(B1_in === v_temp))

This passes in RTL

because B1_in changes

immediately on Clk_A

Page 15: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

A Property that works for

both RTL and GLS

property CDC_prop1;

logic v_temp;

@(posedge Clk_A) ($changed(A_in), v_temp = A_in) |->

@(posedge Clk_B)

##[0:1] ($changed(B1_in) && (B1_in === v_temp))

##[2:3] ($changed(B_out) && (B_out === v_temp));

endproperty:CDC_prop1

A_inA1 B1

Clk_A

Clk_B

B1_inB_out

B2

B2_in

152/26/2015 Don Mills, Microchip Technology Inc.

The ##[0:1] allows for immediate testing in Clk_B domain for RTL or

for a Clk_B to occur during GLS propagation of flip-flop A1

Page 16: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

Passing GLS test

162/26/2015 Don Mills, Microchip Technology Inc.

@(posedge Clk_A)($changed(A_in),

v_temp = A_in)|->

@(posedge Clk_B)##[0:1]($changed(B1_in) &&(B1_in === v_temp))

##[2:3]($changed(B1_out) &&(B1_out === v_temp));

Page 17: SystemVerilog Assertions for Clock-Domain-Crossing Data … 2015 Assertions for CDC...Clock Domain Crossing Issue -Metastability Violating “setup” or “hold” timeof flip-flop

Conclusions

• Lots of papers on CDC in Google land

• Not so many papers on SV Assertions

• This paper presents an SV Assertion that works for

both RTL and GLS

• This SV Assertion can be extended to support loop

back to original clock domain

172/26/2015 Don Mills, Microchip Technology Inc.