Reputation: 163
I have this multiple fields that need to be constrained in this manner:
struct my_struct {
a : uint;
b : uint;
c : uint;
d : uint;
keep 3*a + 4*b + 5*c + 6*d == 206 and a + b + c + d == 50;
my_method() @clk_event is {
while (TRUE) {
if (ctr == 0) {
gen a;
gen b;
gen c;
gen d;
};
if (ctr == 50) {
ctr = 0;
} else {
ctr += 1;
};
wait cycle;
};
};
};
I basically want to generate a new set of values for a
, b
, c
, and d
periodically. The above code is not working as their values did not change in my simulation. Any idea how to do it?
Upvotes: 2
Views: 203
Reputation: 338
When you generate one field, other fields can't change their values, they are inputs for the constraints. Given your constraints, there can be only one correct value for a field if three other can't change.
You probably need to modify the design and put the fields with constraints under a struct, and have a field of this struct type. So instead of four separate gens, you will have only one, and it will do the job right.
Upvotes: 2