当前位置: 首页 > 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.lryc.cn/news/605292.html

相关文章:

  • 关于MyBatis 的懒加载(Lazy Loading)机制
  • 腾讯云市场排名
  • linux进程概念(三)进程状态
  • COZE 开源,新一代 AI Agent 本地部署一条龙
  • 借助 Wisdom SSH 的 AI 助手构建 Linux 开发环境
  • 2. Agent与 React流程
  • 智能Agent场景实战指南 Day 26:Agent评估与性能优化
  • 【面试场景题】随机立减金额计算
  • 三十四、【Linux常用工具】rsync+inotify实时同步演示
  • 游卡,快手26届秋招内推
  • Cortex-M处理器的优势?
  • 解决Nginx的HTTPS跨域内容显示问题
  • Linux日志管理和时钟同步配置指南
  • DFT设计中的不同阶段介绍
  • 【C语言类型转换坑】乘法溢出隐患发现与正确写法
  • 嵌入式系统分层开发:架构模式与工程实践(二)(创建任务篇(二))
  • CSS-in-JS 动态主题切换与首屏渲染优化
  • 人类语言驱动物理机制建模的AIVC
  • Zynq SoC 中断控制系统设计与实现:基于 GPIO 的中断驱动开发
  • 亚马逊Kiro重塑AI编程:从“氛围编码”到规范驱动的革命
  • 论文研读(2025 KDD):细粒度人体轨迹建模
  • Python多线程利器:重入锁(RLock)详解——原理、实战与避坑指南
  • C++代码题部分(1)
  • 模型相关类代码回顾理解 | BatchNorm2d\fc.in_features\nn.Linear\torchsummary
  • c#_文件的读写 IO
  • C#_创建自己的MyList列表
  • 【36】C# WinForm入门到精通 —— flowLayoutPanel 控件 拖拽大小 “在父容器中停靠” ,“取消在父容器中停靠”
  • 独立站如何吃掉平台蛋糕?DTC模式下的成本重构与利润跃升
  • Java内存模型(JMM)
  • 地图可视化实践录:显示高德地图和百度地图