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 ?

Link to comment
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.

Link to comment
Share on other sites

  • 3 weeks later...

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
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.

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...