Jump to content

How to get virtual interface in sequence


Recommended Posts

Praneeth,

 

Try something like this in the sequence:

 

virtual  my_if  m_my_vif;

 

if (! uvm_config_db#(virtual my_if)::get(uvm_root::get(),"*","somestring",m_my_vif))
    `uvm_fatal("config_db"," vif connect failed")
 
 
Elsewhere, you'd need to have added the handle to the config_db, like so:
my_if  m_my_if;
 
uvm_config_db#(virtual my_if)::set(uvm_root::get(),"*", "somestring", m_my_if);
 
 
 
I haven't compiled this to check for typos.
Feedback from gurus welcome.   Particularly, I'd like to hear thoughts on having a clock in a sequence.
 
Link to comment
Share on other sites

I would recommend to get the get the interface handle inside the sequencer's build phase( the way we do in the monitor & driver)

 

 

sequence is static block, static in the sense that it will be not be destroyed and created like the sequences.

 

sequences are not extended from the uvm_component so they dont have access to phasing.

 

you can use p_sequencer handle inside the sequences to access the sequence properties, you have to declare the `uvm_declare_p_sequencer(sample_agent_sequencer) inside sequences to access the p_sequencer handle.

 

Thanks

Nirmish

Link to comment
Share on other sites

  • 1 year later...
  • 4 weeks later...
class my_sequencer extends uvm_sequencer #(my_txn_type) ;
  `uvm_component_utils(my_sequencer);

  virtual interface my_vif;

  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction

endclass

populate my_vif inside the agent, after creating the sequencer.  code not shown.

 

access your testbench resource from a sequence:

class my_seq extends uvm_sequence #(my_txn_type);
  `uvm_object_utils(my_seq);
  `uvm_declare_p_sequencer(my_sequencer); // creates p_sequencer handle

  function new(string name="");
    super.new(name);
  endfunction

  virtual task body();
    p_sequencer.my_vif.wait_clock(5); // example
  endtask

endclass

ps I've run into some opposition on using interface calls in a sequence, but anyway you can use it for accessing other things too.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...