我可以为一个变量设置一次约束并在specman中生成几次吗?
我有一个变量,我想在同一个函数中生成几次,每次都具有相同的约束集。 我可以设置一次约束并多次gen
吗? 也就是说,而不是这样:
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...
我想这样做:
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...
这样,如果我想更改a
的约束,我只需要做一次。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过使变量成为封闭对象的实例成员来实现此目的。
如果多个 my_method() 同时在同一个对象上运行,则此实现不是线程安全的。您可以通过将生成的 'a' 分配给 'my_a' 内的方式使其成为 [specman] 线程安全的方法的范围:
或者您可以编写一个方法来生成“a”:
You can do this by making the variable an instance member of the enclosing object.
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:
Or you can just write a method to generate 'a':