Accessing interface signals inside sequence

Imagine I have a scenario where I will need to access interface signals / configuration class variables from my sequence.
I see multiple ways to do it :

  1. Directly “get” the interface or object using config_db inside the sequence ( Need to use get_sequencer() inside config_db
    Something like uvm_config_db#( pcc_config )::get(get_sequencer(), “”, “pcc_cfg”, pcc_cfg)).
  2. Declare the objects for the vif and config class, in the sequencer. Declare this sequencer as p_sequencer for my sequence. Use p_sequencer.object to access the needed variables.

Which method is preferrable and are there any other methods of accessing interface/config data from the sequence ?

In reply to Abhi_Ash:

Using signals in a sequence violates the rules of transaction-modelling heavily and avoids reuse of sequences. Because of this it is not a good approach to use signals inside a sequence.

I am aware that using IF signals in a sequence has a lot of disadvantages.
What if I have a situation where I MUST implement this ?
Example : If the same question was asked in an interview ?

In reply to Abhi_Ash:

Without knowing what you need to get from the interface signals and that this was an interview question, it’s hard to give specific advice. Usually we try to handle everything through a driver or create another sequencer drive repair to handle this communication.

In general the UVM preaches an OOP “separation of concerns” methodology where we try to avoid introducing dependencies on other classes as much as possible. That is why we do not recommend using p_sequencer. This page shows a number of ways to use the config_db with a sequence.

One other consideration; for performance considerations, we try to limit uvm_config_db access. Depending on how often these sequences get created, you might want to have the object that creates the sequence set the configuration object directly after creation. That would eliminate calls to uvm_config_db::get().

Thanks Dave. The page you had pointed was useful.

you might want to have the object that creates the sequence set the configuration object directly after creation. That would eliminate calls to uvm_config_db::get()”
You are trying to say : instead of 100 sequences calling config_db::get 100 times, I can just do a config_db::get in sequencer / agent only once. Is that right ?

Here are more details on the question :
Consider an adder with inputs enable, input_1 and input_2.
We want the output to be an addition of the inputs everytime enable goes high.
We want to control all possible scenarios from the sequence without use of driver.