检索变量名称以便在 Specman 中打印它们
我希望在 Specman 中执行以下操作:
my_task() is {
var my_var : int;
my_var = 5;
message(LOW,appendf("%s=[%d]",my_var.to_name(),my_var));
};
目前,我正在搜索内部任务 to_name()
。我不想为此创建一个结构。我希望只使用 Specman 内部结构。
I wish to do the following in Specman:
my_task() is {
var my_var : int;
my_var = 5;
message(LOW,appendf("%s=[%d]",my_var.to_name(),my_var));
};
Currently, I'm in search of the internal task to_name()
. I do not want to create a struct for this. I wish to only use Specman internals.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定你会如何做到这一点,除非你以某种方式拥有所有字段的集合,这将为你提供所有字段的名称。
因此,我将进行分支预测并假设您想要给定 struct/unit 的所有字段:
在版本 8.2 上,这将产生:
如果没有要完全回答您的问题,请在您的 Specman 版本的文档中详细了解 Specman 的自省或反射界面。警告,Cadence 的细节有点匮乏。另外, 请参阅我对“Specman:如何检索存储在另一个 var 中的 var 的值”的回答。。最后,在
specview
中,您可以使用数据浏览器来浏览rf_manger
本身(最好的内省)。然后您可以找到 Cadence 在其文档中没有告诉您的所有功能。I'm not sure how you'd do this unless you somehow have the collection of all the fields, which would give you the name of all the fields.
So, I'm going to branch predict and assume that you want all the fields of a given
struct/unit
:On version 8.2, this yields:
If that doesn't quite answer your question, look more into Specman's introspection or reflection interface in the documentation for your version of Specman. Warning, details are a bit scarce from Cadence. Also, see my answer to "Specman: how to retrieve values of var which is stored in another var".. Finally, in
specview
you can use the data browser to browse therf_manger
itself ( introspection at its best). Then you can find all the functions that Cadence doesn't tell you about in their documentation.您无法获取变量的字符串名称。尽管您可以使用
get_name()
获取字段的名称。这是有道理的,因为变量仅在声明它的位置处是已知的。您甚至无法在
my_task()
的后续扩展中访问该变量。因此,如果您已经在声明变量的位置编辑代码,只需说"my_var"
而不是my_var.to_name()
。 (是的,可能会发生拼写错误以及剪切和粘贴错误。)You can't get the string name of a variable. Although you can get the name of a field using
get_name()
.This makes some sense, because the variable is only known at the location it is declared. You can't even access the variable in a later extension of
my_task()
. So if you are already editing the code at the location where the variable was declared, just say"my_var"
rather thanmy_var.to_name()
. (Yes, typos and cut and paste errors can happen.)我认为这就是您正在寻找的:
您可以在 specman 命令行或内部函数中使用此宏,例如:
将给出:
I think this is what you are looking for:
you can use this macro in the specman command line or inside functions, for example:
will give: