Trung tâm đào tạo thiết kế vi mạch Semicon


  • ĐĂNG KÝ TÀI KHOẢN ĐỂ TRUY CẬP NHIỀU TÀI LIỆU HƠN!
  • Đăng ký
    *
    *
    *
    *
    *
    Fields marked with an asterisk (*) are required.
semicon_lab.jpg

DATA TYPES

Email In PDF.

The SystemVerilog DPI supports only SystemVerilog data types, which are the data types that can cross the boundary between SystemVerilog and a foreign language in both the direction. On the other hand, the data types used in C code shall be C types. A value that is passed through the DPI is specified in SystemVerilog code as a value of SystemVerilog data type,

while the same value is declared C code as a value of C data type. Therefore, a pair of matching type definitions is required to pass a value through DPI, the SystemVerilog definition and the C definition.

The following SystemVerilog types are the only permitted types for formal arguments of import and export tasks or functions:

void, byte, shortint, int, longint, real, shortreal, chandle, and string

Scalar values of type bit and logic

Packed arrays, structs, and unions composed of types bit and logic. Every packed type is eventually equivalent to a packed one-dimensional array. On the foreign language side of the DPI, all packed types are perceived as packed one-dimensional arrays regardless of their declaration in the SystemVerilog code.

Enumeration types interpreted as the type associated with that enumeration

Types constructed from the supported types with the help of the constructs: struct , union , Unpacked array , typedef

Mapping data types

Passing Logic Datatype

The DPI defines the canonical representation of packed 2-state (type svBitVecVal) and 4-state arrays (type svBitVecVal). svLogicVecVal is fully equivalent to type s_vpi_vecval, which is used to represent 4-state logic in VPI.

CODE:SV_file.sv

program main;

logic a;

import "DPI" function void show(logic a);

initial begin

a = 1'b0;

show(a);

a = 1'b1;

show(a);

a = 1'bX;

show(a);

a = 1'bZ;

show(a);

end

endprogram

CODE: C_file.v

#include <stdio.h>

#include <svdpi.h>

void show(svLogic a){

if(a == 0)

printf(" a is 0 \n");

else if(a == 1)

printf(" a is 1 \n");

else if(a == 2)

printf(" a is x \n");

else if(a == 3)

printf(" a is z \n");

}

RESULTS

a is 0

a is 1

a is z

a is x

Bạn Có Đam Mê Với Vi Mạch hay Nhúng      -     Bạn Muốn Trau Dồi Thêm Kĩ Năng

Mong Muốn Có Thêm Cơ Hội Trong Công Việc

Và Trở Thành Một Người Có Giá Trị Hơn

Bạn Chưa Biết Phương Thức Nào Nhanh Chóng Để Đạt Được Chúng

Hãy Để Chúng Tôi Hỗ Trợ Cho Bạn. SEMICON  

Lần cập nhật cuối ( Thứ năm, 19 Tháng 8 2021 14:44 )  

Related Articles

Chat Zalo