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

Link to post
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
  config_socket         = new ("config_socket",this); 
endfunction


   // 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")
  end

// Use it the way you want
bsocket.write(uvm_tlm_gp);
endtask: body
Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...