I have a variable that I want to generate a few times in the same function, each time with the same set of constraints. Can I set the constraints once and the just gen
it many times? That is, instead of this:
var a:uint;
gen a keeping {it in [100..120];};
// some code that uses a
.
.
.
gen a keeping {it in [100..120];};
// some code that uses a
.
.
.
gen a keeping {it in [100..120];};
// some code that uses a
// etc...
I'd like to do this:
var a:uint;
keep a in [100..120];
.
.
.
gen a;
// some code that uses a
.
.
.
gen a;
// some code that uses a
.
.
.
gen a;
// some code that uses a
// etc...
That way if I want to change a
s constraints I only have to do it once.
From stackoverflow
-
You can do this by making the variable an instance member of the enclosing object.
a : uint; keep a in [100..120]; my_method()@qualified_clk_rise_e is { gen a; ... gen a; ... gen a; };
This implementation isn't thread-safe if multiple my_method()'s are running on the same object at the same time.You can make it [specman] thread-safe by assigning the generated 'a' to a 'my_a' within the scope of the method:
var my_a : uint; gen a; my_a = a;
Or you can just write a method to generate 'a':
gen_a(): uint is { gen result keeping { it in [100..120] }; }; my_method()@qualified_clock_rise_e is { var a : uint; ... a = gen_a(); ... a = gen_a(); ... a = gen_a(); ... };
0 comments:
Post a Comment