How to set dynamic array via #uvm_config_db

Hello,

I have an dynamic array in my monitor. And I want to set its values from environment usinf uvm_config_db. I am doing this, but it doesn’t work. Is there another way to do it?

code in the monitor:

 typydef enum {CC_0, CC1} unit_e;

 unit_e unit [$];

`uvm_component_utils_begin( cc_monitor )
    `uvm_field_queue_enum(  unit_e, unit , UVM_DEFAULT )
`uvm_component_utils_end
 ....

code in the environment:

 uvm_config_db#( unit_e )::set(this, "cc_agent*", "unit", {CC_0, CC_1});

You have parameterized uvm_config_db with
unit_e
, not a queue of
unit_e
. You need to define a
typedef
for the queue, or you can try

 uvm_config_db#( type(unit) )::set(this, "cc_agent*", "unit", {CC_0, CC_1});

Also, we strongly recommend not using the `uvm_field_macros. See MacroCostBenefit | Verification Academy

In reply to dave_59:

Thank you Dave. So, as I understood advices in the article correct, I should set values directly. Am I right?

For instance:

code in the monitor:

typydef enum {CC_0, CC1} unit_e;

unit_e unit [$];

uvm_component_utils_begin( cc_monitor ) uvm_component_utils_end

code in the environment:

cc_agent.monitor.unit = {CC_0, CC_1};

In reply to Danil:

No. We still recommend using the uvm_config_db to set() override values in the test before lower components are constructed to get() the values.

In reply to dave_59:

New thing I learn from this. Thanks Dave59