返回介绍

附录E DPI C-layer

发布于 2020-09-09 22:56:14 字数 6460 浏览 1016 评论 0 收藏 0

主题

主题描述
E.1 概述The SystemVerilog Direct Programming Interface (DPI) allows direct inter-language function calls between SystemVerilog and any foreign programming language with a C function call protocol and linking model:

  • Functions implemented in C and given import declarations in SystemVerilog can be called from System- Verilog; such functions are referred to as imported functions.
  • Functions implemented in SystemVerilog and specified in export declarations can be called from C; such functions are referred to as exported functions.
  • Tasks implemented in SystemVerilog and specified in export declarations can be called from C; such functions are referred to as exported tasks.
  • Functions implemented in C which... more
E.2 Naming conventionsAll names introduced by this interface shall conform to the following conventions.

  • All names defined in this interface are prefixed with sv or SV_.
  • Function and type names start with sv, followed by initially capitalized words with no separators, e.g., svBitPackedArrRef.
  • Names of symbolic constants start with sv_, e.g., sv_x.
  • Names of macro definitions start with SV_, followed by all upper-case words separated by a underscore (_), e.g., SV_CANONICAL_SIZE.
E.3 PortabilityDepending on the data types used for imported or exported tasks or functions, the C code can be binary-level or source-level compatible. Applications that do not use SystemVerilog packed types are always binary compatible. Applications that don’t mix SystemVerilog packed and unpacked types in the same data type can be written to guarantee binary compatibility. Open arrays with both packed and unpacked parts are also binary compatible.

The values of SystemVerilog packed types can be accessed via interface tasks or functions using the canonical representation of 2-state and 4-state packed arrays, or directly through pointers using the implementation representation. The... more

E.4 Include filesThe C-layer of the Direct Programming Interface defines two include files corresponding to these two levels of compatibility: svdpi.h and svdpi_src.h.

Binary compatibility of an application depends on the data types of the values passed through the interface. If all corresponding type definitions can be written in C without the need to include the svdpi_src.h file, then an application is binary compatible. If the svdpi_src.h file is required, then the application is not binary compatible and needs to be recompiled for each simulator of choice.

Applications that pass solely C-compatible data types or standalone packed arrays (both 2-state and 4-state)... more

E.5 Semantic constraintsFormal and actual arguments of both imported tasks or functions and exported tasks or functions are bound by the principle “What You Specify Is What You Get.” This principle is binding both for the caller and for the callee, in C code and in SystemVerilog code. For the callee, it guarantees the actual arguments are as specified for the formal ones. For the caller, it means the function call arguments shall conform with the types of the formal arguments, which might require type-coercion on the caller side.

Another way to state this is that no compiler (either C or SystemVerilog)... more

E.6 Data typesThis section defines the data types of the C-layer of the Direct Programming Interface.
E.7 Argument passing modesThis section defines the ways to pass arguments in the C-layer of the Direct Programming Interface.
E.8 Context tasks and functionsSome DPI imported tasks and functions require that the context of their call is known. For example, those calls can be associated with instances of C models that have a one-to-one correspondence with instances of SystemVerilog modules that are making the calls. Alternatively, a DPI imported task or function might need to access or modify simulator data structures using PLI or VPI calls, or by making a call back into SystemVerilog via an export task or function. Context knowledge is required for such calls to function properly. It can take special instrumentation of their call to provide such context.

To... more

E.9 Include filesThe C-layer of the Direct Programming Interface defines two include files. The main include file, svdpi.h, is implementation-independent and defines the canonical representation, all basic types, and all interface functions. The second include file, svdpi_src.h, defines only the actual representation of packed arrays and, hence, is implementation-dependent. Both files are shown in Annex B.

Applications which do not need to include svdpi_src.h are binary-level compatible.

E.10 ArraysNormalized ranges are used for accessing SystemVerilog arrays, with the exception of formal arguments specified as open arrays.
E.11 Open arraysFormal arguments specified as open arrays allows passing actual arguments of different sizes (i.e., different range and/or different number of elements), which facilitates writing more general C code that can handle SystemVerilog arrays of different sizes. The elements of an open array can be accessed in C by using the same range of indices and the same indexing as in SystemVerilog. Plus, inquiries about the dimensions and the original boundaries of SystemVerilog actual arguments are supported for open arrays.

NOTE—Both packed and unpacked array dimensions can be unsized.

All formal arguments declared in SystemVerilog as open arrays are passed by... more

链接

主题

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文