Data Type Conversions

The Link for ModelSim interface converts VHDL entity data to types that apply in the MATLAB environment. To program a MATLAB function for a VHDL model, you must understand the type conversions that pertain to your application. You need to know what type of data is being passed into the function so you know:

The following table summarizes how the Link for ModelSim converts supported VHDL data types to MATLAB types based on whether the type is scalar and composite.

VHDL-to-MATLAB Data Type Conversions

VHDL Types...As Scalar Converts to...As Composite Converts to...
STD_LOGIC, STD_ULOGIC, and BITA character that matches the character literal for the desired logic state.  
STD_LOGIC_VECTOR, STD_ULOGIC_VECTOR, BIT_VECTOR, SIGNED, and UNSIGNED A column vector of characters (as defined above) with one bit per character.
Arrays of STD_LOGIC_VECTOR, STD_ULOGIC_VECTOR, BIT_VECTOR, SIGNED, and UNSIGNED An array of characters (as defined above) with a size that is equivalent to the VHDL port size.
INTEGER and NATURALType int32.Arrays of type int32 with a size that is equivalent to the VHDL port size.
REALType double.Arrays of type double with a size that is equivalent to the VHDL port size.
TIMEType double for time values in seconds and type int64 for values representing simulator time increments (see the description of the 'time' option in Starting the MATLAB Server). Arrays of type double or int64 with a size that is equivalent to the VHDL port size.
Enumerated types Character array (string) that contains the MATLAB representation of a VHDL label or character literal. For example, the label high converts to 'high' and the character literal 'c' converts to '''c'''.Cell array of strings with each element equal to a label for the defined enumerated type. Each element is the MATLAB representation of a VHDL label or character literal. For example, the vector (one, '2', three) converts to the column vector ['one'; '''2'''; 'three']. A user-defined enumerated type that contains only character literals, converts to a vector or array of characters as indicated for the types STD_LOGIC_VECTOR, STD_ULOGIC_VECTOR, BIT_VECTOR, SIGNED, and UNSIGNED.


Learn more about the latest releases of MathWorks products:

 © 1994-2009 The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS