Accessing hierarchy in UVM

Hello,

Will it be not possible to access the hierarchy in ubs env like below ?
Lets say requirement is to access one variable of the slave agent monitor in the master driver
(below code needs to be written in one of the task of file ubus_master_driver.sv)
What should be the correct way ?

$display(“hello %s”), m_parent.m_parent.sprint());
This works and prints the env, First m_parent points to the master agent, next m_parent accessed to the env

But if slave_agent is tried to be accessed like below
$display(“hello %s”), m_parent.m_parent.slaves[0].sprint());

Then it gives the error slaves is not a class item.

Thank You,
Sachin Shashikantrao Pampattiwar

In reply to sspampattiwar:
I would need to see the declarations of all variables involved to help you with the error. But a better solution is to use a shared configuration object to hold the variables you want to access. That gets ride of the hierarchical paths.

In reply to dave_59:

Thanks,
I am using ubus example that is is downloaded from the uvm_world.
I’have a condition where I need to decide something in the master_driver based on slave agent monitor. THe slave interface is not available in the master.

Lets say hierarchy is

env

  • masters[0]
    –Driver
    –Monitor
    -Slaves[0]
    –Driver
    –Monitor

I need to transfer the bit from Slave monitor to Master driver.
What should be the correct way to implement this in uvm ?
I tried using the hierarchy as explained (m_parent.m_parent.slaves[0].monitor)
it doesnt work, I see that the hierarchy till env using m_parent.m_parent is accessible in masteragent driver. but then if i try to access the slaves[0] i tgives the error

Is uvm_config_db is correct way ?
Thank You,
Sachin Shashikantrao Pampattiwar