花了很长的篇幅,才粗略地介绍了VPI。所以,另开一贴继续介绍DPI。
先需要指出的是DPI中关键词"DPI"已经替换为“DPI-C”。
1. DPI的来源
DPI标准源自两个专有接口,一个来自Synopsys公司的VCS DirectC接口,另一个是来自Co-Design公司(已被Synopsys 公司收购)的SystemSim Cblend接口。这两个专有接口起初是为他们各自的仿真器专门开发的, 而不是一个能够工作在任何仿真器上的标准。Accellera组织的SystemVerilog标准委员会把这两个捐献技术合并在一起,并定义了DPI接口的语义,使得DPI能够与任何Verilog仿真器一起工作。
[1] 中很好地介绍了,PLI, DPI, DirectC之间的关系。
[1]中关于DPI和TLI的关系
2. DPI的局限
和function void与task的区别一样,DPI imported functions也是要求不要消耗时间。
但DPI也支持both task and function,[2]p445也有提到,“VCS declared exported tasks as void functions in C.”,in sum, C side 不能消耗仿真时间。
我猜想这里所指的utilities应该是包括VCS中的TLI的。
补注:Although SystemVerilog provides different methods (PLI, VPI, DPI, etc) to support communications between SystemVerilog and C/C++ domains, it is not so straight forward for SystemC interface methods. One important reason is that these SystemC methods can be “blocking”, i.e. these methods can “consume” time. And these “blocking” SystemC methods can return value as well. Users should build a very elaborate mechanism to maintain synchronization between the simulations running in the SystemVerilog and the SystemC domains. (from [5])
这段话说的很清楚,systemc models 因为blocking的原因,会consume time,然后需要elaborate mechanism来synchronize,我觉得DPI应该是办不到的,但VPI应该是可以通过callbacktf来达到。这里提到的是synopsys的办法,创建两个domains来run。
3. DPI的分类
imported methods classified as pure, context or generic。
真崩溃。
3b 关于context function的补注 from [1]
Export functions/tasks are always context
An exported task or function declaration has only the routine name. There are no arguments or return type. 这是很容易犯错的地方。
防止名字冲突
// Map your SystemVerilog function “fread” to “sv_fread” in C
同样地,在import时,防止名字冲突
reference
[1] synopsys DPI ppt,VCS 2006.06-SP2-2
[2] SV for verification 3rd ed
[3] PLI vs DPI, 2004 SNUG, S Sutherland
[4] http://www.vmmcentral.org/vmartialarts/category/systemc/
更多关于systemc与vmm之间关系的讨论
[5] How to connect your SystemC reference model to your verification framework
http://www.vmmcentral.org/vmartialarts/2009/07/how-to-connect-your-systemc-reference-model-to-your-verification-framework/