HDL & Verification

What is the difference between Verilog's equality operators "==" and "==="?

  1. A== yields X when the known bits alone cannot decide whether the operands match, while === compares X and Z literally as values and always yields 0 or 1
  2. B== and === behave identically
  3. C=== compares three values at once
Show answer and explanation

Answer: A. == yields X when the known bits alone cannot decide whether the operands match, while === compares X and Z literally as values and always yields 0 or 1

== behaves like a hardware comparator, so if X or Z bits in either operand leave it undecided whether the operands match, the result is X (unknown). === is called case equality and compares X as X and Z as Z literally, so a testbench can use it to check whether an output has become X. Real circuits cannot distinguish X or Z, so synthesis tools either reject === or treat it like ==. === is therefore mainly a testbench operator.

  • A. Correct. === is used mainly in testbenches.
  • B. They treat X and Z differently.
  • C. It compares two values.

Related calculators

Books on HDL & Verification Ad

As an Amazon Associate I earn from qualifying purchases.

More HDL & Verification questions

  1. The code above was written intending an accumulator that keeps adding the input in. Which pair correctly states the problem with this code and how to fix it?
  2. What is a major difference between a description written in an HDL such as Verilog and a software program in a language such as C?
  3. What is the purpose of a module in Verilog?
  4. What is the difference between wire and reg in Verilog?
  5. What circuit does the Verilog assign statement above represent?

Comparisons in this topic