Tutorials

Learn More

Using b_initiator and b_target example

// initiator code
class initiator extends uvm_component;
  seq_item req;
  uvm_tlm_time tlm_delay;
  uvm_tlm_b_initiator_socket #(seq_item) socket_i;
  
  `uvm_component_utils(initiator)
  
  function new(string name = "initiator", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    socket_i = new("socket_i", this);
    tlm_delay = new("tlm_delay");
  endfunction
  
  task run_phase(uvm_phase phase);
    super.run_phase(phase);
    req = seq_item::type_id::create("req");
    assert(req.randomize());
    tlm_delay.reset();
    `uvm_info(get_name(), $sformatf("send req =\n%s", req.sprint()), UVM_NONE);
    socket_i.b_transport(req, tlm_delay);
  endtask
endclass

// target code
class target extends uvm_component;
  uvm_tlm_b_target_socket #(target, seq_item) socket_t;
  
  `uvm_component_utils(target)
  
  function new(string name = "target", uvm_component parent = null);
    super.new(name, parent);
    socket_t = new("socket_t", this);
  endfunction
  
  virtual task b_transport(seq_item req, uvm_tlm_time tlm_delay);
    `uvm_info(get_type_name(), $sformatf("Received payload =\n%s", req.sprint()), UVM_NONE);
  endtask
endclass

Output:

UVM_INFO initiator.sv(23) @ 0: uvm_test_top.env_o.init [init] send req =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @404      
  enable  integral  1     'h1       
  e_addr  integral  32    'hb4b9c45d
  e_data  integral  32    'h26deecce
------------------------------------

UVM_INFO target.sv(12) @ 0: uvm_test_top.env_o.tart [target] Received payload =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @404      
  enable  integral  1     'h1       
  e_addr  integral  32    'hb4b9c45d
  e_data  integral  32    'h26deecce
------------------------------------

Using nb_initiator and nb_target example

// Initiator Code
class initiator extends uvm_component;
  seq_item req;
  uvm_tlm_time tlm_delay;
  uvm_tlm_phase_e tlm_phase;
  uvm_tlm_nb_initiator_socket #(initiator, seq_item, uvm_tlm_phase_e) socket_i;
  
  `uvm_component_utils(initiator)
  
  function new(string name = "initiator", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    socket_i = new("socket_i", this);
    tlm_delay = new("tlm_delay");
  endfunction
  
  function uvm_tlm_sync_e nb_transport_bw(seq_item req, ref uvm_tlm_phase_e tlm_phase, input uvm_tlm_time tlm_delay);
    `uvm_info(get_type_name(), $sformatf("Received payload =\n%s", req.sprint()), UVM_NONE);
  endfunction
  
  task run_phase(uvm_phase phase);
    super.run_phase(phase);
    req = seq_item::type_id::create("req");
    assert(req.randomize());
    tlm_delay.reset();
    `uvm_info(get_type_name(), $sformatf("send req =\n%s", req.sprint()), UVM_NONE);
    tlm_phase = BEGIN_REQ;
    socket_i.nb_transport_fw(req, tlm_phase, tlm_delay);
  endtask
endclass

// Target Code
class target extends uvm_component;
  uvm_tlm_nb_target_socket #(target, seq_item, uvm_tlm_phase_e) socket_t;
  uvm_tlm_phase_e tlm_phase;
  
  `uvm_component_utils(target)
  
  function new(string name = "target", uvm_component parent = null);
    super.new(name, parent);
    socket_t = new("socket_t", this);
  endfunction
  
  function uvm_tlm_sync_e nb_transport_fw(seq_item req, ref uvm_tlm_phase_e tlm_phase, input uvm_tlm_time tlm_delay);
    `uvm_info(get_type_name(), $sformatf("Received payload =\n%s", req.sprint()), UVM_NONE);
    req.enable = 1;
    tlm_phase = END_REQ;
    socket_t.nb_transport_bw(req,tlm_phase, tlm_delay);
  endfunction
endclass

Output:

UVM_INFO initiator.sv(28) @ 0: uvm_test_top.env_o.init [initiator] send req =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @2198     
  enable  integral  1     'h0       
  e_addr  integral  32    'h15a7d0e5
  e_data  integral  32    'hac8eef32
------------------------------------

UVM_INFO target.sv(13) @ 0: uvm_test_top.env_o.tart [target] Received payload =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @2198     
  enable  integral  1     'h0       
  e_addr  integral  32    'h15a7d0e5
  e_data  integral  32    'hac8eef32
------------------------------------

UVM_INFO initiator.sv(20) @ 0: uvm_test_top.env_o.init [initiator] Received payload =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @2198     
  enable  integral  1     'h1       
  e_addr  integral  32    'h15a7d0e5
  e_data  integral  32    'hac8eef32
------------------------------------

b_initiator and passthrough_initiator example

// Initiator Code
class initiator extends uvm_component;
  seq_item req;
  uvm_tlm_time tlm_delay;
  uvm_tlm_b_initiator_socket #(seq_item) socket_i;
  
  `uvm_component_utils(initiator)
  
  function new(string name = "initiator", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    socket_i = new("socket_i", this);
    tlm_delay = new("tlm_delay");
  endfunction
  
  task run_phase(uvm_phase phase);
    super.run_phase(phase);
    req = seq_item::type_id::create("req");
    assert(req.randomize());
    tlm_delay.reset();
    `uvm_info(get_name(), $sformatf("send req =\n%s", req.sprint()), UVM_NONE);
    socket_i.b_transport(req, tlm_delay);
  endtask
endclass

// Target Code
class target extends uvm_component;
  uvm_tlm_b_target_socket #(target, seq_item) socket_t;
  
  `uvm_component_utils(target)
  
  function new(string name = "target", uvm_component parent = null);
    super.new(name, parent);
    socket_t = new("socket_t", this);
  endfunction
  
  virtual task b_transport(seq_item req, uvm_tlm_time tlm_delay);
    `uvm_info(get_type_name(), $sformatf("Received payload =\n%s", req.sprint()), UVM_NONE);
  endtask
endclass

// passthrough Code
class passthrough extends uvm_component;
  seq_item req;
  initiator init;
  uvm_tlm_b_passthrough_initiator_socket #(seq_item) socket_p;
  
  `uvm_component_utils(passthrough)
  
  function new(string name = "passthrough", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    init = initiator::type_id::create("init", this);
    socket_p = new("socket_p", this);
  endfunction
  
  function void connect_phase(uvm_phase phase);
    super.connect_phase(phase);
    init.socket_i.connect(socket_p);
  endfunction
endclass

Output:

UVM_INFO initiator.sv(23) @ 0: uvm_test_top.env_o.pass_init.init [init] send req =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @2181     
  enable  integral  1     'h0       
  e_addr  integral  32    'h7e8c00a1
  e_data  integral  32    'hd3a4d683
------------------------------------

UVM_INFO target.sv(12) @ 0: uvm_test_top.env_o.tart [target] Received payload =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @2181     
  enable  integral  1     'h0       
  e_addr  integral  32    'h7e8c00a1
  e_data  integral  32    'hd3a4d683
------------------------------------

nb_initiator and nb_passthrough_target example

// Initiator Code
class initiator extends uvm_component;
  seq_item req;
  uvm_tlm_time tlm_delay;
  uvm_tlm_phase_e tlm_phase;
  uvm_tlm_nb_initiator_socket #(initiator, seq_item, uvm_tlm_phase_e) socket_i;
  
  `uvm_component_utils(initiator)
  
  function new(string name = "initiator", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    socket_i = new("socket_i", this);
    tlm_delay = new("tlm_delay");
  endfunction
  
  function uvm_tlm_sync_e nb_transport_bw(seq_item req, ref uvm_tlm_phase_e tlm_phase, input uvm_tlm_time tlm_delay);
    `uvm_info(get_type_name(), $sformatf("Received payload =\n%s", req.sprint()), UVM_NONE);
  endfunction
  
  task run_phase(uvm_phase phase);
    super.run_phase(phase);
    req = seq_item::type_id::create("req");
    assert(req.randomize());
    tlm_delay.reset();
    `uvm_info(get_type_name(), $sformatf("send req =\n%s", req.sprint()), UVM_NONE);
    tlm_phase = BEGIN_REQ;
    socket_i.nb_transport_fw(req, tlm_phase, tlm_delay);
  endtask
endclass

// Target Code
class target extends uvm_component;
  uvm_tlm_nb_target_socket #(target, seq_item, uvm_tlm_phase_e) socket_t;
  uvm_tlm_phase_e tlm_phase;
  
  `uvm_component_utils(target)
  
  function new(string name = "target", uvm_component parent = null);
    super.new(name, parent);
    socket_t = new("socket_t", this);
  endfunction
  
  function uvm_tlm_sync_e nb_transport_fw(seq_item req, ref uvm_tlm_phase_e tlm_phase, input uvm_tlm_time tlm_delay);
    `uvm_info(get_type_name(), $sformatf("Received payload =\n%s", req.sprint()), UVM_NONE);
    req.enable = 1;
    tlm_phase = END_REQ;
    socket_t.nb_transport_bw(req,tlm_phase, tlm_delay);
  endfunction 
endclass

// Passthrough Code
class passthrough extends uvm_component;
  seq_item req;
  initiator init;
  uvm_tlm_nb_passthrough_target_socket #(seq_item, uvm_tlm_phase_e) socket_p;
  
  `uvm_component_utils(passthrough)
  
  function new(string name = "passthrough", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    init = initiator::type_id::create("init", this);
    socket_p = new("socket_p", this);
  endfunction
  
  function void connect_phase(uvm_phase phase);
    super.connect_phase(phase);
    init.socket_i.connect(socket_p);
  endfunction
endclass

Output:

UVM_INFO initiator.sv(28) @ 0: uvm_test_top.env_o.pass_targ.init [initiator] send req =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @459      
  enable  integral  1     'h0       
  e_addr  integral  32    'h6598a1cc
  e_data  integral  32    'h29cf85c6
------------------------------------

UVM_INFO target.sv(13) @ 0: uvm_test_top.env_o.tart [target] Received payload =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @459      
  enable  integral  1     'h0       
  e_addr  integral  32    'h6598a1cc
  e_data  integral  32    'h29cf85c6
------------------------------------

UVM_INFO initiator.sv(20) @ 0: uvm_test_top.env_o.pass_targ.init [initiator] Received payload =
------------------------------------
Name      Type      Size  Value     
------------------------------------
req       seq_item  -     @459      
  enable  integral  1     'h1       
  e_addr  integral  32    'h6598a1cc
  e_data  integral  32    'h29cf85c6
------------------------------------