Overriding `uvm_field_int and `uvm_field_array_int values from command line

my_config class is defined as follows -

===============
class my_config extends uvm_object;

rand int my_data1;
rand bit [4:0] my_data2;

uvm_object_utils_begin(my_config) uvm_field_int(my_data1, UVM_ALL_ON)
`uvm_field_array_int(my_data2, UVM_ALL_ON)

.
endclass

I want to override the values of my_data1 and my_data2 from the command line.Does UVM support this feature ?

I found some material on +uvm_set_config_int argument that we can pass on the command line.

+uvm_set_config_int=uvm_test_top.m_env,my_data1,`h23

But it seems when I print to see the configuration the data “my_data1” doesn’t have value 23.
Can someone please help to answer the question ?

In reply to saurabhchauhan:
Two problems arise over the fact that your my_config class is not derived from uvm_component. Both problem occur regardless of whether you try to use the commend line or config_db::set from your test.

The first is the path used to set the config value. Since it is not part of the component hierarchy, these config items exist at the top level, and are not part of m_env. The second is that the field macros apply settings only for fields in classes derived from uvm_component. You need to explicitly apply the settings.

In reply to dave_59:

what is the method to change the uvm_field_int() parameters based on a random value in the object, example pack or no pack based on a value of my_data1 (in the example above) to be UVM_NOPACK for example

Typically you give a constant for the FLAG argument:

`uvm_field_int(ARG, FLAG)

You could pass a variable, but no promises that this would work.


`uvm_field_int(my_int, (UVM_ALL_ON | ((my_data1==1'b1) ? UVM_PACK : UVM_NO_PACK)) 

In reply to chrisspear:

Typically you give a constant for the FLAG argument:

`uvm_field_int(ARG, FLAG)

You could pass a variable, but no promises that this would work.


`uvm_field_int(my_int, (UVM_ALL_ON | ((my_data1==1'b1) ? UVM_PACK : UVM_NO_PACK)) 

It does not work. I had to do my own implementation of the pack with uvm_object_utils instead of uvm_object_utils_begin… It could be a tool issue! The do_pack function always works though but requires work. The `uvm_field_int should have worked too with just changing the flags but it did not do the job not sure why!,

In reply to chrisspear:

Depending on how much you trust your compiler optimizations, you could also make a constrained flag variable.

rand int pflag;
constraint c_pack {pflag == UVM_ALL_ON | ((my_data1==1'b1) ? UVM_PACK : UVM_NO_PACK);}
...
  `uvm_field_int(my_int, pflag)