Specman 有静态变量吗?
我在 Specman 中继承了以下代码:
some_method() is {
var a: bool;
if (!a) {
a = some_other_method();
};
};
我的理解是,每次调用 some_method()
时,都会重新生成 a
,并且检查 是没有意义的>a
被赋值之前的值。 然而,我可能在这里遗漏了一些东西。 例如,如果 a
是静态的,那么这段代码就有意义,这让我想到了我的问题:
有没有办法让一个变量在specman中是静态的?
I have the following code in specman that I inherited:
some_method() is {
var a: bool;
if (!a) {
a = some_other_method();
};
};
My understanding is that each time some_method()
is called, a
is generated anew, and there's no sense in checking a
's value before it's assigned. However, it may be that I'm missing something here. For instance, if a
is static then this code makes sense, which brings me to my question:
Is there any way for a variable to be static in specman?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有像 C 中那样的静态变量。方法中的变量如果未初始化,则有其默认值(在本例中为 False),因此您应该是正确的
if (!a) 应始终为
True
。如果
a
是一个结构成员,情况就会有所不同,那么像其他 OO 语言一样,它会在多个方法调用中保留该值,并且检查会更有意义:您也可以在交互式提示:
交互式帮助也很好,例如尝试:
并选择条目(按数字)
sn_eref:变量:声明
。 在那里您可以找到与您的问题相关的所有信息。干杯,
丹尼尔
there are no static variables as in C. A variable in a method has its default value (
False
in this case) if not initialized, so you should be rightif (!a)
should always beTrue
.Things would be different if
a
was a struct member, then like in other OO languages it would retain there value over several method calls and the check would make more sense:You can check stuff like this also on the interactive prompt:
There the interactive help is also nice, for example try:
and select the entry (by number)
sn_eref: variables : declaring
. There you will find all relevant information for your question.Cheers,
Daniel
Specman v15.2 中的语言中添加了静态结构成员(事件、字段、方法)。 静态字段无法生成、物理(%) 或在when 子类型中使用。
以下是 teamspecman 博客的一些评论:e 中的静态成员
Static struct members (events, fields, methods) were added to the language in Specman v15.2. A static field can't be generated, physical(%) or used in when subtypes.
Here's some comments from the teamspecman blog : Static members in e