Reputation: 105
I wrote the following code:
struct packet {
x:int;
y:int;
x >= 0 => y==1;
x < 0 => y==2;
};
While it solved very fast in Specman, for some seeds the Gen Debugger shows that the generator tries to assign y to values different than 1 and 2 and even “y: set of rollbacks”. What I am doing wrong ?
Upvotes: 0
Views: 67
Reputation: 79
Since the generation engine doesn't know the valid space of y's values, it may try to solve it by assigning a random value for y in [MIN_INT..MAX_INT] and only then for x which leads for endless loop. You can solve it by to options:
Add
keep y in [1,2]
Replace the constraints with
keep y == (x >= 0) ? 1 : 0
Upvotes: 3
Reputation: 31
You can help the generator by reducing the state space for the solution according to your intent. It can be done in two ways 1. keep y in [1..2]; 2. Consolidate the constraints keep y == (x>0) ? 1 : 2;
Upvotes: 0
Reputation: 1
In this case generation engine needs to infer information about y from 2 different constraints, which is expensive. Try to consolidate the constraints in single one and/or add information you already know to help it.
Upvotes: 0
Reputation: 51
Using the trinary construct in this case, the generator can easily solve the constraint.
Upvotes: 0