天天看點

UVM TLM2: SystemC和SV 通信

TODO 不完整,有時間再更新

SystemC 介紹

SystemC不是一門新的語言,而是基于C++開發的library

UVM TLM2: SystemC和SV 通信

TLM2 介紹

如果都是SV code的話,結構上類型TLM1

UVM TLM2: SystemC和SV 通信

TLM2 提供了下面2中傳輸接口

Blocking (b_transport) completes the entire transaction within a single method call
Non-blocking (nb_transport) describes the progress of a transaction using multiple nb_transport() method calls going back-and-forth between initiator and target

Contents

UVM TLM2: SystemC和SV 通信

passthrough: 可以直接initiator connect到passthrough

uvm_tlm_b_initiator_socket#(uvm_tlm_generic_payload) init_skt; 

uvm_tlm_b_passthrough_initiator_socket#(uvm_tlm_generic_payload) pt_init_skt;

init_skt.connect(pt_init_skt);
           

example:

initiator implement

class initiator extends uvm_component;
   `uvm_component_utils (initiator)

   // Declare a blocking transport socket (using initiator socket class)
   uvm_tlm_b_initiator_socket #(simple_packet) initSocket;
   uvm_tlm_time   delay;
   simple_packet  pkt;

   function new (string name = "initiator", uvm_component parent= null);
      super.new (name, parent);
   endfunction

   virtual function void build_phase (uvm_phase phase);
      super.build_phase (phase);
      // Create an instance of the socket
      initSocket = new ("initSocket", this);
      delay = new ();
   endfunction

   virtual task run_phase (uvm_phase phase);
     pkt = simple_packet::type_id::create ("pkt");
     //...
     initSocket.b_transport (pkt, delay);
   endtask
endclass
           

target implement

class target extends uvm_component;
   `uvm_component_utils (target)

   // Declare a blocking target socket
   uvm_tlm_b_target_socket #(target, simple_packet) targetSocket;

   function new (string name = "target", uvm_component parent = null);
      super.new (name, parent);
   endfunction

   virtual function void build_phase (uvm_phase phase);
      super.build_phase (phase);
      // Create an instance of the target socket
      targetSocket = new ("targetSocket", this);
   endfunction

	// Provide the implementation method of b_transport in the target class
   task b_transport (simple_packet pkt, uvm_tlm_time delay);
      pkt.print (uvm_default_line_printer);
   endtask
endclass
           

initiator and target connection

class my_env extends uvm_env;
   `uvm_component_utils (my_env)

   initiator   init;
   target      tgt;

   function new (string name = "my_env", uvm_component parent = null);
      super.new (name, parent);
   endfunction

   virtual function void build_phase (uvm_phase phase);
      super.build_phase (phase);
      // Create an object of both components
      init = initiator::type_id::create ("init", this);
      tgt = target::type_id::create ("tgt", this);
   endfunction

   // Connect both sockets in the connect_phase
   virtual function void connect_phase (uvm_phase phase);
      init.initSocket.connect (tgt.targetSocket);
   endfunction
endclass
           

SC 與 SV 資訊傳遞

ref:

https://www.chipverify.com/uvm/tlm-sockets