当前位置: 首页 > news >正文

uvm-tlm-sockets

TLM 2.0引入了套接字(Socket)机制,实现发起方(initiator)与目标方(target)组件间的异步双向数据传输。套接字与端口(port)和导出(export)同源,均继承自uvm_port_base基类。发起事务的组件使用发起方套接字(initiator socket),称为发起方;接收事务的组件使用目标方套接字(target socket),称为目标方。需注意:发起方套接字仅能连接目标方套接字,目标方套接字仅能连接发起方套接字。

TestBench

tlm-socket

 

让我们来看看启动器组件,了解套接字是如何声明和使用的。b_transport() 方法中使用的时序注解参数允许时序点从调用和返回任务的仿真时间中偏移。

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);endfunctionvirtual function void build_phase (uvm_phase phase);super.build_phase (phase);// Create an instance of the socketinitSocket = new ("initSocket", this);delay = new ();endfunctionvirtual task run_phase (uvm_phase phase);// Let us generate 5 packets and send it via socketrepeat (5) beginpkt = simple_packet::type_id::create ("pkt");assert(pkt.randomize ());`uvm_info ("INIT", "Packet sent to target", UVM_LOW)pkt.print (uvm_default_line_printer);// Use the socket to send datainitSocket.b_transport (pkt, delay);endendtask
endclass

考虑目标套接字,你会发现它与我们在前几次课程中看到的端口和导出方案非常相似。

class target extends uvm_component;`uvm_component_utils (target)// Declare a blocking target socketuvm_tlm_b_target_socket #(target, simple_packet) targetSocket;function new (string name = "target", uvm_component parent = null);super.new (name, parent);endfunctionvirtual function void build_phase (uvm_phase phase);super.build_phase (phase);// Create an instance of the target sockettargetSocket = new ("targetSocket", this);endfunction// Provide the implementation method of b_transport in the target classtask b_transport (simple_packet pkt, uvm_tlm_time delay);`uvm_info ("TGT", "Packet received from Initiator", UVM_MEDIUM)pkt.print (uvm_default_line_printer);endtask
endclass

缺失的一环是两个套接字之间的连接,而实现这一连接的最佳位置是在初始化器和目标组件都被实例化的环境中。

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);endfunctionvirtual function void build_phase (uvm_phase phase);super.build_phase (phase);// Create an object of both componentsinit = initiator::type_id::create ("init", this);tgt = target::type_id::create ("tgt", this);endfunction// Connect both sockets in the connect_phasevirtual function void connect_phase (uvm_phase phase);init.initSocket.connect (tgt.targetSocket);endfunction
endclass
http://www.dtcms.com/a/305590.html

相关文章:

  • 论文Review 3DGSSLAM S3PO-GS | ICCV 2025 港科广出品!| 高效快速的3DGSSLAM!
  • 适配鸿蒙低性能设备的终极优化方案:从启动到渲染全链路实战
  • 企业级web应用服务器TOMCAT
  • Qt 嵌入式系统资源管理
  • 【GEO从入门到精通】生成式引擎与其他 AI 技术的关系
  • Linux线程同步与互斥(上)
  • HTML5 Web 存储
  • 从结构到交互:HTML5进阶开发全解析——语义化标签、Canvas绘图与表单设计实战
  • 【探索进程信号】:信号捕捉
  • iOS 签名证书与上架流程详解,无 Mac 环境下的上架流程
  • 微服务的编程测评系统8-题库管理-竞赛管理
  • 基于Rust与HDFS、YARN、Hue、ZooKeeper、MySQL
  • 【Dolphinscheduler】docker搭建dolphinscheduler集群并与安全的CDH集成
  • C++菱形虚拟继承:解开钻石继承的魔咒
  • 【ee类保研面试】数学类---线性代数
  • 智能车辆热管理测试方案——提升效能与保障安全
  • 设计模式之单例模式及其在多线程下的使用
  • 无人机磁力计模块运行与技术要点!
  • 企业级应用安全传输:Vue3+Nest.js AES加密方案设计与实现
  • 工作笔记-----FreeRTOS中的lwIP网络任务为什么会让出CPU
  • 【网络运维】 Linux:使用 Cockpit 管理服务器
  • Python 程序设计讲义(46):组合数据类型——集合类型:集合间运算
  • [25-cv-08377]Hublot手表商标带着14把“死神镰刀“来收割权!卖家速逃!
  • pyRoboPlan中的微分逆运动学
  • 手撕设计模式——智能家居之外观模式
  • Java Ai For循环 (day07)
  • .NET 10 中的新增功能系列文章2——ASP.NET Core 中的新增功能
  • Linux基本指令,对路径的认识
  • Power Pivot 数据分析表达式(DAX)
  • 【从基础到实战】STL string 学习笔记(上)