检索变量名称以便在 Specman 中打印它们

发布于 2024-12-10 17:06:20 字数 247 浏览 0 评论 0原文

我希望在 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 技术交流群。

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

发布评论

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

评论(3

比忠 2024-12-17 17:06:20

我不确定你会如何做到这一点,除非你以某种方式拥有所有字段的集合,这将为你提供所有字段的名称

因此,我将进行分支预测并假设您想要给定 struct/unit 的所有字段

extend sys {

    A : list of uint;
    B : int;
    cee : string;
    run() is also {

        var rf_sys: rf_struct = rf_manager.get_exact_subtype_of_instance(sys);
        for each (field) in rf_sys.get_declared_fields() {
             print field;
             print field.get_long_name();  // <-- Here's your "get_name()" function
          };
    };
};

在版本 8.2 上,这将产生:

Usage: . env.sh [-32bit|-64bit] [-v] [[VAR=value]...]
Welcome to Specman Elite(64) (09.20.482-d)  -  Linked on Wed Mar  2 13:32:19
2011

Protected by U.S. Patents 6,141,630 ;6,182,258; 6,219,809; 6,347,388;
6,487,704; 6,499,132; 6,502,232; 6,519,727; 6,530,054; 6,675,138; 6,684,359;
6,687,662; 6,907,599; 6,918,076; 6,920,583; Other Patents Pending.

1 notification was modified by command 'set notify -severity=WARNING
DEPR_START_TCM_ARG_BY_REF'
Checking license ... OK
Loading /nfs/pdx/home/rbroger1/tmp.e ...
read...parse...update...patch...h code...code...clean...GC(sys)...

Doing setup ...
Generating the test using seed 1...

Starting the test ...
Running the test ...
  field = rf_field 'time', Specman's private modules
  field.get_long_name() = "time"
  field = rf_field 'logger', Specman's private modules
  field.get_long_name() = "logger"
  field = rf_field 'A', line 5 in @tmp
  field.get_long_name() = "A"
  field = rf_field 'B', line 6 in @tmp
  field.get_long_name() = "B"
  field = rf_field 'cee', line 7 in @tmp
  field.get_long_name() = "cee"
No actual running requested.
Checking the test ...
Checking is complete - 0 DUT errors, 0 DUT warnings.

如果没有要完全回答您的问题,请在您的 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:

extend sys {

    A : list of uint;
    B : int;
    cee : string;
    run() is also {

        var rf_sys: rf_struct = rf_manager.get_exact_subtype_of_instance(sys);
        for each (field) in rf_sys.get_declared_fields() {
             print field;
             print field.get_long_name();  // <-- Here's your "get_name()" function
          };
    };
};

On version 8.2, this yields:

Usage: . env.sh [-32bit|-64bit] [-v] [[VAR=value]...]
Welcome to Specman Elite(64) (09.20.482-d)  -  Linked on Wed Mar  2 13:32:19
2011

Protected by U.S. Patents 6,141,630 ;6,182,258; 6,219,809; 6,347,388;
6,487,704; 6,499,132; 6,502,232; 6,519,727; 6,530,054; 6,675,138; 6,684,359;
6,687,662; 6,907,599; 6,918,076; 6,920,583; Other Patents Pending.

1 notification was modified by command 'set notify -severity=WARNING
DEPR_START_TCM_ARG_BY_REF'
Checking license ... OK
Loading /nfs/pdx/home/rbroger1/tmp.e ...
read...parse...update...patch...h code...code...clean...GC(sys)...

Doing setup ...
Generating the test using seed 1...

Starting the test ...
Running the test ...
  field = rf_field 'time', Specman's private modules
  field.get_long_name() = "time"
  field = rf_field 'logger', Specman's private modules
  field.get_long_name() = "logger"
  field = rf_field 'A', line 5 in @tmp
  field.get_long_name() = "A"
  field = rf_field 'B', line 6 in @tmp
  field.get_long_name() = "B"
  field = rf_field 'cee', line 7 in @tmp
  field.get_long_name() = "cee"
No actual running requested.
Checking the test ...
Checking is complete - 0 DUT errors, 0 DUT warnings.

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 the rf_manger itself ( introspection at its best). Then you can find all the functions that Cadence doesn't tell you about in their documentation.

木有鱼丸 2024-12-17 17:06:20

您无法获取变量的字符串名称。尽管您可以使用 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 than my_var.to_name(). (Yes, typos and cut and paste errors can happen.)

烏雲後面有陽光 2024-12-17 17:06:20

我认为这就是您正在寻找的:

define <dump'action> "dump <exp>" as {
    out("<exp>","=[",<exp>,"]");
};

您可以在 specman 命令行或内部函数中使用此宏,例如:

foo() is {
    var a : int = 5;
    dump a;
};

将给出:

a=[5]

I think this is what you are looking for:

define <dump'action> "dump <exp>" as {
    out("<exp>","=[",<exp>,"]");
};

you can use this macro in the specman command line or inside functions, for example:

foo() is {
    var a : int = 5;
    dump a;
};

will give:

a=[5]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文