Question : My code is mentioned below. when i run simulation it shows solver failure.
program automatic randomization_error_for_rand_mode_off;
bit clk = 1'b0;
class randomize_with_io;
rand bit [3:0] a = 0;
rand bit [3:0] b = 0;
int c = 0;
/* Constraints with implication operator */
constraint on_a {
a inside {[0:5]};
b inside {[0:15]};
}
endclass: randomize_with_io
initial begin
randomize_with_io r;
r = new();
forever@(posedge clk)
begin
/* randomize() */
r.a.rand_mode(0); //disabling the rand mode
r.randomize() with {
(b inside {[0:15]}) -> a == 4;
};
$display("----------------------------------------");
$display("|at time = %0t | a = %0d | b = %0d | c = %0d |", $time,r.a,r.b,r.c);
end
$display("----------------------------------------");
end
initial begin
forever #5 clk = ~clk;
end
initial begin
#500 $finish;
end
endprogram : randomization_error_for_rand_mode_off
I am seeing following solver failure while running the simulation , how can i resolved it.
==================================================
Solver failed when solving following set of constraints
rand bit[3:0] a = 4'h0; // rand_mode = OFF
rand bit[3:0] b; // rand_mode = ON
constraint WITH_CONSTRAINT // (from this) (constraint_mode = ON) (randomization_error_for_rand_mode_off.sv:28)
{
(b inside {[0:15]}) -> (a == 4'h4);
}
==================================================
Solver failed when solving following set of constraints
rand bit[3:0] a = 4'h0; // rand_mode = OFF
rand bit[3:0] b; // rand_mode = ON
constraint WITH_CONSTRAINT // (from this) (constraint_mode = ON) (randomization_error_for_rand_mode_off.sv:28)
{
(b inside {[0:15]}) -> (a == 4'h4);
}
==================================================
it is because you disabled the rand mode of "a" and in randomization you are setting a = 4 if value of "b" lies between 0 to 15. To resolve it, either enable the rand_mode(1) for "a" or change the constraint inside "randomize() with".
ReplyDeleteEnjoy :-)