Achieving a 4x1 Mux using port

In reply to MICRO_91:

I am not sure that there is any way to block the transaction on any port but you can filter it inside the put.


class componentB extends uvm_component;
  
  //indicate the currently selected line
  bit [1:0] selected_line;
  
   `uvm_component_utils (componentB)
 
  uvm_blocking_put_imp #( string ,componentB) m_put_imp;
 
   function new (string name = "componentB", uvm_component parent= null);
      super.new (name, parent);
      selected_line = 0;
   endfunction
  
   virtual function void build_phase (uvm_phase phase);
 
      m_put_imp = new("m_put_imp", this);
 
   endfunction
 
 
   task put ( string INT ) ;
     string tmp;
     tmp.itoa(selected_line);
     tmp = {"compA_", tmp};
     
     //Use the transaction only if it's sent by selected port
     if(tmp == INT)begin 
    	`uvm_info ("CompB", $sformatf(" Called from %0s ",INT), UVM_LOW)
     end
   endtask
 
 
endclass