class ahb_magent extends uvm_agent;
  `uvm_component_utils(ahb_magent)
  //declare pointers to sub components
  ahb_msequencer ahb_msequencer_h;
  ahb_mdriver ahb_mdriver_h;
  virtual ahb_if dut_agent_vi;

  //constructor
  function new (string name, uvm_component parent);
    super.new(name, parent);
  endfunction: new

  //build
  function void build_phase(uvm_phase phase);
  //instantiate subcomponent in build phase and connect them in the connect phase
    ahb_msequencer_h = ahb_msequencer::type_id::create("ahb_msequencer_h",this);
    ahb_mdriver_h    = ahb_mdriver::type_id::create("ahb_mdriver_h",this);
    ahb_mdriver_h.dut_vi = dut_agent_vi;
  endfunction:build_phase

  function void connect_phase(uvm_phase phase);
      ahb_mdriver_h.seq_item_port.connect(ahb_msequencer_h.seq_item_export );
  endfunction:connect_phase
endclass: ahb_magent