我可以为一个变量设置一次约束并在specman中生成几次吗?

发布于 2024-07-09 12:37:38 字数 570 浏览 9 评论 0原文

我有一个变量,我想在同一个函数中生成几次,每次都具有相同的约束集。 我可以设置一次约束并多次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 as constraints I only have to do it once.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遇到 2024-07-16 12:37:38

您可以通过使变量成为封闭对象的实例成员来实现此目的。

a : uint;
keep a in [100..120];
my_method()@qualified_clk_rise_e is {

    gen a;
    ...
    gen a;
    ...
    gen a; 
};

如果多个 my_method() 同时在同一个对象上运行,则此实现不是线程安全的。您可以通过将生成的 'a' 分配给 'my_a' 内的方式使其成为 [specman] 线程安全的方法的范围:

var my_a : uint;
gen a;
my_a = a;

或者您可以编写一个方法来生成“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();
    ...
};

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();
    ...
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文