在 Specman 中返回一个数组
如何从 Specman 中的方法调用返回数组? 例如,
method a : list of uint is {
var data: list of uint;
.....
result = data;
};
extend sys {
var data_sys: list of uint;
run() is also {
data_sys = a();
};
};
我的打印输出显示一些元素与数组数据和 data_sys 不同。 你能告诉我我错过了什么吗?
How do I return an array from a method call in Specman? E.g.
method a : list of uint is {
var data: list of uint;
.....
result = data;
};
extend sys {
var data_sys: list of uint;
run() is also {
data_sys = a();
};
};
My print out shows some elements are different from array data and data_sys. Can you tell me what I missed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您发布的代码无法编译。 放入更多打印语句或在 Specview 中设置断点并单步执行代码。 您知道您正在执行哪个测试阶段的打印输出吗? 如果您想按程序设置 data_sys(而不是让 Specman 生成它),您应该指定不生成修饰符“!”。
The code you posted wont compile. Put in more print statements or set a break point in specview and step through the code. Do you know which test-phase you're doing your printout? If you want to procedurally set data_sys ( instead of having Specman generate it ), you should specify the do-not-generate modifier '!'.
请提供sscce。
如果没有这个,这个非常基本的示例可能会这样做:
方法可以返回一个数组,该数组是默认为您分配的。 它是由指针返回的,所以要注意。
作为一条经验法则,在计算时尽量避免使用返回列表的方法。 尝试将列表作为参数传递,以传达其动态特性,除非该方法是创建方法或 getter:
pls provide a sscce.
without that, this very basic example might do:
methods can return an array, which is allocated for you by default. it's returned by pointer, so be aware.
as a thumb-rule, try to avoid list-returning methods when you calculate on them. try to pass the list as a parameter, to convey its dynamic nature, unless the method is a creation method or a getter: