What is the difference between == and === in Verilog?

前端 未结 3 1341
一生所求
一生所求 2020-12-25 11:19

What is the difference between:

if (dataoutput[7:0] == 8\'bx) begin

and

if (dataoutput[7:0] === 8\'bx) begin 
3条回答
  •  -上瘾入骨i
    2020-12-25 12:01

    Some data types in Verilog, such as reg, are 4-state. This means that each bit can be one of 4 values: 0,1,x,z.

    With the "case equality" operator, ===, x's are compared, and the result is 1.

    With ==, the result of the comparison is not 0, as you stated; rather, the result is x, according to the IEEE Std (1800-2009), section 11.4.5 "Equality operators":

    For the logical equality and logical inequality operators (== and !=), if, due to unknown or high-impedance bits in the operands, the relation is ambiguous, then the result shall be a 1-bit unknown value (x).

提交回复
热议问题