I am learning the SystemVerilog constraints concept. As a part of it, I want to have a constraint to randomize the div variable which are divisible by both 4 and 10. This is the code I tried. I am getting display as '0'. Can anyone please help me with what I am missing here?
class div_4_10;
rand bit [3:0] div;
constraint constr_4_10 { div % 20 == 0; }
endclass
module div_cons;
div_4_10 divisible;
initial begin
divisible = new();
for (int i = 0; i <5; i++) begin
divisible.randomize();
$display("Divisible by 4 and 10 : %0d", divisible.div);
end
end
endmodule