已阅读5页,还剩12页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1. module是一个类,从sc_module扩展而来,包含其他modules以及processes,channels and ports。2. simulation process是由systemc kernel调度执行,它是sc_module的成员函数,并被注册登记到simulation kernel中。由此simulation kernel是这些simulation process唯一的caller,那么这些simulation process没必要带参数和返回值了。sc_module中也可定义一些process,但这些process不被simulation kernel调用,仅仅是一些被simulation process调用的函数。3. simulation process的registeration发生在elaboration的时候,即module的constructor执行的时候(使用SC_METHOD,SC_THREAD)。4. SC_METHOD 是sc_module的成员函数,它没有任何参数和返回值,被simulation kernel不停的反复调用,一旦执行无延迟并执行到底。而SC_THREAD只执行一次带延迟,会挂起自己并等待。5. static sensitivity 和dynamic sensitivity。 对于动态敏感, SC_METHOD用next_trigger(arg), SC_THREAD用wait(arg)来实现。6. systemC的datatype由类模板以及运算符重载来实现。supported data type = Native C+ data type + STL data type + SystemC datatype( logic, integers and fixed-point)systemc 还提供了systemc data type 和 C+ data type 之间的转化函数。 所有的systemc data type都属于sc_dt namespace。1. logic : sc_bv, sc_lv, bool, sc_logic, 注意sc_bit 被 C+里面的 bool取代了。2. integer: sc_int, sc_uint (其中W=64) , sc_bigint, sc_biguint (其中BITWIDTH64) systemC的integer比传统的C+的integer类型提供了bit操作和concatination以及可配置位宽。3. fixed point: sc_fixed1. systemC的入口是sc_main,而实质上是由用户不可见的main,调用sc_main(int argc,char* argv)来实现的。systemC提供了sc_argc(), sc_argv()来读取argc和argv。 sc_main 包含三个阶段: elaboration,simulation,post-processing。 elaboration阶段完成module的连接以及process的注册。由sc_start()进入simulation阶段,由scheduler调度进程。sc_start()结束后进入post-processing阶段,此阶段对result进行处理并报告。而callback在某些点可插入执行代码。如end_of_elaboration(), start_of_simulation, end_of_simulation.2. module 声明如下: cpp view plaincopyprint? 具体内容有:1)ports 2) channel instance 3) data instance 4) sub-designs 5) constructor 6) destructor 7) simulation process 8) member functions module constructor: process 由systemC kernel调用,所以不需要参数和返回值。3. recommanded style *submodules are implemented using pointers instead of direct instantiation. This method allows for dynamicdesign configuration. 以前DSP算法都是用C+的浮点直接表示,但是为了更精确以及综合的方便,systemC引入了fixed-point类型。它定义了整个的bit宽度以及整数部分的bit宽度(WL,IWL)。加_fast后缀的指定精度限制再53bit之内。ed这个过去式表明在compile的时候就固定了,无法改变。4. 由于systemc扩展了自己的datatype,这些datatype就是一个类。它们的赋值以及初始化,有时会使用字符串。譬如 sc_lv mask = 10ZX11 这些datatype变量值的打印,实际上是先把它们转化成字符串,然后打印出来。譬如 coutmask.to_string(SC_BIN, true)endl; 当然,也可以直接给mask赋值(因为systemc重载了=以及stream operator ): sc_lv mask = 15; cout mask5. SystemC data type重载并扩展了所有C+的操作符。类似于C+,不同类型的data type进行运算必须显示的转化其中之一。 6. 常用的STL vector, map,set, List,deque1. systemC sc_time datatype 类似于 systemc datatype, 通过运算符重载支持+=, ,. 以及流, 同样也有到C+类型的转化函数。2. sc_time 类型被simulation kernel用来跟踪simulation time,以及定义timeout和delay3. sc_time name(double, sc_time_unit); sc_time_unit有 SC_NS, SC_PS等枚举4. 在sc_time对象创建前,可用sc_set_time_resolution(double, sc_time_unit); 来指定resolution5. sc_time current_time = sc_time_stamp(); 获得当前时间邮戳。6. sc_start() 也可指定timeout时间。7. wait(sc_time)1. SystemC 使用 simulation process来实现concurrency。simulation process 运行了一段code segment之后我们期望它能返回,将控制权交给simulation kernel。2. SC_THREAD的限制: 1) 只能在module中使用,因此function必须在作为module的成员 2) 只能在elaboration 阶段使用。3)只启动一次,一旦退出不能重启。 4)遇到wait,进行上下文切换,将控制权交给kernel3. SystemC simulation 四个阶段 1) elaboration: connection and registration2) initialization: 将没有特别声明dont initialized的process放入set of runable process,dont initialized process 放入set of waiting process 3) simulation: schedule processes to run and advance time。它又分为两个阶段:evaluate和advance time。当出现下列情况时才会advance time a)nothing in runable process,b)A process meet sc_stop()c)timeout。 4) post-processing4. event syntax: 一个sc_evnet对象只能有一个outstanding scheduled event。譬如: event在触发前可以取消,用event_name.cancel();等待event的语法: Zero Time Delay event_name.notify(SC_ZERO_TIME);/ when all runable process complete, notification are issued. wait (SC_ZERO_TIME);/ wait all runable process complete.5. SC_METHOD SC_METHOD一旦执行必须执行到底永远不会挂起(也不会被其他任何进程中断),所以中间不允许任何时间延迟或者block。 SC_METHOD中的变量会消失,每次调用SC_METHOD时local的变量都必须重新初始化,而SC_THREAD中的变量只要THREAD不消失就一直存在(挂起时会保存现场)。所以一般SC_METHOD会依赖全局变量(即module中声明的变量)。而SC_THREAD多用自己的局部变量。 为了区别method和thread,强烈推荐XX_method, XX_thread这种coding style catching event For Method: Process resume的方法有: SC_THREAD通过wait, SC_METHOD通过next_trigger. SC_METHOD还可以通过static sensitivity list来进行resume。如下 而且可以返回sc_event的对象都可以加入到sensitive list中。 此外SC_THREAD结合其中的wait()也可实现static sensitivity.6. 用sc_event_queue 来支持多个outstanding event schedule。7. dont_initialize() 1. 开启dynamic process enabler: #define SC_INCLUDE_DYNAMIC_PROCESSES #include 2. register dynamic process with void return: 3. register dynamic process with return 以上object指向calling module,通常用this替代。如果所传的参数是ref而不是value,则用 sc_ref(var) / reference sc_cref(var) / constant reference sc_bind 将参数传给类spawned function。sc_process_handle 这个类提供了一种安全的机制用来操作unspawned以及spawned process,而不是依赖于指针。5. spawned process example6. SC_FORK . SC_JOINcpp view plaincopyprint?1. DataStreamd1,d2;2. SC_FORK3. sc_spawn(sc_bind(&dut:AXI_xmt,this,sc_ref(d1),p1)4. ,sc_spawn(sc_bind(&dut:PCIX_rcv,this,sc_ref(d1),p2)5. ,sc_spawn(sc_bind(&dut:USB2,this,sc_ref(d1),p3)6. ,sc_spawn(sc_bind(&dut:HT1_xtm,this,sc_ref(d2),p4)7. ,sc_spawn(sc_bind(&dut:HT2_rcv,this,sc_ref(d2),p5)8. SC_JOIN为了帮助有效地进行communication,引入了channel的概念。sc_prim_channel扩展出了三个primitive channel: sc_mutex, sc_semaphore, sc_fifo。 这些primitive channel实现了对应的interface: sc_mutex_if; sc_semaphore_if; sc_fifo_in_if;sc_fifo_out_if;1. mutex Syntax2. sc_semaphore: syntaxmutex is a semaphore with a count of one3. sc_fifo sc_fifo inherit from sc_fifo_in_if and sc_fifo_out_if; in interface is used for reading out from fifo. out interface is used for writing intofifo.4. software 之间的通讯经常使用unbounded fifo,也就是STL里面的list. 此外还有mailbox。5. 利用指针传递object,效率高,但是需要一种安全的机制,因此出现了smart pointer in boost library,即shared_ptr。 smart_ptr 类似于一个指向 mydata的指针。所不同的是这个指针牛逼得能够自己管理自己,自动删除自己,从来不需要delete这个指针。Evaluate - update Channel: sc_signal.1. notify(SC_ZERO_TIME), the notification 发生在 evaluation结束后的update phase.2. sc_signal 也是systemC的 primitive channel, 他利用request-update作为同步的机制。3. sc_signal重载了=,但不建议使用,这样比较危险。4. sc_buffer 类似于 sc_signal 是 evaluate-update channel. 而且在一个delta cycle内只允许single process 写,不允许多个process写。5. systemc引入了sc_signal_resolved, sc_signal_rv来解决multiple writer的问题(即bus has contention or high Z)。 有点类似于 sc_signal 唯一的区别是但是允许multiple writer。6) 对于sc_signal 还有 signame.posedge_event, signame.negedge_event.7) request update 讲解当一个process调用write method时,write method先将值写入New value存储区域,然后调用sc_primitive_channel:request_update() method 来通知simulation kernel。当 update phase 到来时,kernel 自动调用曾在evaluation phase 时请求更新(request update)的channel 中的update()method。这个update() method不光拷贝new value 到current value,而且会解决竞争,以及notify一些事件从而唤醒某些进程。1. Design Hierarchy2. How to creat hierarchy1) Direct/indirect Top-Level Implementation2) direct submodule3) indirect submodule - For IP deliver注意上例中 Engine.h 没有包括 #include FuelMix.h, etc., 而是移到了Engine.cpp中。这就是最大的好处,你只需要提供Engine.h 和 Engine.o 或者 Engine.a就行了,而且 .o, .a都可以方便的更新。1. 概念的引入:port是一个指针,它指向模块外部的channel。 sc_export是一个指针,它指向其他模块内部的channel。interface是一个抽象类(定义了一些纯虚函数),它也可被看成API,可派生出各个类。2. 定义:A SystemC interface is an abstract class that inherits from sc_interface and provides only pure virtual declarations of methods referenced by SystemC channels and ports. No implementations or data are provided in a SystemC interface.SystemC interface 是个抽象类,它由sc_interface派生而来,仅仅声明了纯虚函数(这些纯虚函数会被channel以及port引用),而不含有任何数据成员。A SystemC channel is a class that inherits from either sc_channel or from sc_prim_channel, and the channel should1 inherit and implement one or more SystemC interface classes. A channel implements all the pure virtual methods of the inherited interface classes.SystemC channel 由sc_channel或sc_prim_channel派生而来,channel必须至少由一个interface派生而来,并实现interface class 中定义的所有纯虚函数。A SystemC port is a class templated with and inheriting from a SystemC interface. Ports allow access of channels across module boundaries. SystemC port 绑定了interface,并重载了-运算符。语法如下:当进行端口连接时(sc_port例化执行时),sc_port重载了()运算符,保存了channel object的指针。因此sc_port可看成一个interface pointer指向了channel。sc_port还重载了-,让sc_port表现得更像一个指针。3. process间的通讯1. 和同层process通讯是通过event以及interface. 如下 processinterfacechannelinterfaceprocess。2. 通过port和module外部通讯3.和同层子module通讯是通过interface。如下processinterfacechannelsubmodule port 或者 processinterface sc_exportStandard Interface1. FIFO interface sc_fifo channel 由 sc_fifo_in_if 以及 sc_fifo_out_if扩展而来。所谓interface的out于in是相对于module的port而言的。sc_fifo_in_if提供了所有的从FIFO输入到module的纯虚函数。而sc_fifo_out_if提供了所有的从module输出到FIFO的纯虚函数。其中read和write函数是blocking的(FIFO空或满时等待)2. Signal Interface 类似的,sc_signal channel由两个interface扩展而来。sc_signal_in_if,sc_signal_inout_if. 3. Sensitivity and Event finder sensitive list 中可以是event,我们很期待SC_METHOD process 能够被channel中定义事件触发。但是channel中的event不能直接放在sensitive list中,因为我们知道port指向了这些channel,这就意味着sensitive list中有port-xxx_event. 而p
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- T/ZSP 010-2024社区自治“365敲门”工作规范
- T/JSXH 0009-2025印制电路板退锡废液再生氢氧化锡
- T/COOA 18-2025渐变焦眼镜用眼镜架
- T/CCPA 63-2025黄金尾矿基免烧免蒸养轻骨料
- T/CSHE 0014-2025抽水蓄能电站工程施工控制网测量规程
- GB/T 48220-2026爆炸物品公共安全管理术语
- AI在科学教育中的应用
- 面向给排水学生的水务科技P PT
- 2027届山东省枣庄市中学区永安乡黄庄中学八年级数学第一学期期末学业质量监测模拟试题含解析
- PHP常见面试题及详细答案(实战版)
- 2026及未来5年中国电力线载波抄表数据监测研究报告
- 第四单元.14 梅兰芳蓄须明志 课件 2026-2027学年统编版小学语文 五年级上册
- 2026年前列腺癌诊疗指南(中国专家共识)
- 急诊护理风险评估与干预
- 2025煤炭行业发展年度报告
- 2026内蒙古鄂尔多斯市国有资产投资控股集团有限公司社会招募见习人员17名笔试历年参考题库附带答案详解
- T∕CPCPA 0017-2026 托育机构婴幼儿回应性照护服务规范
- 2025年卫生高级职称面审答辩(临床医学检验)正高面审练习题及答案
- DB31∕T 1483-2024 建筑垃圾与工程泥浆再生自密实填筑技术规程
- 《设计构成》课件 第1章 认识设计构成;第2章 平面构成基础
- 2023年临夏市教育系统引进人才考试真题及答案
评论
0/150
提交评论