In reply to Bharath_Verif:
Thanks Bharath and Dave.
I am actually using VCS, and I have reproduced the exact same issue using Dave’s self-contained module with a slight additional changes that are the same as my real test case. Here is the updated module and the reproduced problem:
module randc_test_module;
class abc;
randc bit[2:0] xyz;
rand bit specific_mode = 1;
rand bit [2:0] xyz_start = 3’h0;
rand bit [2:0] xyz_offset = 3’h7;
constraint xyz_c {
{specific_mode == 1’b1} → (xyz != xyz_offset); //not working using variable
}
endclass: abc
abc h;
initial repeat(20) begin
h = new;
h.specific_mode.rand_mode(0);
h.xyz_start.rand_mode(0);
h.xyz_offset.rand_mode(0);
assert(h.randomize());
// $display(h.specific_mode,h.xyz,h.xyz_offset);
$display(“transaction is %p”,h);
end
endmodule // randc_test_module
Error message which is the exact same problem as my real test case, where the xyz has become a static variable but a randc, and also the constraint doesn’t work anymore:
transaction is '{xyz:'h1, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h4, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h3, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h3, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h0, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
=======================================================
Solver failed when solving following set of constraints
bit[2:0] xyz = 3’h7;
rand bit[2:0] xyz_offset = 3’h7; // rand_mode = OFF rand bit[0:0] specific_mode = 1’h1; // rand_mode = OFF
constraint xyz_c // (from this) (constraint_mode = ON) (randc_test_module.sv:11)
{
(specific_mode == 1’h1) → (xyz != xyz_offset); }
=======================================================
“randc_test_module.sv”, 22: randc_test_module.unnamed$$_2.unnamed$$_1: started at 0s failed at 0s
Offending ‘h.randomize()’
transaction is '{xyz:'h0, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h5, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h1, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h2, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h4, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h5, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h5, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h4, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h2, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h1, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h6, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h2, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h2, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h0, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}
transaction is '{xyz:'h3, specific_mode:'h1, xyz_start:'h0, xyz_offset:'h7}