How to get configuration from sequence

Hello,

I need to set my configuration using uvm_config_db# in test and get it from my sequnce. I’m doing this, but it doesn’t work. How should I properly use set/get methods in this case?

class pcc_config extends uvm_object;

endclass : pcc_config

class pcc_base_test extends uvm_test;

pcc_cfg = pcc_config::type_id::create( “pcc_cfg”, this );
uvm_config_db#( pcc_config )::set( null, “*”, “pcc_cfg” , pcc_cfg );

class pcc_sys_base_reg_sequence extends uvm_sequence;

if( !uvm_config_db#( pcc_config )::get(null, “”, “pcc_cfg”, pcc_cfg) ) begin
`uvm_warning( “NOCFG”, {"Configuration wasn’t set for ", get_name(), “. Default config was used.”} )

In reply to Danil:

You might need a component to anchor your request to the config DB. Try changing the get to

uvm_config_db#( pcc_config )::get(get_sequencer(), "", "pcc_cfg", pcc_cfg)

In reply to Tudor Timi:

Thank you Tudor for good idea

In reply to Danil:

Danil, I am currently doing the exact scenario you described; no problems.

Can you confirm a couple things:

  1. Make sure your set() is not in the run_phase; place it in the build, connect, or end of elaboration phase ( I just use build_phase ).

  2. Make sure your get() is inside the body() method of the sequence.

This is just to rule out the thread hitting the get() before the set(). Otherwise your code looks fine…

In reply to bmorris:

In reply to Danil:
Danil, I am currently doing the exact scenario you described; no problems.
Can you confirm a couple things:

  1. Make sure your set() is not in the run_phase; place it in the build, connect, or end of elaboration phase ( I just use build_phase ).
  2. Make sure your get() is inside the body() method of the sequence.
    This is just to rule out the thread hitting the get() before the set(). Otherwise your code looks fine…

Hi…
im setting config in test trying to get in sequence_item(transaction_class) is this correct way to get in sequence_item
And in config class i want a random data for that im declaring the rand bit[1:0] char_len ; like this but im getting only initial data not getting random data.
is this correct way to do declare as a rand can u please clarify my doubts

In reply to meenakshi bommu:

Looks like you did not randomize your seq_item.

In reply to chr_sue:

In reply to meenakshi bommu:
Looks like you did not randomize your seq_item.

no im randomizing my seq_item there im constraint the data like {char_len == cfg.char_len} for this im want to get handle in seq_item is it possible to get handle in seq_item

In reply to meenakshi bommu:

I meant you do not randomize your configuration object.