在SystemC/TLM建模中,我们经常需要加一些payload monitor来进行performance counter的统计,或者使用data checker来进行unit test。很多情况下,为了保持代码的整洁和提高仿真速度,我们不希望将monitor和checker的代码直接写在module内部。此时,就可以使用tlm提供的analysis port,然后根据需求来添加特定的monitor或checker。一个tlm::tlm_analysis_port可以绑定0个 /1个或多个tlm::tlm_analysis_if。

具体实现为:

monitor或checker (如下图的module B和C)继承于tlm::tlm_analysis_if,同时对write 函数进行改写,在函数内部进行 performance counter的统计计算,或test check。

在module内部(如下图的module A)定义一个tlm::tlm_analysis_port的成员变量,在module 内部 调用这个成员变量的write 函数。

在top中,对tlm::tlm_analysis_port 和多个tlm::tlm_analysis_if进行bind。这样module内call write函数时,所有bind的tlm::tlm_analysis_if 子类模块中的write函数 都会被调用一次。

在SystemC spec中给出了一个analysis port的示例,以下代码是在此基础上的一个完整使用,其中class parent和 child都定义了一个tlm::tlm_analysis_port;child->ap.bind(parent_ap);是两个tlm_analysis_port的层次间绑定,在top module中的两个bind是 tlm_analysis_port和tlm_analysis_if的绑定。

// execute:
//     g++ -g -Wall -lsystemc -m64 -pthread main.cpp
//         -L/$(your systemc path)/lib-linux64
//         -I/$(your systemc path)/include  -I/$(your systemc
//         path)/src/tlm_utils -o sim#include "tlm"
#include <systemc>using namespace std;struct Trans // Analysis transaction class
{int i;
};
struct Subscriber : sc_core::sc_module, tlm::tlm_analysis_if<Trans> {Subscriber(sc_core::sc_module_name name) : sc_core::sc_module(name) {}virtual void write(const Trans &t) {cout << this->name() << " Hello, got " << t.i<< "\n"; // Implementation of the write method}
};class Child : public sc_core::sc_module {
public:tlm::tlm_analysis_port<Trans> ap;SC_HAS_PROCESS(Child); // must have this lineexplicit Child(sc_core::sc_module_name name): sc_core::sc_module(name), ap("ap") {SC_THREAD(thread);}void thread() {Trans t = {999};ap.write(t); // Interface method call to the write method of the analysis port}
};
class Parent : public sc_core::sc_module {
public:tlm::tlm_analysis_port<Trans> parent_ap;Child *child;explicit Parent(sc_core::sc_module_name name): sc_core::sc_module(name), parent_ap("ap") {child = new Child("child");child->ap.bind(parent_ap); // Bind analysis port of child to analysis port of parent}
};class Top : public sc_core::sc_module {
public:Parent *parent;Subscriber *subscriber1;Subscriber *subscriber2;explicit Top(sc_core::sc_module_name name) : sc_core::sc_module(name) {parent = new Parent("parent");subscriber1 = new Subscriber("monitor");subscriber2 = new Subscriber("checker");parent->parent_ap.bind(*subscriber1); // Bind analysis port to two separate subscribersparent->parent_ap.bind(*subscriber2); // This is the key feature of analysis ports}
};int sc_main(int argc, char **argv) {Top m_top("top");sc_core::sc_start();return 0;
}

tlm::tlm_analysis_port tlm::tlm_analysis_if相关推荐

  1. 【从零开始学习 UVM】10.5、UVM TLM —— UVM TLM Blocking Get Port

    文章目录 UVM TLM Get Port Example 1. 创建一个发送方类,其端口类型为 uvm_blocking_get_imp 3. 创建接收器类,等待 get 方法. 4. 在更高层次上 ...

  2. UVM中的TLM通信

    UVM中的TLM通信 1.TLM简介 TLM:Transaction Level Modeling(事务级建模),它是一个独立于语言的一个标准,常用于系统建模,加速软硬件协同开发.在芯片开发中,常配合 ...

  3. UVM学习笔记--TLM通信

    Table of Contents 1.TLM简介 2.UVM TLM基本概念 2.1 TLM 通信常用的的三种传输:Put/Get/Transport 2.2 TLM 通信中的三种端口:Port,E ...

  4. [UVM]UVM TLM1.0 Interface归纳总结 --- 图解UVM TLM1.0 Interface

    UVM TLM1.0 Interface归纳总结 --- 图解UVM TLM1.0 Interface Transaction-Level Modeling (TLM) 用户模块之间的通信. 是实现基 ...

  5. 26、BDS B1I电文处理实现

    \qquad下面是HD-GR GNSS导航软件的BDS B1I电文处理实现代码,入口函数b1i _process_message (-): // b1i_message.c -- BDS B1I Na ...

  6. 翻译 第10章 of IEEE Std 1666-2011 IEEE Standard for Standard SystemC Language Reference Manual

    10. Introduction to TLM-2.0 第10章.TLM-2.0的介绍 10.1 Background 10.1 背景 The TLM-1 standard defined a set ...

  7. 学习笔记:深度学习(6)——基于深度学习的语言模型

    学习时间:2022.04.22~2022.04.25 文章目录 5. 基于深度学习的语言模型 5.1 从NNLM到词嵌入 5.1.1 神经网络语言模型 NNLM 5.1.2 基于循环神经网络的语言模型 ...

  8. UVM基础-TLM通信机制(二)

    目录 TLM 2.0 通信 端口定义 传送数据 时间标记 同步通信元件 uvm_event uvm_event 总结 uvm_barrier uvm_callback TLM 2.0 通信 TLM 2 ...

  9. uvm基础(2)TLM通信,看这一篇就够了

    tlm通信概述 tlm通信的步骤:1.分辨出initiator和target,producer和consumer. 2.在target中实现tlm通信方法. 3.在俩个对象中创建tlm端口. 4.在更 ...

最新文章

  1. Linux服务器出现java.net.UnknownHostException 异常处理
  2. mybatis插入mysql出现中文乱码
  3. UOJ #131 BZOJ 4199 luogu P2178【NOI2015】品酒大会 (后缀自动机、树形DP)
  4. mysql调优_MYSQL企业常用架构与调优经验分享
  5. php上传图片显示在当前页,PHP上传图片到数据库并显示
  6. 如何从课堂与教学内容两方面提高培训效率------张孝祥
  7. 【C语言】矩阵的最大值(指针专题)
  8. [tldk][dpdk][dev] TLDK--基于dpdk的用户态协议栈传输层组件简单调研
  9. sqlmap 基本使用教程--个人笔记
  10. AG螺纹的螺套安装后反复脱出,怎么办?
  11. Asus ROG Zephyrus G14 / 幻14 Ubuntu 外接HDMI显示屏检测不到,AMD核显驱动配置,AMD+Nvidia双显卡配置
  12. c语言case用多重语句,switch多重选择
  13. 2021年全国职业院校技能大赛获奖名单(高职组网络系统管理)
  14. NoSQLBooster for MongoDB 7.0.5
  15. 文件管理服务器win7,Win7如何取得文件管理所有权
  16. 蓝牙文件传输之obex层之上的分析【Android源码解析】
  17. wan端口未连接怎么弄_路由器wan口未连接怎么办?
  18. 怎样快速将excel表格内容转换到word中
  19. 浏览器暗黑模式-Dark深色模式
  20. Nginx proxy反向代理 缓存处理流程

热门文章

  1. 两个整数的四则运算(python)
  2. Pycharm下运行调试Python项目时,当调试既需要给调试的程序传入命令行参数又需要程序在设置的断点处停下里查看变量时的解决方法
  3. 【知识图谱】两种 Python 方法实现社区发现之标签传播算法(LPA)
  4. 共模电感模型matlab,混成式共模电感的原理及功能讲解?
  5. JVM干货!最全最详细的JVM性能优化专题 第二弹
  6. 水平耀斑_将带有油漆和透明度键的耀斑添加到您的C#项目中
  7. [Inheritance]Collection with Inheritance (eden)
  8. 关于mos管的压降问题(项目遇到问题总结)
  9. 程序员编程艺术:第六章、求解500万以内的亲和数
  10. leetcode 5607. 生成平衡数组的方案数 前缀和