Jump to content

Communication between uvm_sequence and uvm_component

Recommended Posts

I have two classes, one is block_seq which extends from uvm_sequence and other is block_cfg_mngr which extends from uvm_component. How do I exchange information between these two. I need to generate random values in block_cfg_mngr which depends on the values I generate in the bock_sequence body method. I need a communication mechanism to pass the information from uvm_sequence to uvm_component or vice versa. How can I do that ?

Share this post

Link to post
Share on other sites

Your sequence has a handle to the sequencer it runs on, called p_sequencer.

You can create a TLM imp there, and a TLM port in your block_cfg_mngr component, and then write the data from the port to the imp.

Your sequence can then see the value using its handle to the sequencer.

Share this post

Link to post
Share on other sites

One other way could be:


Since binding of port can be possible with the components(which are supposed to be hierarchical members unlike sequence which associated during run-time).


So you can create one port in your env and connect it to block_cfg_mngr import.


Now in the sequence you might be already having the env pointer through config_db (if not set the port from env in the config_db) , get the pointer of env,port in your sequence and start accessing it.

///// Env Classs /////
class my_env extends uvm_env;
   uvm_tlm_b_initiator_socket #(uvm_tlm_gp)    config_socket;

function my_env::new(string name = "my_env", uvm_component parent = null);
  super.new(name, parent);
  config_socket         = new ("config_socket",this); 

   // build_phase:
  uvm_config_db #(uvm_tlm_b_initiator_socket)::set(this, "", "config", config_socket);

//// Sequence Class ///

class my_seq extends uvm_sequence(uvm_sequence_item)

// CONFIG tlm block socket for configuration
uvm_tlm_b_initiator_socket #(uvm_tlm_gp)    bsocket;

task body;
  // CONFIG GEtting Handle from env for config socket
  if(!uvm_config_db #(uvm_tlm_b_initiator_socket)::get(null,"uvm_test_top.m_env", "config", bsocket)) begin
    `uvm_error("CONFIG_DB_ERROR", "Could not find config")

// Use it the way you want
endtask: body

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now