1

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.

Ross Rogers
  • 23,523
  • 27
  • 108
  • 164
max krumer
  • 11
  • 1

3 Answers3

1

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.

Community
  • 1
  • 1
Ross Rogers
  • 23,523
  • 27
  • 108
  • 164
0

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.)

Hackonteur
  • 821
  • 7
  • 12
0

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]
guy
  • 21
  • 3