![]() |
![]() |
![]() |
![]() |
mti_GetVarImageById()
Gets the string image of a VHDL variable's value (by ID).
Syntax
image = mti_GetVarImageById( variable_id )Returns
Name Type Description image char * A string image of the specified variable's valueArguments
Name Type Description variable_id mtiVariableIdT A handle to a VHDL variableDescription
mti_GetVarImageById() returns a pointer to a static buffer containing the string image of the specified VHDL variable's value. The image is the same as would be returned by the VHDL 1076-1993 attribute 'IMAGE. The returned string is valid only until the next call to any FLI function. The returned pointer must not be freed.
Related functions
Example
FLI code
#include <mti.h> typedef struct varInfoT_tag { struct varInfoT_tag * next; char * name; mtiTypeIdT typeid; mtiVariableIdT varid; } varInfoT; typedef struct { varInfoT * var_info; /* List of variables. */ mtiProcessIdT proc; /* Test process id.*/ } instanceInfoT; static void checkValues( void *inst_info ) { instanceInfoT * inst_data = (instanceInfoT *)inst_info; varInfoT * varinfo; mti_PrintFormatted( "Time [%d,%d]:\n", mti_NowUpper(), mti_Now() ); for ( varinfo = inst_data->var_info; varinfo; varinfo = varinfo->next ) { mti_PrintFormatted( " Variable %s = %s\n", varinfo->name, mti_GetVarImageById( varinfo->varid )); } mti_ScheduleWakeup( inst_data->proc, 5 ); } static varInfoT * setupVariable( mtiVariableIdT varid ) { varInfoT * varinfo; varinfo = (varInfoT *) mti_Malloc( sizeof(varInfoT) ); varinfo->varid = varid; varinfo->name = mti_GetVarName( varid ); varinfo->typeid = mti_GetVarType( varid ); varinfo->next = 0; return( varinfo ); } static void initInstance( void ) { instanceInfoT * inst_data; mtiProcessIdT procid; mtiRegionIdT regid; mtiVariableIdT varid; varInfoT * curr_info; varInfoT * varinfo; inst_data = mti_Malloc( sizeof(instanceInfoT) ); inst_data->var_info = 0; regid = mti_GetTopRegion(); for ( procid = mti_FirstProcess( regid ); procid; procid = mti_NextProcess() ) { for ( varid = mti_FirstVar( procid ); varid; varid = mti_NextVar() ) { varinfo = setupVariable( varid ); if ( inst_data->var_info == 0 ) { inst_data->var_info = varinfo; } else { curr_info->next = varinfo; } curr_info = varinfo; } } inst_data->proc = mti_CreateProcess( "Test Process", checkValues, (void *)inst_data ); mti_ScheduleWakeup( inst_data->proc, 4 ); } void initForeign( mtiRegionIdT region, /* The ID of the region in which this */ /* foreign architecture is instantiated. */ char *param, /* The last part of the string in the */ /* foreign attribute. */ mtiInterfaceListT *generics, /* A list of generics for the foreign model.*/ mtiInterfaceListT *ports /* A list of ports for the foreign model. */ ) { mti_AddLoadDoneCB( initInstance, 0 ); }HDL code
entity for_model is end for_model; architecture a of for_model is attribute foreign of a : architecture is "initForeign for_model.sl;"; begin end a; library ieee; use ieee.std_logic_1164.all; entity top is type bitarray is array( 3 downto 0 ) of bit; type intarray is array( 1 to 3 ) of integer; type realarray is array( 1 to 2 ) of real; type timearray is array( -1 to 0 ) of time; type rectype is record a : real; b : std_logic; c : bitarray; end record; end top; architecture a of top is component for_model end component; for all : for_model use entity work.for_model(a); begin inst1 : for_model; p1 : process variable bitsig : bit := '1'; variable intsig : integer := 21; variable realsig : real := 16.35; variable timesig : time := 5 ns; variable stdlogicsig : std_logic := 'H'; variable bitarr : bitarray := "0110"; variable stdlogicarr : std_logic_vector( 1 to 4 ) := "01LH"; variable intarr : intarray := ( 10, 11, 12 ); variable realarr : realarray := ( 11.6, 101.22 ); variable timearr : timearray := ( 15 ns, 6 ns ); variable rec : rectype := ( 1.2, '0', "1001" ); begin bitsig := not bitsig; intsig := intsig + 1; realsig := realsig + 1.1; timesig := timesig + 1 ns; stdlogicsig := not stdlogicsig; bitarr := not bitarr; stdlogicarr := not stdlogicarr; intarr(1) := intarr(1) + 1; intarr(2) := intarr(2) + 1; intarr(3) := intarr(3) + 1; realarr(1) := realarr(1) + 1.1; realarr(2) := realarr(2) + 1.1; timearr(-1) := timearr(-1) + 1 ns; timearr(0) := timearr(0) + 1 ns; rec.a := rec.a + 1.1; rec.b := not rec.b; rec.c := not rec.c; wait for 5 ns; end process; end a;Simulation output
% vsim -c top Reading .../modeltech/sunos5/../tcl/vsim/pref.tcl # 5.4b # vsim -c top # Loading .../modeltech/sunos5/../std.standard # Loading .../modeltech/sunos5/../ieee.std_logic_1164(body) # Loading work.top(a) # Loading work.for_model(a) # Loading ./for_model.sl VSIM 1> run 12 # Time [0,4]: # Variable bitsig = '0' # Variable intsig = 22 # Variable realsig = 17.45 # Variable timesig = 6 ns # Variable stdlogicsig = '0' # Variable bitarr = "1001" # Variable stdlogicarr = "1010" # Variable intarr = {11} {12} {13} # Variable realarr = {12.7} {102.32} # Variable timearr = {16 ns} {7 ns} # Variable rec = {2.3} {'1'} {"0110"} # Time [0,9]: # Variable bitsig = '1' # Variable intsig = 23 # Variable realsig = 18.55 # Variable timesig = 7 ns # Variable stdlogicsig = '1' # Variable bitarr = "0110" # Variable stdlogicarr = "0101" # Variable intarr = {12} {13} {14} # Variable realarr = {13.8} {103.42} # Variable timearr = {17 ns} {8 ns} # Variable rec = {3.4} {'0'} {"1001"} VSIM 2> quit
![]() Model Technology Inc. Voice: (503) 641-1340 Fax: (503)526-5410 http://www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |