natasv
1
class datatype;
rand integer fchk;
endclass
module top();
datatype dt_new;
dt_new = new();
randomize(dt_new) with {dt_new.fckh == 'hx;};
endmodule
Compile Error:
Values of ‘X’ and ‘Z’ cannot be used within a constraint expression.
Why is this illegal?
In reply to natasv:
The IEEE 1800-2017 SystemVerilog LRM states that constraints only support 2-state values. Section 18.3, specifically:
- Constraints support only 2-state values. The 4-state values (X or Z) or 4-state operators (e.g., ===, !== ) are illegal and shall result in an error.