• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Electrical Engineering News and Products

Electronics Engineering Resources, Articles, Forums, Tear Down Videos and Technical Electronics How-To's

  • Products / Components
    • Analog ICs
    • Battery Power
    • Connectors
    • Microcontrollers
    • Power Electronics
    • Sensors
    • Test and Measurement
    • Wire / Cable
  • Applications
    • 5G
    • Automotive/Transportation
    • EV Engineering
    • Industrial
    • IoT
    • Medical
    • Telecommunications
    • Wearables
    • Wireless
  • Learn
    • eBooks / Handbooks
    • EE Training Days
    • Tutorials
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • White Papers
    • Educational Assets
    • Design Guide Library
    • Digital Issues
    • Engineering Diversity & Inclusion
    • LEAP Awards
    • Podcasts
    • DesignFast
  • Videos
    • EE Videos and Interviews
    • Teardown Videos
  • EE Forums
    • EDABoard.com
    • Electro-Tech-Online.com
  • Bill’s Blogs
  • Advertise
  • Subscribe

Catch that glitch: Finding race conditions

September 22, 2021 By dherres

Among the problems circuit designers have to contend with in their fast and complex electronic environment are race conditions.

The term used to be exclusively applied to electronic logic problems but has now been adopted by software engineers working on multithreaded programs. Briefly, software race conditions arise in multithreaded software when multiple threads attempt to modify a piece of shared data simultaneously. Serious problems arise if the output of one thread affects another thread’s execution in a way that causes unexpected or incorrect results.

But in electronics, a race condition arises when a logic gate combines signals that traveled via different, unequal paths from a single source. In response to changes in the source signal, the inputs at the gates will change at different times.

race condition The classic example of a race condition is that of a two-input AND gate that receives logic signal A at one input and NOT A at the other as produced by an inverter. Theoretically, the AND gate output will always be 0. However, the signal passing through inverter will have some delay. If the signal through inverter reaches the AND gate later than the one without inverter, there will be a glitch. The result can be a system that exists in an undefined state.

The key to avoiding race conditions in digital designs is to ensure setup-and-hold criteria are met for each logic gate. The usual place where potential race problems can arise is in systems having multiple clocks. Different clock domains that are not properly synchronized can easily cause metastability events.

The typical way of dealing with multiple clocks is through a digital circuit called a synchronizer. This circuit converts a signal from a different clock domain into the recipient clock domain. That said, synchronizers don’t totally guarantee prevention of metastability. They only reduce the chances of it.

synchronizerThe simplest synchronizer consists of two or more flip-flops in chain working on the destination clock domain. This approach allows for an entire clock period for the first flop to resolve metastability.

The input to the first stage is asynchronous to the destination clock. So, the output of first stage might occasionally go metastable. However, as long as metastability is resolved before next clock edge, the output of second stage should have valid logic levels. Thus, the asynchronous signal is synchronized with a maximum latency of two clock cycles.

Theoretically, it is still possible for the output of the first stage to be unresolved before it is sampled by the second stage. In that case, the output of second stage will also go metastable. Then a three-stage synchronizer is used if the probability of a metastable second stage is high.

Synchronizer schemes grow more complicated when there are multiple lines requiring synchronization. For example, handshaking-based synchronization controls the transfer of data via a handshaking protocol wherein source domain places data on a ‘REQ’ signal line. When it goes high, receiver knows data is stable on the bus and it is safe to sample it. After sampling, the receiver asserts an ‘ACK’ signal. This signal is synchronized to the source domain and informs the sender that data has been sampled successfully and that it’s safe to send new data. The problem with handshaking-based synchronizers is it takes many cycles to exchange handshaking signals. But it works well when the response time of one or both circuits is unpredictable.

The designer has various available tools to find race problems. One such is the Karnaugh map, wherein Boolean results are transferred from a truth table onto a two-dimensional grid in which the cells are ordered in Gray code. Race conditions are evident.

logic analyzer display
Top, the dialog for specifying the setup/hold violation parameters on a Tektronix logic analyzer. Below, the result of the logic analyzer triggering on a setup violation. In this case, the signal only had a set-up time of 1.875 nsec which is less than the required 2 nsec.

Because inadequate setup/hold margin is a common source of intermittent problems, modern logic analyzers have capabilities oriented toward noodling out these issues. It an be time consuming to search for setup/hold violations with a scope. The typical approach is to probe a clock and individual data lines. Modern logic analyzers can automate the search by triggering on and displaying any user-defined setup/hold violation on all signals simultaneously.

It is common to find logic analyzers with special setup-and-hold triggering modes. A point to note in using this feature is that logic analyzers have two ways to clock target signals:  asynchronous mode and synchronous mode. In the asynchronous mode, also called timing mode, the logic analyzer samples the signals of the DUT using its internal clock. It is the synchronous mode, also called state mode, that is used for setup-and-hold triggering. To capture setup-and-hold violations, a comparison between the waveform edge timing relationship of the clock and target signals must be made. Here the logic analyzer samples acquired signals according using an external clock which is typically synchronized with DUT signals. In this mode, waveform states are only visible when they are valid.

You Might Also Like

Filed Under: FAQ, Featured, Test and Measurement Tips Tagged With: FAQ, tektronix

Primary Sidebar

EE Engineering Training Days

engineering

Featured Contributions

Integrating MEMS technology into next-gen vehicle safety features

Five challenges for developing next-generation ADAS and autonomous vehicles

Robust design for Variable Frequency Drives and starters

Meeting demand for hidden wearables via Schottky rectifiers

GaN reliability milestones break through the silicon ceiling

More Featured Contributions

EE Tech Toolbox

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“ee
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.
“bills
contribute

R&D World Podcasts

R&D 100 Episode 10
See More >

Sponsored Content

Designing for Serviceability: The Role of Interconnects in HVAC Maintenance

From Control Boards to Comfort: How Signal Integrity Drives HVAC Innovation

Built to Withstand: Sealing and Thermal Protection in HVAC Sub-Systems

Revolutionizing Manufacturing with Smart Factories

Smarter HVAC Starts at the Sub-System Level

Empowering aerospace E/E design and innovation through Siemens Xcelerator and Capital in the Cloud

More Sponsored Content >>

RSS Current EDABoard.com discussions

  • Sendust vs Ferrite for SMPS
  • On/Off Slide Switch Reassembly Help
  • sim7090g
  • Industrial Relay Board Design for Motorcycle Use
  • connector model question

RSS Current Electro-Tech-Online.com Discussions

  • using a RTC in SF basic
  • Is AI making embedded software developers more productive?
  • Wierd makita battery
  • ac current limiting
  • I Wanna build a robot
Search Millions of Parts from Thousands of Suppliers.

Search Now!
design fast globle

Footer

EE World Online

EE WORLD ONLINE NETWORK

  • 5G Technology World
  • Analog IC Tips
  • Battery Power Tips
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • Electro-Tech-Online Forums
  • Engineer's Garage
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips

EE WORLD ONLINE

  • Subscribe to our newsletter
  • Teardown Videos
  • Advertise with us
  • Contact us
  • About Us

Copyright © 2025 · WTWH Media LLC and its licensors. All rights reserved.
The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media.

Privacy Policy