Home / Learn Verilog / Race Conditions in Simulation

Race Conditions in Simulation

Order-dependent results.

Bottom lineOrder-dependent results.

Breaking it down

Raceblocking in clocked blocksorder dependentnon-blockingdeterministic
Race

Definition

When two blocks read and write the same variable at the same time with =, the result depends on execution order.

Why you need this

Races give different results in different simulators.

How it works

Use <= for clocked logic, and never drive a clock with =.

Where you'll see this

  • Everyday RTL design
  • FPGA and ASIC projects
  • Testbenches and debugging

Try it

Race-free pipelineVerilog: edit and run

Non-blocking makes b always the previous a.

Test what you just read

1. Cure for races?