DEDICATED TO EMBEDDED SOLUTIONS

Similar documents

Clock Domain Crossing. Presented by Abramov B. 1

EE178 Spring 2018 Lecture Module 5. Eric Crabill

2.6 Reset Design Strategy

Laboratory 1 - Introduction to Digital Electronics and Lab Equipment (Logic Analyzers, Digital Oscilloscope, and FPGA-based Labkit)

Figure 1 shows a simple implementation of a clock switch, using an AND-OR type multiplexer logic.

EE178 Lecture Module 4. Eric Crabill SJSU / Xilinx Fall 2005

Glitches/hazards and how to avoid them. What to do when the state machine doesn t fit!

(CSC-3501) Lecture 7 (07 Feb 2008) Seung-Jong Park (Jay) CSC S.J. Park. Announcement

Sequential Circuit Design: Principle

Combinational vs Sequential

Lecture 13: Clock and Synchronization. TIE Logic Synthesis Arto Perttula Tampere University of Technology Spring 2017

Flip-Flops. Because of this the state of the latch may keep changing in circuits with feedback as long as the clock pulse remains active.

EITF35: Introduction to Structured VLSI Design

Software Engineering 2DA4. Slides 9: Asynchronous Sequential Circuits

Sequential Logic. E&CE 223 Digital Circuits and Systems (A. Kennings) Page 1

Introduction to Sequential Circuits

Prototyping an ASIC with FPGAs. By Rafey Mahmud, FAE at Synplicity.

Lecture 12: Clock and Synchronization. TIE Logic Synthesis Arto Perttula Tampere University of Technology Spring 2018

Modeling Latches and Flip-flops

EECS 373 Design of Microprocessor-Based Systems

EEE2135 Digital Logic Design Chapter 6. Latches/Flip-Flops and Registers/Counters 서강대학교 전자공학과

The outputs are formed by a combinational logic function of the inputs to the circuit or the values stored in the flip-flops (or both).

Chapter 2 Clocks and Resets

CSE140: Components and Design Techniques for Digital Systems. More D-Flip-Flops. Tajana Simunic Rosing. Sources: TSR, Katz, Boriello & Vahid

Synchronous Sequential Logic

Logic Analyzer Triggering Techniques to Capture Elusive Problems

EECS 373 Design of Microprocessor-Based Systems

CAD for VLSI Design - I Lecture 38. V. Kamakoti and Shankar Balachandran

Digital Logic Design Sequential Circuits. Dr. Basem ElHalawany

Synchronous Sequential Design

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

Digital System Design

More on Flip-Flops Digital Design and Computer Architecture: ARM Edition 2015 Chapter 3 <98> 98

Introduction. NAND Gate Latch. Digital Logic Design 1 FLIP-FLOP. Digital Logic Design 1

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

FPGA TechNote: Asynchronous signals and Metastability

Unit 11. Latches and Flip-Flops

ALGORITHMS IN HW EECS150 ALGORITHMS IN HW. COMBINATIONAL vs. SEQUENTIAL. Sequential Circuits ALGORITHMS IN HW

HDL & High Level Synthesize (EEET 2035) Laboratory II Sequential Circuits with VHDL: DFF, Counter, TFF and Timer

Logic Design. Flip Flops, Registers and Counters

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

Logic and Computer Design Fundamentals. Chapter 7. Registers and Counters

Chapter 11 Latches and Flip-Flops

Rangkaian Sekuensial. Flip-flop

Outline. EECS150 - Digital Design Lecture 27 - Asynchronous Sequential Circuits. Cross-coupled NOR gates. Asynchronous State Transition Diagram

Solutions to Embedded System Design Challenges Part II

EECS 373 Design of Microprocessor-Based Systems

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

Keeping The Clock Pure. Making The Impurities Digestible

Chapter 3 Unit Combinational

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

CHAPTER 4: Logic Circuits

EECS150 - Digital Design Lecture 10 - Interfacing. Recap and Topics

Modeling Latches and Flip-flops

Tutorial 11 ChipscopePro, ISE 10.1 and Xilinx Simulator on the Digilent Spartan-3E board

A clock is a free-running signal with a cycle time. A clock may be either high or low, and alternates between the two states.

CS8803: Advanced Digital Design for Embedded Hardware

Automated Verification and Clock Frequency Characteristics in CDC Solution

Chapter 5 Synchronous Sequential Logic

ECEN454 Digital Integrated Circuit Design. Sequential Circuits. Sequencing. Output depends on current inputs

Unit 9 Latches and Flip-Flops. Dept. of Electrical and Computer Eng., NCTU 1

Basis of sequential circuits: the R-S latch

Synchronous Sequential Logic

Lecture 11: Sequential Circuit Design

cascading flip-flops for proper operation clock skew Hardware description languages and sequential logic

Advanced Digital Logic Design EECS 303

Rensselaer Polytechnic Institute Computer Hardware Design ECSE Report. Lab Three Xilinx Richards Controller and Logic Analyzer Laboratory

Other Flip-Flops. Lecture 27 1

L14: Quiz Information and Final Project Kickoff. L14: Spring 2004 Introductory Digital Systems Laboratory

TKK S ASIC-PIIRIEN SUUNNITTELU

Scan. This is a sample of the first 15 pages of the Scan chapter.

Clocks. Sequential Logic. A clock is a free-running signal with a cycle time.

Introduction to Digital Logic Missouri S&T University CPE 2210 Flip-Flops

CS61C : Machine Structures

Chapter 5: Synchronous Sequential Logic

EECS150 - Digital Design Lecture 3 Synchronous Digital Systems Review. Announcements

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o. Lecture #14

Experiment 8 Introduction to Latches and Flip-Flops and registers

Asynchronous IC Interconnect Network Design and Implementation Using a Standard ASIC Flow

Momentary Changes in Outputs. State Machine Signaling. Oscillatory Behavior. Hazards/Glitches. Types of Hazards. Static Hazards

Lecture 21: Sequential Circuits. Review: Timing Definitions

Asynchronous inputs. 9 - Metastability and Clock Recovery. A simple synchronizer. Only one synchronizer per input

Lecture 8: Sequential Logic

Synchronizing Multiple ADC08xxxx Giga-Sample ADCs

CHAPTER 4: Logic Circuits

CSE 352 Laboratory Assignment 3

DEPARTMENT OF ELECTRICAL &ELECTRONICS ENGINEERING DIGITAL DESIGN

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

Sequential circuits. Same input can produce different output. Logic circuit. William Sandqvist

Digital Integrated Circuits EECS 312

Chapter 5 Flip-Flops and Related Devices

Digital Design, Kyung Hee Univ. Chapter 5. Synchronous Sequential Logic

6.S084 Tutorial Problems L05 Sequential Circuits

(12) United States Patent (10) Patent No.: US 8,707,080 B1

Chapter 6. sequential logic design. This is the beginning of the second part of this course, sequential logic.

Chapter 2. Digital Circuits

INTRODUCTION TO SEQUENTIAL CIRCUITS

Transcription:

DEDICATED TO EMBEDDED SOLUTIONS DESIGN SAFE FPGA INTERNAL CLOCK DOMAIN CROSSINGS ESPEN TALLAKSEN DATA RESPONS

SCOPE Clock domain crossings (CDC) is probably the worst source for serious FPGA-bugs that can make your final product fail in fatal and mysterious ways. This presentation shows why this is a problem and how to handle the most common CDC scenarios. Excerpt from FPGA development Best Practices (A two day Digitas course by Data Respons) Originally a total of 80 slides Removed basics, details on Metastability, Glitch generation, FPGA re-convergence glitching, handshaking Reduced number of explained CDC cases and variations Added and modified a few slides Design safe FPGA internal clock domain crossings 2

The worst kind of FPGA bugs An FPGA may fail in many different ways: Logic functionality General timing-problems (clock domain internal) Clock domain crossing (FPGA internal and I/O) Asynchronous logic Other: I/O characteristics and interfacing, FPGA configuration, power supply, temperature, etc... Logic functionality can be verified by simulation and testing Internal synchronous timing can be verified by static timing analysis Clock domain crossing and Asynchronous logic: Cannot be fully verified by simulation Cannot be fully verified by testing (e.g. lab, system, field) Can only be fully verified by manual analysis» Sometimes in combination with static timing analysis Design safe FPGA internal clock domain crossings 3

FPGA Timing - Basics FPGA clk1 clk1 clk1 clk1 timing path & timing requirement clk2 timing path & timing req. clk2 Clock domain clk1 timing path & timing req. Clock domain clk2 External Component External Component timing path & timing req. timing path & timing req. clk Async logic External Component Storage elements: Flops, memories, latch, black-box Timing path: From active clock edge on source element to input on destination element plus setup-time Clock relations, synchronization, handshake, etc CDC: Clock Domain Crossing I/O timing could be pure timing path or additional CDC with different timing for each external component Storage element Combinat. logic Design safe FPGA internal clock domain crossings 4

Initial effects of a timing violation A violation of the setup/hold times may result in: 1. Small additional delay on Q 2. Major additional delay on Q 3. New data is not stored (keeping the old data) 4. Q temporarily reflects new data, then returns to the old 5. Q has multiple glitches before settling 6. Q has undetermined level (voltage) before settling D C Q Meta-stability (or undetermined output or delay) Some FPGA providers claim to have meta-stable free storage elements The The initial uncertainty effects of a of timing whether problem new data may is seem stored trivial. This means they handle some of the effects of meta-stability. They cannot handle all. They may is actually however as result bad as in major any meta-stability. functional problems. Design safe FPGA internal clock domain crossings 5

Some results of timing violations Wrong data is sampled (e.g. by SW) Trigger-signal is missed or multiplied State machine enters wrong state State machine (or FPGA) enters illegal state May result in deadlock Counters jump to spurious value Words are lost or duplicated in a data flow Design safe FPGA internal clock domain crossings 6

Consequences of CDC problems - some real examples Project delays 2 months delay due to sporadic errors in the system test 3-4 months delay due to unstable complex interface 1 year delay after product was actually ready More than 5 man months to debug a problem that appeared some time after product release Product deficiencies after customer release Communication switch with lots of bit errors Industrial system increasingly failing after a few years Customer s application SW not working And there are MANY more... Design safe FPGA internal clock domain crossings 7

Motivation for proper CDC design and manual timing analysis An FPGA with a timing problem Will not be detected by an RTL simulation May fail in test once in a while for no obvious reason Is extremely» May however expensive also pass all lab increasingly tests per stage May occasionally fail in system test for no obvious reason Is very time consuming» And uncertain whether SW, HW, FPGA or test is to blame» May however also pass all system tests Is bad for credibility and customer relations May occasionally fail in field test for no obvious reason» May however also pass all field tests May fail in field operation for no obvious reason» May happen for new SW, HW, FW» May happen for different temperature, voltage, power» May happen for FPGA #7, or for FPGAs #17 to #3472 Design safe FPGA internal clock domain crossings 8

Types of CDC Single signal CDC Multi-signal CDC Vector CDC Complex signal transfer. (E.g. a bus system) Source and destination relations Frequency relations Transfer intervals Handshake variations (two vs four-phase, Boolean- vs toggle-based) Possible CDC exceptions to be treated in a simpler way Rising + falling (derived from rising) Aligned clock (several clocks generated from the same source) Derived clocks (generated from another clock) clock selection (mux ing between multiple sources) clock enabling (gated with enable-signal before clock input) Design safe FPGA internal clock domain crossings 9

Always: Single signal synchronization - with faster destination Ensure stable and glitch free signal out of source domain For input to a faster domain: Two synchronization flip-flops normally recommended High frequencies or tight timing may require more May utilise both edges to reduce latency Clock domain clk1 @f1 stable, glitch free signal No logic Clock domain clk2 @ f2 >> f1 (or stable source) clk2 clk2 For input to a slower domain (or unknown frequency): Need handshake Design safe FPGA internal clock domain crossings 10

Why two flip-flops? Clock domain clk2 @ f2 >> f1 clk2 clk2 Two flops the rule of thumb for several decades But, meta-stability characteristics has significantly improved - So why isn t a single flop sufficient? In fact in many cases it would be, but» Would require tightened timing requirements out of flop 1» Needs tighter follow-up throughout design-phase» Does still have a higher risk of failure for critical applications» Why save a flop? Still a good rule: Use two flip-flops for synchronization Design safe FPGA internal clock domain crossings 11

Pulse detection in destination domain clk2 clk2 clk2 Required when synchronized signal used as enable/trigger To assure single enable/trigger Position after 2nd synch-flop Design safe FPGA internal clock domain crossings 12

Single asynchronous sampling For input to (pot.) slower domain when source cannot be held sig_a - Detect pulse - Synchronize - Generate pulse (sync d) Two main categories depending on application Counting multiple fast pulses (faster than available clock periods) Need to count in a separate sig_a clock domain Handle as normal CDC between domains Detection of single pulse with sufficient time between pulses,» or multiple pulses where only first pulse is of interest May synchronize immediately after detection Various solutions observed - Some applied solutions are definitely error prone Design safe FPGA internal clock domain crossings 13

Sampling a single, fast pulse For input to (pot.) slower domain when source cannot be held sig_a D1 Q1 clk Q2 clk Q3 clk XOR Recommended solution Uses no asynchronous set/reset Will only detect one out of multiple pulses within 3 T (clk period)» Multiple fast pulses will require a separate clock ) Dual edge triggering requires dual implementation Note: The feedback to D1 must come from Q3. If coming from Q1, input pulses may be lost if pulsing twice (or any even number) between rising edges of clk. Design safe FPGA internal clock domain crossings 14

Vector CDC Default solution Clock domain clk1 @f1 Clock domain clk2 @ f2 >> f1 DATA Valid Registers Synchronize data and trigger Use extra delay flop in trigger path if needed for timing balancing Register data out of source if required for stability Design safe FPGA internal clock domain crossings 15

Vector CDC Optimized solution Clock domain clk1 @f1 Clock domain clk2 @ f2 >> f1 DATA Valid Registers - Small combinatorial logic and fan in (3 inputs 4 incl. synch. reset) - No sharing of intermediate terms Complete combinatorial logic can be handled in a single LUT No need to synchronize data But - what if control signals are added later or functional update of registers (e.g. a loadable counter)? Flip-flops are cheap in FPGAs Always synchronize all signals Design safe FPGA internal clock domain crossings 16

Complex CDC with stable data Clock domain clk1 @f1 DATA ADDR WR CS Clock domain clk2 @ f2 >> f1 Registers DATA ADDR WR CS Assume stable bus and known trigger condition Data and control valid for a sufficient time around trigger (e.g. a slow bus writing to registers in a fast clock domain) Design safe FPGA internal clock domain crossings 17

Complex CDC with stable data - for write access Clock domain clk1 @f1 DATA ADDR WR CS Clock domain clk2 @ f2 >> f1 Registers DATA ADDR WR CS Dual flop sync is not required for data/addr/ctr in this scenario Derive single trigger signal Might have to combine in source domain Assure glitch-less trigger signal from source domain (e.g. directly from flop) Synchronize trigger signal (as for single signal synchronization) Use edge trigger to load synchronized data into register. Design safe FPGA internal clock domain crossings 18

Possible CDC exceptions Related clocks may often be handled in a synchronous or quasi synchronous manner Worst case they must be handled as asynchronous Typical related clock scenarios are: Using both rising and falling edges of the same clock Aligned clocks e.g. 4 and 8 MHz, both derived from 32 MHz Derived clock - and its source Clock selection selecting same or derived clock Clock enabling Design safe FPGA internal clock domain crossings 19

Derived clock Logic clocked by a source clock and a derived clock must sometimes be treated as two separate clock domains Implementation in device will depend on lots of issues B Some clock generation logic d1 clk_a clk_b B d2 - Must consider architecture and coding - Must consider FPGA technology - Must consider synthesis + P&R tool - Must consider constraints - Must be ensure correct implementation - Must document properly - Must review May be dead simple May require semi asynchronous handling Design safe FPGA internal clock domain crossings 20

Potential CDC bug secondary effects Power consumption may increase if more toggling/glitches if unintended state is reached (e.g. bit-rate, clock-control, memory-outputs, ) if illegal combinations occur (e.g. enabling 2 external chip selects for read) An FPGA deadlock may occur e.g. if entering an undefined state External HW may be damaged Temporarily or permanent Design safe FPGA internal clock domain crossings 21

Conclusion on CDC Bugs sometimes result in serious product malfunction Bugs often result in major project delays Manual analysis and reviews may be time consuming If so spend that time Documenting CDC may be time consuming The better reason to do it Lots of designers/companies do not handle CDC properly They often lose magnitudes of time compared to what they save Design safe FPGA internal clock domain crossings 22

WWW.DATARESPONS.COM