How to provide access from config to sequence item?

Hi,

I am trying to create a sequence item and it requires information from agent config. Can this be done ? Also which is a better approach to collect the information from config, is it through sequence item directly or through the sequence ?

Thanks
jv

Hi ,

i too, have same issue . please can any suggest about this topic.

Thanks
kbkdec15

I’ll answer your second question first.
There is a cost associated with doing uvm_config_db::get(), so it’s always best to minimize the number of times you call it. If you build the call into your sequence_item, then every sequence item will do a uvm_config_db::get(), even if the information hasn’t changed since the last sequence_item. This would be wasteful.
Instead, if you have the sequence do the uvm_config_db::get() call, then you may be able to use the information from a single get() call for multiple sequence_items. In your sequence, you could do something like:

task body();
  if (!uvm_config_db#(seq_config_t)::get(this, "", "seq_config", seq_config))
    begin `uvm_error(...) end
  item = my_item::type_id::create("item");
  for(int i = 0; i<10; i++) begin
    start_item(item);
    void'(item.randomize());
    item.config_field = seq_config.item_config_field;
    finish_item(item);
  end
endtask

The uvm_config_db::get() could be done at the beginning of body(), as shown, or you may want to do it an each nth iteration of the loop, or whatever. That’s up to you. If you want to change the config information during the test, this is probably the best place to do the config_db::get. Remember that the concatenation of {this.get_full_name(),“”,“seq_config”} of the sequence must match the path you specify in the uvm_config_db::set() call, so you’ll need to know the name of the sequence.
If you only need to do it once, then it’s probably easier to do the get() call in the agent, most likely in pre_simulation_phase. Then, the sequence can access the agent’s config via this.m_sequencer.parent, rather than the agent trying to keep track of sequences and push the information down.
Let me know if this helps.
-Tom

In reply to tfitz:

I’ll answer your second question first.
There is a cost associated with doing uvm_config_db::get(), so it’s always best to minimize the number of times you call it. If you build the call into your sequence_item, then every sequence item will do a uvm_config_db::get(), even if the information hasn’t changed since the last sequence_item. This would be wasteful.
Instead, if you have the sequence do the uvm_config_db::get() call, then you may be able to use the information from a single get() call for multiple sequence_items. In your sequence, you could do something like:

task body();
if (!uvm_config_db#(seq_config_t)::get(this, "", "seq_config", seq_config))
begin `uvm_error(...) end
item = my_item::type_id::create("item");
for(int i = 0; i<10; i++) begin
start_item(item);
void'(item.randomize());
item.config_field = seq_config.item_config_field;
finish_item(item);
end
endtask

The uvm_config_db::get() could be done at the beginning of body(), as shown, or you may want to do it an each nth iteration of the loop, or whatever. That’s up to you. If you want to change the config information during the test, this is probably the best place to do the config_db::get. Remember that the concatenation of {this.get_full_name(),“”,“seq_config”} of the sequence must match the path you specify in the uvm_config_db::set() call, so you’ll need to know the name of the sequence.
If you only need to do it once, then it’s probably easier to do the get() call in the agent, most likely in pre_simulation_phase. Then, the sequence can access the agent’s config via this.m_sequencer.parent, rather than the agent trying to keep track of sequences and push the information down.
Let me know if this helps.
-Tom

Hi Tom,
Thank you for help, it got me started!

When I tried to retrieve the value from config_db in sequence run phase, I got a message “trying to use void function without void’” and it pointed to system “get” function.

When I added the build phase, I got the value from config_db without error. I used ncsim simulator.

Alex.