Connect analysis_port to another analysis_port's provider

Hi,

I have a reference model in my test environment that I want to upgrade. I want to add a component inside this class that is a model of some part of its logic. A simplified block diagram is shown below. Output of subRef is also an output of Ref Model.

  1. How should I create and use uvm analysis ports to pass data from subRef’s UAP to Ref’s UAP?
  2. What should be the correct way of connecting Ref’s UAPI to subRef’s UAP?
    Note: Currently I am passing the data “manually” by calling subRef’s write_XXX method from Ref’s write_XXX method. They both need to be executed. However, they are independent of each other.

My goal is to update Ref model in such a way, that using Ref model requires connecting only its UAP/UAPI without the need of connecting subRef’s ports. subRef would stay “hidden” for a user.

Thank you for your time and help!

UAP - uvm_analysis_port
UAPI - uvm_analysis_port_imp_XXX

Block diagram. Before and after creating subRef.

I was able to answer to my first question - output ports. I didn’t expect that I can connect it like this.

class SubRefModel extends uvm_component;
  `uvm_component_utils(SubRefModel)
  // Input port
  `uvm_analysis_imp_decl(_ctrl_in_port)
  uvm_analysis_imp_ctrl_in_port#(ControlTrans, SubRefModel) ctrl_in_port;
  // Output port
  uvm_analysis_port #(DataTrans) data_out_port;
  // Other lines: new, build_phase, etc.
endclass

class RefModel extends uvm_component;
  `uvm_component_utils(RefModel)
  // Input port
  `uvm_analysis_imp_decl(_ctrl_in_port)
  uvm_analysis_imp_ctrl_in_port#(ControlTrans, RefModel) ctrl_in_port;
  // Output port
  uvm_analysis_port #(DataTrans) data_out_port;
  // SubRef
  SubRefModel u_sub_ref;
  function void connect_phase(uvm_phase phase);
    // Connecting output ports is easy
    u_sub_ref.data_out_port.connect(this.data_out_port);
  endfunction
  // Other lines: new, build_phase, etc.
endclass

I still struggle to connect input ports from Ref’s connect_phase.
Is there a way to get ctrl_in_port’s uvm_analysis_port it is connected to?
Something like:

this.ctrl_in_port.<SOMETHING_HERE>.connect(u_sub_ref.ctrl_in_port);

The closest I could get to ports provided to uvm_analysis_port_imp_XXX is this code.

Part of Ref’s class:

  function void end_of_elaboration_phase(uvm_phase phase);
    uvm_port_list list;

    this.ctrl_in_port.get_provided_to(list);
    if (list.size() == 0) begin
      `uvm_error(get_type_name(), $sformatf("%s.ctrl_in_port c to any uvm_analysis_port", this.get_full_name()));
    end
    else begin
      `uvm_info(get_type_name(), $sformatf("%s.ctrl_in_port is connected to d%0d uvm_analysis_port", this.get_full_name(), list.size()), UVM_HIGH)
    end
  endfunction

I have tried to get uvm_analysis_port from list but I failed to find what method should I use.

[Q] Does anyone know how could I execute .connect(…) on element from list?

I think it should be something like this:

foreach(list[elem] begin
  list[elem].<SOMETHING_HERE>.connect(sub_ref.ctrl_in_port);
end