About ovm_set_attribute_by_name

Hi,
The function declaration of ovm_set_attribute_by_name is as follows:

function void ovm_set_attribute_by_name (TRH txh,
                                         string nm, 
                                         logic [1023:0] value,
                                         string radix,
                                         TRH numbits=0);

I notice that there is a radix argument in this function.
It seems that this argument is used to record the radix of the attribute.
How can user set the radix of the attribute in a transaction so that ovm_set_attribute_by_name() can record the radix? Should user call any macro to set radix of specific attribute in the transaction?

Thanks!

Best regards
rex

Hi Rex,

As you might be aware in ovm, these are functions to be simulator neutral for transaction recording purpose.

If you are using ncsim/irun simulator,these are just wrappers over the $sdi_* system tasks/functions.To understand how these methods work, kindly look at the documentation for $sdi* tasks (Cadence Transaction recording SDI/HDL reference) .

There is a function :

$sdi_set_attribute_by_name(fiber_handle, // Required
attribute_name, // Required
verilog_variable // Required
format_string,
position, // Optional
)
and the format_string descriptions are

“'b” Binary (0, 1, X, Z)
“'o” Octal
“'d” Unsigned decimal
“'u” Unsigned decimal
“'s” Signed decimal
“'h” Hexadecimal
“'x” Hexadecimal
“'a” ASCII string

Please send a mail to support@cadence.com incase you need more information on this.

Regards
Chinmay

Hi Chinmay,
Thanks for your information. I am curious about if user can call the macro like ovm_field_int(arg,flag) to specify the radix of attribute in a transaction. In fact, I have traced the codes in OVM library and found that radix argument of ovm_set_attribute_by_name() is affected by the flag of ovm_field_int() AND OVM_RADIX.
Accoding my calculation, the value is always 0, which is equal to OVM_NORADIX.
So I guess that users can NOT control the radix of attribute in a transaction. If I am wrong, please let me know. Thanks!

Best regards
rex

Hello Rex,

You are correct that using ovm_field_* macros provides the more abstract interface to set the Radix of a transaction.

I have never had the need to use the ovm_set_attribute_by_name function because I prefer the ovm_field macros to achieve this.

For example, I changed the xbus_transfer.sv in the xbus example to change the radix of addr and data variables as follows:

`ovm_object_utils_begin(xbus_transfer)
    `ovm_field_int      (addr,           OVM_ALL_ON|<font color=Red>OVM_DEC</font>)
    `ovm_field_enum     (xbus_read_write_enum, read_write, OVM_ALL_ON)
    `ovm_field_int      (size,           OVM_ALL_ON)
    `ovm_field_array_int(data,           OVM_ALL_ON|<font color=Red>OVM_DEC</font>)
    `ovm_field_array_int(wait_state,     OVM_ALL_ON)
    `ovm_field_int      (error_pos,      OVM_ALL_ON)
    `ovm_field_int      (transmit_delay, OVM_ALL_ON)
    `ovm_field_string   (master,         OVM_ALL_ON|OVM_NOCOMPARE)
    `ovm_field_string   (slave,          OVM_ALL_ON|OVM_NOCOMPARE)
  `ovm_object_utils_end

And due to this change I observed that the object.print() and object.record() function (used for transaction recording) both use the provided radix.

Here’s the output of printing the xbus_transfer with this change:

<span style="font-family:'Courier New'">
----------------------------------------------------------------------
Name                     Type                Size                Value
----------------------------------------------------------------------
xbus_transfer_inst       xbus_transfer       -                   @1322
  addr                   integral            16                    'd4
  read_write             xbus_read_write_en+ 32                   READ
  size                   integral            32                    'h1
  data                   da(integral)        1                       -
    [0]                  integral            8                   'd117
  wait_state             da(integral)        0                       -
  error_pos              integral            32                    'h0
  transmit_delay         integral            32                    'h0
  master                 string              10             masters[0]
  slave                  string              9               slaves[0]
  begin_time             time                64                    970
  end_time               time                64                   1010
----------------------------------------------------------------------</span>

Are you observing that you cannot affect the radix using ovm_field macros in your simulation?

Thanks,

Umer

Hi Umer,
Thanks for your example. I have tried to change the radix by ovm_field_* macros and it works!

Thanks a lot!

Best regards
rex