UVM TLM2: SystemC和SV 通信

本文深入解析了SystemC,一种基于C++的库,以及TLM2(Transaction Level Modeling),介绍了其Blocking和Non-blocking传输接口的工作原理。通过具体的initiator和target实现示例,展示了如何使用SystemC进行SV(SystemVerilog)代码的结构类型设计。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

TODO 不完整,有时间再更新

SystemC 介绍

SystemC不是一门新的语言,而是基于C++开发的library

TLM2 介绍

如果都是SV code的话,结构上类型TLM1

tlm-socket

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

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:

[UVMC]UVM Connect基础教程-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值