Randomize multiple times using same constraints

Hi

I have a sequence defined with many constraints to randomize the

constraint a {
a inside {[1:10]};
}
constraint b {
b > a ;
}
constraint stop {
if a >5 stop = 1;
}

task body ();
$display("a value is %d", a);
result = a + b;
...
if (restart)
new_result = a + b;

endtask:body

so if the sequence needs to be restarted during the execution , i want a new set of values and not the previously randomized values for a and b
they should follow the constraints defined in the sequence.

i wanted to use std::randomize but there are many variables that need to be randomized which have a dependency on a and b etc, and they need to get new values as well. I didnt want to specify contraint definitions with std::randomize

Thanks in advance for the help!

In reply to theketi:
You did not complete your first sentence, so I’ll assume you meant to say you have two sets of random variables; one that you only randomize when restart is true, and another set of variables that are randomized whenever.

You can add the following constraint

constraint restart_c {
if (!restart) {a == const'(a);b == const'(b);}
}

Hi

Sorry for the confusion, what i meant is
I have a sequence defined with many constraints to randomize the variables used in that sequence

i dont have two sets of random variables. Everything needs to get randomized once restart is asserted

restart however is not something we know at the beginning, so im not sure how i can use that value to define a constraint.

i just want to do this:

if (restart condition is met)
then
randomize all variables according to their constraints to get new values for a,b

else
continue operations with old a,b

In reply to theketi:

if (restart condition is met)
   this.randomize()

I guess the bigger question might be what is this restart condition and how do you get notified that it has occurred.

Thanks for the reply. I get the restart condition from another sequence.

also , is there a way to make sure i dont get previous values for a,b but get another set of values within the constraint

Thank you!

In reply to theketi:

also , is there a way to make sure i dont get previous values for a,b but get another set of values within the constraint
Thank you!

I have that you you in my first reply.