Table of Contents Previous page Next page Index

ModelSim

Model Technology Inc.


Mapping to VHDL data types

Many FLI functions have parameters and return values that represent VHDL object values. This section describes how the object values are mapped to the various VHDL data types.

VHDL data types are identified in the C interface by a type ID. A type ID can be obtained for a signal by calling mti_GetSignalType( ) and for a variable by calling
mti_GetVarType( ).

Alternatively, the mti_CreateScalarType( ), mti_CreateRealType( ), mti_CreateEnumType( ), and mti_CreateArrayType( ) functions return type IDs for the data types they create.

Given a type ID handle, the mti_GetTypeKind( ) function returns a C enumeration of mtiTypeKindT that describes the data type. The mapping between mtiTypeKindT values and VHDL data types is as follows:

mtiTypeKindT value
VHDL data type
MTI_TYPE_ACCESS
Access type (pointer)
MTI_TYPE_ARRAY
Array composite type
MTI_TYPE_ENUM
Enumeration scalar type
MTI_TYPE_FILE
File type
MTI_TYPE_PHYSICAL
Physical scalar type
MTI_TYPE_REAL
Floating point scalar type
MTI_TYPE_RECORD
Record composite type
MTI_TYPE_SCALAR
Integer scalar type
MTI_TYPE_TIME
Time type

Object values for access and file types are not supported by the C interface. Values for record types are supported at the non-record subelement level. Effectively, this leaves scalar types and arrays of scalar types as valid types for C interface object values. In addition, multi-dimensional arrays are accessed in the same manner as arrays of arrays. For example, toto(x,y,z) is accessed as toto(x)(y)(z).

Scalar and physical types use 4 bytes of memory; TIME and REAL types use 8 bytes. An enumeration type uses either 1 byte or 4 bytes, depending on how many values are in the enumeration. If it has 256 or fewer values, then it uses 1 byte; otherwise, it uses 4 bytes. In some cases, all scalar types are cast to "long" before being passed as a non-array scalar object value across the C interface. The mti_GetSignalValue( ) function can be used to get the value of any non-array scalar signal object except TIME and REAL types, which can be retrieved using mti_GetSignalValueIndirect( ). Use mti_GetVarValue( ) and mti_GetVarValueIndirect( ) for variables.

Enumeration types

Enumeration object values are equated to the position number of the corresponding identifier or character literal in the VHDL type declaration. For example:

-- C interface values
     TYPE std_ulogic IS('U',-- 0
                        'X',-- 1
                        '0',-- 2
                        '1',-- 3
                        'Z',-- 4
                        'W',-- 5
                        'L',-- 6
                        'H',-- 7
                        '-' -- 8
                           ); 

Real and time types

Eight bytes are required to store the values of variables and signals of type REAL and TIME. In C, this corresponds, respectively, to the C "double" data type and the mtiTime64T structure defined in mti.h. The mti_GetSignalValueIndirect( ) and mti_GetVarValueIndirect( ) functions are used to retrieve these values.

Array types

The C type "void *" is used for array type object values. The pointer points to the first element of an array of C type "char" for enumeration types with 256 or fewer values, "double" for REAL types, "mtiTime64T" for TIME types, and "mtiInt32T" in all other cases. The first element of the array corresponds to the left bound of the array index range.

Multi-dimensional arrays are represented internally as arrays of arrays. For example, toto(x,y,z) is represented as toto(x)(y)(z). In order to get the values of the scalar subelements, you must use mti_GetSignalSubelements( ) or mti_GetVarSubelements( ) at each level of the array until you get to an array of scalars.

Note: A STRING data type is represented as an array of enumeration values. The array is not NULL terminated as you would expect for a C string, so you must call mti_TickLength( ) to get its length.



Model Technology Inc.
Voice: (503) 641-1340
Fax: (503)526-5410
http://www.model.com
sales@model.com
TOC PREV NEXT INDEX

ModelSim