Home

FLI function definitions

image

Contents

1. mti RemoveEnvCB FLI 537 The ID of the region in which this iA foreign architecture is instantiated The last part of the string in the foreign attribute A list of generics for the foreign model A list of ports for the foreign model mti AddEnvCB envCallback region 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 entity bottom is end bottom architecture b of bottom is begin end b entity top is end top architecture a of top is signal sl bit VOT component for model is end component for all for model use entity work for model a component bottom is end component begin bot bottom il for model S lt not sl after 5 ns end a ModelSim FLI Reference FLI 538 FLI function definitions ModelSim FLI Reference Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c Loading Loading Loading Loading Loading Foreign VSIM 1 en sim top VSIM 2 gt ru VSIM 3 en Foreign sim top VSIM 4 gt ru VSIM 5 en Foreign sim top VSIM 6 ru VSIM 7 en Foreign sim top VSIM 8 ru VSIM 9 en sim top VSIM 10 q top modeltech sunos5 work top a work bottom b work for model a for model sl Arch in Region il V n 10 v top i
2. Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 Loading modeltech sunos5 Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 15 Time 0 6 Signal bitsig Q Signal intsig 43 Signal physsig 4 Signal realsig 11 3 Signal timesig 0 5 Signal stdlogicsig BO Slgnal bitares TO Ung cito 1s Signal intarr 6 8 10 Signal stelogicarr LS v OQ VI Signal rec 1 POX a PIEN HEP Mg Time 0 11 Signal bitsig 1 Signal intsig 44 Signal physsig 5 Signal realsig 12 4 Signal timesig 0 7 Signal stdlogicsig 1 Signal bitarrs p ARC OQ To Signal intarr 7 9 Il Signal stdlogicarrt mor TIY fg Signal rec ro 2 ede SON TII VSIM 2 gt quit std standard ieee std_logic_1164 body mti GetTopRegion FLI 399 mti GetTopRegion Gets the first top level region Syntax region id mti GetTopRegion Returns Name Type Description region id mtiRegionIdT A handle to the first top level region Arguments None Description mti_GetTopRegion returns the region ID of the first top level region in the design hierarchy mti_NextRegion can be used to get additional top level regions Top level regions are VHDL architectures and packages Verilog modules and SystemC sc_modules If the region_id is a handle to a Verilog region then it can be used with PLI functions to obtain information about and acc
3. mti GetSignalName FLI 363 mti GetSignalName Syntax Returns Arguments Description Gets the simple name of a scalar or top level composite VHDL signal signal name mti GetSignalName signal id Name Description signal name The simple name of the signal Name Type Description signal id mtiSignalldT A handle to a VHDL signal mti_GetSignalName returns the simple name of the specified VHDL signal If the signal is acomposite subelement then the name returned is the name of the top level composite The returned pointer must not be freed To get the name of a composite subelement signal use mti GetSignalNamelndirect Related functions Example mti_GetSignalNamelIndirect FLI 367 FLI code include lt mti h gt void printSignals mtiRegionIdT region int indent mtiSignalIdT sigid for sigid mti FirstSignal region sigid sigid mti NextSignal if sigid mti_PrintFormatted cSignal s n indent mti GetSignalName sigid ModelSim FLI Reference FLI 364 FLI function definitions ModelSim FLI Reference void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s n indent region name indent 2 printSignals region indent for regid mti FirstLowerRegion region reg
4. 1 The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute x A list of generics for the foreign model A list of ports for the foreign model x initForeign for model sl generic delay time 5 ns port a in bit b r out bit i end inv architecture b of inv is signal count integer 0 begin b lt a after delay pl process a begin count lt count 1 after 0 ns end process end b entity mid is end mid architecture a of mid is signal sl bit s 0 j signal s2 bit Vs signal s3 bit VU ModelSim FLI Reference signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit b out bit i end component begin flip inv port map s3 s4 il for model S lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin insti mid end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for_model sl Hierarchy Region top Region top
5. fulltype region_name S cRegion s is mti GetRegionKind region case accArchitecture mti PrintFormatted break case accForeign break case accFunction brea case accModule Ki break case accPackage break mti PrintFormatted printFullType region mti PrintFormatted mti PrintFormatted mti PrintFormatted printFullType region mti GetRegionKind FLI 329 accArchVitalLevell accEntityVitalLevelO accForeignArch accForeignArchMixed accFunction accModuleInstance accPackage accShadow accTask ad Hierarchy mtiRegionIdT region a VHDL package fulltype int indent mti GetRegionFullName region indent a Verilog module printFullType region a VHDL architecture printFullType region a Verilog function printFullType region an FLI created region U region name ModelSim FLI Reference FLI 330 FLI function definitions case accTask mti PrintFormatted a Verilog task printFullType region break default mti mti PrintFormatted UNKNOWN printFullType region break An PrintFormatted indent 2 for pr mti_FirstLowerRegion region regid regid regid mti_NextRegion regid intHierarchy r
6. else char val array_val for i 0 i lt num elems i mti PrintFormatted s enum_values val i break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted d val i break case MTI_TYPE_ARRAY mti_PrintMessage ARRAY break case MTI_TYPE_RECORD mti PrintMessage RECORD break case MTI TYPE REAL double val array_val for i 0 i lt num elems i mti PrintFormatted g val i ModelSim FLI Reference mti GetNumRecordElements FLI 297 break case MTI_TYPE_TIME mtiTime64T val array val for i 0 i lt num elems i mti PrintFormatted d d MTI TIME64 HI32 val il MTI TIME64 LO32 val il break default break mti PrintFormatted n mti VsimFree array val break case MTI_TYPE_RECORD int i mtiSignalIdT elem list mtilnt32T num elems elem list mti GetSignalSubelements sigid 0 num elems mti GetNumRecordElements sigtype mti PrintFormatted n for i 0 i lt num elems i mti PrintFormatted cField d indent itl printValue elem list i mti GetSignalType elem list i indent 2 mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetSignalValueIndirect sigid amp real val mti PrintFo
7. case MTI_TYPE_ENUM char enum_values enum values mti GetEnumValues vartype if mti TickLength vartype gt 256 mtilnt32T scalar val void mti GetVarValueIndirect varid amp scalar val mti PrintFormatted s n enum values scalar val else char scalar val void mti GetVarValueIndirect varid amp scalar val mti PrintFormatted s n enum values int scalar val break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val scalar val mti GetVarValue varid mti PrintFormatted d n scalar val ModelSim FLI Reference mti GetVarValuelndirect FLI 451 break case MTI TYPE ARRAY int is mtiInt32T num elems mtiTypelIdT elem type mtiTypeKindT elem typekind void array val array val mti GetArrayVarValue varid 0 num elems mti TickLength vartype elem type mti GetArrayElementType vartype elem typekind mti GetTypeKind elem type switch elem typekind case MTI TYPE ENUM char enum_values enum values mti GetEnumValues elem type if mti TickLength elem type 256 mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted s enum values val i else char val array_val for i 0 i lt num elems i mti PrintFormatted s enum values val i break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtiInt32T val
8. foreign architecture is instantiated char param The last part of the string in the J foreign attribute mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model char primary name char region name mti PrintFormatted Foreign Init Function Mn region name mti GetRegionFullName region primary name mti GetPrimaryName region mti PrintFormatted Region parameter is s Primary name is s n region name primary name mti VsimFree region name 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 package for pkg is procedure test proc end for pkg package body for pkg is procedure test proc is begin assert false report I m in the test proc severity note end end for pkg mti GetPrimaryName FLI 313 use work for pkg all entity lower is end lower architecture level of lower is begin pl process begin test proc wait for 20 ns end process end level library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is component for model end component component lower end component begin linstl lower linst2 lower finst for_model end a configuration cfg_top of top is
9. sigid sigid mti NextSignal typeid mti GetSignalType sigid mti PrintFormatted 14s type 12s direction s d n mti GetSignalName sigid getTypeStr typeid getDirStr typeid mti TickDir typeid void initForeign mtiRegionIdT region The ID of the region in which this PU foreign architecture is instantiated char param The last part of the string in the xy foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model E 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 a11 entity top is type bitarray is array 3 downto 0 of bit ModelSim FLI Reference type rectype is record a 4 lt baty b integer C bitarray end record type bigtime is range 0 to integer high units hour day 24 hour week 7 day month 4 week year 12 month end units end top architecture a of top is signal bitsig east 1 signal intsig integer 42 signal physsig bigtime 3 hour signal realsig real 10 2 signal timesig time 3 ns signal stdlogicsig std_logic H signal bitarr bitarray 1100 signal stdlogicarr std
10. 2 32 mtiTime64T tMinusl MTI TIME64 INIT 1 0U 1 void increment time mtiTime64T tval fif defined LP64 defined __LP64__ tval tval 1 else int t_hi unsigned int t_lo t hi MTI TIME64 HI32 tval t lo MTI TIME64 LO32 tval FLE lo if t lo 0 ttt hi MTI TIME64 ASGN tval t hi t 10 endif ModelSim FLI Reference FLI 36 Introduction Shared library dependency Example 1 ModelSim FLI Reference By default ModelSim does not share the symbols defined by any of the shared libraries that it dynamically loads because of the many problems this can cause for example symbol clashing However you can load libraries with global symbol visibility by using the gblso argument to vsim see the ModelSim Command Reference for details on this argument If you have a shared library that needs access to symbols in another shared library but global visibility is not viable then you must do one of the following Put the shared library dependency in the link of the shared library that has the dependency Code your shared library to dynamically load the shared library on which it depends and look up the symbols that it needs Following are examples of both styles of handling library dependencies In this example there are two shared libraries A and B Library B uses functions in library A and both libraries are dynamically loaded by ModelSim FLI code include mti h
11. Memory allocation failure Please check your system for available memory and swap space Related functions mti Free FLI 219 mti Realloc FLI 523 ModelSim FLI Reference Example mti Malloc FLI 483 FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char inst info char param mti PrintFormatted Saving instance info pointer to s n inst info mti SaveBlock char amp inst info sizeof inst info void restoreCallback void param mti RestoreBlock char amp instance info mti PrintFormatted Restored instance info s n instance info void cleanupCallback void param mti_PrintMessage Cleaning up n NOTE Memory allocated by mti Malloc will be freed by vsim 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 y foreign attribute E7 mtiInterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model KL if mti IsRestore mti PrintMessage Restore in progress n else instance info mti Malloc strlen param 1 strcpy instance info param mti_AddSaveCB saveCallback instance_info mti_AddRestoreCB restoreCallback instance_info
12. char param The last part of the string in the wf foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model char region name mtiRegionIdT regid mti PrintFormatted Foreign Init Function Mn region name mti GetRegionFullName region mti PrintFormatted Region parameter is s n region name mti VsimFree region name regid mti GetCurrentRegion ModelSim FLI Reference FLI 250 FLI function definitions region name mti GetRegionFullName regid mti PrintFormatted Current region is s n region name mti VsimFree region name mti AddLoadDoneCB initInstance 0 mti AddEnvCB checkEnv 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 package for pkg is procedure test proc attribute foreign of test proc procedure is doProc for model sl end for pkg package body for pkg is procedure test proc is begin end end for pkg use work for pkg all entity lower is end lower architecture level of lower is begin pl process begin test proc wait for 15 ns end process end level library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is component for model end component for all
13. end case cl wait for 5 ns end process end a ModelSim FLI Reference FLI 166 FLI function definitions ModelSim FLI Reference Simulation output vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl vest vsim foreign initForeign for_model sl c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading for_model sl VSIM 1 run 20 Time 0 15 delta 0 Signal sl is UNKNOWN Fatal Foreign module requested halt Fatal error at line 0 VSIM 2 cont Cannot continue because of fatal error VSIM 3 quit Time 15 ns Iteration 0 Foreign Process top SignalMonitor File Foreign mti FindDriver Determines if a VHDL signal has any drivers on it driver id mti FindDriver signal id Type mti FindDriver FLI 167 Description mtiDriverldT Type A handle to a driver of the specified signal or NULL if there is an error if no drivers are found for a scalar signal or if any element of an array signal does not have a driver Description Syntax Returns Name driver_id Arguments Name signal_id Description mtiSignalldT A handle to the VHDL signal mti_FindDriver returns a handle to a driver of the specified signal If no drivers are found for a scalar signal or if any element of an array signal does not have a driver then NUL
14. ic_1164 body Variabl Variabl Variabl Time 0 Variabl Variabl Variabl Variabl Varia o 0 0000000000 000 Varia Varia Varia Varia Q X Q5 XR SE Varia Variabl VSIM 2 quit realarr 1 270000e 01 1 023200e 02 timearr 16 ns 7 ns rec 2 300000e 00 1 0110 bitsig 1 intsig 23 realsig 1 855000e 01 timesig 7 ns stdlogicsig 1 bitarr 0110 stdlogicarr 0101 intarr 12 I3 14 realarr 1 380000e 01 1 034200e 02 timearr 17 ns 8 ns rec 3 400000e 00 0 1001 mti_GetVarlmageByld FLI 425 ModelSim FLI Reference FLI 426 FLI function definitions mti GetVarName Gets the simple name of a VHDL variable Syntax var name mti GetVarName variable id Returns Description The simple name of the specified variable Arguments Name Type Description variable id mtiVariableIdT A handle to a VHDL variable Description mti GetVarName returns the simple name of the specified VHDL variable or NULL if no information can be found The returned pointer must not be freed mti GetVarName cannot be used with variable IDs passed as foreign subprogram parameters Related functions None Example FLI code include lt stdio h gt include lt mti h gt define NAME_MAX 1024 typedef struct varInfoT tag struct varInfoT tag next char name mtiProcessIdT procid mtiRegionIdT regid mtiT
15. int Afuncl char str mti_PrintFormatted Afuncl was called with parameter s n str return 17 int Afunc2 char str mti_PrintFormatted Afunc2 was called with parameter s n str return 211 void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports mti PrintFormatted Shared lib A initialized n include mti h extern int Afuncl char extern int Afunc2 char void loadDoneCallback void param Shared library dependency FLI 37 int retval retval Afunc2 B calling Afunc2 mti PrintFormatted B called Afunc2 which returned d n retval void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports int retval mti PrintFormatted Shared lib B initialized n retval Afuncl B calling Afuncl mti PrintFormatted B called Afuncl which returned d n retval mti AddLoadDoneCB loadDoneCallback O0 Compilation instructions The following commands illustrate how to compile the files on Solaris See Compiling and linking FLI C applications FLI 25 for instructions on other platforms gcc c ISMTI HOME include src A c ld G B symbolic o libA so A o gcc c IS MTI HOME include src B c ld G B symbolic L l A o B so B o Simulation output setenv LD_LIBRARY_PATH vsim c test do test do
16. integer 0 5 Ef y count count 1 wait on a end process end b entity top is end top architecture a of top is signal sl bit 0 signal 52 bit r 0 signal sS 2 bit ie EOT signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit b out bit i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 procl process variable count integer 0 begin wait on sl count count 1 end process procl end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl vsim c top Loading work top a Loading work inv b Loading work for model a Loading for model sl Loading modeltech sunos5 std standard mti GetProcessRegion FLI 321 ModelSim FLI Reference FLI 322 FLI function definitions ModelSim FLI Reference Process Process Process Process Process Process Process Process Process Elaboration phase pl is in line 19 Load Done phase procl is line 58 line 57 pl is in line 19 pl xs in line 19 VSIM 1 run 10 VSIM 2 quit region top flip is in region top flip in region top is in region top is in region top region top flip is in regio
17. Drivers L top instl p0 0 top p2 L top pl VSIM 4 drivers top sl Drivers for top sl 0 Signal top sl L Driver top inst1 p0 0 Driver top p2 L Driver top pl VSIM 5 run 5 Time 0 11 delta O0 Signal sl is X Drivers W top instl pO W top p2 IXY top pl VSIM 6 drivers top sl Drivers for top sl X Signal top s1 W Driver top inst1 p0 W Driver top p2 X Driver top pl VSIM 7 quit Cleaning up mti GetDriverNames FLI 257 ModelSim FLI Reference FLI 258 FLI function definitions mti GetDriverSubelements Gets the subelements of a composite driver Syntax driver list mti GetDriverSubelements driver id buffer Returns Name Type Description driver list mtiDriverldT A pointer to an array of driver IDs for each of the subelements of the specified array type driver or NULL if the specified driver is not of an array type Arguments Name Type Description driver id mtiDriverldT A handle to an array type driver buffer mtiDriverldT A buffer into which the subelement driver IDs are to be placed OPTIONAL can be NULL Description mti_GetDriverSubelements returns an array of driver IDs for each of the subelements of the specified array type driver If the buffer parameter is NULL then mti_GetDriverSubelements allocates memory for the value and returns a pointer to it The caller is responsible for freeing
18. FLI 47 Table 5 FLI variable functions Continued Function Action mti GetVarImageBylId FLI 421 Gets the string image of a VHDL variable s value by ID mti GetVarName FLI 426 Gets the simple name of a VHDL variable mti GetVarSubelements FLI 431 Gets the subelements of a composite VHDL variable mti GetVarType FLI 438 Gets the type of a VHDL variable mti GetVarValue FLI 442 Gets the value of a scalar VHDL variable of type enumeration integer or physical mti GetVarValueIndirect FLI 449 Gets the value of a VHDL variable of any type except record mti SetVarValue FLI 628 Sets the value of a VHDL variable Table 6 FLI type functions Function Action mti CreateArray Type FLI 108 Creates an array type mti CreateEnumType FLI 118 Creates an enumeration type mti CreateRealType FLI 139 Creates a real type mti CreateScalarType FLI 146 Creates a scalar type mti CreateTimeType FLI 154 Creates a time type mti_GetArrayElementType FLI 222 Gets the type of an array type s subelements mti GetNumRecordElements FLI 295 Gets the number of subelements in a record type mti GetEnumValues FLI 271 Gets the values of an enumeration type mti GetParentSignal FLI 301 Gets the unit information of a physical type mti GetTypeKind FLI 404 Gets the kind of a
19. G S lt n end a for_model use entity work for_model a r_model ot sl after 5 ns Simulation output 9 vsim c Reading 5 4b vsim c Loading Loading Loading Loading VSIM 1 r Saving Saving Saving Saving Saving VSIM 3 r VSIM 4 gt r Loading Checkpo Restori Restori Restori Restori Restori Restori VSIM 5 gt r top modeltech tcl vsim pref tcl top modeltech sunos5 std standard work top a work for model a for model sl un 20 VSIM 2 checkpoint cpfile instance info my for model char Z long 123456 short 587 string Howdy un 40 estore cpfile checkpoint restore data from file cpfile int created Fri Jul 7 16 09 02 2000 ng state at time 20 ns iteration 1 ng instance info my for model ng char Z ng long 123456 ng short 587 ng string Howdy un 10 VSIM 6 quit ModelSim FLI Reference mti SaveChar FLI 583 mti SaveChar Saves a byte of data to the checkpoint file Syntax mti SaveChar data Returns Nothing Arguments Description The byte of data to be saved Description mti SaveChar saves the specified byte of data to the checkpoint file Related functions mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveLong FLI 586 mti SaveShor
20. Signal s s is UNKNOWN Wn mti Delta mti PrintFormatted Time d d delta mti NowUpper mti Now region name signal name sprintf buffer drivers s s region name interp mti Interp status mti Cmd buffer if status TCL OK mti PrintMessage ERROR while executing drivers command n else mti PrintFormatted The drivers of s s are n s n region name signal name Tcl ResetResult interp mti VsimFree region name break default break void initForeign signal name interp result mtiRegionIdT region The ID of the region in which this QUA foreign architecture is instantiated char param The last part of the string in the f foreign attribute ER mtiInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model mtiProcessIdT procid mtiSignalIdT sigid sigid mti FindSignal top sl1 procid mti CreateProcess SignalMonitor mti Sensitize procid sigid MTI EVENT HDL code library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal sl std logic 0 begin ModelSim FLI Reference monitorSignal pl process begin Cl case sl is when U gt sl when X gt sl when 0 gt sl when 1 gt sl when Z gt sl when W gt sl when L gt sl when H gt s
21. X0U signal intarrl intarray 10 11 12 signal recl rectype eo vt Lg vx ys ModelSim FLI Reference K FLI 216 FLI function definitions component for model end component for all for model use entity work for model a begin instl for model bitsigl lt not bitsigl after 5 ns intsigl lt intsigl 1 after 5 ns stdlogicsigl lt after 5 ns when stdlogicsigl H U after 5 ns when stdlogicsigl X after 5 ns when stdlogicsigl U 0 after 5 ns when stdlogicsigl X 1 after 5 ns when stdlogicsigl 0 Z after 5 ns when stdlogicsigl 1 W after 5 ns when stdlogicsigl Z L after 5 ns when stdlogicsigl W H after 5 ns bitarrl lt not bitarrl after 5 ns intarr1 1 lt intarrl 1 1 after 5 ns intarr1 2 lt intarr1 2 1 after 5 ns intarrl 3 lt intarrl 3 1 after 5 ns stdlogicarrl1 1 lt after 5 ns when stdlogicarrl 1 U after 5 ns when stdlogicarrl 1 X after 5 ns when stdlogicarrl 1 O after 5 ns when stdlogicarrl 1 1 after 5 ns when stdlogicarrl 1 Z after 5 ns when stdlogicarrl 1 W after 5 ns when stdlogicarrl 1 L after 5 ns when stdlogicarrl 1 H after 5 ns stdlogicarr1 2 lt after 5 ns when stdlogicarrl 2 U after 5 ns when stdlogicarrl 2 X after 5 ns when stdlogicarrl 2 0 after 5 ns when stdlogicarr1 2 1 after 5 ns when stdlogicarrl 2 Z after 5 ns when stdlogicarr
22. case MTI_TYPE_TIME mtiTime64T val array val for i 0 i lt num elems i mti_PrintFormatted d d MTI TIME64 HI32 val il MTI TIME64 LO32 val il break default break mti PrintFormatted n mti VsimFree array val break case MTI_TYPE_RECORD int i mtiSignalIdT elem list mtiInt32T num elems elem list mti GetSignalSubelements sigid 0 num elems mti GetNumRecordElements sigtype mti PrintFormatted An for i 0 i lt num elems i mti PrintFormatted c indent printValue elem list i mti GetSignalType elem list i indent 2 mti_VsimFree elem_list ModelSim FLI Reference mti GetArraySignalValue FLI 229 break case MTI TYPE REAL double real_val mti GetSignalValueIndirect sigid amp real val mti PrintFormatted gYn real val break case MTI_TYPE_TIME mtiTime64T time_val mti GetSignalValueIndirect sigid amp time val mti PrintFormatted d d n MTI TIME64 H132 time val MTI TIME64 LO32 time val break default mti PrintMessage n break static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info signallInfoT siginfo mti PrintFormatted Time d d Mn mti NowUpper mti Now for siginfo inst data sig info siginfo siginfo siginfo gt next mti PrintFormatted Signal s siginfo
23. if inst data var info 0 inst data var info varinfo else curr_info gt next varinfo curr_info varinfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 6 ModelSim FLI Reference FLI 446 FLI function definitions 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 xy x Ej mtiInterfaceListT generics A list of generics for the foreign model mtilnterfaceListT 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 a11 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 bit b integer e real d std logic e 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 instl for model pl process variable bitsig SBE 1 variable intsig
24. if mti IsFirstInit mti PrintMessage nFirst call to init function Mn mti PrintFormatted test global d n test global test global 42 mti PrintFormatted Setting test global to dWMn test global else mti PrintMessage nSimulation has been restarted n mti PrintFormatted test global d n test global test global 3 mti PrintFormatted Setting test global to d n test global instance_info malloc strlen param 1 strcpy instance info param mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info 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 for model begin end a entity top is end top architecture a of top is signal sl cs bit e tOr component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a ModelSim FLI Reference Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl First call to init function test global 15 Setting test global to 42 VSIM 1 run 30 VSIM 2 restart f Cleanup callback Freeing param for model test glob
25. modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 20 VSIM 2 restart f Loading for_model sl VSIM 3 run 10 VSIM 4 quit Cleaning up for model for simulator exit mti RemoveRestartCB Removes a simulator restart callback mti RemoveRestartCB FLI 545 Syntax mti RemoveRestartCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function being called at simulator restart void The parameter that was specified in the call to mti_AddRestartCB when the callback was created Description mti_RemoveRestartCB removes the specified function from the simulator restart callback list The param parameter must be the same parameter that was specified in the call to mti_AddRestartCB when the callback was created Related functions mti_AddRestartCB FLI 71 Example FLI code include lt stdlib h gt include lt mti h gt void restartCallback void param if param mti_PrintFormatted Cleaning up s for char param free param else mti_PrintMessage Restarting simulator void loadDoneCallback void param simulator restart n aee n F ModelSim FLI Reference FLI b46 FLI function definitions ModelSim FLI Reference if int param 1 mti RemoveR
26. mti IsColdRestore FLI 470 Determines if a cold restore operation is in progress mti SaveBlock FLI 580 Saves a block of data to the checkpoint file mti SaveChar FLI 583 Saves a byte of data to the checkpoint file mti SaveLong FLI 586 Saves sizeof long bytes of data to the checkpoint file mti SaveShort FLI 589 Saves sizeof short bytes of data to the checkpoint file mti SaveString FLI 592 Saves a null terminated string to the checkpoint file mti RestoreBlock FLI 560 Gets a block of data from the checkpoint file mti RestoreChar FLI 563 Gets a byte of data from the checkpoint file mti RestoreLong FLI 566 Gets sizeof long bytes of data from the checkpoint file mti RestoreShort FLI 574 Gets sizeof short bytes of data from the checkpoint file mti RestoreString FLI 577 Gets a null terminated string from the checkpoint file mti RestoreProcess FLI 569 Restores a process that was created by mti CreateProcess FLI 123 or mti CreateProcessWithPriority FLI 128 Table 10 FLI time and event functions Function Action mti Delta FLI 157 Gets the simulator iteration count for the current time step mti Now FLI 501 Gets the low order 32 bits of the 64 bit current simulation time mti NowUpper FLI 510 Gets the high order 32 bits of the 64 bit current simulation time mti
27. void initForeign mtiRegionIdT region The ID of the region in which this EJ foreign architecture is instantiated char param The last part of the string in the foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model instance info malloc strlen param 1 strcpy instance info param mti AddSaveCB saveCallback instance info mti AddRestoreCB restoreCallback instance info mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info 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 for model begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a mti GetCheckpointFilename FLI 247 Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 20 VSIM 2 checkpoint my checkpoint file Saving instance info for model Checkpoint filename is my checkpoint file VSIM 3 run
28. 11 10 ps 12 1 ps 13 100 fs 14 10 fs 15 1 fs Related functions Example None FLI code include lt mti h gt static char convertLimit int limit switch limit case 2 return 100 sec case 1 return 10 sec case 0 return 1 sec case 1 return 100 ms case 2 return 10 ms case 3 return 1 ms case 4 return 100 us case 5 return 10 us case 6 return 1 us case 7 return 100 ns case 8 return 10 ns case 9 return TL ns case 10 return 100 ps case 11 return 10 ps case 12 return 1 ps case 13 return 100 fs case 14 return 10 fs J case 15 return 1 fs default return Unexpected void initForeign mtiRegionIdT char region param mtilnterfaceListT generics mtilnterfaceListT ports limit The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute A list of generics for the foreign model A list of ports for the foreign model mti GetResolutionLimit FLI 349 E E y ModelSim FLI Reference FLI 350 FLI function definitions mti PrintFormatted The resolution limit of the simulator is s n convertLimit mti GetResolutionLimit HDL code entity for model is end for model architecture a of for model is attribute foreign
29. Example FLI code include lt stdlib h gt include lt mti h gt typedef enum SIGVAL 0 SIGVAL 1 SIGVAL X mySigType char enum lits 3 0 1 X typedef struct mtiSignalIdT sigidl dT dT dT sigid2 sigid3 drvidl dT drvid2 dT drvid3 instanceInfoT mtiSignal mtiSignal mtiDriver mtiDriver mtiDriver This function inverts mySigl every 5 ns void driveSignall void param char region name instanceInfoT inst instanceInfoT param mtilInt32T sigval sigval mti GetSignalValue inst gt sigidl switch sigval case SIGVAL 0 mti ScheduleDriver inst drvidl SIGVAL 1 break case SIGVAL 1 mti ScheduleDriver inst gt drvidl SIGVAL 0 break case SIGVAL X region name mti PrintFormatted Time d d mti NowUpper delta d region name mti VsimFree region name break default region name mti Now mti GetSignalName mti CreateEnumType FLI 119 5 MTI INERTIAL 5 MTI INERTIAL mti GetRegionFullName mti GetSignalRegion inst sigid1 Signal s s is UNKNOWN Wn mti Delta inst sigidl mti GetRegionFullName mti GetSignalRegion inst sigid1 ModelSim FLI Reference FLI 120 FLI function definitions n mti PrintFormatted Time d d delta d Unexpected value d on signal s s n mti NowUpper mti Now mti Delta sigval region name mti GetSignalName inst gt s
30. Loading work for model a Loading for model sl VSIM 1 add list top il top tl VSIM 2 run 10 sec Time 0 ns Executing driveSignal Time 4294967297 ns Executing driveSignal Time 8589934595 ns Executing driveSignal VSIM 3 write list list out VSIM 4 quit Cleaning up cat list out ns top il delta top t1 0 0 0 0 5 0 Jar 4294967302 0 0 0 8589934600 0 11 mti ScheduleWakeup64 FLI 613 ModelSim FLI Reference FLI 614 FLI function definitions mti Sensitize Sensitizes a VHDL process to a VHDL signal Syntax mti Sensitize process id signal id trigger Returns Nothing Arguments Name Type Description process id mtiProcessIdT A handle to a VHDL process signal id mtiSignalldT A handle to a VHDL signal trigger mtiProcessTriggerT Indicates either event based or activity based triggering Description mti_Sensitize causes the specified process to be called when the specified signal is updated If the trigger parameter is MTI EVENT then the process is called when the signal changes value If the trigger parameter is MTI ACTIVE then the process is called whenever the signal is active Related functions mti CreateProcess FLI 123 mti CreateProcessWithPriority FLI 128 mti Desensitize FLI 160 mti ScheduleWakeup FLI 606 mti ScheduleWakeup64 FLI 610 Example FLI code include lt stdlib h gt include lt mti h gt typedef struct
31. ModelSim FLI Reference printSignalInfo mti FindSignal Signal top fo mti FindSignal Signal top printSignallInfo mti FindSignal mti PrintMessage Signal top fo mti FindSignal Signal top fo mti FindSignal mti PrintMessage printSignalIn mti PrintMessage printSignalIn mti PrintMessage printSignalIn void initForeign mtiRegionIdT region 7 gt char param mtilnterfaceListT generics mtilnterfaceListT ports ZF mti_AddLoadDoneCB loadDoneCB 0 HDL code entity for_model is end for_model architecture a of for_model is attribute foreign of a archite begin end a entity top is type rectype is record a integer Eb e prti c bit_vector 3 downto O0 end record type rectype2 is record fl bit 2 rectype end record type al is array 2 downto 0 type a2 is array 3 downto 2 type a3 is array 1 to 2 0 to end top architecture a of top is signal sl DIt tSo hs signal s2 rectype 42 1 signal s3 bit_vector 7 downto signal s4 rectype2 1 signal s5 a2 101 011 signal s6 a3 Hello th mti GetSignalType FLI 383 Cop s2 yid d S3 T js top s3 4 dst ys top s4 4 gib SYG top s5 4 fs top s6 4 The ID of the region in which this foreign architecture The last part of the foreign attribute is instantiated string in the x EJ A li
32. Returns Nothing Arguments Name Type Description driver id mtiDriverldT A handle to a VHDL driver process id mtiProcessIdT A handle to a VHDL process Description mti SetDriverOwner makes the specified process the owner of the specified driver Normally mti CreateDriver makes the MTI foreign architecture process the owner of a new driver When using mti CreateDriver it is necessary to follow up with a call to mti SetDriverOwner otherwise the drivers command and the Dataflow window may give unexpected or incorrect information regarding FLI created drivers Related functions mti CreateDriver FLI 113 Example FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD_LOGIC_X STD LOGIC 0 STD LOGIC 1 STD LOGIC Z STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D mySigType char std logic lits 9 mbpsw decem gebpPm oqurqum gerggge cm grrm mer Ya mpi mgl pz ModelSim FLI Reference FLI 618 FLI function definitions typedef struct mtiSignalldT mtiSignalldT mtiDriverIdT mtiDriverIdT fe This sigidl sigid2 drvidl drvid2 instanceInfoT ky function inverts mySigl every 5 ns void driveSignall void param char region name instanceInfoT inst instanceInfoT param mtilInt32T sigval sigval mti GetSignalValue inst gt sigidl switch sigval case STD LOGIC U mti Schedule
33. Syntax region id mti CreateRegion parent name Returns Name Type Description region id mtiRegionIdT A handle to the new region or NULL if there is an error Arguments Name Type Description parent mtiRegionIdT A handle to the parent region under which the new region is to be placed OPTIONAL can be NULL name char The name of the new region OPTIONAL can be NULL Description mti_CreateRegion creates a new region with the specified name under the specified parent region The name is converted to lower case unless it is an extended identifier If the name is NULL then the region is hidden If the parent region is NULL then the new region is not connected to the design hierarchy The new region can be created below either a VHDL region or a Verilog region The new region is of type accForeign and of fulltype accShadow see acc_vhdl h If a region is created with no name or with no parent the returned handle to the region must be saved as there is no way to find the region by name or by traversing the design with the region traversal functions mti_CreateRegion allows you to create a region with an illegal HDL name This can be useful for integrators who provide shared libraries for use by end customers as this is an easy way to avoid potential name conflicts with HDL regions We recommend the following naming style lt PREFIX_name gt where PREFIX is 3 or 4 characters that denote your software to avoid name conflic
34. begin sl lt not sl after 5 ns end a Simulation output vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading work top a Loading for model sl VSIM 1 run 0 VSIM 2 examine mySigl mySig2 mySig3 000 VSIM 3 run 5 VSIM 4 examine mySigl mySig2 mySig3 10X VSIM 5 run 5 VSIM 6 examine mySigl mySig2 mySig3 01xX VSIM 7 run 5 VSIM 8 examine mySigl mySig2 mySig3 l 1 1 VSIM 9 quit Cleaning up mti CreateSignal FLI 153 ModelSim FLI Reference FLI 154 FLI function definitions mti CreateTimeTyper Creates a time type Syntax type id mti CreateTimeType Returns Type Description mtiTypeldT A handle to the new time type Arguments None Description mti CreateTimeType creates a new type ID that describes a VHDL time type Related functions mti CreateArray Type FLI 108 mti CreateEnumType FLI 118 mti CreateRealType FLI 139 mti CreateScalarType FLI 146 Example FLI code include lt stdlib h gt include lt mti h gt typedef struct mtiSignalIdT sigid mtiDriverIdT drvid mtiTime64T sigval mtiTypeIdT time type instanceInfoT void driveSignal void param char region name char curr time str instanceInfoT inst instanceInfoT param mtiTime64T curr ti
35. end inv architecture b of inv is signal count integer 0 begin b lt a after delay pl process a begin count lt count 1 after 0 ns end process end b entity mid is end mid architecture a of mid is signal sl bit 0 signal s2 bit 0 signal 3 bit 0O signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit b out bit i end component begin flip inv port map s3 s4 il for model S lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin insti mid end a mti FirstSignal FLI 201 ModelSim FLI Reference FLI 202 FLI function definitions Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for_model sl Elaboration phase Region top Region top instl Signal s4 Signal s3 Signal s2 Signal s1 Region top instl il Region top instl flip Signal count Signal b Signal a Load Done phase Region top Region top instl Signal sl Signal s2 Signal s3 Signal s4 Region top instl flip Sign
36. entity top is ModelSim FLI Reference setupVariable varid inst data var info 0 varinfo varinfo mti CreateProcess mti FirstProcess regid mti NextProcess mti FirstVar procid varid varid mti NextVar regid procid Test Process checkValues void inst data 4 The ID of the region in which this f foreign architecture is instantiated The last part of the string in the EL foreign attribute KL A list of generics for the foreign model A list of ports for the foreign model E7 0 initForeign for model sl type bitarray is array 3 downto 0 type intarray is array 1 to 3 type realarray is array 1 to 2 type timearray is array 1 to 0 type rectype is record a real b std logie C bitarray end record end top architecture a of top is component for model end component mti GetVarlmage FLI 419 of of of of bit integer real time for all for model use entity work for model a begin instl for_model pl 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 O1LH variable intarr intarray I0 ll 12 3 variable realarr realarray 11 6 101 22 variable timearr timear
37. g n real val break case MTI_TYPE_TIME mtiTime64T time_val mti GetSignalValueIndirect sigid amp time val mti PrintFormatted d d Wn MTI TIME64 HI132 time val MTI TIME64 LO32 time val break default ModelSim FLI Reference mti GetSignalValue FLI 389 mti PrintMessage Mn break static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info signallInfoT siginfo mti PrintFormatted Time d d n mti NowUpper mti Now for siginfo inst data sig info siginfo siginfo siginfo gt next mti PrintFormatted Signal s siginfo gt name printValue siginfo gt sigid siginfo gt typeid 4 mti ScheduleWakeup inst data proc 5 static signallnfoT setupSignal mtiSignalIdT sigid signaliInfoT siginfo siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo next z return siginfo static void initInstance void param instanceInfoT inst data mtiSignalldT sigid signallnfoT curr info signallInfoT siginto inst data mti Malloc sizeof instanceInfoT inst data 5sig info 0 for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig
38. inst i2 sigid mti FindSignal top i2 inst i2 drvid mti CreateDriver inst gt i2 sigid mti SetDriverOwner inst i2 drvid inst procid inst i3 sigid mti FindSignal top i3 inst i3 drvid mti CreateDriver inst gt i3_sigid mti SetDriverOwner inst i3 drvid inst procid y iy DA Jd inst tl sigid inst tl drvid mti SetDriverOwner inst tl drvid mti FindSignal inst gt t2_sigid inst gt t2_drvid mti_SetDriverOwner inst gt t2_drvid mti_FindSignal inst gt t3_sigid inst gt t3_drvid mti SetDriverOwner inst t3 drvid mti FindSignal mti AddLoadDoneCB loadDoneCallback mti AddQuitCB cleanupCallback mti AddRestartCB cleanupCallback HDL code entity for model is end for model architecture a of for model is attribute foreign of a architecture begin end a library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is bit ots std logic 0 bit vector 3 downto 0 signal il signal i2 signal i3 signal t1 bit i TOT signal t2 std_logic 0 signal t3 bit_vector 3 downto 0 component for_model end component begin forinst for_model end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading E btepALL4 ys mti CreateDriver inst gt tl_sigid inst procid nI cop t2 35 mti CreateDri
39. modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading for_model sl VSIM 1 run 30 Time 0 15 delta 0 Signal sl is UNKNOWN oe ModelSim FLI Reference mti Realloc FLI 523 mti Realloc Reallocates simulator managed memory Syntax memptr mti Realloc origptr size Returns Name Description memptr A pointer to the reallocated memory Arguments Name Type Description origptr void A pointer to the currently allocated memory size unsigned long The size in bytes of the new memory to be allocated Description mti Realloc works like the C realloc function on memory allocated by mti Malloc If the specified size is larger than the size of memory already allocated to the origptr parameter then new memory of the required size is allocated and initialized to zero the entire content of the old memory is copied into the new memory and a pointer to the new memory is returned Otherwise a pointer to the old memory is returned Any memory allocated by mti Realloc is guaranteed to be checkpointed and restored just like memory allocated by mti Malloc Memory allocated by mti Realloc can be freed only by mti Free mti Realloc automatically checks for a NULL pointer In the case of an allocation error mti Realloc issues the following error message and aborts the simulation Memory allocation failu
40. not stdlogicarr 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 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 Variable bitsig is of type Enum Variable intsig is of type Scalar Variable realsig is of type Real Variable timesig is of type Time ModelSim FLI Reference Variable stdlogicsig is of type Enum Variable bitarr is of type Array Variable stdlogicarr is of type Array Variable rec is of type Record VSIM 1 quit mti GetVarType FLI 441 ModelSim FLI Reference FLI 442 FLI function definitions mti GetVarValue Gets the value of a scalar VHDL variable of type enumeration integer or physical Syntax value mti GetVarValue variable id Returns Type Description mtiInt32T The current value of the specified variable Arguments Name Type Description variable id mtiVariableIdT A handle to a VHDL scalar variable of type enumeration integer or physical Description mti GetVarValue returns the value of variables of type enumeration integer and physical For composite real and time type variables use mti GetVarValueIndirect Related functions mti GetArrayVarValue FLI 233 m
41. regid mti GetCurrentRegion region name mti GetRegionFullName regid mti PrintFormatted Time d d doProc Procedure Current region is s n mti NowUpper mti Now region name mti VsimFree region name ModelSim FLI Reference mti GetCurrentRegion FLI 249 static void checkEnv void char region_name mtiRegionIdT regid regid mti GetCurrentRegion region name mti GetRegionFullName regid mti PrintFormatted Time d d checkEnv Function Current region is s n mti NowUpper mti Now region name mti VsimFree region name static void checkRegion void char region_name mtiRegionIdT regid regid mti GetCurrentRegion region name mti GetRegionFullName regid mti PrintFormatted Time d d checkRegion Function Current region is s n mti NowUpper mti Now region name mti VsimFree region name static void initInstance void param Ghar region_name mtiProcessIdT procid mtiRegionIdT regid regid mti GetCurrentRegion region name mti GetRegionFullName regid mti PrintFormatted Load Done Callback Function Current region is s n region name mti VsimFree region name procid mti CreateProcess Test Process checkRegion 0 mti ScheduleWakeup procid 10 void initForeign mtiRegionIdT region The ID of the region in which this QUA foreign architecture is instantiated
42. signal bitsig EBIT 1 signal intsig integer 42 signal physsig bigtime 3 hour signal realsig real 10 2 signal timesig time 3 ns signal stdlogicsig std logic H signal rangesig intrange 128 signal bitarr bitarray 1100 signal stdlogicarr std logic vector 3 downto 2 01 signal uparray bit vector 1 to 5 01010 signal rec rectype seco Sb 7058 POOLS ys component for model end component for all for model use entity work for model a begin instl for model end a Simulation output 9 vsim c top Reading modeltech 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 mti TickLength FLI 659 ModelSim FLI Reference FLI 660 FLI function definitions ModelSim FLI Reference VSIM 1 quit Design Signals bitsig intsig physsig realsig timesig stdlogicsig rangesig bitarr stdlogicarr uparray rec type type type type type type type type type type type Enumeration Scalar Physical Real Time Enumeration Scalar Array Array Array Record lengt lengt lengt lengt lengt lengt lengt lengt lengt lengt lengt JJ em ED DDD MD Won BN WO OOCAON mti TickLow Gets the low value of a ranged ty
43. variable bitarr bitarray 0110 ModelSim FLI Reference FLI 424 FLI function definitions variable stdlogicarr std logic vector 1 to 4 O1LH variable intarr intarray 10 11 12 variable realarr realarray 11 6 101 22 variable timearr timearray 15 ns 6 ns variable rec rectype Imo beer VOS DOO LH Jy begin bitsig not bitsig intsig intsig 1 realsig 7 realsig 1 1 timesig timesig 1 ns stdlogicsig bitarr stdlogicarr intarr 1 intarr 2 intarr 3 Uc realarr 1 realarr 2 timearr 1 timearr 0 rec a rec b rec c not stdlogicsig not bitarr not stdlogicarr intarr 1 intarr 2 intarr 3 TS e E te elie realarr 1 realarr 2 dob p die te ie timearr 1 timearr 0 t1ns t1ns rec a 1 1 not rec b not rec c ModelSim FLI Reference wait for 5 ns end process end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl Dl vsim c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std log 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 1 745000e 01 Variable timesig 6 ns Variable stdlogicsig 0 Variable bitarr 1001 Variable stdlogicarr 1010 Variable intarr 11 12 13
44. 2 regid regid for regid printHierarchy regid mti VsimFree region name void loadDoneCB void param mti PrintMessage printHierarchy mti GetTopRegion void initForeign mtiRegionIdT region Pd char param PR mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB loadDoneCB mti PrintMessage printHierarchy mti GetTopRegion HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is nLoad Done phase Vn architecture is mti FirstLowerRegion region mti NextRegion regid indent 1 The ID of the region in which this EJ foreign architecture is instantiated The last part of the string in the XJ foreign attribute x A list of generics for the foreign model A list of ports for the foreign model v 0 nElaboration phase Mn Log initForeign for model sl generic delay time 5 ns port a in bit bt out bit i end inv architecture b of inv is begin b lt a after delay end b entity mid is end mid architecture a of mid is signal sl pit c OS signal s2 bit ge 70 s signal s3 bit 0 signal s4 bit KOs component for_model is ModelSim FLI Reference end component for all component inv is generic delay time 5 ns port a in bit bor out bit i end component beg
45. FLI 392 Example FLI code include mti h typedef struct signalInfoT tag struct signalInfoT tag next char name mtiSignalIdT sigid mtiTypeIdT typeid signalInfoT typedef struct signallInfoT sig info List of signals mtiProcessIdT proc Test process id instanceInfoT static void printValue mtiSignalIdT sigid mtiTypeIdT sigtype int indent ModelSim FLI Reference mti GetSignalValue FLI 387 switch mti GetTypeKind sigtype case MTI TYPE ENUM char enum_values mtilnt32T scalar val Scalar val mti GetSignalValue sigid enum values mti GetEnumValues sigtype mti PrintFormatted s n enum values scalar val break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val Scalar val mti GetSignalValue sigid mti PrintFormatted d n scalar val break case MTI_TYPE_ARRAY int 1 mtiInt32T num elems mtiTypeldT elem type mtiTypeKindT elem typekind void array val array val mti GetArraySignalValue sigid 0 num elems mti TickLength sigtype elem type mti GetArrayElementType sigtype elem typekind mti GetTypeKind elem type switch elem typekind case MTI TYPE ENUM char enum_values enum values mti GetEnumValues elem type if mti TickLength elem type 256 mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted s en
46. Loading work for model a Loading for model sl The parent of top ml il a is top s1 3 whose parent is NULL The parent of top ml il b is top s2 2 whose parent is lt NULL gt The parent of top ml il c is top ml midslv 7 whose parent is lt NULL gt VSIM 1 quit The second example uses the nocollapse argument to vsim to cause all ports to be retained so that multiple levels of signal connection are shown The parent signal to top mI midslw 7 cannot be found because of the type conversion in the top level port map vsim c nocollapse top Reading modeltech tcl vsim pref tcl vsim c nocollapse top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for model sl The parent of top ml il a is top ml midin whose parent is top s1 3 The parent of top ml il b is top ml midout 2 whose parent is top s2 2 The parent of top ml il c is top ml midslv 7 whose parent is lt NULL gt VSIM 1 quit ModelSim FLI Reference FLI 306 FLI function definitions mti GetPhysicalData Gets the unit information of a physical type Syntax phys data mti GetPhysicalData type id Returns Name Type Description phys data mtiPhysicalDataT A pointer to a linked list of structures each describing the name and position o
47. STD LOGIC 0 STD LOGIC 1 STD LOGIC 4 STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType typedef struct mtiSignalIdT sigid mtiDriverIdT drvid mtiTypeIdT time type instanceInfoT void driveScalarSignal void param char curr time str char region name instanceInfoT inst instanceInfoT param mtilnt32T sigval mtiTime64T curr time region name mti GetRegionFullName mti GetSignalRegion inst sigid sigval mti GetSignalValue inst gt sigid curr time str mti Image mti NowIndirect amp curr time inst time type mti PrintFormatted Time s delta d Signal s s is s n curr time str region name mti Delta mti GetSignalName inst sigid mti Signallmage inst sigid switch sigval case STD LOGIC U sigval case STD LOGIC X sigval case STD LOGIC 0 sigval case STD LOGIC 1 sigval case STD LOGIC 2 sigval case STD LOGIC W sigval case STD LOGIC L sigval STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC 2 STD LOGIC W STD LOGIC L STD LOGIC H break break break break break break break mti CreateDriver FLI 115 case STD LOGIC H sigval STD LOGIC D break case STD LOGIC D sigval STD LOGIC U break default sigval STD LOGIC U break mti ScheduleDriver inst gt drvid sigval 5 MTI_INERTIAL mti VsimFree region name void driveArraySignal void param char
48. The name of a package signal must include the name of the package During elaboration signals in design units that have not yet been instantiated will not be found by mti FindSignal If the specified name is for a subelement of an input port that has been collapsed due to optimizations the handle that is returned is a handle to the subelement of the actual signal connected to that port mti_FindSignal cannot be used to find slices of arrays Related functions ModelSim FLI Reference mti FindPort FLI 170 mti FirstSignal FLI 199 mti NextSignal FLI 493 Example mti FindSignal FLI 183 FLI code include mti h void loadDoneCB void param char region_name mtiSignalIdT sigid mti PrintMessage nLoad Done phase n sigid mti FindSignal s1 if sigid 1 region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Found signal s s n region name mti GetSignalName sigid mti VsimFree region name Signal pl is not found here because the current context when elaboration is complete is the top level design unit and pl exists in the context top il ay sigid mti_FindSignal pl if sigid region_name mti_GetRegionFullName mti_GetSignalRegion sigid mti_PrintFormatted Found signal s s n region_name mti_GetSignalName sigid mti VsimFree region name sigid mti FindSignal mypkg packsig jt
49. copies the value into the time buf parameter and also returns the time buf parameter Related functions mti Delta FLI 157 mti GetResolutionLimit mti Now FLI 501 mti NowUpper FLI 510 FLI 348 ModelSim FLI Reference FLI 506 FLI function definitions Example FLI code include mti h typedef struct signalInfoT tag struct signalInfoT tag next char name mtiSignalldT sigid mtiTypeIdT typeid signalInfoT typedef struct signalInfoT sig_info List of signals mtiProcessIdT proc Test process id instanceInfoT static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info mtiTime64T curr time signallInfoT siginfo void mti NowIndirect amp curr time mti PrintFormatted Time d d n MTI TIME64 HI32 curr time MTI TIME64 LO32 curr time for siginfo inst data sig info siginfo siginfo siginfo gt next mti PrintFormatted Signal s s n siginfo name mti Signallmage siginfo gt sigid mti ScheduleWakeup inst data proc 5 static signalInfoT setupSignal mtiSignalIdT sigid signalInfoT siginfo siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo next SEE return siginfo static void initInstance void para
50. curr time str char region name char sigval instanceInfoT inst instanceInfoT param int Z5 mtiTime64T curr time region name mti GetRegionFullName mti GetSignalRegion inst sigid sigval char mti GetArraySignalValue inst gt sigid 0 curr time str mti Image mti NowIndirect amp curr time inst time type mti PrintFormatted Time s delta d Signal s s is s n curr time str mti Delta region name mti GetSignalName inst gt sigid mti Signallmage inst sigid for i 0 i lt mti TickLength mti GetSignalType inst sigid i switch sigval i case STD LOGIC U sigval i STD LOGIC X break case STD LOGIC X sigval i STD LOGIC 0 break case STD LOGIC 0 sigval i STD LOGIC 1 break case STD LOGIC 1 sigval i STD LOGIC Z2 break case STD LOGIC 2 sigval i STD LOGIC W break case STD LOGIC W sigval i STD LOGIC L break case STD LOGIC L sigval i STD LOGIC H break case STD LOGIC H sigval i STD LOGIC D break case STD LOGIC D sigval i STD LOGIC U break default sigval i STD LOGIC U break mti ScheduleDriver inst gt drvid long sigval 5 MTI INERTIAL mti VsimFree sigval mti VsimFree region name 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 EY foreign attribute
51. inst instanceInfoT malloc sizeof instanceInfoT inst sigid mti FindSignal top s1 inst signame mti GetSignalName inst gt sigid inst procid mti CreateProcess checkSignal checkSignal inst mti ScheduleWakeup inst procid 1 mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst HDL code library ieee use ieee std logic 1164 a11 entity lower is port pt INOUT std logic 0 end lower architecture a of lower is begin pO process begin ptem Mg wait for 5 ns pt lt L wait for 5 ns pt W wait for 5 ns end process end a library ieee use ieee std logic 1164 a11 ModelSim FLI Reference mti GetDriverValues FLI 265 entity top is end top architecture a of top is signal sl std logic 0 component lower port pt INOUT std logic end component begin pl process begin sl lt H wait for 5 ns sl lt L wait for 5 ns sl lt X wait for 5 ns end process p2 process begin sl lt 1 wait for 5 ns sl lt 0 wait for 5 ns sl lt W wait for 5 ns end process instl lower port map sl end a Simulation output vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee st
52. mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetSignalValueIndirect sigid amp real val mti PrintFormatted gYn real val break case MTI_TYPE_TIME mtiTime64T time_val ModelSim FLI Reference FLI 274 FLI function definitions mti GetSignalValueIndirect sigid amp time val mti PrintFormatted d d Wn MTI TIME64 HI132 time val MTI TIME64 LO32 time val break default mti PrintMessage An break static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info signallInfoT siginfo mti PrintFormatted Time d d n mti NowUpper mti Now for siginfo inst data sig info siginfo siginfo siginfo gt next mti PrintFormatted Signal s siginfo gt name printValue siginfo gt sigid siginfo gt typeid 4 mti ScheduleWakeup inst data proc 5 static signallnfoT setupSignal mtiSignalIdT sigid signalInfoT siginfo siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo next 0 return siginfo static void initInstance void param instanceInfoT inst data mtiSignalldT sigid signallnfoT curr info signallInfoT signo inst data mti Malloc sizeof instanceInfoT inst data
53. mti_VsimFree elem_list break default break ModelSim FLI Reference mti ReleaseSignal FLI 531 static void testForce void inst info instanceInfoT inst data instanceInfoT inst info signallInfoT siginfo switch inst data state case 0 case 2 case 4 for siginfo inst data sig info siginfo siginfo siginfo next forceSignal siginfo gt sigid siginfo gt typeid siginfo gt typekind inst_data gt state break case 1 case 3 case 5 for siginfo inst data sig info siginfo siginfo siginfo gt next releaseSignal siginfo gt sigid siginfo gt typeid siginfo gt typekind break default break inst_data gt statett mti_ScheduleWakeup inst_data gt proc 10 static signalInfoT setupSignal mtiSignalIdT sigid signallInfoT siginfo siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti_GetSignalType sigid siginfo gt typekind mti_GetTypeKind siginfo gt typeid siginfo gt direction mti_GetSignalMode sigid siginfo gt last_value mti GetSignalValueIndirect sigid 0 siginfo child 0 siginfo gt next 0 X For records and arrays of composites we want to set drive values at the subelement level For scalars and arrays of scalars we want to set drive values at the top level sy switch si
54. myconfig g myentry tia brary mti_PrintFormatted Library mti VsimFree entry entry mti FindProjectEntry VSIM std s n mti_PrintFormatted vsim Resolution mti VsimFree entry HDL code entity for model is end for model architecture a of for model is attribute foreign of a architecture is begin end a entity top is end top architecture a of top is signal sl i bit re 0 component for model is end component myentry 0 sWMn entry myentry 1 sWMn entry scam 0 entry resolution 1 Ss n entry initForeign for model sl for all for model use entity work for model a begin il for model S lt not sl after 5 ns ay EJ KY mti FindProjectEntry FLI 175 end a Project file Library std MODEL TECH std ieee MODEL TECH ieee verilog MODEL TECH verilog Std developerskit MODEL TECH std developerskit synopsys MODEL TECH synopsys work work myconfig myentry MODEL TECH xyz vcom Turn on VHDL 1993 as the default Normally is off VHDL 1987 VHDL93 1 Turn on resolving of ambiguous function overloading in favor of the explicit function declaration not the one automatically created by the compiler for each type declaration Default is off ini file has Explict enable so that std logic signed unsigned will mat
55. not rec d after 5 ns rec e not rec e after 5 ns end a ModelSim FLI Reference FLI 300 FLI function definitions ModelSim FLI Reference Simulation output 9 vsim c top Reading modeltech 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 15 Time 0 6 Signal rec Field 41 1 Field 42 2 Field 43 6 2 Field 44 uo NS UE rg S MI HO 19 Field 45 SO es UL 02 Time 0 11 Signal rec Field 1 0 Field 2 3 Field 3 8 7 Field 4 tent QO Loy Ll QF QO qs ts Field 45 nq tos 94 nb VSIM 2 quit mti GetParentSignal FLI 301 mti GetParentSignal Syntax Returns Arguments Description Gets the higher up VHDL or SystemC signal to which a VHDL or SystemC signal is connected parent mti GetParentSignal signal Type Description mtiSignalldT A handle to the VHDL or SystemC signal higher up in the hierarchy to which the specified signal is connected or NULL if no VHDL or SystemC signal is found Type Description mtiSignalldT A handle to a VHDL or SystemC signal mti GetParentSignal returns a handle to the VHDL or SystemC signal higher up in the hierarchy to which the specified IN OUT or INOUT signal is connected A NULL is returned if no higher up VHDL or SystemC
56. printHierarchy mti GetTopRegion 1 ModelSim FLI Reference HDL code entity for model is end for model architecture a of for model is mti FirstVar FLI 205 attribute foreign of a architecture is initForeign for model sl begin end a entity inv is generic delay time 5 ns port a in bit b out bit end inv architecture b of inv is begin b lt a after delay pl process constant increment integer 1 variable count integer 0 begin count count increment wait on a end process end b entity mid is generic genl string Mid end mid architecture a of mid is signal sl r bit re 0 signal s2 bit 0 signal s3 bit 0 signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit BES OUT bit i end component begin testproc process constant cl string mystring variable vl bit 0 variable v2 integer 42 variable v3 real 7 82 begin ModelSim FLI Reference FLI 206 FLI function definitions ModelSim FLI Reference vl not vl v2 v2 2 v3 v3 1 5 wait for 5 ns end process s4 flip inv port map s3 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top
57. signallInfoT mtiProcessIdT int instanceInfoT sig info direction granulate proc state static void forceSignal mtiSignalIdT sigid mtiTypeIdT mtiTypeKindT int int i int mtiSignalldT mtiSignalldT mtiTypeIdT switch sigtypeid sigtypekind state result 1 elem list elem sigid elem typeid sigtypekind case MTI TYPE SCALAR switch case 0 result break case 2 result break case 4 result break break mti ForceSignal sigid mti ForceSignal sigid mti ForceSignal sigid state 42 zl 120 1 777 1 case MTI_TYPE_ARRAY mti_GetArrayElementType sigtypeid elem_typeid List of signals Test process id Current state of test Al 2 if mti GetTypeKind elem typeid MTI TYPE ENUM NOTE ASSUMING ARRAY OF LENGTH 4 if mti TickLength elem typeid 9 switch state case 0 result mti ForceSignal sigid ZW1H 1 MTI FORCE FREEZE 1 break case 2 result mti ForceSignal sigid LLLL 1 MTI FORCE FREEZE 7 break case 4 result mti ForceSignal sigid 1 1 1 MTI FORCE DEPOSIT 1 break else ASSUME bit switch state case 0 result mti ForceSignal sigid 0011 1 ModelSim FLI Reference MTI FORCE FREEZE EM L MTI_FORCE_FREEZE MTI_FORCE_FREEZE ez xL MTI FORCE DEPOSIT E Kit
58. state case 0 result mti ForceSignal sigid 0011 1 ModelSim FLI Reference mti ForceSignal FLI 211 MTI FORCE FREEZE 1 1 break case 2 result mti ForceSignal sigid 1000 1 MTI FORCE FREEZE 7 1 break case 4 result mti ForceSignal sigid 0010 1 MTI FORCE DEPOSIT 1 2 break else elem_list mti_GetSignalSubelements sigid 0 for i 0 i lt mti TickLength sigtypeid i elem sigid elem_list i elem_typeid mti_GetSignalType elem_sigid forceSignal elem_sigid elem_typeid mti_GetTypeKind elem_typeid state mti_VsimFree elem_list break case MTI_TYPE_RECORD elem_list mti_GetSignalSubelements sigid 0 for i 0 i lt mti GetNumRecordElements sigtypeid i elem sigid elem list i elem typeid mti GetSignalType elem sigid forceSignal elem sigid elem typeid mti GetTypeKind elem typeid state mti_VsimFree elem_list break case MTI_TYPE_ENUM if mti_TickLength sigtypeid 9 ASSUME std_logic switch state case 0 result mti ForceSignal sigid W 1 MTI FORCE FREEZE 1 1 break case 2 result mti ForceSignal sigid O 1 MTI FORCE FREEZE 7 1 break case 4 result mti ForceSignal sigid H 1 MTI FORCE DEPOSIT 1 2 break else switch state ASSUME bit case 0 result mti ForceSignal sigid 0 1 T
59. testForce void inst data j mti ScheduleWakeup inst data proc 11 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 wy mtilnterfaceListT generics A list of generics for the foreign model ModelSim FLI Reference mti ReleaseSignal FLI 533 mtilInterfaceListT ports A list of ports for the foreign model mti_AddLoadDoneCB initInstance 0 HDL code library ieee use ieee std_logic_1164 all package typepkg is type bitarray is array 3 downto 0 of bit type intarray is array 1 to 3 of integer type rectype is record a bit b integer e std logic end record end package typepkg entity for model is end for model architecture a of for model is attribute foreign of a architecture is begin end a library ieee use ieee std logic 1164 a11 use work typepkg all entity top is end top architecture a of top is initForeign for model sl signal bitsigl bit 1 signal intsigl integer 21 signal stdlogicsigl std logic H signal bitarrl bitarray 0110 signal stdlogicarrl std logic vector 1 to 4 X0U signal intarrl intarray 0G 0 ll 12 2 signal recl rectype SC PQ i Xt yg component for model end component for all for model use entity work for model a begin insti for
60. type rectype is record a t bit b integer c bitarray end record type bigtime is range 0 to integer high units hour day 24 hour ModelSim FLI Reference FLI 656 FLI function definitions wee mon yea end u end top architect signal signal signal signal signal signal signal signal signal signal compone end com for all begin instl end a k 7 day th 4 week r 12 month nits ure a of top is bitsig bit 1 intsig integer 42 physsig bigtime 3 hour realsig real 10 2 timesig time 3 ns stdlogicsig std logic H bitarr bitarray 1100 stdlogicarr std logic vector 3 downto 0 OILH uparray bit vector 1to 4 0101 rec rectype Lm FOT 0 ST DTE pa nt for model ponent for model use entity work for model a for model Simulation output 9 vsim c Reading 5 4b vsim c Loading Loading Loading Loading Loading Design stdl stdl VSIM 1 gt q ModelSim FLI Reference top modeltech tcl vsim pref tcl top modeltech sunos5 std standard modeltech sunos5 ieee std logic 1164 body work top a work for model a for model sl Signals bitsig type Enumeration left 0 right 1 intsig type Scalar left 2147483648 right physsig type Physical left 0 right 2147483647 realsig type Real left 0 right 0 timesig type Time left 0 rig
61. vhdl enum IN severity level vhdl real IN real vhdl array t IN string as begin report ERROR foreign subprogram in params not called end procedure out params vhdl integer OUT integer vhdl enum OUT severity level vhdl real OUT real vhdl array OUT string is begin report ERROR foreign subprogram out params not called end end Entity test example The VHDL model test contains calls to procedures in params and out params that are declared in pkg and linked to functions in the C code entity test is end test use work pkg all architecture only of test is begin process variable int integer 0 variable enum severity level note variable r real 0 0 variable s string 1 to 5 abcde begin for i in 1 to 10 loop in params int enum r s out params int enum r s end loop wait end process end ModelSim FLI Reference FLI 18 Introduction Mapping to VHDL data types ModelSim FLI Reference 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 CreateTimeType mti Cr
62. 0 0 delta 1 Signal top sl is 1 Time 0 5 delta 1 Signal top sl is O Time 0 5 delta 2 Signal top sl is 1 Time 0 5 delta 3 Signal top sl is 0 Time 0 10 delta 1 Signal top s1 is 1 Time 0 15 delta 1 Signal top s1 is 0 Time 0 15 delta 2 Signal top s1 is 1 Time 0 15 delta 3 Signal top s1 is 0 Time 0 20 delta 1 Signal top s1 is 1 VSIM 2 quit T mti Delta FLI 159 ModelSim FLI Reference FLI 160 FLI function definitions mti Desensitize Desensitizes a VHDL process to the VHDL signals to which it is sensitive Syntax mti Desensitize proc Returns Nothing Arguments Type Description mtiProcessIdT A handle to a VHDL process Description mti Desensitize disconnects a process from the signals to which it is sensitive The process can then be re sensitized mti Sensitize or scheduled mti ScheduleWakeup Related functions mti ScheduleWakeup FLI 606 mti ScheduleWakeup64 FLI 610 mti Sensitize FLI 614 Example FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC Z STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType typedef struct mtiSignalIdT sigid mtiProcessIdT procid instanceInfoT ModelSim FLI Reference mti Desensitize FLI 161 char convertStdLogicValue mtiInt32T sigval ch
63. 0 45 0 50 0 55 VSIM 6 quit delta delta delta delta delta delta delta delta delta 0 0 0 0 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 3 49 X CX CX Signal Signal Signal Signal Signal Signal Signal Signal Signal top s1 top s1 top s1 top s1 7 16 48 29 2000 Restoring state at time 30 ns VSIM 5 run 25 top s1 top s1 top s1 top s1 top s1 is is is is is is qus is is ty X ro 11 iteration 1 U X 10 EY wg mti_RestoreProcess FLI 573 ModelSim FLI Reference FLI 574 FLI function definitions mti RestoreShort Syntax Returns Arguments Description Gets sizeof short bytes of data from the checkpoint file value mti RestoreShort Description Sizeof short bytes of data None mti RestoreShort returns sizeof short bytes of data from the checkpoint file This function should be called only from a restore callback function It should not be called from an initialization procedure Related functions Example ModelSim FLI Reference mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveShort FLI 589 mti SaveString FLI 592 FLI code incl
64. 100 inst sigid mti CreateSignal mySig region scalar type inst drvid mti CreateDriver inst sigid procid mti CreateProcess mySigDriver driveSignal inst mti Sensitize procid inst gt sigid MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvid procid mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst ModelSim FLI Reference FLI 148 FLI function definitions ModelSim FLI Reference HDL code entity top is end top architecture a of top is signal sl bit 0 begin sl lt not sl after 5 ns end a Simulation output 9 vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading work top a Loading for model sl VSIM 1 run 50 Time 0 0 delta 1 Signal top mysig is 0 Time 0 5 delta 0 Signal top mysig is 2 Time 0 10 delta Signal top mysig is 4 Time 0 15 delta Signal top mysig is 6 Time 0 20 delta Signal top mysig is 8 Time 0 25 delta Signal top mysig is 10 Time 0 30 delta Signal top mysig is 12 Time 0 35 delta Signal top mysig is 14 Time 0 40 delta Signal top mysig is 16 Time 0 45 delta Signal top mysig is 18 Time 0 50 delta Signal top mysig is 20 VSIM 2 quit Cleaning up Oh 00 0D OX ap SES sp SE as 009 mti Create
65. 23 realsig 1 855000e 01 timesig 7 ns stdlogicsig U bitarr 0110 stdlogicarr ZW U intarr 12 13 14 realarr 1 380000e 01 1 034200e 02 timearr 17 ns 8 ns rec 0 3 5 900000e 00 U 1001 mti Signallmager Gets the string image of a VHDL signal s value value mti Signallmage signal id mti Signallmage FLI 635 Description A string image of the specified signal s value Type Description Syntax Returns Arguments Name signal id Description mtiSignalldT A handle to a VHDL signal mti_Signallmage returns a pointer to a static buffer containing the string image of the value of the specified signal 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 This pointer must not be freed Related functions mti GetArraySignalValue FLI 226 mti GetSignalValue FLI 386 mti GetSignalValueIndirect FLI 392 Example FLI code include mti h typedef struct signalInfoT tag struct signalInfoT tag next char mtiSignalldT mtiTypeIdT signalInfoT pon typedef struct signallnfoT sig info name sigid typeid List of signals ModelSim FLI Reference FLI 636 mtiProcessIdT proc Test process id instanceInfoT Static void checkValues void inst info inst
66. 5sig info 0 for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo ModelSim FLI Reference inst data proc mti CreateProcess mti ScheduleWakeup inst data proc 6 void initForeign mtiRegionIdT region LX char param JE mtilnterfaceListT generics mtilnterfaceListT ports p mti AddLoadDoneCB initInstance HDL code entity fo end for m r model is odel architecture a of for model is attribute foreign of a begin end a library i eee use ieee std logic 1164 a11 entity to type bitarray is array 3 downto 0 p is type rectype is record a b b c8 e rb end rec end top it td logic itarray ord architecture a of top is signal signal signal signal signal compone bitsig stdlogicsig bitarr stdlogicarr rec nt for model end component for all begin instl bitsig of bit bit tli std_logic H bitarray 0110 std logic vector 1 to 4 O1LH rectype 0 THT 1001 Test Process void inst_data The ID of the region foreign architecture The last part of the foreign attribute A list of generics for the foreign model A list of ports for the foreign model x 0 architect
67. EY mtiInterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model 2 instanceInfoT inst mtiProcessIdT procid inst instanceInfoT mti Malloc sizeof instanceInfoT inst gt sigid mti FindSignal top sl inst drvid mti CreateDriver inst sigid ModelSim FLI Reference FLI 116 FLI function definitions procid mti CreateProcess sigDriverl driveScalarSignal inst mti Sensitize procid inst gt sigid MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvid procid inst time type mti CreateTimeType inst instanceInfoT mti Malloc sizeof instanceInfoT inst gt sigid mti FindSignal top s2 inst drvid mti CreateDriver inst gt sigid procid mti CreateProcess sigDriver2 driveArraySignal inst mti Sensitize procid inst gt sigid MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvid procid inst time type mti CreateTimeType HDL code library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal sl std logic Q signal s2 std logic vector 3 downto 0 UXOI1 begin end a Simulation output vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl Sue vsim foreign initForeign for model sl c top Loading mo
68. Gets the type of an array type s subelements Syntax elem type mti GetArrayElementType array type Returns Name Type Description elem type mtiTypeldT The type ID for the subelements of the array Arguments Name Type Description array type mtiTypeldT A type ID for a VHDL array type Description mti GetArrayElementType returns a handle to the type ID for the subelements of the specified array type If the array type parameter is not a handle to an array type then NULL is returned Related functions mti GetTypeKind FLI 404 Example FLI code include lt mti h gt static char getTypeStr mtiTypeIdT typeid char typestr switch mti_GetTypeKind typeid case MTI_TYPE_SCALAR typestr Scalar break case MTI TYPE ARRAY typestr Array break case MTI_TYPE_RECORD typestr Record break case MTI_TYPE_ENUM typestr Enum break case MTI_TYPE_PHYSICAL typestr Physical break case MTI_TYPE_REAL typestr Real break case MTI_TYPE_ACCESS typestr Access break case MTI_TYPE_FILE typestr File break case MTI_TYPE_TIME typestr Time break ModelSim FLI Reference mti GetArrayElementType FLI 223 default typestr UNKNOWN break return typestr static void printSignalInfo mtiSignalIdT sigid int indent char fullname int i mtilnt32T num elems mtiSignalIdT elem list mtiTypeIdT sig type mtiTypeId
69. In order to get the value of a record signal use mti GetSignalSubelements to get handles to the signal subelements and then use mti GetSignalValue mti GetSignalValueIndirect or mti GetArraySignalValue on each of the subelements Related functions mti GetArraySignalValue FLI 226 mti GetSignalValue FLI 386 Example FLI code include lt mti h gt typedef struct signalInfoT tag struct signalInfoT tag next char name mtiSignalldT sigid mtiTypeIdT typeid signalInfoT typedef struct signallInfoT sig info List of signals mtiProcessIdT proc Test process id instanceInfoT static void printValue mtiSignalIdT sigid mtiTypeIdT sigtype int indent switch mti_GetTypeKind sigtype case MTI_TYPE_ENUM char enum_values mtilnt32T scalar val Scalar val mti GetSignalValue sigid enum values mti GetEnumValues sigtype mti PrintFormatted s n enum values scalar val break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val Scalar val mti GetSignalValue sigid mti PrintFormatted d n scalar val break case MTI_TYPE_ARRAY int i mtilnt32T num elems ModelSim FLI Reference FLI 394 FLI function definitions mtiTypeldT mtiTypeKindT void array val num elems elem type elem typekind switch elem type elem typekind array val mti GetSignalValueIndirect sigid 0 mti TickLeng
70. Loading work for model a Loading for_model sl Hierarchy Region top Region top instl Process line 58 Process line 57 Region top instl flip mti NextProcess FLI 487 ModelSim FLI Reference FLI 488 FLI function definitions ModelSim FLI Reference Process pl Process line 19 Region top instl il Region top inst1 toggle Process pl Process line 19 VSIM 1 quit dE db db dE db db mti NextRegion FLI 489 mti NextRegion Gets the next region at the same level as a region Syntax next reg id mti NextRegion region id Returns Name Type Description next reg id mtiRegionIdT A handle to the next VHDL Verilog or SystemC region at the same level of hierarchy as the specified region Arguments Name Type Description region id mtiRegionIdT A handle to a VHDL Verilog or SystemC region Description mti NextRegion returns a handle to the next VHDL Verilog or SystemC region at the same level of hierarchy as the specified VHDL Verilog or SystemC region mti NextRegion returns NULL if there are no more regions at this level If the next reg idis a handle to a Verilog region then it can be used with PLI functions to obtain information about or access objects in the Verilog region Related functions mti FindRegion FLI 177 mti FirstLowerRegion FLI 191 mti GetRegionKind FLI 328 mti GetTopRegion FLI 399 mti HigherRegion FLI 459 Example FLI co
71. Process pl Process line 19 Load Done phase Region top Region top instl Process line 58 Process line 57 Region top instl flip Process pl Process line 19 Region top instl il Region top instl toggle Process pl Process line 19 VSIM 1 run 20 VSIM 2 quit ModelSim FLI Reference mti FirstSignal FLI 199 mti FirstSignal Syntax Returns Arguments Description Gets the first VHDL or SystemC signal in a region signal id mti FirstSignal region id Name Type Description signal id mtiSignalldT A handle to the first VHDL or SystemC signal in a region or NULL if there are no signals in the region Name Type Description region id mtiRegionIdT A handle to a VHDL or SystemC region mti_FirstSignal returns a handle to the first VHDL or SystemC signal in the specified region mti_NextSignal can be used to get the subsequent VHDL or SystemC signals in the specified region mti_FirstSignal resets the region used by previous calls to mti_FirstSignal and mti_NextSignal therefore mti_NextSignal always uses the region set by the latest call to mti_FirstSignal Related functions Example mti_FindPort FLI 170 mti_FindSignal FLI 182 mti_NextSignal FLI 493 FLI code include lt mti h gt void printSignals mtiRegionIdT region int indent mtiSignalIdT sigid for sigid mti FirstSignal region sigid ModelSim FLI Reference
72. Saving char c n lon sho str mti RestoreLong FLI 567 instance info i sizeof instance_info tmp char g 1dWMn tmp long rt d n tmp short ing s n tmp str void restoreCallback void param mti_RestoreBlock mti_PrintFormatted nRestoring instance info s n mti_PrintFormatted Restoring mti_PrintFormatted Restoring mti_PrintFormatted Restoring mti_PrintFormatted Restoring mti_PrintFormatted n void initForeign mtiRegionIdT region JE char param KR fs mtiInterfaceListT generics mtilnterfaceListT ports 73 instance_info strcpy instance info mti_AddSaveCB saveCallback mti_AddRestoreCB restoreCallback HDL code entity for_model is end for_model architecture a of for_model is attribute foreign of a initForeign for_model sl begin end a entity top is end top architecture a of top is mti Malloc strlen param param in char amp instance info instance info i mti_RestoreChar mti_RestoreLong mti RestoreShort mti RestoreString char Sc n long ld n short d n string s n The ID of the region in which this xy foreign architecture is instantiated The last part of the string in the f foreign attribute ER A list of generics for the foreign model A list of ports for the foreign model xy Roy stance info instance info architecture i
73. architecture a of top is signal sl bit 0 begin sl lt not sl after 5 ns end a ModelSim FLI Reference FLI 156 FLI function definitions ModelSim FLI Reference Simulation output 9 vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl vsim foreign initForeign for_model sl c top Loading modeltech sunos5 std standard Loading work top a Loading for model sl VSIM 1 run 50 Time 0 ns delta 1 Signal top mysig is 0 ns Time 5 ns delta 0 Signal top mysig is 1 ns Time 10 ns delta Signal top mysig is 2 ns Time 15 ns delta Signal top mysig is 3 ns Time 20 ns delta Signal top mysig is 4 ns Time 25 ns delta Signal top mysig is 5 ns Time 30 ns delta Signal top mysig is 6 ns Time 35 ns delta Signal top mysig is 7 ns Time 40 ns delta Signal top mysig is 8 ns Time 45 ns delta Signal top mysig is 9 ns Time 50 ns delta Signal top mysig is 10 ns VSIM 2 quit Cx XX X Ou x xc O0 mti Delta mti Delta FLI 157 Gets the simulator iteration count for the current time step Syntax delta mti Delta Returns Type Description mtiUInt32T The simulator iteration count for the current time step Arguments None Description mti Delta returns the simulator iteration count for the current time step Related functions mti Now FLI 501 mti NowlIndirect FLI 505 mti NowUp
74. array_val for i 0 i lt num elems i mti PrintFormatted d val i break case MTI_TYPE_ARRAY mti_PrintMessage ARRAY break case MTI_TYPE_RECORD mti PrintMessage RECORD break case MTI TYPE REAL double val array_val for i 0 i lt num elems i mti PrintFormatted g val i break case MTI_TYPE_TIME mtiTime64T val array_val for i 0 i lt num elems i mti_PrintFormatted d d MTI TIME64 HI32 val il MTI TIME64 LO32 val il ModelSim FLI Reference FLI 452 FLI function definitions break default break mti_PrintFormatted n break case MTI_TYPE_RECORD int i mtiVariableIdT elem list mtilnt32T num elems elem list mti GetVarSubelements varid 0 num elems mti GetNumRecordElements vartype mti PrintFormatted An for i 0 i lt num elems i mti PrintFormatted c indent printValue elem list i mti GetVarType elem list il indent 2 mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetVarValueIndirect varid amp real val mti PrintFormatted g n real val break case MTI_TYPE_TIME mtiTime64T time_val mti GetVarValueIndirect varid amp time val mti PrintFormatted d d Wn MTI TIME64 HI132 time val MTI TIME64 LO32 time val break default mti PrintMessage Mn
75. end component ModelSim FLI Reference FLI b50 FLI function definitions ModelSim FLI Reference for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info for model VSIM 3 run 50 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 14 55 48 2000 Restoring state at time 20 ns iteration 1 Restored instance info for model VSIM 5 run 15 VSIM 6 quit Cleaning up mti RemoveRestoreDoneCBY FLI 551 mti RemoveRestoreDoneCBY Removes a simulator restore done callback Syntax mti RemoveRestoreDoneCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function being called at simulator restore done void The parameter that was specified in the call to mti_AddRestoreDoneCB when the callback was created Description mti_RemoveRestoreDoneCB removes the specified function from the simulator restore done callback list The param parameter must be the same parameter that was specified in the call to mti_AddRestoreDoneCB when the callback was created mti_Remo
76. fora for all lower use entity work lower level end for for all for_model use entity work for_model a end for end for end cfg_top Simulation output vsim c cfg top Reading modeltech tcl vsim pref tcl 5 4b vsim c cfg top modeltech sunos5 std standard modeltech sunos5 ieee std logic 1164 body Loading work for pkg body Loading Loading Loading work cfg top Loading work top a Loading work lower level Loading work for model a Loading for_model sl Foreign Init Function ModelSim FLI Reference FLI 314 FLI function definitions Region parameter is top finst Primary name is for model Load Done Callback Function Region top Primary name is top Region top linstl Primary name is lower Region top linst2 Primary name is lower Region top finst Primary name is for model Region for pkg Primary name is for pkg VSIM 1 run 20 Note I m in the test proc Time 0 ns Iteration 0 Instance top linst2 Note I m in the test proc Time 0 ns Iteration 0 Instance top linstl Note I m in the test proc Time 20 ns Iteration 0 Instance top linst2 Note I m in the test proc Time 20 ns Iteration 0 Instance top linstl VSIM 2 quit ModelSim FLI Reference mti GetProcessName FLI 315 mti GetProcessName Syntax Returns Arguments Description Gets the name of a VHDL process proc name mti GetProcessName proc
77. foreign architecture is instantiated char param The last part of the string in the J foreign attribute mtilnterfaceListT 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 a11 entity top is end top architecture a of top is signal bitsig TE s 11 signal intsig integer 42 signal realsig real 10 2 signal timesig time 3 ns signal stdlogicsig std logic H signal stdlogicarr std logic vector 1 to 4 O1LH component for model end component for all for model use entity work for model a ModelSim FLI Reference FLI 504 FLI function definitions begin instl bitsig intsig realsig timesig for_model lt not bitsig after 5 ns lt intsig 1 after 5 ns lt realsig 1 1 after 5 ns lt timesig 2 ns after 5 ns stdlogicsig lt stdlogicarr lt not stdlogicsig after 5 ns not stdlogicarr after 5 ns end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 7 vsim c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading w
78. foreign architecture is instantiated char param The last part of the string in the y foreign attribute mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model FL 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 a11 entity top is type bitarray is array 2 downto 5 of bit type rectype is record a t bit b integer c bitarray end record type bigtime is range 0 to integer high units hour day 24 hour week 7 day month 4 week year 12 month end units end top architecture a of top is signal bitsig bit 1 signal intsig integer 42 signal physsig bigtime 3 hour signal realsig real 10 2 signal timesig time 3 ns signal stdlogicsig std logic H signal bitarr bitarray 1100 signal stdlogicarr std logic vector 3 downto 0 OILH signal uparray bit vector 1to 4 0101 signal rec rectype Se TOT 0 LOO Ja component for model end component for all for model use entity work for model a begin instl for_model end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech su
79. gt name printValue siginfo gt sigid siginfo gt typeid 4 mti ScheduleWakeup inst data proc 5 static signallnfoT setupSignal mtiSignalIdT sigid signalInfoT siginfoj siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo next 0 return siginfo static void initInstance void param instanceInfoT inst data mtiSignalldT sigid signalInfoT curr info signallInfoT siginfo inst data mti Malloc sizeof instanceInfoT inst data 5sig info 0 ModelSim FLI Reference FLI 230 FLI function definitions ModelSim FLI Reference for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 6 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 Kop foreign attribute DA mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT
80. gt next varinfo curr_info varinfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 4 ModelSim FLI Reference mti GetVarlmageByld FLI 423 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 wf foreign attribute X mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT 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 a11 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 Cc 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 instl for model pl process variable bitsig rt 1 variable intsig integer 21 variable realsig real 16 35 variable timesig time 5 ns variable stdlogicsig std logic H
81. library ieee use ieee std logic 1164 a11 entity top is end architecture only of top is component proc port clk in std_logic addr out data inout rw out std_logic strb out std_logic initForeign for model sl std logic vector 7 downto 0 std logic vector 15 downto 0 ModelSim FLI Reference FLI 338 FLI function definitions rdy i end component component cache port elk paddr pdata prw pstrb prdy saddr sdata srw sstrb srdy i end component component memor port clk addr data rw strb rdy i end component component for_m end component signal clk st Processor bu signal prw pst signal paddr signal pdata System bus s signal srw sst signal saddr signal sdata begin clk lt not clk p proc port C cache port m memory port instl for mod end in std logic in std logic in std logic vector 7 downto 0 inout std logic vector 15 downto 0 in std logic in std logic out std logic out std logic vector 7 downto 0 inout std logic vector 15 downto 0 out std logic out std logic in std logic y in std logic in std logic vector 7 downto 0 inout std logic vector 15 downto 0 in std logic in std logic out std logic odel d logic 0 S signals rb prdy std logic std logic vector 7 downto 0 std logic vector 15 downto 0 ignals rb srdy std logic std logic vector 7 downto 0 std logi
82. modeltech tcl vsim pref tcl top modeltech sunos5 std standard work top a work bottom b work for model a for model sl Arch in Region il the top level region is top VSIM 1 run 10 VSIM 2 restart f for model sl VSIM 3 run 10 VSIM 4 quit ModelSim FLI Reference FLI 542 FLI function definitions mti RemoveQuitCB Removes a simulator exit callback Syntax mti RemoveQuitCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function being called at simulator exit void The parameter that was specified in the call to mti_AddQuitCB when the callback was created Description mti_RemoveQuitCB removes the specified function from the simulator exit callback list The param parameter must be the same parameter that was specified in the call to mti_AddQuitCB when the callback was created Related functions mti_AddQuitCB FLI 69 Example FLI code include lt stdlib h gt include lt mti h gt void quitCallback void param if param mti_PrintFormatted Cleaning up s for simulator exit n char param free param else mti_PrintFormatted Exiting simulator n void loadDoneCallback void param ModelSim FLI Reference if int param 1 mti RemoveQuitCB quitCallback 0 void initForeign mti RemoveQuitCB FLI 543 mtiRegionIdT region The ID of the
83. modeltech tcl vsim pref tcl vest 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 gt run 12 Time 0 4 Variable top pl bitsig 0 Variable top pl intsig 22 Variable top pl realsig 1 745000e 01 Variable top pl timesig 6 ns Variable top pl stdlogicsig 0 Variable top pl bitarr 1001 Variable top pl stdlogicarr 1010 Variable top pl intarr 11 12 13 Variable top pl realarr 1 270000e 01 1 023200e 02 Variable top pl timearr 16 ns 7 ns Variable top pl rec 2 300000e 00 1 0110 Time 0 9 Variable top pl bitsig 1 Variable top pl intsig 23 Variable top pl realsig 1 855000e 01 Variable top pl timesig 7 ns Variable top pl stdlogicsig 1 Variable top pl bitarr 0110 Variable top pl stdlogicarr 0101 Variable top pl intarr 12 13 14 Variable top pl realarr 1 380000e 01 1 034200e 02 Variable top pl timearr 17 ns 8 ns Variable top pl rec 3 400000e 00 0 1001 VSIM 2 gt quit ModelSim FLI Reference mti GetVarSubelements FLI 431 mti GetVarSubelements Gets the subelements of a composite VHDL variable Syntax elem list mti GetVarSubelements variable id buffer Returns Name Type Description elem list mtiVariableIdT An array containing the var
84. mti CreateProcessWithPriority synch name synch func inst MTI PROC SYNCH mti CreateProcessWithPriority nba name nba func inst MTI PROC NBA mti CreateProcessWithPriority inst MTI PROC POSTPONED inst inst j3 ModelSim FLI Reference FLI 136 FLI function definitions HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity top is end top architecture a of top is signal sl signal s2 bit bit ror 0 107 0 component for model is end component for all begin for model use entity work S lt not sl after 5 ns il end a for model Simulation output 9 Reading 5 4 vsim c Loading Loading Loading Loading VSIM 1 run Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 Time 0 0 ModelSim FLI Reference vsim c top modeltech tcl vsim pref tcl top modeltech sunos5 std standard 8 delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta work top a work for model a for model sl nbaProcessb5 synchProcessb5 normalProcess5 immedProcess5 nbaProcess4 synchProcess4 normalProcess4 immedProcess4 nbaProcess3 synchProcess3 normal
85. mtiSignalIdT sigidl mtiSignalIdT sigid2 instanceInfoT ModelSim FLI Reference mti Sensitize FLI 615 void monitorSignall void param instanceInfoT inst instanceInfoT param mti PrintFormatted Time d d mti NowUpper mti Now mti PrintFormatted s sWMn mti GetSignalName inst gt sigidl mti Signallmage inst gt sigidl void monitorSignal2 void param instanceInfoT inst instanceInfoT param mti PrintFormatted Time d d mti NowUpper mti Now mti PrintFormatted s sWMn mti GetSignalName inst sigid2 mti Signallmage inst gt sigid2 void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 y foreign attribute wa mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model t7 instanceInfoT inst mtiProcessIdT procid inst instanceInfoT malloc sizeof instanceInfoT inst gt sigidl mti FindSignal top s1 procid mti CreateProcess slMonitor monitorSignall inst mti Sensitize procid inst gt sigidl MTI EVENT inst gt sigid2 mti FindSignal top s2 procid mti CreateProcess s2Moni
86. mti_GetTopRegion FLI 399 mti_NextRegion FLI 489 FLI code include lt mti h gt void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT parent mtiRegionIdT regid ModelSim FLI Reference FLI 460 FLI function definitions region name mti PrintFormatted mti VsimFree region name mti GetRegionFullName region cRegion s indent region name parent mti HigherRegion region if parent mti PrintFormatted Parent region is s n mti GetRegionName parent else mti_PrintFormatted n indent 2 for regid mti_FirstLowerRegion region regid regid mti_NextRegion regid printHierarchy regid indent void loadDoneCB void param mti_PrintMessage printHierarchy mti GetTopRegion void initForeign mtiRegionIdT region char param y mtilnterfaceListT generics mtilnterfaceListT ports mti_AddLoadDoneCB loadDoneCB mti_PrintMessage printHierarchy mti_GetTopRegion HDL code entity for_model is end for_model architecture a of for_model is attribute foreign of a begin end a entity inv is generic delay port a in bit bos Out bit i end inv time architecture b of inv is begin b lt a after delay end b ModelSim FLI Reference architecture is nLoad Done phase n 1 The ID of the region in which this ay
87. mti_GetTypeKind sigtype case MTI_TYPE_ENUM case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val Scalar val mti GetSignalValue sigid mti PrintFormatted break case MTI_TYPE_ARRAY dNn scalar val int i mtilInt32T num elems mtiTypeIdT elem type mtiTypeKindT elem typekind void array val array val mti GetArraySignalValue sigid 0 num elems mti TickLength sigtype elem type mti GetArrayElementType sigtype elem typekind mti GetTypeKind elem type switch elem typekind case MTI TYPE ENUM char enum_values enum_values mti_GetEnumValues elem_type if mti_TickLength elem_type gt 256 mtiInt32T val array val for i 0 i lt num elems i mti PrintFormatted s enum_values val i else char val array_val ModelSim FLI Reference FLI 228 FLI function definitions for i 0 i lt num elems i mti PrintFormatted s enum_values val i break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted d val i break case MTI_TYPE_ARRAY mti_PrintMessage ARRAY break case MTI_TYPE_RECORD mti PrintMessage RECORD break case MTI TYPE REAL double val array_val for i 0 i lt num elems i mti PrintFormatted g val i break
88. mti_Malloc strlen param param in char amp instance info instance_info i mti_RestoreChar mti_RestoreLong mti RestoreShort mti RestoreString char Sc n long ld n short d n string s n The ID of the region in which this xy foreign architecture is instantiated The last part of the string in the f foreign attribute ER A list of generics for the foreign model A list of ports for the foreign model xy Roy stance info instance info architecture is my for model signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info my for model Saving char Z Saving long 123456 Saving short 587 Saving string Howdy VSIM 3 run 40 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 16 09 02 2000 Restoring state at time 20 ns iteration 1 Restoring instance info my for model Restoring char Z Restoring long 123456 Restoring short 587 Restoring string Howdy VSIM 5 run 10 VSI
89. of type ARRAY 3 is of type 2 is of type 1 of type 0 of type ENUM ENUM ENUM ENUM is is ARRAY mti GetSignalType FLI 385 S5 3 is of type ARRAY S5 3 2 is of type ENUM S5 3 1 is of type ENUM s5 3 0 is of type ENUM s5 2 is of type ARRAY S5 2 2 is of type ENUM S5 2 1 is of type ENUM s5 2 0 is of type ENUM Signal top s6 S6 is of type ARRAY S6 1 is of type ARRAY S6 1 0 is of type ENU S6 1 1 is of type ENU S6 1 2 is of type ENU S6 1 3 is of type ENU S6 1 4 is of type ENU S6 2 is of type ARRAY S6 2 0 is of type ENU S6 2 1 is of type ENU S6 2 2 is of type ENU s6 2 3 is of type ENU S6 2 4 is of type ENU VSIM 1 quit ModelSim FLI Reference FLI 386 FLI function definitions mti GetSignalValue Gets the value of a scalar VHDL signal of type enumeration integer or physical Syntax value mti GetSignalValue signal id Returns Type Description mtiInt32T The current value of the specified signal Arguments Name Type Description signal id mtiSignalldT A handle to a VHDL scalar signal of type enumeration integer or physical Description mti GetSignalValue returns the value of signals of type enumeration integer and physical For composite real and time type signals use mti GetSignalValueIndirect Related functions mti GetArraySignalValue FLI 226 mti GetSignalValueIndirect
90. region initForeign for model sl for model use entity work for model a Simulation output 9 vsim c top Reading modeltech 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 Region top Architecture Region region_under_parent_post_elab Foreign Region il Architecture Region reg_under_for_arch_post_elab Foreign Region region_under_foreign_arch Foreign Region region_under_parent Foreign Region standard Package Region std_logic_1164 Package VSIM 1 gt run 5 VSIM 2 gt quit mti_CreateRegion FLI 145 ModelSim FLI Reference FLI 146 FLI function definitions mti CreateScalarTyper Syntax Returns Arguments Description Creates a scalar type type id mti CreateScalarType left right Type Description mtiTypeldT Type A handle to the new scalar type Description mtiInt32T The left most value of the new scalar type mtiInt32T The right most value of the new scalar type mti CreateScalarType creates a new type ID that describes a VHDL scalar integer type whose value range is determined by the specified left and right values Related functions Example ModelSim FLI Reference mti CreateArrayType FLI 108 mti CreateEnumType
91. return Enumeration return Physical return Real return Time return UNKNOWN static void initInstance void param mtiSignalIdT sigid mtiTypeIdT typeid mti PrintMessage Design Signals n for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal typeid mti GetSignalType sigid mti PrintFormatted 14s type 12s length d n mti mti void initForeign GetSignalName sigid getTypeStr typeid TickLength typeid mtiRegionIdT region The ID of the region in which this x foreign architecture is instantiated char param The last part of the string in the x foreign attribute KJ mtiInterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model A mti AddLoadDoneCB initInstance 0 HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a library ieee architecture is initForeign for model sl use ieee std logic 1164 a11 entity top is type bitarray is array 2 downto 5 of bit type intrange is range 0 to 255 type rectype is record a T Diti b integer Cc bitarray end record type bigtime is range 0 to integer high units hour day 24 hour week 7 day month 4 week year 12 month end units end top architecture a of top is
92. s s n mti FindSignal FLI 185 mti GetSignalRegion sigid signal name region name Signal top toggle a is not found because the toggle instance has not yet been elaborated Er sigid mti FindSignal top toggle a if sigid region name mti PrintFormatted region name mti VsimFree region name HDL code package mypkg is signal packsig end mypkg bit Qs is BLE 7 entity for model port pl end for model in architecture a of for model is attribute foreign of a architecture is begin end a entity inv is generic delay time 5 ns port a in bit b out bit i end inv architecture b of inv is begin b lt a after delay end b use work mypkg all entity top is end top architecture a of top is signal sl bit 0 signal s2 bit ene signal s3 bit_vector 7 downto 0 component for_model is port pl in bit end component for all mti_GetRegionFullName mti_GetSignalRegion sigid Found signal s s n mti_GetSignalName sigid initForeign for model sl 01101010 for model use entity work for model a ModelSim FLI Reference FLI 186 FLI function definitions ModelSim FLI Reference component inv is generic delay time 5 ns port a in bit b out bit i end component begin il for model port map sl sl lt not sl after 5 ns S3 lt not s3 after 5 ns pac
93. sigid siginfo next 0 return siginfo static void initInstance void param instanceInfoT inst data mtiSignalldT sigid signallnfoT curr info signallInfoT siginfoy inst data mti Malloc sizeof instanceInfoT inst data 5sig info 0 for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 6 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 wf foreign attribute af mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT 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 a11 ModelSim FLI Reference mti GetSignalValuelndirect FLI 397 entity top is type bitarray is array 3 downto 0 of bit type intarray is array 2 downto 0 of integer
94. top instl Parent region is top Region top inst1 il Parent region is instl Parent region is inst1 Region top instl Parent region is top Parent region is instl1 Region top inst1 il Parent region is instl Parent region is instl mti Image FLI 463 mti Imager Gets the string image of a value of a specific type Syntax strval mti Image value type id Returns Name Description strval A string image of the specified value Arguments Type Description void A pointer to a value that is in the correct format for the specified type mtiTypeldT A handle to a VHDL type Description mti Image returns a pointer to a buffer containing the string image of the specified value The format is determined by the specified type 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 mti Image The returned pointer must not be freed Related functions mti GetVarlImage FLI 416 mti Signallmage FLI 635 Example FLI code include lt mti h gt typedef struct varInfoT tag struct varInfoT tag next char name mtiTypeIdT typeid mtiVariableIdT varid varInfoT typedef struct varlInfoT var info List of variables ModelSim FLI Reference FLI 464 FLI function definitions mtiProcessIdT proc Test process id instanceInfoT static void checkValues void inst
95. vartype switch mti GetTypeKind elem type case MTI TYPE SCALAR case MTI TYPE PHYSICAL mtilnt32T array val mti GetArrayVarValue varid 0 for i 0 i lt mti TickLength vartype i array val i mti SetVarValue varid long array val break case MTI_TYPE_ARRAY case MTI_TYPE_RECORD default elem_list mti_GetVarSubelements varid 0 for i 0 i lt mti TickLength vartype i setVarValue elem list i mti GetVarType elem list i mti_VsimFree elem_list break case MTI_TYPE_ENUM if mti TickLength elem type lt 256 char array val mti GetArrayVarValue varid 0 for i 0 i lt mti TickLength vartype i array val i if array val i mti TickLow elem type array val i gt mti TickHigh elem type array val i mti TickLeft elem type mti SetVarValue varid long array val ModelSim FLI Reference FLI 630 ModelSim FLI Reference FLI function definitions else mtilnt32T array val for i 0 array val i if array valli array val i array val i i lt mti TickLength vartype mti TickLeft i lt mti_TickLow elem_type mti_TickHigh elem_type elem_type mti SetVarValue varid long array_val break case MTI_TYPE_REAL double array_val for i 0 array_val i mti_SetVarValue varid b
96. 0 begin b lt a after delay pl process a begin count lt count 1 after 0 ns end process end b entity mid is type rectype is record a integer bi 4 oats C bit_vector 3 downto 0 end record end mid architecture a of mid is signal sl bit 0 signal s2 bit 0 signal s3 rectype 42 1 1100 signal s4 bit_vector 7 downto 0 10001111 component for_model is end component for all for model use entity work for_model a component inv is generic delay time 5 ns port a in bit b out bit i end component begin il for model sl lt not sl after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin instl mid mti GetSignalName FLI 365 ModelSim FLI Reference FLI 366 FLI function definitions ModelSim FLI Reference end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work for model a Loading for_model sl Loading work inv b Load Done phase Region top Region top instl Signal s1 Signal s2 Signal s3 Signal s4 Region top instl il Region top instil toggle Signal a Signal b Signal count Testing names of composite subelements Signal s3 Si
97. 15 15 02 2000 Restoring state at time 20 ns iteration 1 Restored instance info for model for model Restore complete VSIM 5 run 15 VSIM 6 quit Cleaning up ModelSim FLI Reference FLI 554 FLI function definitions mti RemoveSaveCBY Removes a simulator checkpoint callback Syntax mti RemoveSaveCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function being called at simulator checkpoint void The parameter that was specified in the call to mti_AddSaveCB when the callback was created Description mti_RemoveSaveCB removes the specified function from the simulator checkpoint callback list The param parameter must be the same parameter that was specified in the call to mti_AddSaveCB when the callback was created Related functions mti_AddSaveCB FLI 80 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char inst_info char param if param mti PrintFormatted Saving instance info s n inst info mti SaveString inst info else mti PrintFormatted Save in progress n ModelSim FLI Reference mti RemoveSaveCBY FLI 555 void restoreCallback void param char inst info char param strcpy inst info mti_RestoreString mti PrintFormatted Restored instance info s n instan
98. 22 variable timearr timearray 15 ns 6 ns variable rec rectype E Wt gly Sod Woe LOGI ys begin wait end process end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl SEM 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 gt run 15 Time 0 5 Variable bitsig 1 Variable intsig 21 Variable realsig 1 635000e 01 Variable timesig 5 ns Variable stdlogicsig H Variable bitarr 0110 Variable stdlogicarr 01LH Variable intarr 10 11 12 Variable realarr 1 160000e 01 1 012200e 02 Variable timearr 15 ns 6 ns Variable rec 0 1 3 700000e 00 H 1001 Time 0 10 Variable bitsig 0 Variable intsig 22 Variable realsig 1 745000e 01 Variable timesig 6 ns Variable stdlogicsig Variable bitarr 1001 Variable stdlogicarr 1ZH Variable intarr 11 12 13 Variable realarr 1 270000e 01 1 023200e 02 Variable timearr 16 ns 7 ns Variable rec 1 2 4 800000e 00 0110 Time 0 15 Variable bitsig 1 ModelSim FLI Reference FLI 634 FLI function definitions Varia Varia Varia Varia Varia Varia Varia Varia Varia Varia Ol MESE OE NE OEC OO 00000000020 VSIM 2 quit ModelSim FLI Reference intsig
99. A list of ports for the foreign model mti AddCommand printSig printSigInfo HDL code entity top is end top architecture a of top is signal sl bit 0 signal s2 real 1 0 begin S lt not sl after 5 ns S2 lt s2 1 0 after 5 ns end a ModelSim FLI Reference FLI 56 FLI function definitions ModelSim FLI Reference Simulation output 9 vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading work top a Loading for model sl VSIM 1 printSig Time 0 0 delta 0 Command printSig Usage printSig lt signame gt VSIM 2 printSig top s2 Time 0 0 delta 0 Command printSig top s2 The type of signal top s2 is not supported VSIM 3 printSig top s3 Time 0 0 delta 0 Command printSig top s3 Signal top s3 not found VSIM 4 printSig top sl Time 0 0 delta 0 Command printSig top s1 Signal top sl 0 VSIM 5 gt run 5 VSIM 6 printSig top sl Time 0 5 delta 1 Command printSig top sl Signal top s1 1 VSIM 7 quit mti AddEnvCB FLI 57 mti AddEnvCB Syntax Returns Arguments Description Adds an environment change callback mti AddEnvCB func param Nothing Type Description mtiEnvCBFuncPtrT A pointer to a function to be called whenever the simulation environment changes A
100. FLI Reference FLI 668 FLI function definitions ModelSim FLI Reference typedef struct mtiSignalIdT sigid mtiProcessIdT procid instanceInfoT char convertStdLogicValue mtiInt32T sigval char retval switch sigval case STD LOGIC U retval U break case STD LOGIC X retval X break case STD LOGIC 0 retval O break case STD_LOGIC_1 retval 1 break case STD LOGIC 2 retval Z break case STD_LOGIC_W retval W break case STD_LOGIC_L retval L break case STD_LOGIC_H retval H break case STD_LOGIC_D retval break default retval break return retval void watchSignal void param char region_name instanceInfoT inst instanceInfoT param mtiInt32T sigval region name mti GetRegionFullName mti GetSignalRegion inst sigid sigval mti GetSignalValue inst sigid mti PrintFormatted Time d d delta d Signal s s is s n mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid convertStdLogicValue sigval mti VsimFree region name if mti Now gt 30 mti PrintMessage Turning off signal watcher n mti Free inst else mti ScheduleWakeup inst procid 5 void initForeign mtiRegionIdT region The ID of the region in which this foreign architecture is instantiated char param The last p
101. FLI Reference end process end a Simulation output 9 vsim c top mti GetArrayVarValue FLI 239 Reading modeltech 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 15 Time 0 6 Variable bitsig 1 Variable intsig 23 Variable realsig 19 35 Variable timesig 0 7 Variable stdlogicsig 3 Variable bitarr rg FL LIU EO Variable stdlogicarr vor ULT Bo LU Variable intarr 12 13 14 Variable realarr 12 6 102 22 Variable timearr O LT 0 8 Variable rec 0 3 8 7 3 Up ont r COT Sept Time 0 11 Variable bitsig 0 Variable intsig 24 Variable realsig 20 85 Variable timesig 0 8 Variable stdlogicsig 2 Variable bitarr I vg ro ayy Variable stdlogicarr 1 0O 1 Q Variable intarr 13 14 15 Variable realarr 13 1 102 72 Variable timearr 0 18 0 9 Variable rec 1 4 1152 2 Wow FES WE MoT VSIM 2 quit ModelSim FLI Reference FLI 240 FLI function definitions mti GetCallingRegion Gets the current elaboration region during elaboration or the region of the currently active process or signal resolution function or the current environment during simulation Syntax region id mti GetCallingRegion Returns Name Type Description region id mtiRegionIdT A handle to the c
102. G generics restrictions on FLI 12 ModelSim FLI Reference Index H halting the simulator FLI 99 FLI 164 FLI 520 input prompt FLI 96 input ready callback FLI 60 iteration count FLI 157 L library keep loaded FLI 479 linking C applications FLI 25 C applications FLI 30 LP64 data model FLI 34 M manuals FLI iv mapping to VHDL data types FLI 18 memory allocating FLI 482 freeing FLI 219 FLI 667 reallocating FLI 523 memory management functions FLI 48 MinGW gcc FLI 25 FLI 30 miscellaneous functions FLI 50 mti AddCommand FLI 54 mti AddEnvCB FLI 57 mti AddInputReadyCB FLI 60 mti AddLoadDoneCB FLI 65 mti AddOutputReadyCB FLI 68 mti AddQuitCB FLI 69 mti AddRestartCB FLI 71 mti AddRestoreCB FLI 74 mti AddRestoreDoneCB FLI 77 mti AddSaveCB FLI 80 mti AddSimStatusCB FLI 83 mti AddSocketInputReadyCB FLI 85 mti AddSocketOutputReadyCB FLI 90 mti_AddTclCommand FLI 91 mti AskStdin FLI 96 mti Break FLI 99 mti Cmd FLI 102 mti Command FLI 105 mti CreateArrayType FLI 108 ModelSim FLI Reference mti CreateDriver FLI 113 mti CreateEnumType FLI 118 mti CreateProcess FLI 123 mti CreateProcessWithPriority FLI 128 mti CreateRealType FLI 139 mti CreateRegion FLI 142 mti CreateScalarType FLI 146 mti CreateSignal FLI 149 mti Delta FLI 157 mti Desensitize FLI 160 mti FatalError FLI 164 mti FindDriver FLI 167 mti FindPort FLI 170 mti FindProjec
103. INVALID SOCKET ifdef WIN32 WORD wVersionRequested WSADATA wsaData int err wVersionRequested MAKEWORD 1 1 ModelSim FLI Reference err WSAStartup wVersionRequested amp wsaData if err 0 mti PrintMessage Cannot find a usable winsock dll n return Confirm that the Windows Sockets DLL supports 1 1 Note that if the DLL supports versions greater than 1 1 in addition to 1 1 it will still return 1 1 in wVersion since that is the version we requested y if LOBYTE wsaData wVersion 1 HIBYTE wsaData wVersion 1 mti PrintMessage Cannot find a usable winsock dll n WSACleanup return The Windows Sockets DLL is acceptable Proceed endif sock socket AF INET SOCK STREAM O0 if sock INVALID SOCKET ifdef WIN32 DWORD le GetLastError mti_PrintFormatted Error opening socket Error d n le else mt i PrintMessage Error opening socket n mti AddlnputReadyCB FLI 63 endif return while retry_cnt 2 memset char amp server 0 sizeof server server sin_family AF_INET if hp gethostbyname hostname 0 mti_PrintFormatted s Unknown host n hostname close sock return memcpy char amp server sin_addr char hp gt h_addr hp gt h_length portNum 19 chargen server sin port htons portNum server length sizeof server Status c
104. M as V 397 ere rr Te M e 4 The ID of the region in which this EY foreign architecture is instantiated The last part of the string in the x7 foreign attribute KR A list of generics for the foreign model A list of ports for the foreign model x initForeign for model sl of bit of al 4 of character 1100 signal signal signal signal S3 s4 s5 s6 bit vector 7 downto O0 scc gp Br ede TOIT OLIY rectype2 a2 a3 Hello component for model is end component for all begin il for model sl lt not sl after 5 ns end a Simulation output vsim c top Reading 5 4b vsim c Loading Loading Loading Loading Signa sl Signa s2 S S S s3 s4 top modeltech sunos5 std standard work top a work for model a for model sl Composite Signals l top s1 l top s2 2 a 2 b 2 6 S2 s2 B23 S2 Signal top s3 s4 s4 s4 c 3 c 2 c 1 c 0 Signal top s4 s4 f1 s4 f 2 f2 a EZ sEZC S4 2 c 3 there modeltech tcl vsim pref tcl I0DDITIIT VOM 1111 mti GetSignalSubelements FLI 379 for model use entity work for model a ModelSim FLI Reference FLI 380 FLI function definitions s4 f2 c 2 s4 f2 c 1 s4 2 c 0 Signal top s5 s5 s5 3 s5 3 2 s5 3 1 s5 3 0 s5 2 s5 2 2 s5 2 1 s5 2 0 Signal top
105. ModelSim FLI Reference FLI 290 FLI function definitions signal sl i bit 04 begin sl lt not sl after 7 ns finst for model pl postponed process begin wait for 15 ns test proc end process end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work for pkg body Loading for model sl Loading work top a Loading work for model a Time 0 0 checkEnv Pending events Next time is 0 0 VSIM 1 run 3 VSIM 2 env finst Time 0 3 checkEnv Pending events Next time is 0 7 sim top finst VSIM 3 run 5 Time 0 7 checkRegion Pending events Next time is 0 7 VSIM 4 env top Time 0 8 checkEnv Pending events Next time is 0 14 sim top VSIM 5 run 7 Time 0 14 checkRegion Pending events Next time is 0 14 VSIM 6 env finst Time 0 15 checkEnv Pending postponed processes Next time is 0 21 sim top finst VSIM 7 quit ModelSim FLI Reference mti GetNextNextEventTime FLI 291 mti GetNextNextEventTime Gets the next event time from a VHDL process Syntax status mti GetNextNextEventTime next time Returns Name Description status i A number that indicates which types of events are pending See below for details Arguments Name Type Description next time mtiTime64T Returns the time at which t
106. Not supported a On Linux the compiler switch freg struct return must be used when compiling any FLI application code that contains foreign functions that return real or time values MtiRealT is a special type that must be used as the return type of a foreign function that returns a real value Macros are provided in mti h for setting values in and getting values out of variables of type mtiRealT C code and VHDL examples The following examples illustrate the association between C functions and VHDL procedures The C function is connected to the VHDL procedure through the FOREIGN attribute specification C subprogram example Functions declared in this code in params and out params have parameters and return types that match the procedures in the subsequent package declaration pkg include lt stdio h gt include mti h char severity NOTE WARNING ERROR FAILURE static char get string mtiVariableIdT id void in params int vhdl integer IN integer m int vhdl enum IN severity level double vhdl real IN real ER mtiVariableIdT vhdl array IN string a printf Integer Sd n vhdl integer printf Enum s n severity vhdl enum ModelSim FLI Reference FLI 16 Introduction printf Real g n vhdl real printf String sWMn get string vhdl array void out params int vhdl integer OUT integer Kh char vhdl enum OUT seve
107. PrintFormatted Time d d delta d Signal s s is UNKNOWN Mn mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid2 Cx MTI INERTIAL mti VsimFree region name break default region name mti GetRegionFullName mti GetSignalRegion inst sigid2 mti PrintFormatted Time d d delta d Unexpected value d on signal s s n mti NowUpper mti Now mti Delta sigval region name mti GetSignalName inst gt sigid2 mti VsimFree region name break This function drives mySig3 with the values of mySigl and mySig2 void driveSignal3 void param instanceInfoT inst instanceInfoT param mtiiInt32T sigvall ModelSim FLI Reference FLI 152 FLI function definitions ModelSim FLI Reference mtilInt32T sigval2 sigvall mti GetSignalValue inst gt sigidl sigval2 mti GetSignalValue inst sigid2 if sigvall sigval2 mti ScheduleDriver inst drvid3 sigvall 0 MTI INERTIAL else mti ScheduleDriver inst drvid3 STD LOGIC X 0 MTI INERTIAL void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 wy foreign attribute EL mtiInterfaceListT generics A list of g
108. Read hit to set 3 2660 Reading from addr 08 2700 Read hit to set 3 2740 Reading from addr 09 2780 Read hit to set 3 Read Write test done Note stop E proc v 77 Time 2820 ns Iteration 0 Instance top p Break at proc v line 77 Stopped at proc v line 77 VSIM 2 quit ModelSim FLI Reference mti GetRegionName Gets the simple name of a region mti GetRegionName FLI 341 Syntax region name mti GetRegionName region id Returns Name Description region name The simple name of the specified region Arguments Name Type Description region id mtiRegionIdT A handle to a VHDL or Verilog region Description mti GetRegionName returns the simple name of the specified VHDL or Verilog region The returned pointer must not be freed Related functions mti_GetLibraryName FLI 283 mti GetPrimaryName FLI 311 mti GetRegionFullName FLI 325 mti GetRegionSourceName FLI 344 mti GetSecondaryName FLI 355 Example FLI code include mti h void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region_name mti_GetRegionName mti_PrintFormatted cRegion s n indent 2 for regid mti_FirstLowerRegion indent region name region ModelSim FLI Reference FLI 342 FLI function definitions ModelSim FLI Reference regid regid printHierarchy regid indent v
109. RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveString FLI 592 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char tmp_char Z char tmp_str Howdy ModelSim FLI Reference FLI 590 FLI function definitions long tmp long 123456 short tmp short 587 mti PrintFormatted mti SaveBlock mti PrintFormatted mti SaveChar tmp char mti PrintFormatted mti SaveLong tmp long mti PrintFormatted hort tmp short Formatted mti SaveS mti Print mti SaveString tmp str Formatted Mn mti Print nSaving instance info s n char amp instance info Saving char c n Saving long ld n Saving short d n Saving string s n instance info sizeof instance info tmp char tmp long tmp short tmp str void restoreCallback void param mti_RestoreBlock mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted n mti_PrintFormatted VE void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports instance info strcpy instance info mti AddSaveCB saveCallback mti AddResto
110. Time 0 20 delta 1 Signal info for for_model Signal sl 0 Signal s2 3 Time 0 20 delta 1 Deleting old command data for for_model VSIM 10 gt run 5 VSIM 11 gt printSigs Time 0 25 delta 1 The printSigs command has been deactivated VSIM 12 gt quit Cleaning up ModelSim FLI Reference FLI 96 FLI function definitions mti AskStdin Prompts the user for an input string Syntax error code mti AskStdin buffer prompt Returns Name Description error code i if the buffer parameter is NULL 0 otherwise Arguments Name Type Description buffer char A pointer to a character buffer in which the user s input is returned prompt char A character string that will be used as the prompt to the user Description mti AsksStdin gets input from the user by displaying the specified prompt on the vsim command line and returning what the user types All characters entered up to but not including a newline character are returned in the character buffer The character string is null terminated The caller is responsible for allocating the space for the buffer Related functions None Example FLI code include lt strings h gt include lt mti h gt void printSigInfo void param char buffer 128 int done 0 mtiSignalIdT sigid while done ModelSim FLI Reference mti AskStdin FLI 97 quit j 20 Signal s not found n buffer
111. a handle to the first subregion of the specified region mti_NextRegion FLI 489 can be used to get the subsequent subregions of the specified region mti_FirstLowerRegion will return a handle to a VHDL a Verilog or a SystemC region Verilog regions include tasks and functions A handle to a Verilog region can be used with PLI functions to obtain information about or access objects in the Verilog region During elaboration design units that have not yet been instantiated will not be found by mti_FirstLowerRegion Related functions mti_FindRegion FLI 177 mti_GetRegionKind FLI 328 mti_GetTopRegion FLI 399 mti_HigherRegion FLI 459 mti_NextRegion FLI 489 ModelSim FLI Reference FLI 192 FLI function definitions Example ModelSim FLI Reference FLI code include lt mti h gt void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s n indent region name indent 2 for regid mti FirstLowerRegion region regid regid mti NextRegion regid printHierarchy regid indent mti VsimFree region name void loadDoneCB void param mti PrintMessage nLoad Done phase n printHierarchy mti GetTopRegion 1 void initForeign mtiRegionIdT region The ID of the region in which this foreign architecture is i
112. a process mti GetNextNextEventTime FLI 291 or outside of a process mti GetNextEventTime FLI 287 There are others that have slightly different behavior depending on when they are called and from which context e g mti GetCurrentRegion FLI 248 and mti GetCallingRegion FLI 240 There are also several FLI functions that can be used on Verilog and SystemC regions in addition to VHDL regions e g mti GetRegionKind FLI 328 gt Note Function arguments are required unless marked as optional ModelSim FLI Reference FLI 54 FLI function definitions mti AddCommand Adds a user defined simulator command Syntax mti AddCommand cmd name cmd func Returns Nothing Arguments Name Type Description cmd name char The name of the command being added cmd func mtiVoidFuncPtrT A pointer to the function that will be called whenever the command is recognized by the command interpreter Description mti AddCommand adds the specified command to the simulator The case of the command name is significant The simulator command interpreter subsequently recognizes the command and calls the command function whenever the command is recognized The entire command line the command and any arguments is passed to the command function as a character string The command function prototype is void commandFuncName void command A command can be added with the same name as a previously added command
113. architecture a of top is component mid is generic gen1 end component string Top begin instl mid end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for_model sl Elaboration phase Region top Region top instl Process testproc Variable genl Variable c1 Variable v1 Variable v2 Variable v3 Region top instl il Region top instl flip Process pl Variable delay Variable increment Variable count Process line 19 Variable delay Variabl Process Variabl Process Variabl Variabl Variabl Variabl Le Le Variabl VSIM 1 run 10 VSIM 2 quit Load Done phase Region top Region top instl Process line 72 genl line 71 genl testproc genl onl vl v2 v3 Region top instl flip Process pl Variable delay Variable increment Variable count Process line 19 Variable delay Region top instl il Region top instl toggle Process pl Variable delay Variable increment Variable count Process line 19 Variable delay mti FirstVar FLI 207 ModelSim FLI Reference FLI 208 FLI function definitions mti ForceSignal Forces a value onto a VHDL signal Syntax error code mti ForceSignal signal id value string delay force type cancel period rep
114. architecture is instantiated char param The last part of the string in the foreign attribute mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model instanceInfoT inst inst instanceInfoT mti Malloc sizeof instanceInfoT inst procid mti CreateProcess SignalDriver driveSignal inst MTI TIME64 ASGN inst gt delay 1 30 mti ScheduleWakeup64 inst procid inst gt delay inst il sigid mti FindSignal top il inst il drvid mti CreateDriver inst gt il_sigid inst procid y mti SetDriverOwner inst gt il drvid inst i2 sigid mti FindSignal top i2 inst i2 drvid mti CreateDriver inst gt i2 sigid inst procid mti SetDriverOwner inst i2 drvid inst i3 sigid mti FindSignal top i3 inst i3 drvid mti CreateDriver inst gt i3_sigid mti SetDriverOwner inst i3 drvid inst procid inst tl sigid mti FindSignal top t1 inst tl drvid mti CreateDriver inst gt tl_sigid inst procid mti SetDriverOwner inst tl drvid inst gt t2_sigid mti FindSignal top t2 inst t2 drvid mti CreateDriver inst gt t2_sigid inst procid mti SetDriverOwner inst t2 drvid inst t3 sigid mti FindSignal top t3 inst t3 drvid mti CreateDriver inst 5t3 sigid mti SetDriverOwner inst t3 d
115. array is the left most value of the enumeration type Related functions mti TickLeft FLI 654 mti TickLength FLI 657 mti TickRight FLI 664 Example FLI code include mti h typedef struct signalInfoT tag struct signalInfoT tag next char name mtiSignalldT sigid mtiTypeIdT typeid signalInfoT ModelSim FLI Reference FLI 272 FLI function definitions typedef struct signallInfoT sig infos List of signals mtiProcessIdT proc Test process id instanceInfoT static void printValue mtiSignalIdT sigid mtiTypeIdT sigtype int indent switch mti_GetTypeKind sigtype case MTI_TYPE_ENUM char Ss enum_values mtilnt32T scalar val Scalar val mti GetSignalValue sigid enum values mti GetEnumValues sigtype mti PrintFormatted s n enum values scalar val break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val Scalar val mti GetSignalValue sigid mti PrintFormatted d n scalar val break case MTI_TYPE_ARRAY int i mtilInt32T num elems mtiTypeIdT elem type mtiTypeKindT elem typekind void array val array val mti GetArraySignalValue sigid 0 num elems mti TickLength sigtype elem type mti GetArrayElementType sigtype elem typekind mti GetTypeKind elem type switch elem typekind case MTI TYPE ENUM char enum_values enum values mti GetEnumValue
116. begin end a entity bottom is end bottom architecture b of bottom is begin end b entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a component bottom is end component begin bot bottom il for model sl lt not sl after 5 ns end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a de dB dB GE Loading work bottom b Loading for_model sl Foreign Arch in Region VSIM 1 env top sim top VSIM 2 env top il Foreign Arch in Region sim top il VSIM 3 env top bot Foreign Arch in Region sim top bot VSIM 4 env top Foreign Arch in Region sim top VSIM 5 quit Loading work for model a il Tl qub ydg the the the the current current current current region region region region is is is is now now now now top il bot top mti AddEnvCB FLI 59 ModelSim FLI Reference FLI 60 FLI function definitions mti AddlnputReadyCBY Add or remove a file pipe socket input ready callback Syntax mti AddInputReadyCB file desc func param Returns Nothing Arguments Name Description file desc i On UNIX a file pipe or socket descriptor on Windows a
117. bitsigl lt not bitsigl after 5 ns end a Simulation output 9 vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl Suo vsim foreign initForeign for_model sl c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work typepkg body Loading work top a Loading for_model sl Signal bitsigl is not resolved Signal intsigl is not resolved Signal realsigl is not resolved Signal timesigl is not resolved Signal physsigl is not resolved Signal stdulogicsigl is not resolved Signal resbitsigl is resolved Signal resintsigl is resolved Signal resrealsigl is resolved Signal restimesigl is resolved Signal resphyssigl is resolved Signal stdlogicsigl is resolved Signal bitsigr is resolved Signal intsigr is resolved Signal realsigr is resolved Signal timesigr is resolved Signal physsigr is resolved Signal stdulogicsigr is resolved DE Cae UE M TA A hour ModelSim FLI Reference FLI 646 FLI function definitions ModelSim FLI Reference Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sis Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig Sig nal bitarrl is not resolved intarrl is not re
118. by ModelSim Microsoft Visual C C is supported for creating Windows DLLs while gcc and cc compilers are supported for creating UNIX shared libraries Although compilation and simulation switches are platform specific references to load shared objects are the same for all platforms For information on loading objects see Using the VHDL FLI with foreign architectures FLI 11 and Declaring a foreign subprogram in VHDL FLI 13 Windows platforms Under Windows ModelSim loads a 32 bit dynamically linked library for each FLI application Microsoft Visual C 4 1 or later cl c I lt install_dir gt modeltech include app c link dll export C init function app obj lt install_dir gt modeltech win32 mtipli lib out app dll Multiple export options can be specified one for each different FOREIGN attribute function name C init function is the function name specified in the FOREIGN attribute When executing cl commands in a DO file use the NOLOGO switch to prevent the Microsoft C compiler from writing the logo banner to stderr Writing the logo causes Tcl to think an error occurred If you need to run the Performance Analyzer on a design that contains FLI code add these two switches to the linking command shown above DEBUG DEBUGTYPE COFF These switches add symbols to the d that the profiler can use in its report MinGW gcc 3 2 3 gcc c I lt install_dir gt modeltech include app c gcc shared o app dll app
119. c top Loading modeltech sunos5 std standard Loading work top a Loading work inv b Loading work for model a Loading for_model sl Elaboration phase Region top Region top il Region top flip Process pl mti GetProcessNamer FLI 317 ModelSim FLI Reference FLI 318 FLI function definitions Process line 19 Load Done phase Region top Process procl Process line 58 Process line 57 Region top flip Process pl Process line 19 Region top il Region top toggle Process pl Process line 19 VSIM 1 run 10 VSIM 2 quit ModelSim FLI Reference mti GetProcessRegion FLI 319 mti GetProcessRegion Gets a handle to a process region Syntax region mti GetProcessRegion proc id Returns Name Type Description region mtiRegionIdT A handle to the region in which the process exists Arguments Type Description mtiProcessIdT A handle to a process Description mti_GetProcessRegion returns a handle to the VHDL or SystemC region in which the specified process exists Related functions None Example FLI code include lt mti h gt void printProcesses mtiRegionIdT region int indent char region_name mtiProcessIdT procid mtiRegionIdT regid for procid mti_FirstProcess region procid procid mti_NextProcess if procid regid mti GetProcessRegion procid region name mti GetRegionFullName regid mti PrintF
120. case MTI_TYPE_SCALAR case MTI_TYPE_ARRAY case MTI_TYPE_RECORD case MTI_TYPE_ENUM ModelSim FLI Reference return Scalar return Array return Record return Enumeration mti TickLeft FLI 655 case MTI TYPE PHYSICAL return Physical case MTI TYPE REAL return Real case MTI TYPE TIME return Time default return UNKNOWN static void initInstance void param mtiSignalIdT sigid mtiTypeIdT typeid mti PrintMessage Design Signals n for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal typeid mti GetSignalType sigid mti PrintFormatted 14s type 12s left d right d n mti GetSignalName sigid getTypeStr typeid mti TickLeft typeid mti TickRight typeid 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 y foreign attribute mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model FL 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 a11 entity top is type bitarray is array 2 downto 5 of bit
121. contexts The default is For example sim top Must not be the same character as PathSeparator DatasetSeparator Control VHDL files opened for write 0 Buffered 1 Unbuffered UnbufferedOutput 0 Control number of VHDL files open concurrently z This number should always be less then the current ulimit setting for max file descriptors A 0 unlimited ConcurrentFileLimit 40 Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl myconfig myentry SMODEL_TECH xyz myconfig myentry modeltech sunos5 xyz Library std MODEL TECH std vsim Resolution ns VSIM 1 run 5 VSIM 2 quit mti FindRegion FLI 177 mti FindRegion Finds a region by name Syntax region id mti FindRegion name Returns Name Type Description region id mtiRegionIdT A handle to the region or NULL if the region is not found Arguments Description The name of the region to be found Description mti_FindRegion returns a handle to the specified region The region name can be either a full hierarchical name or a relative name A relative name is relative to the current region set by the simulator s environment command The default current region is the foreign architecture region during elaboration and the top lev
122. d delta d Signal s is UNKNOWN Mn mti NowUpper mti Now mti Delta mti GetSignalName sigid mti Break break default break void initForeign mtiRegionIdT region The ID of the region in which this EJ foreign architecture is instantiated char param The last part of the string in the foreign attribute x mtilInterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model mtiProcessIdT procid mtiSignalIdT sigid sigid mti FindSignal top sl1 procid mti CreateProcess SignalMonitor monitorSignal sigid mti Sensitize procid sigid MTI EVENT HDL code library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal sl std logic O s begin pl process begin cl case sl is when U gt sl lt X after 5 ns when X gt sl lt 0 after 5 ns when 0 gt sl lt 1 after 5 ns when l gt sl lt Z after 5 ns when Z gt sl lt W after 5 ns when W gt sl lt L after 5 ns when L gt sl lt H after 5 ns when H gt sl lt after 5 ns when gt sl lt U after 5 ns end case cl wait for 5 ns end process end a ModelSim FLI Reference Simulation output 9 vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b
123. definitions HDL code entity top is end top architecture a of top is signal sl bit 0 begin sl lt not sl after 10 ns end a Simulation output vsim c wlf mydata wlf top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl ol o1 vsim foreign initForeign for model sl c wlf mydata wlf top Loading modeltech sunos5 std standard Loading work top a Loading for_model sl WLF filename mydata wlf VSIM 1 add log r VSIM 2 run 100 VSIM 3 quit Se b db b dk ModelSim FLI Reference mti HigherRegion FLI 459 mti HigherRegion Syntax Returns Arguments Description Gets the parent region of a region parent id mti HigherRegion region id Name Type Description parent id mtiRegionIdT A handle to the parent region of the specified region Name Type Description region_id mtiRegionIdT A handle to a VHDL Verilog or SystemC region mti_HigherRegion returns a handle to the parent region of the specified region or NULL if the specified region is a top level region The specified and returned region IDs can be handles to either VHDL Verilog or SystemC regions A handle to a Verilog region can be used with PLI functions to obtain information about or access objects in the Verilog region Related functions Example mti_FindRegion FLI 177 mti_FirstLowerRegion FLI 191 mti_GetRegionKind FLI 328
124. drvid3 procid mti Sensitize mti Sensitize mti CreateSignal mySig3 region enum type mti CreateDriver inst gt sigid3 mti CreateProcess mySig3Driver driveSignal3 inst procid inst gt sigidl MTI EVENT procid inst gt sigid2 MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvid3 procid mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst HDL code entity top is end top architecture a of top is signal sl pit r VON begin S lt not sl after 5 ns end a ModelSim FLI Reference FLI 122 FLI function definitions ModelSim FLI Reference Simulation output 9 Reading 5 4b VSIM 1 000 VSIM 2 VSIM 3 10x VSIM 4 gt VSIM 5 gt 01x VSIM 6 VSIM 7 111 VSIM 8 Loading vsim c top foreign initForeign for model sl modeltech tcl vsim pref tcl Loading for model sl examine mySigl mySig2 run 5 examine mySigl mySig2 run 5 examine mySigl mySig2 run 5 examine mySigl mySig2 quit Cleaning up vsim foreign initForeign for_model sl c top modeltech sunos5 std standard Loading work top a mySig3 mySig3 mySig3 mySig3 mti CreateProcess FLI 123 mti CreateProcess Syntax Returns Arguments Description Creates a new VHDL process process id mti CreateProcess name func param Name Type Description proces
125. end b entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a component bottom is end component begin bot bottom il for model sl lt not sl after 5 ns end a Kx mti AddLoadDoneCB FLI 67 Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work bottom b Loading work for model a Loading for model sl VSIM 1 quit Foreign Arch in Region il the top level region is top ModelSim FLI Reference FLI 68 FLI function definitions mti AddOutputReadyCB Adds or removes a file pipe socket output ready callback Syntax mti AddOutputReadyCB file desc func param Returns Nothing Arguments Name Description file desc i On UNIX a file pipe or socket descriptor on Windows a pipe descriptor mtiVoidFuncPtrT A pointer to a function to be called whenever the file descriptor is available for writing A parameter to be passed to the function OPTIONAL can be NULL Description mti AddOutputReadyCB puts a watch on the specified file descriptor Whenever the file descriptor is available for writing the specified function is called along with its parameter In a UNIX environment mti AddOutputReadyCB can be used wi
126. f sigid y 1 region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Found signal s s n region name mti GetSignalName sigid mti VsimFree region name sigid mti FindSignal top s2 if sigid region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Found signal s s n region name mti GetSignalName sigid mti VsimFree region name sigid mti FindSignal top s3 0 if sigid char signal name mti GetSignalNameIndirect sigid 0 0 region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Found signal s s n region name signal name mti VsimFree region name mti VsimFree signal name sigid mti FindSignal toggle a if sigid region name mti GetRegionFullName mti GetSignalRegion sigid ModelSim FLI Reference FLI 184 FLI function definitions mti PrintFormatted Found signal s s n region name mti GetSignalName sigid mti VsimFree region name void initForeign ModelSim FLI Reference mtiRegionIdT region The ID of the region in which this A foreign architecture is instantiated char param The last part of the string in the foreign attribute EJ mtiInterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model x char region name mtiSig
127. for model use entity work for model a ModelSim FLI Reference mti GetCurrentRegion FLI 251 component lower end component for all lower use entity work lower level begin linstl lower linst2 lower finst for model end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work for_pkg body Loading for model sl Loading work top a Loading work lower level Loading work for model a Foreign Init Function Region parameter is top finst Current region is top finst Time 0 0 checkEnv Function Current region is top Load Done Callback Function Current region is top VSIM 1 gt run 0 Time 0 0 doProc Procedure Current region is top Time 0 0 doProc Procedure Current region is top VSIM 2 gt env sim top VSIM 3 gt env finst Time 0 0 checkEnv Function Current region is top finst sim top finst VSIM 4 gt run 10 Time 0 10 checkRegion Function Current region is top finst VSIM 5 gt env sim top finst VSIM 6 gt env top Time 0 10 checkEnv Function Current region is top sim top VSIM 7 gt run 10 Time 0 15 doProc Procedure Current region is top Time 0 15 doProc Procedure Current region is top VSIM 8 gt env sim top VSIM 9 env linstl Time 0 20 checkEnv Function Current region is top li
128. for the foreign model mtilInterfaceListT ports A list of ports for the foreign model instanceInfoT inst inst instanceInfoT malloc sizeof instanceInfoT inst gt sigid mti FindSignal top sl1 inst procid mti CreateProcess sigMonitor monitorSignal inst mti Sensitize inst procid inst sigid MTI EVENT ModelSim FLI Reference FLI 162 FLI function definitions mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst 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 a11 entity top is end top architecture a of top is signal sl std logic 0 component for model is end component for all for model use entity work for model a begin il for model pl process begin Bl eec its wait for 5 ns sl lt 0 wait for 0 ns Si lt xq wait for 0 ns sl xm UO wait for 5 ns end process end a Simulation output 9 vsim c top Reading modeltech 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 30 ModelSim FLI Reference Time Time Time Time Time Time Time Time Time T
129. for_model sl lt not sl after 5 ns end a Simulation output vsim c Reading 5 4b vsim c Loading Loading Loading Loading ModelSim FLI Reference top modeltech tcl vsim pref tcl top modeltech sunos5 std standard work top a work for model a for model sl VSIM 1 run 15 Time 0 0 Region il the simulator is about to run Time 0 15 Region il the simulator just completed a run VSIM 2 run 5 Time 0 15 Region il the simulator is about to run Time 0 20 Region il the simulator just completed a run A list of ports for the foreign model Ki A list of generics for the foreign model EL VSIM 3 run 8 Time Time VSIM VSIM 55 VSIM VSIM 4 gt 55 6 7 9 20 0 28 run 27 echo now run 15 quit Region il Region il mti RemoveSimStatusCB FLI 559 the simulator is about to run the simulator just completed a run ModelSim FLI Reference FLI b60 FLI function definitions mti RestoreBlock Syntax Returns Arguments Description Gets a block of data from the checkpoint file mti RestoreBlock ptr Nothing Description A pointer to the place where the block of data is to be restored mti RestoreBlock restores a block of data from the checkpoint file to the address pointed to by the ptr parameter The size of the data block restored is the same as the size that was saved
130. foreign architecture is instantiated The last part of the string in the x foreign attribute EL A list of generics for the foreign model A list of ports for the foreign model x 0 nElaboration phase Vn Tog initForeign for model sl 5 ns entity mid is end mid architecture a of mid is signal sl 2 bit c tory signal s2 bit 0 signal 83 2 bit ie O s signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit b out bit i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin instl mid end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for model sl Elaboration phase Loading modeltech sunos5 std standard mti HigherRegion FLI 461 ModelSim FLI Reference FLI 462 FLI function definitions Region top Region top inst1 flip Load Done phase Region top Region top inst1 flip Region top inst1 toggle VSIM 1 gt quit ModelSim FLI Reference Region
131. generic list mtiInterfaceListT A pointer to a NULL terminated list of generics for the specified region or NULL if there are no generics in the specified region Arguments Name Type Description region id mtiRegionIdT A handle to a VHDL region Description mti GetGenericList returns a NULL terminated list of the generics defined for the specified region This list is in the same interface format as the C initialization function generics list The caller is responsible for freeing each element in the list with mti Free If there are no generics in the region then mti GetGenericList returns NULL Related functions None Example FLI code include mti h void printGenericList mtiInterfaceListT generic list int free it mtiInterfaceListT glp mtiInterfaceListT glp_next for glp generic_list glp glp glp_next mti_PrintFormatted s glp gt name switch mti GetTypeKind glp gt type case MTI_TYPE_ENUM case MTI_TYPE_PHYSICAL ModelSim FLI Reference FLI 278 FLI function definitions case MTI TYPE SCALAR mti PrintFormatted d n glp u generic value break case MTI TYPE REAL mti PrintFormatted g n glp u generic value real break case MTI TYPE TIME mti PrintFormatted d d n MTI TIME64 HI32 glp u generic value time MTI TIME64 LO32 glp u generic value time break case MTI TYPE ARRAY int ay mtilnt32T num elems mti_TickLengt
132. i end for_model architecture a of for_model is attribute foreign of a architecture is initForeign for_model sl for_model begin end a library ieee use ieee std_logic_1164 all entity top is end top architecture a of top is signal sl bit Ote signal s2 std logic 1 component for model is port inb in bit ins in std logic i end component for all for model use entity work for_model a begin il for model port map sl s2 S lt not sl after 5 ns S2 lt not s2 after 5 ns end a ModelSim FLI Reference mti AddTclCommand FLI 95 Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 5 Dev 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 printSigs Time 0 0 delta O0 Signal info for for model Signal sl 0 Signal s2 3 VSIM 2 printSigs full Time 0 0 delta O0 Signal info for for model Signal top sl 0 Signal top s2 3 VSIM 3 gt run 5 VSIM 4 gt printSigs Time 0 5 delta 1 Signal info for for_model Signal sl 1 Signal s2 2 VSIM 5 gt printSigs all printRegionInfo Unknown argument VSIM 6 gt run 5 VSIM 7 gt printSigs Time 0 10 delta 1 Signal info for for_model Signal sl 0 Signal s2 3 VSIM 8 gt run 10 VSIM 9 gt printSigs
133. id Name Description proc name The name of the specified process Type Description mtiProcessIdT A handle to a VHDL process mti GetProcessName returns the name of the specified process The returned pointer must not be freed Related functions Example None FLI code include lt mti h gt void printProcesses mtiRegionIdT region int indent mtiProcessIdT procid for procid mti FirstProcess region procid procid mti NextProcess if procid mti PrintFormatted cProcess s n indent mti GetProcessName procid void printHierarchy mtiRegionIdT region int indent char region_name ModelSim FLI Reference FLI 316 FLI function definitions mtiRegionIdT regid region name mti PrintFormatted indent 2 printProcesses region for regid regid regid printHierarchy regid mti VsimFree region name void loadDoneCB void param mti PrintMessage printHierarchy mti GetTopRegion void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports fE mti AddLoadDoneCB loadDoneCB mti PrintMessage printHierarchy mti GetTopRegion HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is cRegion s n architecture is mti GetRe
134. ieee std_logic_1164 all architecture is initForeign mti_GetParentSignal FLI 303 for model sl ModelSim FLI Reference FLI 304 FLI function definitions entity top is end top architecture a of top is signal sl bit vector 3 downto 0 0000 signal s2 bit vector 3 downto 0 0000 signal s3 bit vector 3 downto 0 0000 component for model is end component for all for model use entity work for model a component mid is generic delay time 5 ns port migdin in bat midout out bit vector 3 downto 0 midslv in std logic vector 7 downto 4 end component begin s1 3 lt not s1 3 after 5 ns ml mid port map s1 3 s2 to stdlogicvector s3 f1 for model end a ModelSim FLI Reference mti GetParentSignal FLI 305 Simulation output The first example shows vsim running in its normal optimization mode In this case the simple ports are collapsed for performance and memory efficiency The immediate parents of the lowest level signals a and b are shown to be the top level signals and the parent signal to top mI midslv 7 cannot be found because of the type conversion in the top level port map 9 vsim c top Reading modeltech tcl vsim pref tcl vsim c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading work mid a Loading work inv b
135. il indent 1 mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetVarValueIndirect varid amp real val mti PrintFormatted g real val break case MTI_TYPE_TIME mtiTime64T time_val mti GetVarValueIndirect varid amp time val mti PrintFormatted d d MTI TIME64 HI32 time val MTI TIME64 LO32 time val break default break if print newline mti_PrintFormatted n static void checkValues void inst_info instanceInfoT inst data instanceInfoT inst info variInfoT varinfo mti_PrintFormatted Time d d n mti_NowUpper mti_Now for varinfo inst data var info varinfo varinfo varinfo gt next mti PrintFormatted Variable s varinfo gt name printValue varinfo varid varinfo gt typeid 4 1 mti ScheduleWakeup inst data proc 5 static varInfoT setupVariable mtiVariableIdT varid varlInfoT varinfo varinfo varInfoT mti Malloc sizeof varInfoT varinfo varid varid varinfo name mti GetVarName varid varinfo gt typeid mti GetVarType varid varinfo next 0 return varinfo ModelSim FLI Reference FLI 434 FLI function definitions ModelSim FLI Reference static void initInstance void param instanceInfoT inst_data mtiProcessIdT procid mtiVariableIdT varid varlInfoT Gurr Into varlInfoT varinfo inst da
136. info instanceInfoT inst data instanceInfoT inst info variInfoT varinfo void value mti_PrintFormatted Time d d n mti_NowUpper mti_Now for varinfo inst_data gt var_info varinfo varinfo varinfo gt next value mti GetVarValueIndirect varinfo gt varid 0 mti PrintFormatted Variable s s n varinfo name mti Image value varinfo gt typeid mti ScheduleWakeup inst_data gt 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 param instanceInfoT inst data mtiProcessIdT procid mtiRegionIdT regid mtiVariableIdT varid varlInfoT curr info varlInfoT 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 gt next varinfo curr_info varinfo inst_data gt proc mti CreateProcess Test Process checkValues void inst da
137. info Saving char c n Saving long ld n Saving short d n Saving string s n mti SaveLong FLI 587 instance info sizeof instance info tmp char tmp long tmp short tmp str void restoreCallback void param mti_RestoreBlock mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted n mti_PrintFormatted VE void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports instance info strcpy instance info mti AddSaveCB saveCallback mti AddRestoreCB restoreCallback HDL code entity for model is end for model architecture a of for model is attribute foreign of a initForeign for model s1l begin end a entity top is end top architecture a of top is bit signal sl tots component for model is Restoring Restoring Restoring mti Malloc strlen param param char amp instance info nRestoring instance info s n Restoring instance_info mti RestoreLong mti RestoreShort mti RestoreString char c n mti RestoreChar long ld n short d n string s n The ID of the region in which this t4 foreign architecture is instantiated The last part of the string in the x foreign attribute x A list of generics for the foreign model A list of por
138. info mti RestoreString mti PrintFormatted Restored instance info s n instance info void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 y foreign attribute E7 mtiInterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model Kl instance info malloc strlen param 1 strcpy instance info param mti AddSaveCB saveCallback instance info mti AddRestoreCB restoreCallback instance info mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info 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 for model begin end a entity top is end top architecture a of top is ModelSim FLI Reference FLI 82 FLI function definitions ModelSim FLI Reference signal sl gt bit O component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modelt
139. inside of a region mti GetCallingRegion FLI 240 Gets the current elaboration region during elaboration or the region of the currently active process or signal resolution function or the current environment during simulation mti GetCurrentRegion FLI 248 Gets the current elaboration region during elaboration or the current environment during simulation mti GetGenericList FLI 277 Gets a list of the VHDL generics defined for a region mti GetTopRegion FLI 399 Gets the first top level region mti HigherRegion FLI 459 Gets the parent region of a region mti NextRegion FLI 489 Gets the next region at the same level as a region mti GetLibraryName FLI 283 Gets the physical name of the library that contains a region mti GetPrimaryName FLI 311 Gets the primary name of a region entity package or module mti GetRegionFullName FLI 325 Gets the full hierarchical name of a region mti GetRegionKind FLI 328 Gets the type of a region VHDL Verilog or SystemC mti GetRegionName FLI 341 Gets the simple name of a region mti GetRegionSourceName FLI 344 Gets the name of the source file which contains a region mti GetSecondaryName FLI 355 Function Gets the secondary name of a region Table 2 FLI process functions Action mti CreateProcess FLI 123 Creates a new VHDL process mti CreatePr
140. instl Signal s1 Signal s2 Signal s3 Signal s4 Region top instl flip Signal a mti NextSignal FLI 495 ModelSim FLI Reference FLI 496 FLI function definitions ModelSim FLI Reference Signal b Signal count Region top inst1 il Region top insti toggle Signal a Signal b SE de db db dE db db Signal count VSIM 1 quit mti NextVar FLI 497 mti NextVar Gets the next VHDL variable generic or constant visible to a process Syntax variable id mti NextVar Returns Name Type Description variable id mtiVariableIdT A handle to the next VHDL variable generic or constant visible to the current process Arguments None Description mti NextVar returns a handle to the next variable generic or constant visible to the process set by the latest call to mti FirstVar mti NextVar returns NULL if there are no more variables generics or constants Related functions mti FirstVar FLI 203 Example FLI code include lt mti h gt void printVariables mtiProcessIdT process int indent mtiVariableIdT varid for varid mti_FirstVar process varid varid mti_NextVar if varid mti PrintFormatted cVariable s n indent r mti GetVarName varid void printProcesses mtiRegionIdT region int indent mtiProcessIdT procid for procid mti_FirstProcess region procid ModelSim FLI Reference FLI 498 FLI function definit
141. inv is ModelSim FLI Reference mti NextVar FLI 499 begin b lt a after delay pl process constant increment integer 1 variable count integer 0 begin count count increment wait on a end process end b entity mid is generic genl string Mid end mid architecture a of mid is signal sl bit O signal s2 x bit e O17 signal 3 bit ro Q 3 signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit b r out bit i end component begin testproc process constant cl string mystring variable vl bit 0 variable v2 integer 42 variable v3 real 7 82 begin vl not vl v2 v2 2 v3 v3 1 5 wait for 5 ns end process flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is ModelSim FLI Reference FLI 500 FLI function definitions ModelSim FLI Reference end top architect compone gener ure a of top is nt mid is ic genl string Top end component begin instl end a mid Simulation output vsim c Reading 5 4b vsim c Loading Loading Loading Loading Loading Loading Hierarc Region Regi Pr Pr Er Re Re Re VSIM 1 gt q
142. is component mid is end component begin insti mid end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for model sl Hierarchy top top instl top instl flip top instl il top instl toggle standard VSIM 1 quit Loading modeltech sunos5 std standard mti PrintMessage FLI 519 ModelSim FLI Reference FLI 520 FLI function definitions mti Quit Requests the simulator to exit immediately Syntax mti Quit Returns Nothing Arguments None Description mti Quit shuts down the simulator immediately Related functions mti Break FLI 99 mti FatalError FLI 164 Example FLI code include lt mti h gt typedef enum STD_LOGIC_U Le VOY x STD_LOGIC_X fe NE RY STD LOGIC O0 JE OT FY STD LOGIC 1 TEE RL STD LOGIC Z Z STD LOGIC W W STD LOGIC L L STD LOGIC H H STD LOGIC D JUR Nek SKS StdLogicT void monitorSignal void param mtiSignalIdT sigid mtiSignallIdT param switch mti GetSignalValue sigid case STD LOGIC X case STD LOGIC W mti PrintFormatted Time d d delta d Signal s is UNKNOWN Mn mti NowUpper mti Now mti Delta mti GetSignalName sigid mti Quit break default ModelSim FLI Reference break vo
143. is component mid is end component begin instl mid end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for_model sl Load Done phase Region top Region insti Region flip Region il Region toggle VSIM 1 quit mti GetRegionName FLI 343 ModelSim FLI Reference FLI 344 FLI function definitions mti GetRegionSourceName Syntax Returns Arguments Description Gets the name of the source file which contains a region Source name Name mti GetRegionSourceName region id Description Source name Name Type The name of the source file which contains the specified region Description region id mtiRegionIdT A handle to a VHDL or Verilog region mti GetRegionSourceName returns the name of the source file which contains the specified VHDL or Verilog region The returned pointer must not be freed Related functions Example ModelSim FLI Reference mti_GetLibraryName FLI 283 mti GetPrimaryName FLI 311 mti GetRegionFullName FLI 325 mti GetRegionName FLI 341 mti GetSecondaryName FLI 355 FLI code include mti h static void printRegionInfo mtiRegionIdT regid char source name char regi
144. is generic delay port a in bit b out bit i end inv time architecture b of inv is begin b lt a after delay end b package my_pkg is type my_type is array end package my_pkg use work my pkg all entity mid is end mid architecture a of mid is architecture is 7 downto 0 3 initForeign for model sl 5 ns of integer mti GetTopRegion FLI 401 signal sl bit 0 signal s2 bit 0 signal s3 bit 0 signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit b out bit i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin instl mid end a vertop v module verbot reg reg2 initial begin reg2 0 end always begin 5 reg2 gt reg2 end endmodule module vertop reg regl initial begin ModelSim FLI Reference FLI 402 FLI function definitions ModelSim FLI Reference regl 0 end always begin 5 regl regl end verbot verinstl endmodule Simulation output 9 vlog vertop v Model Technology ModelSim SE EE vlog 5 4b Compiler 2000 06 Jun 9 2000 Compiling module verbo
145. length mti ScheduleDriver64 inst i3 drvid long inst i3 last value at time MTI INERTIAL inst tl1 last value invertBit inst tl last value mti ScheduleDriver64 inst gt tl drvid inst gt tl last value at time MTI TRANSPORT inst t2 last value incrStdLogic inst 5t2 last value mti ScheduleDriver64 inst gt t2_drvid inst gt t2 last value at time MTI TRANSPORT invertBitArray inst 5t3 last value inst 5t3 value length mti ScheduleDriver64 inst t3 drvid long inst 5t3 last value at time MTI TRANSPORT mti ScheduleWakeup64 inst procid inst delay void loadDoneCallback void param instanceInfoT inst param inst il last value mti GetSignalValue inst gt il_sigid inst i2 last value mti GetSignalValue inst gt i2 sigid mti GetArraySignalValue inst gt i3_sigid 0 inst i3 last value ModelSim FLI Reference FLI 604 FLI function definitions ModelSim FLI Reference inst i3 value length mti TickLength mti GetSignalType inst i3 sigid inst tl last value mti GetSignalValue inst gt tl_sigid inst 5t2 last value mti GetSignalValue inst gt t2_sigid inst 5t3 last value mti GetArraySignalValue inst gt t3_sigid 0 inst gt t3 value length mti TickLength mti GetSignalType inst gt t3 sigid void initForeign mtiRegionIdT region The ID of the region in which this foreign
146. logic vector 1 to 4 O1LH signal rec rectype pm TOT 105 LOOL ys component for_model end component ModelSim FLI Reference KJ mti GetSignalValue FLI 391 for all for model use entity work for model a begin instl for_model bitsig lt not bitsig after 5 ns intsig lt intsig 1 after 5 ns physsig lt physsig 1 hour after 5 ns realsig lt realsig 1 1 after 5 ns timesig lt timesig 2 ns after 5 ns stdlogicsig lt not stdlogicsig after 5 ns stdlogicarr lt not stdlogicarr after 5 ns rec a lt not rec a after 5 ns rec b lt rec b 1 after 5 ns rec c lt not rec c after 5 ns end a Simulation output 9 vsim c top modeltech sunos5 ieee std logic 1164 body Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading Loading work top a Loading work for_model a Loading for_model sl VSIM 1 gt run 15 Time 0 6 Signal bitsig 0 Signal intsig 43 Signal physsig 4 Signal realsig 11 3 Signal timesig 0 5 Signal stdlogicsig Eo Signal stdlogicarr 1 TOF 1 Signal rec rome TLT ET EAI Time 0 11 Signal bitsig l Signal intsig 44 Signal physsig 5 Signal realsig 12 4 Signal timesig 0 7 Signal stdlogicsig 1 Signal s tdlogic rt VOV FIT 107 Signal rec Ur 2 Fre EGE Odo UIS VSIM 2 quit ModelSim FLI Reference FLI 392 FLI function definition
147. logic vector 3 downto 0 OILH signal uparray bit vector 1 to 4 0101 signal rec rectype 206 CQ 50 FRODO ys component for model end component for all for model use entity work for model a begin instl for model end a Simulation output 9 vsim c top Reading modeltech 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 Design Signals bitsig type Enumeration direction Ascending 1 intsig type Scalar direction Ascending 1 physsig type Physical direction Ascending 1 realsig type Real direction Ascending 1 mti TickDir FLI 649 ModelSim FLI Reference FLI 650 FLI function definitions ModelSim FLI Reference He de db db ub HE VSIM 1 quit timesig stdlogicsig bitarr stdlogicarr uparray rec type type type type type type Time Enumeration Array Array Array Record direction direction direction direction direction direction Ascending 1 Ascending 1 Descending 1 Descending 1 Ascending 1 No direction 0 mti TickHigh Gets the high value of a ranged type Syntax Returns Arguments Description high mti TickHigh type id Type mti TickHigh FLI 651 Description Type mtiInt32T The high value of the range
148. model bitsigl lt not bitsigl after 5 ns ModelSim FLI Reference FLI 534 FLI function definitions intsigl lt intsigl 1 after 5 ns stdlogicsigl lt after 5 ns when stdlogicsigl H U after 5 ns when stdlogicsigl pet X after 5 ns when stdlogicsigl U 0 after 5 ns when stdlogicsigl X 1 after 5 ns when stdlogicsigl QO Z after 5 ns when stdlogicsigl Y W after 5 ns when stdlogicsigl uz L after 5 ns when stdlogicsigl WU H after 5 ns bitarrl lt not bitarrl after 5 ns intarrl 1 lt intarrl 1 1 after 5 ns intarr1 2 lt intarrl 2 1 after 5 ns intarrl 3 lt intarrl 3 1 after 5 ns stdlogicarrl 1 lt after 5 ns when stdlogicarrl1 1 U after 5 ns when stdlogicarrl 1 X after 5 ns when stdlogicarrl 1 O after 5 ns when stdlogicarrl 1 l after 5 ns when stdlogicarrl 1 Z after 5 ns when stdlogicarrl 1 W after 5 ns when stdlogicarrl 1 L after 5 ns when stdlogicarrl 1 H after 5 ns stdlogicarrl 2 lt after 5 ns when stdlogicarrl 2 U after 5 ns when stdlogicarrl 2 X after 5 ns when stdlogicarrl 2 O after 5 ns when stdlogicarrl 2 1 after 5 ns when stdlogicarrl 2 Z after 5 ns when stdlogicarrl 2 W after 5 ns when stdlogicarrl 2 L after 5 ns when stdlogicarrl 2 H after 5 ns stdlogicarr1 3 lt after 5 ns when stdlogicarrl 3 U after 5 ns when stdlogicarrl 3 X after 5 ns when st
149. model EL ModelSim FLI Reference FLI 242 FLI function definitions mtiRegionIdT regid mti PrintFormatted Foreign Init Function Mn region name mti GetRegionFullName region mti PrintFormatted Region parameter is s n region name mti VsimFree region name regid mti GetCallingRegion region name mti GetRegionFullName regid mti PrintFormatted Calling region is s n region name mti VsimFree region name mti AddLoadDoneCB initInstance 0 mti AddEnvCB checkEnv 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 package for pkg is procedure test proc attribute foreign of test proc procedure is doProc for model sl end for pkg package body for pkg is procedure test proc is begin end end for pkg use work for pkg all entity lower is end lower architecture level of lower is begin pl process begin test proc wait for 15 ns end process end level library ieee use ieee std logic 1164 a11 ModelSim FLI Reference mti GetCallingRegion FLI 243 entity top is end top architecture a of top is component for model end component for all for model use entity work for model a component lower end component for all lower use entity work lower level begin linstl lower linst2 lower finst for mode
150. model for simulator restart Loading for_model sl VSIM 3 run 45 VSIM 4 restart f Cleaning up for model for simulator restart Loading for model sl VSIM 5 run 10 VSIM 6 quit ModelSim FLI Reference FLI b48 FLI function definitions mti RemoveRestoreCB Removes a simulator restore callback Syntax mti RemoveRestoreCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function being called at simulator restore void The parameter that was specified in the call to mti_AddRestoreCB when the callback was created Description mti_RemoveRestoreCB removes the specified function from the simulator restore callback list The param parameter must be the same parameter that was specified in the call to mti_AddRestoreCB when the callback was created mti_RemoveRestoreCB must be called from the foreign initialization function in order for the callback to take effect A foreign initialization function is specified either in the foreign attribute string of a foreign architecture or in the foreign string option of a vsim command Related functions mti AddRestoreCB FLI 74 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char inst_info char param mti PrintFormatted Saving instance info s n inst info mti SaveString inst info
151. modeltech sunos5 ieee std logic 1164 body Loading modeltech sunos5 verilog vl types body Loading work top only Loading work proc Loading work cache Loading work std logic util body Loading work cache set only Loading work memory Loading work for model a Loading for model sl Design Regions Region top is a VHDL architecture of fulltype accArchitecture Region top p is a Verilog module of fulltype accModuleInstance Region top p read is a Verilog task of fulltype accTask Region top p write is a Verilog task of fulltype accTask Region top c is a Verilog module of fulltype accModuleInstance Region top c hash is a Verilog function of fulltype accFunction Region top c update mru is a Verilog task of fulltype accTask Region top c sysread is a Verilog task of fulltype accTask Region top c syswrite is a Verilog task of fulltype accTask Region top c pick set is a Verilog function of fulltype accFunction ModelSim FLI Reference FLI 340 FLI function definitions Region top c get hit is a Verilog function of fulltype accFunction Region top c s0 is a VHDL architecture of fulltype accArchitecture Region top c sl is a VHDL architecture of fulltype accArchitecture Region top c s2 is a VHDL architecture of fulltype accArchitecture Region top c s3 is a VHDL architecture of fulltype accArchitecture Region top m is a Verilog module of fulltype accModuleInstance Region top instl is a V
152. mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info 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 my for model begin end a ModelSim FLI Reference FLI 484 FLI function definitions entity top is end top architecture a of top is signal sl bit e O component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for_model a Loading for_model sl VSIM 1 gt run 35 VSIM 2 gt checkpoint cpfile Saving instance info pointer to my_for_model VSIM 3 gt run 10 VSIM 4 gt restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Wed Jul 5 15 24 18 2000 Restoring state at time 35 ns iteration 1 Restore in progress Restored instance info my for model VSIM 5 run 20 VSIM 6 quit Cleaning up ModelSim FLI Reference mti NextProcess FLI 485 mti NextProcess Syntax Returns Arguments Description Gets the next VHDL process in a region process id mti NextProcess Name Type Description process id mtiProcessIdT A handle to
153. mti AskStdin buffer printSigs if strcasecmp buffer done 1 else sigid mti_FindSignal buffer If s srgrd 1 mti PrintFormatted else switch mti GetTypeKind mti GetSignalType sigid case MTI TYPE SCALAR case MTI TYPE ENUM case MTI TYPE PHYSICAL mti PrintFormatted break default mti PrintFormatted break void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports pE mti AddCommand printSigs HDL code entity top is end top architecture a of top is signal sl Dit PONS signal s2 real 1 0 begin sl lt not sl after 5 ns s2 lt s2 1 0 after 5 ns end a Simulation output sd n mti_GetSignalValue sigid Signal s buffer The type of signal s is not supported Yn buffer The ID of the region in which this foreign architecture is instantiated The last part of the string in the Br foreign attribute x7 A list of generics for the foreign model A list of ports for the foreign model p printsiginfe j vsim c top foreign initForeign for model sl c top Reading modeltech tcl vsim pref tcl 4 5 4b vsim foreign initForeign for model sl Loading modeltech sunos5 std standard Loading work top a Loading for model sl ModelSim FLI Reference FLI 98 FLI function definitions ModelSim FLI Referenc
154. mti CreateProcess SignalDriver driveSignal inst inst delay 1 mti ScheduleWakeup inst procid inst delay inst il sigid mti FindSignal top il inst il drvid mti CreateDriver inst gt il sigid mti SetDriverOwner inst il drvid inst procid inst tl sigid mti FindSignal top t1 inst tl drvid mti CreateDriver inst gt tl_sigid mti SetDriverOwner inst tl drvid inst procid mti AddLoadDoneCB loadDoneCallback inst mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst 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 entity top is end top architecture a of top is Signal il bit o O US signal ti t prt Q 3 component for model end component begin forinst for model end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 6 vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for_model a Loading for_model sl VSIM 1 add list top il top tl ModelSim FLI Reference VSIM 2 run 35 VSIM 3 write list list out VSIM 4 quit Cleaning up 9 cat list out ns top il delta top t1 0 0 0 0 5 0 01 6 0 0 0 8 0 01 11 0 0 0 15 0 du 20 0 0 0 204 0 11 33 0 0 0 mti ScheduleWa
155. name mti GetRegionFullName regid mti PrintFormatted Region s n region name mti VsimFree region name generic list mti GetGenericList regid printGenericList generic list 1 void loadDoneCB void param mti PrintMessage nLoad Done phase n printRegionInfo top printRegionInfo instl printRegionInfo instl il printRegionInfo instl flip printRegionInfo top instl toggle 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 kil foreign attribute TE mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB loadDoneCB 0 mti PrintMessage nElaboration phase n mti PrintMessage Foreign function generics n printGenericList generics 0 ModelSim FLI Reference FLI 280 FLI function definitions HDL code package my pkg is type bigtime is range 0 to integer high units hour day 24 hour week 7 day month 4 week year 12 month end units type intarray is array 1 to 3 of integer type realarray is array 0 to 2 of real type timearray is array 2 to 4 of time type bigtimearray is array 1 to 3 of bigtime end my pkg entity for model is generic whoami string Don t know end for
156. of a architecture is initForeign for model sl begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output vsim c t 10ps top Reading modeltech tcl vsim pref tcl 5 4b vsim c t 10ps top Loading modeltech sunos5 std standard Loading work top a Loading work for_model a Loading for model sl The resolution limit of the simulator is 10 ps VSIM 1 quit vsim c t 100fs top Reading modeltech tcl vsim pref tcl 5 4b vsim c t 100fs top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl The resolution limit of the simulator is 100 fs VSIM 1 quit 9 vsim c top ModelSim FLI Reference mti GetResolutionLimit FLI 351 Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl The resolution limit of the simulator is 1 ns VSIM 1 quit ModelSim FLI Reference FLI 352 FLI function definitions mti GetRunStopTimer Syntax Returns Arguments Description Gets the stop time of the current simulation run mti GetRunStopTime stop time Nothing N
157. of a type mti TickDir FLI 647 Syntax direction mti TickDir type id Returns Name Type Description direction mtiInt32T 1 for ascending 1 for descending or 0 for no direction Arguments Type Description mtiTypeldT A handle to a VHDL type Description mti TickDir returns the index direction of an array type or the range direction of any type that has a range Related functions mti TickHigh FLI 651 mti TickLeft FLI 654 mti TickLength FLI 657 mti TickLow FLI 661 mti TickRight FLI 664 Example FLI code include mti h static char getTypeStr mtiTypeIdT switch mti GetTypeKind typeid case MTI TYPE SCALAR case MTI TYPE ARRAY case MTI TYPE RECORD case MTI TYPE ENUM case MTI TYPE PHYSICAL return return return return return typeid Scalar Array Record Enumeration Physical ModelSim FLI Reference FLI 648 FLI function definitions case MTI TYPE REAL return Real case MTI TYPE TIME return Time default return UNKNOWN static char getDirStr mtiTypeIdT typeid switch mti_TickDir typeid case 1 return Descending case 0 return No direction case 1 return Ascending default return UNKNOWN static void initInstance void param mtiSignalIdT sigid mtiTypeIdT typeid mti PrintMessage Design Signals n for sigid mti FirstSignal mti GetTopRegion
158. order therefore each driver name can be associated with a value mti GetDriverNames returns the same information as the driver name part of the output of the drivers command Related functions mti GetDriverValues FLI 262 mti GetDrivingSignals FLI 267 ModelSim FLI Reference FLI 254 FLI function definitions Example ModelSim FLI Reference FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC 4 STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType typedef struct char signame mtiProcessIdT procid mtiSignalIdT sigid instanceInfoT char convertStdLogicValue mtilnt32T sigval char retval switch sigval case STD_LOGIC_U retval U break case STD LOGIC X retval X break case STD LOGIC 0 retval 0 break case STD LOGIC 1 retval 1 break case STD LOGIC 2 retval Z break case STD LOGIC W retval W break case STD LOGIC L retval L break case STD LOGIC H retval H break case STD LOGIC D retval break default retval break return retval void checkSignal void param char drv_names char drv_values instanceInfoT inst instanceInfoT param int ir mtilnt32T names length mtilInt32T sigval mtilnt32T values length sigval mti GetSigna
159. ports for the foreign model instanceInfoT inst inst instanceInfoT mti Malloc sizeof instanceInfoT inst gt sigid mti FindSignal top sl1 inst procid mti CreateProcess sigWatcher watchSignal inst HDL code entity for model is end for model architecture a of for model is mti Free FLI 221 attribute foreign of a architecture is initForeign for model sl begin end a library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal sl std logic 0 component for model is end component for all for model use entity work for model a begin sl lt not sl after 5 ns il for model end a Simulation output 9 vsim c top Reading modeltech 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 50 Time 0 0 delta 0 Signal top sl is 0 Time 0 5 delta 0 Signal top sl is 1 Time 0 10 delta Signal top sl is 0 Time 0 15 delta Signal top sl is 1 Time 0 20 delta Signal top sl is 0 Time 0 25 delta Signal top sl is 1 Time 0 30 delta Signal top sl is 0 Turning off signal watcher VSIM 2 quit CX G4 x gt x15 ModelSim FLI Reference FLI 222 FLI function definitions mti GetArrayElementType
160. postponed func immed name normal name synch name nba name postponed name break case 3 immed func normal func synch func nba func postponed func immed name normal name synch name nba name postponed name break case 4 immed func normal func synch func nba func postponed func immed name normal name synch name nba name postponed name break nbaProcess2 postponedProcess2 immedProcess3 normalProcess3 synchProcess3 nbaProcess3 postponedProcess3 immedProcess3 normalProcess3 synchProcess3 nbaProcess3 postponedProcess3 immedProcess4 normalProcess4 synchProcess4 nbaProcess4 postponedProcess4 immedProcess4 normalProcess4 synchProcess4 nbaProcess4 postponedProcess4 immedProcess5 normalProcess5 synchProcess5 nbaProcess5 postponedProcess5 immedProcess5 normalProcess5 synchProcess5 nbaProcess5 postponedProcess5 mti CreateProcessWithPriority FLI 135 inst immed procid i mti CreateProcessWithPriority immed name inst normal procid i inst sync inst nba inst post postponed name mti AddQuitC h procid i procid i poned procid i postponed func B cleanupCallback mti AddRestartCB cleanupCallback immed func inst MTI PROC IMMEDIATE mti CreateProcessWithPriority normal name normal func inst MTI PROC NORMAL
161. process Instead the load done callbacks see mti_AddLoadDoneCB FLI 65 are called Related functions Example mti_AddRestoreCB FLI 74 mti_AddSaveCB FLI 80 mti_RemoveRestoreDoneCB FLI 551 FLI code include lt stdlib h gt include lt mti h gt static char instance_info ModelSim FLI Reference FLI 78 ModelSim FLI Reference FLI function definitions void saveCallback void param char inst_info char param mti PrintFormatted Saving instance info s n inst info mti SaveString inst info void restoreCallback void param char inst info char param strcpy inst info mti RestoreString mti PrintFormatted Restored instance info s n instance info void restoreDoneCallback void param char inst info char param mti PrintFormatted Ss Restore complete n inst info void cleanupCallback void param mti_PrintMessage Cleaning up n free param void initForeign mtiRegionIdT region The ID of the region in which this EL foreign architecture is instantiated char param The last part of the string in the y foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model instance info malloc strlen param 1 strcpy instance info param mti AddSaveCB saveCallback in
162. procid 0 mti SetDriverOwner inst drvid3 procid mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst mti VsimFree elem list ModelSim FLI Reference FLI 112 FLI function definitions ModelSim FLI Reference HDL code entity top is end top architecture a of top is signal sl bit 0 begin sl lt not sl after 5 ns end a Simulation output vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading work top a Loading for model sl VSIM 1 examine mysig 000 VSIM 2 run 5 VSIM 3 examine mysig 1 0 X VSIM 4 gt run 5 VSIM 5 gt examine mysig 0 1X VSIM 6 gt run 5 VSIM 7 gt examine mysig 1 i 1 VSIM 8 quit Cleaning up mti CreateDriver FLI 113 mti CreateDriver Syntax Returns Arguments Description Creates a driver on a VHDL signal driver id mti CreateDriver signal id Name Type Description driver id mtiDriverldT A handle to the new driver or NULL if there is an error Name Type Description signal_id mtiSignalldT A handle to a VHDL signal mti_CreateDriver creates a new driver for the specified array or scalar signal A driver must be created for a resolved signal in order to be able to drive values onto that signal and have the values be
163. real s real vector VARIABLE result real 0 0 BEGIN IF s LENGTH 1 THEN RETURN s s LOW ELSE FOR i IN s RANGE LOOP result result s i END LOOP END IF RETURN result END resolve real FUNCTION resolve time s time vector VARIABLE result time 0 ns BEGIN IF s LENGTH 1 THEN RETURN s s LOW ELSE mti SignallsResolved FLI 643 of resbit of resint of resreal of restime of resphys RETURN bit IS RETURN integer IS RETURN real IS RETURN time IS ModelSim FLI Reference FLI 644 FLI function definitions FOR i IN s RANGE LOOP result END LOOP END IF RETURN result END resolve time result s i FUNCTION resolve phys s phys vector RETURN bigtime IS VARIABLE result bigtime 0 hour BEGIN IF s LENGTH 1 THEN RETURN s s LOW ELSE FOR i IN s RANGE LOOP result result s i END LOOP END IF RETURN result END resolve_phys end package body typepkg library ieee use ieee std_logic_1164 all use work typepkg all entity top is end top architecture a of top is Unresolved scalars signal bitsigl bit 1 signal intsigl integer 21 signal realsigl real 21 21 signal timesigl time 21 ns signal physsigl bigtime 21 hour signal stdulogicsigl std ulogic L Scalars with resolved types signal resbitsigl resbit r 0 signal resintsigl resint 42 signal resrealsigl resreal 11 9 signal restimesigl restim
164. restoreCallback instance_info mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info 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 for model begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a ModelSim FLI Reference FLI 472 FLI function definitions Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 45 VSIM 2 checkpoint cpfile Saving instance info for model VSIM 3 quit Cleaning up vsim c top restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Wed Jul 5 11 02 06 2000 Restoring state at time 45 ns iteration 1 Reading modeltech tcl vsim pref tcl oe 5 4b Loading checkpoint restore data from file cpfile Checkpoint created Wed Jul 5 11 02 06 2000 Restoring state at time 45 ns iteration 1 Loading for_model sl Cold Restore in progress Restored instance info for model Simulation kernel restore completed Restoring graphical user int
165. return TCL OK void deleteCB ClientData param instanceInfoT inst info instanceInfoT param mti PrintFormatted Time ld ld delta d n mti NowUpper mti Now mti Delta mti PrintFormatted Deleting old command data for s n inst info model name void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 y foreign attribute v mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model instanceInfoT inst info mtilnterfaceListT portp inst info instanceInfoT malloc sizeof instanceInfoT ASSUME param is less than 100 chars and there are at least two signal ports strcpy inst info model name param portp ports inst info sigl portp gt u port portp portp gt nxt inst_info gt sig2 portp gt u port mti AddTclCommand printSigs printRegionInfo inst info deleteCB mti AddQuitCB cleanupCallback inst info ModelSim FLI Reference FLI 94 FLI function definitions mti AddRestartCB cleanupCallback inst info HDL code library ieee use ieee std_logic_1164 all entity for_model is port inb in bit ins in std logic
166. s6 s6 s6 1 1 0 1 1 s6 1 2 1 3 1 4 2 0 2 1 s6 2 2 2 3 2 4 VSIM 1 gt quit ModelSim FLI Reference mti GetSignalType FLI 381 mti GetSignalTyper Gets the type of a VHDL signal Syntax type id mti GetSignalType signal id Returns Type Description mtiTypeldT A handle to the type ID of the specified signal Arguments Name Type Description signal id mtiSignalldT A handle to a VHDL signal Description mti_GetSignalType returns a handle to the type ID of the specified VHDL signal Related functions None Example FLI code include lt mti h gt static char getTypeName mtiTypeIdT type id switch mti GetTypeKind type id case MTI TYPE SCALAR return SCALAR case MTI TYPE ARRAY return ARRAY case MTI TYPE RECORD return RECORD case MTI TYPE ENUM return ENUM case MTI TYPE PHYSICAL return PHYSICAL case MTI TYPE REAL return REAL case MTI TYPE TIME return TIME default return UNKNOWN static void printSignalInfo mtiSignalIdT sigid int indent ModelSim FLI Reference FLI 382 FLI function definitions char signame int 1 mtiSignallIdT elem list mtiTypeIdT sigtype sigtype mti GetSignalType sigid signame mti GetSignalNameIndirect sigid 0 0 mti PrintFormatted c s is of type s n indent signame getTypeName mti GetSignalType sigid mti
167. signal is found if the signal is connected through a port mapping which includes a type conversion or conversion function or if the higher up signal is a Verilog object Related functions Example None FLI code include mti h void printSignallInfo mtiSignalIdT sigid char signame char regname mtiRegionIdT regid mtiSignalIdT parent ModelSim FLI Reference FLI 302 FLI function definitions ModelSim FLI Reference regid mti GetSignalRegion sigid regname mti GetRegionFullName regid signame mti GetSignalNameIndirect sigid 0 0 mti PrintFormatted The parent of s s is regname signame mti VsimFree signame mti VsimFree regname parent mti GetParentSignal sigid regid mti GetSignalRegion parent regname mti GetRegionFullName regid signame mti GetSignalNameIndirect parent 0 0 mti PrintFormatted s s whose parent is regname signame mti VsimFree signame mti VsimFree regname parent mti GetParentSignal parent if parent regid mti GetSignalRegion parent regname mti GetRegionFullName regid signame mti GetSignalNameIndirect parent 0 0 mti PrintFormatted s s n regname signame mti VsimFree signame mti VsimFree regname else mti_PrintFormatted lt NULL gt n void loadDoneCB void param mtiSignalIdT siga mtiSignalIdT sigb mtiSignalIdT sigc siga mti FindSignal t
168. the conversion characters in the format string mti PrintFormatted prints a formatted message in the Main simulator window and in the transcript file The functionality is similar to the C printf function The format string must contain newline characters where line breaks are desired Related functions Example ModelSim FLI Reference mti PrintMessage FLI 517 FLI code include mti h void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT parent mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s indent region name mti VsimFree region name parent mti HigherRegion region if parent mti PrintFormatted Parent region is s n mti GetRegionName parent else mti PrintFormatted n mti PrintFormatted FLI 515 indent 2 for regid mti_FirstLowerRegion region regid regid mti_NextRegion regid printHierarchy regid indent void loadDoneCB void param mtiRegionIdT regid mti_PrintFormatted nHierarchy n for regid mti GetTopRegion regid regid mti_NextRegion regid printHierarchy regid 1 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 J foreign attribute mtilnterfaceLi
169. the signals driving a signal mti GetParentSignal FLI 301 Gets the higher up VHDL or SystemC signal to which a VHDL or SystemC signal is connected mti GetSignalMode FLI 359 Gets the mode direction of a VHDL signal mti_GetSignalName FLI 363 Gets the simple name of a scalar or top level composite VHDL signal mti GetSignalNamelndirect FLI 367 Gets the full simple name of a VHDL signal including array indices and record subelement names mti GetSignalRegion FLI 372 Gets the region in which a VHDL signal is declared mti GetSignalSubelements FLI 376 Gets the subelements of a composite VHDL or SystemC signal mti GetSignalType FLI 381 Gets the type of a VHDL signal mti GetSignalValue FLI 386 Gets the value of a scalar VHDL signal of type enumeration integer or physical ModelSim FLI Reference FLI 46 FLI functions by category Table 3 FLI signal functions Continued Function Action mti GetSignalValueIndirect FLI 392 Gets the value of a VHDL signal of any type except record mti NextSignal FLI 493 Gets the next VHDL or SystemC signal in a region mti ReleaseSignal FLI 527 Releases a force on a VHDL signal mti SetSignalValue FLI 621 Sets the value of a VHDL signal mti Signallmage FLI 635 Gets the string image of a VHDL signal s value mti SignalIsResolved FLI 639 Indicates w
170. to 4 of bitarray type rectype is record a ibis b integer C real d std logic e 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 instl for model pl process variable bitsig bit 1 variable stdlogicsig std_logic UH variable bitarr bitarray 0110 variable stdlogicarr std logic vector 1 to 4 O1LH variable intarr intarray 10 11 12 variable realarr realarray 11 6 101 22 variable timearr timearray 15 ns 6 ns variable alarr al 1111 0001 0110 variable a2arr a2 0001 0010 t 0100 OTOT y 35 variable rec rectype Sate CO JE Ste SO HOM DOO ys begin bitsig not bitsig stdlogicsig not stdlogicsig bitarr not bitarr intarr 1 intarr 1 1 intarr 2 z intarr 2 1 intarr 3 intarr 3 1 realarr 1 realarr 1 0 5 realarr 2 realarr 2 0 5 timearr 1 timearr 0 timearr 1 1 ns timearr 0 1 ns ModelSim FLI Reference FLI 436 FLI function definitions not alarr 2 alarr 1 not alarr 1 alarr 0 not alarr 0 not a2arr 1 3 not a2arr 1 4 a2arr 2 3 a2arr 2 4 not not ModelSim FLI Reference stdlogicarr not stdlogicarr rec a NOt fec a rec b rec b 1 rec c rec c 2 5 rec d not rec d rec e J not rec e wait for 5 n
171. to aid you in debugging FLI code The primary purpose of the replay facility is to send the replay file to MTI support for debugging co simulation problems or debugging FLI problems for which it is impractical to send the FLI code MTI would still require a copy of the VHDL Verilog part of the design to actually execute a replay but many problems can be resolved with the trace only Invoking a trace ModelSim FLI Reference To invoke the trace call vsim see ModelSim Command Reference with the trace foreign option Syntax vsim trace foreign action tag name Arguments action Specifies one of the following actions Value Action Result 1 create log only writes a local file called mti_trace_ lt tag gt 2 create replay only writes local files called mti_data_ lt tag gt c mti init tag c mti replay tag c and mti top tag c 3 create both log and replay tag lt name gt Used to give distinct file names for multiple traces Optional Examples vsim trace foreign 1 mydesign Creates a logfile FLI tracing FLI 41 vsim trace foreign 3 mydesign Creates both a logfile and a set of replay files vsim trace foreign 1 tag 2 mydesign Creates a logfile with a tag of 2 The tracing operations will provide tracing during all user foreign code calls including VHDL foreign process callbacks and Verilog VCL callbacks The miscellaneous VHDL callbacks LoadC
172. top modeltech tcl vsim pref tcl top modeltech sunos5 std standard work top a work mid a work inv b work for model a for model sl hy top on top instl ocess line 72 Variable genl ocess line 71 Variable genl ocess testproc Variable genl Variable cl Variable v1 Variable v2 Variable v3 gion top instl flip Process pl Variable delay Variable increment Variable count Process line 19 Variable delay gion top inst1 il gion top insti toggle Process pl Variable delay Variable increment Variable count Process line 19 Variable delay uit mti Now Syntax Returns Arguments Description Gets the low order 32 bits of the 64 bit current simulation time low time mti Now Name Type Description mti Now FLI 501 low time mtiInt32T None The low order 32 bits of the current simulation time mti Now returns the low order 32 bits of the current simulation time The time units are equivalent to the current simulator time unit setting Related functions Example mti Delta FLI 157 mti GetResolutionLimit FLI 348 mti Nowlndirect FLI 505 mti NowUpper FLI 510 FLI code include lt mti h gt typedef struct signalInfoT tag struct signalInfoT tag next char name mtiSignalldT sigid mtiTypeIdT typeid signalInfoT typedef struct signallInfoT sig info List of signals ef mtiProcessIdT proc Test pr
173. top Loading work top a Loading work for model a Loading for model sl The version of the simulator is 2000 VSIM 1 quit architecture is for model a modeltech tcl vsim pref tcl Loading modeltech sunos5 std standard Model Technology ModelSim SE EE PLUS vsim 5 4b Simulator 2000 06 Jun initForeign for model sl 9 mti GetRegionFullName FLI 325 mti GetRegionFullName Gets the full hierarchical name of a region Syntax region name mti GetRegionFullName region id Returns Name Description region name The full hierarchical name of the specified region Arguments Name Type Description region id mtiRegionIdT A handle to a VHDL or Verilog region Description mti GetRegionFullNameY returns the full hierarchical name of the specified VHDL or Verilog region The caller is responsible for freeing the returned pointer with mti VsimFree Related functions mti_GetLibraryName FLI 283 mti GetPrimaryName FLI 311 mti GetRegionName FLI 341 mti GetRegionSourceName FLI 344 mti GetSecondaryName FLI 355 Example FLI code include lt mti h gt void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s n indent region name ModelSim FLI Reference FLI 326 FLI function definitions indent
174. top intsigl printSignalInfo top realsigl printSignalInfo top timesigl printSignalInfo top physsigl printSignalInfo top stdulogicsigl Scalars with resolved types printSignalInfo top resbitsigl printSignalInfo top resintsigl printSignalInfo top resrealsigl printSignalInfo top restimesigl printSignalInfo top resphyssigl printSignalInfo top stdlogicsigl Resolved scalars with unresolved types printSignalInfo top bitsigr printSignalInfo top intsigr printSignalInfo top realsigr printSignalInfo top timesigr printSignalInfo top physsigr printSignalInfo top stdulogicsigr Unresolved 1D arrays printSignalInfo top bitarrl printSignalInfo top intarrl printSignalInfo top realarrl printSignalInfo top timearrl printSignalInfo top physarrl printSignalInfo top stdulogicarrl Elements of unresolved 1D arrays printSignalInfo top bitarr1 3 printSignalInfo top intarr1 2 printSignalInfo top realarr1 3 printSignalInfo top timearr1 0 printSignalInfo top physarrl 1 1D Arrays of resolved subelements oprintSignallnfo top rbitarrl y printSignalInfo top rintarrl printSignalInfo top rrealarrl printSignalInfo top rtimearrl printSignalInfo top rphysarrl printSignalInfo top stdlogic
175. type mti Image FLI 463 Gets the string image of a value of a specific type mti TickDir FLI 647 Gets the direction of a type mti TickHigh FLI 651 Gets the high value of a ranged type mti TickLeft FLI 654 Gets the left value of a ranged type mti TickLength FLI 657 Gets the length of a type mti TickLow FLI 661 Gets the low value of a ranged type mti TickRight FLI 664 Gets the right value of a ranged type ModelSim FLI Reference FLI 48 FLI functions by category Table 7 FLI callback functions Function Action mti AddEnvCB FLI 57 Adds an environment change callback mti_AddLoadDoneCB FLI 65 Adds an elaboration done callback mti AddQuitCB FLI 69 Adds a simulator exit callback mti AddRestartCB FLI 71 Adds a simulator restart callback mti AddRestoreCB FLI 74 Adds a simulator restore callback mti AddRestoreDoneCBY FLI 77 Adds a simulator restore done callback mti AddSaveCB FLI 80 Adds a simulator checkpoint callback mti AddSimStatusCB FLI 83 Adds a simulator run status change callback mti AddInputReadyCB FLI 60 Adds or removes a file pipe input ready callback mti AddOutputReadyCB FLI 68 Adds or removes a file pipe output ready callback mti AddSocketInputReadyCB FLI 85 Adds or removes a socket input ready callback mti Add
176. type rectype is record a 2 bit b integer Cc bitarray end record type bigtime is range 0 to integer high units hour day 24 hour week 7 day month 4 week year 12 month end units end top architecture a of top is signal bitsig bit 1 signal intsig integer 42 signal physsig bigtime 3 hour signal realsig real 10 2 signal timesig time 3 ns signal stdlogicsig std_logic H signal bitarr bitarray 1100 signal intarr intarray 5 7 9 signal stdlogicarr std logic vector 1 to 4 O1LH signal rec rectype imt TOL Oy ULOOLY Jes component for model end component for all for model use entity work for model a begin instl for model bitsig lt not bitsig after 5 ns intsig lt intsig 1 after 5 ns physsig lt physsig 1 hour after 5 ns realsig lt realsig 1 1 after 5 ns timesig lt timesig 2 ns after 5 ns stdlogicsig lt not stdlogicsig after 5 ns bitarr lt not bitarr after 5 ns stdlogicarr lt not stdlogicarr after 5 ns intarr 2 lt intarr 2 1 after 5 ns intarr 1 lt intarr 1 1 after 5 ns intarr 0 lt intarr 0 1 after 5 ns ModelSim FLI Reference FLI 398 FLI function definitions ModelSim FLI Reference rec a lt not rec a after 5 ns rec b lt rec b 1 after 5 ns rec c lt not rec c after 5 ns end a Simulation output 9 vsim c top
177. values val i val i 1 if val i gt mti TickHigh elem type val i lt mti TickLow elem type val i mti TickLeft elem type else char val array_val for i 0 i lt num elems i mti PrintFormatted s enum values val i val i 1 if val i gt mti TickHigh elem type val i lt mti TickLow elem type val i mti TickLeft elem type break case MTI_TYPE_PHYSICAL ModelSim FLI Reference mti GetVarAddr FLI 411 case MTI TYPE SCALAR mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted d val i val i 1 break case MTI_TYPE_ARRAY mti_PrintMessage ARRAY break case MTI_TYPE_RECORD mti PrintMessage RECORD break case MTI TYPE REAL double val array_val for i 0 i lt num_elems i mti PrintFormatted g val i val i 1 1 break case MTI_TYPE_TIME mtiTime64T val array_val for i 0 i lt num_elems i mti PrintFormatted d d MTI TIME64 HI32 val i l MTI TIME64 LO32 val il MTI TIME64 ASGN val i MTI TIME64 HI32 val il MTI TIME64 LO32 val i 1 break default break mti_PrintFormatted n break case MTI_TYPE_RECORD mti PrintFormatted RECORD break case MTI TYPE REAL mti PrintFormatted g n double varinfo var addr double vari
178. void cleanupCallback void param mti_PrintMessage Cleaning up n free param void loadDoneCallback void param instanceInfoT inst param inst il last value mti GetSignalValue inst gt il_sigid inst i2 last value mti GetSignalValue inst gt i2_sigid inst i3 last value mti GetArraySignalValue inst i3 sigid 0 inst i3 value length mti TickLength mti GetSignalType inst i3 sigid inst tl last value mti GetSignalValue inst gt tl_sigid inst 5t2 last value mti GetSignalValue inst gt t2_sigid inst 5t3 last value mti GetArraySignalValue inst 5t3 sigid 0 inst t3 value length mti TickLength mti GetSignalType inst t3 sigid 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 mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model instanceInfoT inst inst instanceInfoT malloc sizeof instanceInfoT inst procid mti CreateProcess SignalDriver driveSignal inst inst delay convertToNS 1 mti ScheduleWakeup inst procid inst delay inst il sigid mti FindSignal top il inst il drvid mti CreateDriver inst gt il_sigid mti SetDriverOwner inst il drvid inst procid
179. 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 ModelSim FLI Reference FLI 70 FLI function definitions foreign attribute x7 mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model char instance info instance info malloc strlen param 1 strcpy instance info param mti AddQuitCB quitCallback instance info 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 for model begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model S lt not sl after 5 ns end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 quit Cleaning up for model for simulator exit ModelSim FLI Reference mti AddRestartCB FLI 71 mti AddRestartCB Adds a simulator restart callback Syntax mti AddRestartCB func param Returns Nothing Arguments Typ
180. vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading for_model sl VSIM 1 run 50 Time 0 15 delta 0 Signal sl is UNKNOWN Simulation halt requested by foreign interface Stopped at top vhd line 27 VSIM 2 drivers top s1 Drivers for top s1l W Signal top s1 W Driver top pl VSIM 3 cont Time 0 40 delta 0 Signal sl is UNKNOWN Simulation halt requested by foreign interface Stopped at top vhd line 27 VSIM 4 drivers top s1 Drivers for top sl X Signal top s1 X Driver top pl VSIM 5 quit mti Break FLI 101 ModelSim FLI Reference FLI 102 FLI function definitions mti Cmd Syntax Returns Arguments Description Executes a simulator command with Tcl return status and no transcribing tcl status mti Cmd command Name Description tcl status TCL OK if the command is successful or TCL ERROR if there is an error Description A simulator command mti Cmd causes the specified command to be executed by the simulator The string must contain the command just as it would be typed at the VSIM prompt The results of the command are not transcribed into the vsim transcript but they can be obtained by using the Tcl interp pointer See mti Interp FLI 467 The command result should be reset using Tcl ResetResult aft
181. 0 HDL code entity for model end for model is mti CreateProcess Test Process void inst data 5 checkValues region The ID of the region in which this EPA foreign architecture is instantiated param The last part of the string in the x foreign attribute EL A list of generics for the foreign model A list of ports for the foreign model AY architecture a of for model is attribute foreign of a begin end a library ieee use ieee std logic 1164 all entity top is architecture is initForeign for model sl array 3 downto 0 of bit array 1 to 3 of integer array 1 to 2 of real array 1 to 0 of time type bitarray is type intarray is type realarray is type timearray is type rectype is record a bit b integer c real d std logic e bitarray end record end top architecture a of top is component for model end component for all begin instl pl process variable bitsig ModelSim FLI Reference for model for model use entity work for_model a bit mti SetVarValue FLI 633 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 O1LH variable intarr intarray 10 11 12 variable realarr realarray 11 6 101
182. 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 end top architecture a of top is component for model end component for all for model use entity work for model a begin instl for model ModelSim FLI Reference FLI 414 FLI function definitions pl process variable bitsig bit s TIT 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 O1LH variable intarr intarray T0 ll 12 5 variable realarr realarray 11 6 101 22 variable timearr timearray 15 ns 6 ns begin wait for 5 ns end process end a Simulation output vsim c top Reading modeltech 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 16 Time 0 5 Variable bitsig 1 Variable intsig 21 Variable realsig 16 35 Variable timesig 0 5 Variable stdlogicsig H Variable bitarr 0 1 fl OQ Variable stdlogicarr 0 1 L H Variable intarr 10 11 12 Variable realarr 11 6 101 22 Variable timearr 0 15 0 6 Time 0 10 Variable bitsig Qt Variable intsig 22 Variable rea
183. 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 amp bit b integer C real ModelSim FLI Reference FLI 238 FLI function definitions d std logic e 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 instl for model pl process variable bitsig BLE oe FILS 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 OILH variable intarr intarray 10 11 12 variable realarr realarray 11 6 101 22 variable timearr timearray 15 ns 6 ns variable rec rectype 2S ue NO No IE Sud BEL NIEDOOIT ys begin bitsig not bitsig intsig intsig 1 realsig 7 realsig 1 5 timesig timesig 1 ns stdlogicsig not stdlogicsig bitarr not bitarr intarr 1 intarr 1 1 intarr 2 intarr 2 1 intarr 3 intarr 3 1 realarr 1 realarr 1 0 5 realarr 2 realarr 2 0 5 timearr 1 timearr 1 1 ns timearr 0 timearr 0 1 ns stdlogicarr not stdlogicarr rec a not rec a rec b rec b 1 rec c rec c 2 5 rec d not rec d rec e not rec e wait for 5 ns ModelSim
184. 2 restart f Restart callback Param is for model test global 42 Setting test global to initial value of 15 Simulation has been restarted test global 15 Setting test global to 3 VSIM 3 run 100 VSIM 4 restart f Restart callback Param is for model test global 3 Setting test global to initial value of 15 Simulation has been restarted test global 15 Setting test global to 3 VSIM 5 quit Cleanup callback Freeing param for model test global 3 mti KeepLoaded FLI 481 ModelSim FLI Reference FLI 482 FLI function definitions mti Malloc Allocates simulator managed memory Description Type A pointer to the allocated memory Description unsigned long The size in bytes of the memory to be allocated Syntax memptr mti Malloc size Returns Name memptr Arguments Description mti Malloc allocates a block of memory of the specified size from an internal simulator memory pool and returns a pointer to it The memory is initialized to zero Memory allocated by mti Malloc is automatically checkpointed On restore this memory is guaranteed to be restored to the same location with the values it contained at the time of the checkpoint This memory can be freed only by mti Free mti Malloc automatically checks for a NULL pointer In the case of an allocation error mti Malloc issues the following error message and aborts the simulation
185. 3 2 2 You may need to add the location of libgcc_s so 1 to the LD LIBRARY PATH environment variable cc compiler cc v xarch v9 O I install dir modeltech include c app c ld G B symbolic app o o app so lc When using B symbolic with ld all symbols are first resolved within the shared library at link time This will result in a list of undefined symbols This is only a warning for shared libraries and can be ignored See Using 64 bit ModelSim with 32 bit FLI Applications FLI 34 for more information on 64 bit platforms 32 bit HP700 platform A shared library is created by creating object files that contain position independent code use the z or fpic compiler option and by linking as a shared library use the b linker option If your foreign module uses anything from a system library you ll need to specify that library when you link your foreign module For example to use the standard C library specify Ic to the Id command gcc compiler gcc c fpic I install dir modeltech include app c ld b o app sl app o lo cc compiler cC c z DD32 I install dir modeltech include app c ld b o app sl app o lc Note that fpic may not work with all versions of gcc ModelSim FLI Reference FLI 28 Introduction 64 bit HP platform cc compiler cc v DD64 O I install dir modeltech include c app c ld b o app so app o lc See Using 64 bit ModelSim with 32 bit FLI Applica
186. 30 VSIM 4 checkpoint my other cp file Saving instance info for model Checkpoint filename is my other cp file VSIM 5 run 40 VSIM 6 restore my checkpoint file Loading checkpoint restore data from file my checkpoint file Checkpoint created Fri Jun 23 10 18 12 2000 Restoring state at time 20 ns iteration 1 Restored instance info for model Checkpoint filename is my checkpoint file VSIM 7 run 10 VSIM 8 quit Cleaning up ModelSim FLI Reference FLI 248 FLI function definitions mti GetCurrentRegion Gets the current elaboration region during elaboration or the current environment during simulation Syntax region id mti GetCurrentRegion Returns Name Type Description region id mtiRegionIdT A handle to the current region Arguments None Description During elaboration mti_GetCurrentRegion returns the region ID of the current elaboration region During simulation mti_GetCurrentRegion returns the region ID of the current environment set by the environment command The region ID returned by mti_GetCurrentRegion can be either a VHDL Verilog or SystemC region A handle to a Verilog region can be used with PLI functions to obtain information about or access objects in the Verilog region Related functions mti_GetCallingRegion FLI 240 mti_GetRegionKind FLI 328 Example FLI code include lt mti h gt void doProc void char region_name mtiRegionIdT regid
187. 600000000 Signal intsig 762 Time 0 4100000000 Signal intsig 862 Time 305032704 Signal intsig 962 Time 805032704 Signal intsig 1062 Time 1305032704 Signal intsig 1162 Time 1805032704 Signal intsig 1262 Time 2305032704 Signal intsig 1362 Time 72805032704 Signal intsig 1462 Time 1 3305032704 Signal intsig 1562 Time 1 3805032704 Signal intsig 1662 Time 2 10065408 Signal intsig 1762 Time 2 510065408 Signal intsig 1862 Time 2 1010065408 Signal intsig 1962 VSIM 2 gt quit Signal realsig 3 622000e 02 Signal realsig 4 722000e 02 Signal realsig 5 822000e 02 Signal realsig 6 922000e 02 Signal realsig 8 022000e 02 Signal realsig 9 122000e 02 Signal realsig 1 022200e 03 Signal realsig 1 132200e 03 Signal realsig 1 242200e 03 Signal realsig 1 352200e 03 Signal realsig 1 462200e 03 Signal realsig 1 572200e 03 Signal realsig 1 682200e 03 Signal realsig 1 792200e 03 Signal realsig 1 902200e 03 Signal realsig 2 012200e 03 Signal realsig 2 122200e 03 mti NowUpper FLI 513 ModelSim FLI Reference FLI b14 FLI function definitions mti PrintFormatted Syntax Returns Arguments Description Prints a formatted message to the Main window transcript mti PrintFormatted format Nothing Description The formatted string to be printed Zero or more arguments corresponding to
188. 64 HI32 array val i MTI TIME64 LO32 array val i 1 mti_SetSignalValue sigid long array_val mti VsimFree array val break break case MTI_TYPE_RECORD int i ModelSim FLI Reference FLI 624 FLI function definitions mtiSignalIdT elem list elem list mti GetSignalSubelements sigid 0 for i 0 i lt mti TickLength sigtype i setValue elem list i mti GetSignalType elem list i mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetSignalValueIndirect sigid amp real val real val 1 1 mti SetSignalValue sigid long amp real val break case MTI_TYPE_TIME mtiTime64T time_val mti GetSignalValueIndirect sigid amp time val MTI TIME64 ASGN time val MTI TIME64 HI32 time val MTI TIME64 LO32 time val 1 mti SetSignalValue sigid long amp time val break default break static void checkValues void inst_info instanceInfoT inst data instanceInfoT inst info signallInfoT siginfo mti PrintFormatted Time d d n mti NowUpper mti Now for siginfo inst data sig info siginfo siginfo siginfo gt next mti PrintFormatted Signal s s n siginfo gt name mti Signallmage siginfo gt sigid setValue siginfo sigid siginfo gt typeid mti ScheduleWakeup inst data proc 5 static signallnfoT setupSignal mtiSignalIdT sigid signallIn
189. 654 mti TickLength FLI 657 mti TickLow FLI 661 Example FLI code include lt mti h gt static char getTypeStr mtiTypeIdT typeid switch mti_GetTypeKind typeid case MTI_TYPE_SCALAR return Scalar case MTI_TYPE_ARRAY return Array case MTI_TYPE_RECORD return Record case MTI_TYPE_ENUM return Enumeration ModelSim FLI Reference mti TickRight FLI 665 case MTI TYPE PHYSICAL return Physical case MTI TYPE REAL return Real case MTI TYPE TIME return Time default return UNKNOWN static void initInstance void param mtiSignalIdT sigid mtiTypeIdT typeid mti PrintMessage Design Signals n for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal typeid mti GetSignalType sigid mti PrintFormatted 14s type 12s left d right d n mti GetSignalName sigid getTypeStr typeid mti TickLeft typeid mti TickRight typeid 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 y foreign attribute mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model FL mti AddLoadDoneCB initInstance 0 HDL code entity for model is end for model architecture a of for model is attribute f
190. 7 A list of generics for the foreign model A list of ports for the foreign model instance info malloc strlen param 1 strcpy instance info param mti AddRestartCB restartCal HDL code entity for model is end for model architecture a of for model is lback instance info for model attribute foreign of a architecture is initForeign for model sl begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a K Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 10 VSIM 2 restart f Cleaning up for model for simulator restart Loading for model sl VSIM 3 quit mti AddRestartCB FLI 73 ModelSim FLI Reference FLI 74 FLI function definitions mti AddRestoreCB Adds a simulator restore callback Syntax mti AddRestoreCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function to be called when the simulator does a restore void A parameter to be passed to the function OPTIONAL can be NULL Description mti AddRestoreCB adds the
191. 87 Saving string Howdy VSIM 3 run 40 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 16 09 02 2000 Restoring state at time 20 ns iteration 1 Restoring instance info my for model Restoring char Z Restoring long 123456 Restoring short 587 Restoring string Howdy VSIM 5 run 10 VSIM 6 quit mti SaveShort FLI 591 ModelSim FLI Reference FLI 592 FLI function definitions mti SaveString Saves a null terminated string to the checkpoint file Syntax mti SaveString data Returns Nothing Arguments Description A pointer to a null terminated string Description mti SaveString saves the specified null terminated string to the checkpoint file mti SaveString is designed to handle strings of unlimited size Related functions mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveShort FLI 589 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param ModelSim FLI Reference mti SaveString FLI 593 char tmp char Z char tmp str Howdy long tmp long 123456 short tmp short 587 nSavin instance info VSN Tas g si
192. 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 a11 entity top is type bitarray is array 3 downto 0 of bit type intarray is array 1 to 3 of integer type rectype is record a real b xtd logic C bitarray end record end top architecture a of top is signal bitsigl Pit 1 signal stdlogicsigl std logic 1 signal bitarrl bitarray 0110 signal stdlogicarrl std logic vector 1 to 4 O1LH signal intarrl intarray 10 11 12 signal strarrl string 1 to 5 hello signal recl rectype IA UU UL DOOT y component for model end component for all for model use entity work for model a begin instl for model bitsig lt not bitsigl after 5 ns stdlogicsigl lt not stdlogicsigl after 5 ns bitarr lt not bitarrl after 5 ns intarr1 1 lt intarrl 1 1 after 5 ns intarr1 2 lt intarr1 2 1 after 5 ns intarr1 3 lt intarr1 3 1 after 5 ns stdlogicarrl lt not stdlogicarrl after 5 ns ModelSim FLI Reference mti GetArrayElementType FLI 225 strarrl lt there after 10 ns recl a lt recl a 1 1 after 5 ns recl b lt not recl b after 5 ns recl c not recl c after 5 ns end a Simulation output vsim c
193. B FLI 74 mti AddRestoreDoneCB FLI 77 mti AddSaveCB FLI 80 mti AddSimStatusCB FLI 83 mti AddSocketInputReadyCB FLI 85 mti AddSocketOutputReadyCB FLI 90 mti AddTclCommand FLI 91 mti AskStdin FLI 96 mti Break FLI 99 mti Cmd FLI 102 mti Command FLI 105 mti CreateArrayType FLI 108 mti CreateDriver FLI 113 mti CreateEnumType FLI 118 mti CreateProcess FLI 123 mti CreateProcessWithPriority FLI 128 mti CreateRealType FLI 139 mti CreateRegion FLI 142 mti CreateScalarType FLI 146 mti CreateSignal FLI 149 mti CreateTimeType FLI 154 mti Delta FLI 157 mti Desensitize FLI 160 mti FatalError FLI 164 mti FindDriver FLI 167 mti FindPort FLI 170 mti FindProjectEntry FLI 173 mti FindRegion FLI 177 mti FindSignal FLI 182 mti FindVar FLI 187 ModelSim FLI Reference mti FirstLowerRegion FLI 191 mti FirstProcess FLI 195 mti FirstSignal FLI 199 mti FirstVar FLI 203 mti ForceSignal FLI 208 mti Free FLI 219 mti GetArrayElementType FLI 222 mti GetArraySignalValue FLI 226 mti_GetArray VarValue FLI 233 mti_GetCallingRegion FLI 240 mti_GetCheckpointFilename FLI 245 mti_GetCurrentRegion FLI 248 mti_GetDriverNames FLI 253 mti_GetDriverSubelements FLI 258 mti_GetDriverValues FLI 262 mti_GetDrivingSignals FLI 267 mti_GetEnumValues FLI 271 mti_GetGenericList FLI 277 mti_GetLibraryName FLI 283 mti_GetNextEventTime FLI 287 mti_GetNextNe
194. DL package or a Verilog region that was not compiled with fast The returned pointer must not be freed Related functions Example mti_GetLibraryName FLI 283 mti GetPrimaryName FLI 311 mti GetRegionFullName FLI 325 mti GetRegionName FLI 341 mti GetRegionSourceName FLI 344 FLI code include mti h static void printRegionInfo char region char char primary_name region_name ModelSim FLI Reference FLI 356 FLI function definitions ModelSim FLI Reference Char Secondary name mtiRegionIdT regid regid mti FindRegion region region name mti GetRegionFullName regid primary name mti GetPrimaryName regid Secondary name mti GetSecondaryName regid mti PrintFormatted Region s Primary name is s Secondary name is s n region name primary name Secondary name secondary name lt NULL gt mti VsimFree region name static void initInstance void param mti PrintFormatted Load Done Callback Function n printRegionInfo top printRegionInfo top linstl printRegionInfo top linst2 printRegionInfo top finst printRegionInfo for pkg void initForeign mtiRegionIdT region The ID of the region in which this Sy foreign architecture is instantiated char param The last part of the string in the wf foreign attribute x mtilnterfaceListT generics A list of gen
195. DL signal Syntax mti ScheduleDriver driver id value delay mode Returns Nothing Arguments Name Type Description driver mtiDriverldT A handle to the driver value long void For a signal of scalar type the value to be driven for a signal of real time or array type a pointer to the value to be driven mtiDelayT The delay to be used in terms of the current simulator resolution limit mtiDriverModeT Indicates either inertial or transport delay Description mti_ScheduleDriver schedules a transaction on the specified driver If the signal being driven is of an array real or time type then the value type is considered to be void instead of long The specified delay value is multiplied by the current simulator resolution limit For example if vsim was invoked with t 10ns and the delay was specified as 5 then the actual delay would be 50 ns The mode parameter can be either MTI_INERTIAL or MTI TRANSPORT Related functions mti_CreateDriver FLI 113 mti_ForceSignal FLI 208 mti_GetResolutionLimit FLI 348 mti_ScheduleDriver64 FLI 601 mti SetSignalValue FLI 621 ModelSim FLI Reference FLI 5b96 FLI function definitions Example ModelSim FLI Reference FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC 4 STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D StdLogic
196. Driver inst gt drvidl STD LOGIC 0 0 MTI INERTIAL break case STD LOGIC 0 mti ScheduleDriver inst gt drvidl STD LOGIC 1 5 MTI INERTIAL break case STD LOGIC 1 mti ScheduleDriver inst gt drvidl STD LOGIC 0 5 MTI INERTIAL break case STD LOGIC X region name mti GetRegionFullName mti GetSignalRegion inst sigidl mti PrintFormatted Time d d delta d Signal s s is UNKNOWN Mn mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigidl mti VsimFree region name break default region name mti GetRegionFullName mti GetSignalRegion inst sigidl mti PrintFormatted Time d d delta d Unexpected value d on signal s s n mti NowUpper mti Now mti Delta Sigval region name mti GetSignalName inst gt sigidl mti VsimFree region name break This function inverts mySig2 every 10 ns void dri char instan mtiInt sigval switch case mti brea case mti ModelSim FLI Reference veSignal2 void param region name instanceInfoT param ceInfoT inst 32T sigval mti GetSignalValue inst sigid2 sigval STD_LOGIC_U ScheduleDriver inst drvid2 STD LOGIC 0 0 MTI INERTIAL k STD LOGIC 0 ScheduleDriver inst gt drvid2 STD LOGIC 1 10 MTI INERTIAL mti SetDriverOwner FLI 619 break case STD LOGIC 1 mti ScheduleDriver inst drvid2 STD LOGIC 0 10 MTI INER
197. DriverIdT drvid instanceInfoT void driveSignal void param char region name instanceInfoT inst instanceInfoT param double sigval void mti GetSignalValueIndirect inst sigid amp sigval region name mti GetRegionFullName mti GetSignalRegion inst gt sigid mti PrintFormatted Time d d delta d Signal s s is g n mti NowUpper mti Now mti Delta ModelSim FLI Reference FLI 140 FLI function definitions ModelSim FLI Reference region name sigval sigval 1 5 mti ScheduleDriver inst drvid mti VsimFree region name mti GetSignalName inst gt sigid sigval long amp sigval 5 MTI_INERTIAL void cleanupCallback void param mti PrintMessage free param void initForeign mtiRegionIdT char mtilnterfaceListT generics mtilnterfaceListT ports instanceInfoT mtiProcessIdT mtiTypeIdT inst real_type inst gt sigid inst gt drvid procid mti_Sensitize procid Cleaning up n region The ID of the region in which this foreign architecture is instantiated param The last part of the string in the x foreign attribute Ef A list of generics for the foreign model A list of ports for the foreign model 7 FLSE procid real type instanceInfoT malloc sizeof instanceInfoT mti CreateRealType mti CreateSignal mti CreateDriver inst gt sigid mti CreatePro
198. EVENT The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute Y L A list of generics for the foreign model A list of ports for the foreign model 0 for model use entity work for model a initForeign for model sl X ModelSim FLI Reference FLI 354 FLI function definitions Simulation output vsim c top Reading 5 4b vsim c top Loading Loading VSIM 1 run 6 Time 0 5 VSIM 2 run 7 Time VSIM 3 run 6 Time VSIM 4 quit ModelSim FLI Reference POLO 3 I 1573 modeltech tcl vsim pref tcl modeltech sunos5 std standard Loading work top a Loading work for model a for model sl Run stop time is 0 6 Run stop time is 0 13 Run stop time is 0 19 mti GetSecondaryName Syntax Returns Arguments Description Gets the secondary name of a VHDL region Sec name Name mti GetSecondaryName FLI 355 mti GetSecondaryName region id Description sec name Name Type The secondary name of the specified region Description region id mtiRegionIdT A handle to a VHDL region mti GetSecondaryName returns the secondary name of the specified region that is an architecture name If the region is not a secondary design unit then the parent secondary design unit is used A NULL is returned if the region is a VH
199. FLI 118 mti CreateRealType FLI 139 mti CreateTimeType FLI 154 mti TickLeft FLI 654 mti TickRight FLI 664 FLI code include lt stdlib h gt include lt mti h gt typedef struct mtiSignalIdT sigid mti_CreateScalarType FLI 147 mtiDriverIdT drvid instanceInfoT void driveSignal void param char region name instanceInfoT inst instanceInfoT param mtilInt32T sigval sigval mti GetSignalValue inst gt sigid region name mti GetRegionFullName mti GetSignalRegion inst gt sigid mti PrintFormatted Time d d delta d Signal s s is d n mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid sigval sigval sigval 2 mti ScheduleDriver inst drvid sigval 5 MTI INERTIAL mti VsimFree region name void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 E foreign attribute Kl mtiInterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model x instanceInfoT inst mtiProcessIdT procid mtiTypeIdT scalar type inst instanceInfoT malloc sizeof instanceInfoT Scalar type mti CreateScalarType 0
200. FLI 200 FLI function definitions ModelSim FLI Reference sigid mti NextSignal if G srgid k 4 mti PrintFormatted cSignal s n indent mti GetSignalName sigid void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s n indent region name indent 2 printSignals region indent for regid mti FirstLowerRegion region regid regid mti NextRegion regid printHierarchy regid indent mti VsimFree region name void loadDoneCB void param mti PrintMessage nLoad Done phase n printHierarchy mti GetTopRegion 1 void initForeign mtiRegionIdT region The ID of the region in which this QUA foreign architecture is instantiated char param The last part of the string in the f foreign attribute ER mtilnterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB loadDoneCB 0 mti PrintMessage nElaboration phase n printHierarchy mti_GetTopRegion 1 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 entity inv is generic delay time 5 ns port mw In HET b out bit i
201. FLI 517 mti Quit FLI 520 mti Realloc FLI 523 mti ReleaseSignal FLI 527 mti RemoveEnvCB FLI 536 mti RemoveLoadDoneCB FLI 539 FLI 7 mti RemoveQuitCB FLI 542 mti RemoveRestartCB FLI 545 mti RemoveRestoreCB FLI 548 mti RemoveRestoreDoneCB FLI 551 mti RemoveSaveCB FLI 554 mti RemoveSimStatusCB FLI 557 mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveShort FLI 589 mti SaveString FLI 592 mti ScheduleDriver FLI 595 mti ScheduleDriver64 FLI 601 mti ScheduleWakeup FLI 606 mti ScheduleWakeup64 FLI 610 mti Sensitize FLI 614 mti SetDriverOwner FLI 617 mti SetSignalValue FLI 621 mti SetVarValue FLI 628 mti Signallmage FLI 635 mti SignalIsResolved FLI 639 mti TickDir FLI 647 mti TickHigh FLI 651 mti TickLeft FLI 654 mti TickLength FLI 657 mti TickLow FLI 661 mti TickRight FLI 664 mti VsimFree FLI 667 mti WriteProjectEntry FLI 670 Index FLI 673 ModelSim FLI Reference FLI 8 ModelSim FLI Reference FLI 9 Introduction Chapter contents Using the VHDL FLI FLI 10 Important concepts FLI 10 Using the VHDL FLI with foreign architectures FLI 11 Using the VHDL FLI with foreign subp
202. FLI Reference 51 53 56 NA 58 59 61 66 0 0 0 0 0 0 1 0 OH ede oO DDD TI ETAT 778 777 777 TI 778 779 0010 0010 1101 0010 0010 0010 1101 0010 pL 1 1 ZUZU 1 1 ISIS Lat ZUZU WXWX 1777 TE 778 777 777 777 778 779 777 GE 778 777 TAXT 777 778 77 9 FEEF TREN 778 777 TITY TALLY 778 779 0 0 0 0 fa 0 1 0 777 777 778 777 777 777 18 779 H H H H H U mti Free Syntax Returns Arguments Description Frees simulator managed memory mti Free pointer Nothing Name mti Free FLI 219 Description pointer A pointer to some memory previously allocated by mti Malloc mti Free returns the specified block of memory allocated by mti Malloc to the vsim memory allocator mti Free cannot be used for memory allocated by direct calls to malloc Related functions Example mti_Malloc FLI 482 mti_Realloc FLI 523 mti_VsimFree FLI 667 FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC Z STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType typedef struct mtiSignalIdT sigid ModelSim FLI Reference FLI 220 FLI function definitions ModelSim FLI Reference mtiProcessIdT procid instanceInfoT char conv
203. FLI Reference FLI 456 FLI function definitions ModelSim FLI Reference Time 0 Varia Varia Varia Varia Varia Varia Varia Varia Varia Varia Varia 0 0000006020000 CC 00000000000 4 PLZ ror ro VSIM 2 gt quit bitsig PANT intsig 24 realsig 20 timesig 0 stdlogicsig brt rr allt stdlogicarr intarr 13 realarr I3 timearr 0 rec Ur LIS gt 85 8 Y Te OT 4 wp Tto p ED c rugs 14 15 1 102 72 18 0 9 mti GetWlfFilename mti GetWlfFilename FLI 457 Gets the name of the waveform logfile wlf Syntax filename mti GetWlfFilename Returns Name Description filename A pointer to the name of the waveform logfile wlf Arguments None Description mti GetWlfFilename returns the name of the waveform logfile wlf The returned pointer must not be freed Related functions None Example FLI code include lt mti h gt void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports char filename filename mti GetWlfFilename The ID of the region in which this foreign architecture is instantiated The last part of the string in the x foreign attribute x A list of generics for the foreign model A list of ports for the foreign model Ef mti PrintFormatted WLF filename s n filename ModelSim FLI Reference FLI 458 FLI function
204. FLI Reference mti SetSignalValue Sets the value of a VHDL signal mti SetSignalValue FLI 621 Syntax mti SetSignalValue signal id value Returns Nothing Arguments Name Type Description signal id mtiSignalldT A handle to a VHDL signal value long void For a signal of scalar type the value to be set for a signal of real time or array type a pointer to the value to be set Description mti SetSignalValue sets the specified VHDL signal to the specified value immediately The signal can be either an unresolved signal or a resolved signal Setting the signal marks it as active in the current delta If the new value is different than the old value then an event occurs on the signal in the current delta If the specified signal is of type array real or time then the value type is considered to be void instead of long mti SetSignalValue cannot be used to set the value of a signal of type record but it can be used to set the values on the individual scalar or array subelements Setting a resolved signal is not the same as driving it After a resolved signal is set it may be changed to a new value the next time its resolution function is executed mti ScheduleDriver and mti ScheduleDriver64 can be used to drive a value onto a signal Related functions mti ForceSignal FLI 208 mti ReleaseSignal FLI 527 mti ScheduleDriver FLI 595 mti ScheduleDriver64 FLI 601 ModelSim FLI R
205. FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC 4 STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType typedef struct mtiProcessIdT procid mtiSignalIdT sigid mtiDriverIdT drvid instanceInfoT static instanceInfoT inst info char convertStdLogicValue mtiInt32T sigval char retval switch sigval case STD LOGIC U retval U break case STD LOGIC X retval X break case STD LOGIC 0 retval O break case STD LOGIC 1 retval 1 break case STD LOGIC 2 retval Z break case STD LOGIC W retval W break ModelSim FLI Reference mti RestoreProcess FLI 571 case STD LOGIC L retval L break case STD LOGIC H retval H break case STD LOGIC D retval break default retval break return retval void driveSignal void param char region_name instanceInfoT inst instanceInfoT param mtiInt32T sigval region name mti GetRegionFullName mti GetSignalRegion inst sigid sigval mti GetSignalValue inst gt sigid mti PrintFormatted Time d d delta d Signal s s is s n mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid convertStdLogicValue sigval mti VsimFree region name switch sigval case STD LOGIC U sigval STD L
206. FTP Tcl from the Scriptics Inc web site ModelSim FLI Reference FLI 10 Introduction Using the VHDL FLI FLI routines are C programming language functions that provide procedural access to information within Model Technology s HDL simulator vsim A user written application can use these functions to traverse the hierarchy of an HDL design get information about and set the values of VHDL objects in the design get information about a simulation and control to some extent a simulation run The header file mti h externs all of the FLI functions and types that can be used by an FLI application Important concepts ModelSim FLI Reference A good understanding of the following concepts is necessary before creating an FLI application Elaboration When the simulator starts it first goes through an elaboration phase during which the entire design is loaded and connected and initial values are set During this phase all foreign shared libraries are loaded and the initialization functions of all foreign architectures are executed Simulation The simulation phase of the simulator begins when the first run command is executed and continues until a quit or restart command is executed When a restart command is executed the simulator goes through its elaboration phase again Foreign architecture A foreign architecture is a design unit that is instantiated in a design but that does not generally contain any VHDL code Instead it is a
207. Fer char param The last part of the string in the J foreign attribute A mtiInterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model 4 instanceInfoT inst inst instanceInfoT malloc sizeof instanceInfoT inst procid mti CreateProcess SignalDriver driveSignal inst MTI TIME64 ASGN inst delay 1 1 mti ScheduleWakeup64 inst procid inst delay inst il sigid mti FindSignal top il inst il drvid mti CreateDriver inst il sigid mti SetDriverOwner inst il drvid inst procid inst gt tl_sigid mti FindSignal top tl1 inst tl drvid mti CreateDriver inst gt tl sigid mti SetDriverOwner inst tl drvid inst procid mti AddLoadDoneCB loadDoneCallback inst mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst 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 entity top is end top architecture a of top is signal il bit 0 signal tl bit r tOr component for model end component begin forinst for model end a ModelSim FLI Reference Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl vsim c top Loading modeltech sunos5 std standard Loading work top a
208. First call to init function n mti PrintFormatted test global d n test global test global 42 mti PrintFormatted Setting test global to d n test global mti PrintFormatted Shared library will NOT be reloaded n mti KeepLoaded instance info malloc strlen param 1 strcpy instance info param else mti_PrintMessage nSimulation has been restarted n mti PrintFormatted test global d n test global test global 3 mti PrintFormatted Setting test global to d n test global mti AddQuitCB cleanupCallback instance info mti AddRestartCB restartCallback instance info HDL code entity for model is end for model architecture a of for model is attribute foreign of a architecture is initForeign for model sl1 for model begin end a entity top is end top architecture a of top is signal sl bit Q s component for model is end component for all for model use entity work for model a begin il for model ModelSim FLI Reference sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl First call to init function test global 15 Setting test global to 42 Shared library will NOT be reloaded VSIM 1 run 30 VSIM
209. Foreign mtiRegionIdT region The ID of the region in which this foreign architecture is instantiated char param The last part of the string in the x foreign attribute id mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model KJ 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 a11 entity top is type bitarray is array 3 downto 0 of bit type rectype is record a real b std logic Cc bitarray end record end top ModelSim FLI Reference FLI 440 FLI function definitions architecture a of top is component for model end component for all for model use entity work for model a begin instl for model pl process variable bitsig n Bit ies FIs 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 OILH variable rec rectype seo 1 25 0T 1001 J4 begin bitsig not bitsig intsig intsig 1 realsig realsig 1 1 timesig timesig 1 ns stdlogicsig not stdlogicsig bitarr not bitarr stdlogicarr
210. Formatted Found region s n region name mti VsimFree region name regid mti FindRegion instl flip if regid region name mti GetRegionFullName regid mti PrintFormatted Found region s n region name mti VsimFree region name regid mti FindRegion top inst1l toggle if regid region_name mti_GetRegionFullName regid mti_PrintFormatted Found region s n region_name mti VsimFree region name 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 x Ej mtiInterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model ien mti FindRegion FLI 179 char region name mtiRegionIdT regid mti AddLoadDoneCB loadDoneCB 0 mti PrintMessage nElaboration phase n regid mti FindRegion top if regid region name mti GetRegionFullName regid mti PrintFormatted Found region s n region name mti VsimFree region name regid mti FindRegion instl if regid region name mti GetRegionFullName regid mti PrintFormatted Found region s n region name mti VsimFree region name regid mti FindRegion il if regid region name mti GetRegionFullName regid mti PrintFormatted Found region s n regio
211. HDL architecture of fulltype accForeignArch Region top instl my region is an FLI created region of fulltype accShadow Region standard is a VHDL package of fulltype accPackage Region std logic 1164 is a VHDL package of fulltype accPackage Region vl types is a VHDL package of fulltype accPackage Region std logic util is a VHDL package of fulltype accPackage VSIM 1 run all 20 Starting Read Write test 20 Writing data 0000 to addr 00 60 Write miss picking set 3 220 Writing data 0001 to addr 01 260 Write miss picking set 3 420 Writing data 0002 to addr 02 460 Write miss picking set 3 620 Writing data 0003 to addr 03 660 Write miss picking set 3 820 Writing data 0004 to addr 04 860 Write miss picking set 3 1020 Writing data 0005 to addr 05 1060 Write miss picking set 3 1220 Writing data 0006 to addr 06 1260 Write miss picking set 3 1420 Writing data 0007 to addr 07 1460 Write miss picking set 3 1620 Writing data 0008 to addr 08 1660 Write miss picking set 3 1820 Writing data 0009 to addr 09 1860 Write miss picking set 3 2020 Reading from addr 00 2060 Read hit to set 3 2100 Reading from addr 01 2140 Read hit to set 3 2180 Reading from addr 02 2220 Read hit to set 3 2260 Reading from addr 03 2300 Read hit to set 3 2340 Reading from addr 04 2380 Read hit to set 3 2420 Reading from addr 05 2460 Read hit to set 3 2500 Reading from addr 06 2540 Read hit to set 3 2580 Reading from addr 07 2620
212. I 80 simulator exit FLI 69 simulator restart FLI 71 simulator warm restore FLI 74 simulator warm restore done FLI 77 socket input ready FLI 85 socket output ready FLI 90 callback functions FLI 48 checkpoint restore using with the FLI FLI 20 checkpoint restore functions FLI 49 code examples FLI 24 cold restore FLI 470 command executing FLI 102 FLI 105 user defined FLI 54 FLI 91 communication and command functions FLI 50 compiling and linking C applications FLI 25 C applications FLI 30 D data types VHDL mapping to FLI 18 debugging FLI code FLI 42 desensitizing a process FLI 160 documentation FLI iv driver creating FLI 113 finding FLI 167 scheduling a transaction FLI 595 FLI 601 subelements FLI 258 driver functions FLI 46 E elaboration done callback FLI 65 enumeration object values FLI 19 enumeration type creating FLI 118 environment change callback FLI 57 Environment variables used in Solaris linking for FLI FLI 27 within FOREIGN attribute string FLI 11 error FLI 164 examples FLI 24 executing a command FLI 102 exiting the simulator FLI 520 F fatal error FLI 164 foreign architectures FLI 11 FOREIGN attribute declaring FLI 11 foriegn subprograms FLI 13 function categories callback FLI 48 checkpoint restore FLI 49 communication and command FLI 50 driver FLI 46 memory management FLI 48 miscellaneous FLI 50 process FLI 44 region FLI 44 signal FLI 45 time and event FLI 49 type FLI 47 variable FLI 46
213. I FORCE FREEZE 1 1 break case 2 result mti ForceSignal sigid 1 1 TI FORCE FREEZE 7 1 break case 4 result mti ForceSignal sigid 0 1 ModelSim FLI Reference FLI 212 FLI function definitions MTI FORCE DEPOSIT break break default break AE X 1 owesclb 4 fprintf stderr Error in signal force n static void releaseSignal mtiSignalIdT sigid mtiTypeIdT sigtypeid mtiTypeKindT sigtypekind int qs mtiSignalIdT elem list mtiSignalIdT elem sigid mtiTypeIdT elem typeid switch sigtypekind case MTI TYPE SCALAR case MTI TYPE ENUM case MTI TYPE TIME if mti ReleaseSignal sigid fprintf stderr Error in signal release Mn break case MTI_TYPE_ARRAY elem typeid mti GetArrayElementType sigtypeid if mti GetTypeKind elem typeid MTI TYPE ENUM if mti ReleaseSignal sigid fprintf stderr Error in signal release n else elem_list mti_GetSignalSubelements sigid for i 0 i lt mti TickLength sigtypeid elem sigid elem list i 0 1445 elem typeid mti GetSignalType elem sigid releaseSignal elem sigid elem typeid mti GetTypeKind elem typeid mti_VsimFree elem_list break case MTI_TYPE_RECORD elem list mti GetSignalSubelements sigid 0 for i 0 i lt mti GetNumRecordElements sigtypeid elem sigid elem list i elem typeid m
214. IAL else mti ScheduleDriver inst drvid3 SIGVAL X 0 MTI_INERTIAL ModelSim FLI Reference mti CreateEnumType FLI 121 void cleanupCallback void param mti PrintMessage Cleaning up n free param void initForeign mtiRegionIdT char region The ID of the region in which this foreign architecture is instantiated param The last part of the string in the kf foreign attribute uA mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model instanceInfoT inst mtiProcessIdT mtiTypeIdT inst enum type inst sigidl inst gt drvidl procid mti Sensitize procid enum type instanceInfoT malloc sizeof instanceInfoT mti CreateEnumType 1 3 enum lits mti CreateSignal mySigl region enum type mti CreateDriver inst gt sigidl mti CreateProcess mySiglDriver driveSignall inst procid inst gt sigidl MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvidl procid inst sigid2 inst drvid2 procid mti Sensitize mti CreateSignal mySig2 region enum type mti CreateDriver inst gt sigid2 mti CreateProcess mySig2Driver driveSignal2 inst procid inst gt sigid2 MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvid2 procid inst 5sigid3 inst
215. IC_H retval H break case STD_LOGIC_D retval break default retval break return retval void checkSignal void param char drv_names char drv_values instanceInfoT inst instanceInfoT param int ir mtilnt32T names length mtilInt32T sigval mtilnt32T values length sigval mti GetSignalValue inst gt sigid mti PrintFormatted Time d d delta d n mti NowUpper mti Now mti GetDriverValues FLI 263 Signal s is s n mti Delta inst signame convertStdLogicValue sigval mti PrintFormatted Drivers n drv names mti GetDriverNames inst sigid amp names length ModelSim FLI Reference FLI 264 FLI function definitions drv values mti GetDriverValues inst gt sigid amp values length for i 0 i lt names length i mti PrintFormatted s s n convertStdLogicValue drv values il drv names i mti ScheduleWakeup inst procid 5 void cleanupCallback void param mti PrintMessage Cleaning up n free param 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 X foreign attribute DA mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model instanceInfoT inst
216. IdT mtiVariableIdT Not supported Access File Not supported Access Record Not supported gt Note Handles to foreign subprogram parameters non signals are not persistent The handles are no longer valid after the subprogram has exited so they cannot be saved and used later by other foreign code Arrays are not NULL terminated The length of an array can be determined by calling mti TickLength FLI 657 on the array s type Array and record SIGNAL parameters are passed as an mtiVariableIdT type Any array or record subelements of these composite variables are also of type mtiVariableIdT The values of all scalar subelements are of type mtiSignalIdT To access the signal IDs use mti GetVarSubelements FLI 431 at each composite level For each subelement that is of a scalar type use mti GetVarValueIndirect FLI 449 to get the signal ID of the scalar Once you have the signal IDs of the scalar subelements you can use the FLI signal functions to manipulate the signals ModelSim FLI Reference Using the VHDL FLI FLI 15 Matching VHDL return types with C return types Use the table below to match the C return types in your foreign C subprogram to the VHDL return types in your VHDL code VHDL Return Type C Return Type Integer int Enumeration int Real mtiRealT Time mtiTime64T Array Not supported File Not supported Record Not supported Access
217. L is returned The returned handle can be freed with mti_Free FLI 219 The driver remains in effect even if the handle is freed mti_FindDriver essentially returns the first driver in the signal s driver list You cannot tell which driver it is so we don t recommend that you use this driver to drive values from an FLI application Use mti_FindDriver simply to determine whether a signal has any drivers Related functions mti_CreateDriver FLI 113 mti_GetDriverNames FLI 253 mti_GetDriverSubelements FLI 258 mti_GetDriverValues FLI 262 mti_SignallsResolved FLI 639 ModelSim FLI Reference FLI 168 FLI function definitions Example ModelSim FLI Reference FLI code include mti h void loadDoneCB void param mtiDriverIdT mtiSignalldT drvid sigid sigid mti FindSignal drvid top s1 mti FindDriver sigid mti PrintFormatted Driver sfound for top slYn drvid noter sigid mti FindSignal top s2 drvid mti FindDriver sigid mti PrintFormatted Driver sfound for top s2 n drvid not sigid mti FindSignal top s3 drvid mti FindDriver sigid mti PrintFormatted Driver sfound for top s3 n drvid not j sigid mti FindSignal top s4 drvid mti FindDriver sigid mti PrintFormatted Driver sfound for top s4 n drvid ry Ih 3 void initForeign mtiRegionIdT region The ID of the regio
218. LA ASSUME std logic mti ReleaseSignal FLI 529 break case 2 result mti ForceSignal sigid 1000 1 MTI FORCE FREEZE 7 1 break case 4 result mti ForceSignal sigid 0010 1 MTI FORCE DEPOSIT 1 2 break else elem_list mti_GetSignalSubelements sigid 0 for i 0 i lt mti TickLength sigtypeid i elem sigid elem list i elem typeid mti GetSignalType elem sigid forceSignal elem sigid elem typeid mti GetTypeKind elem typeid state mti_VsimFree elem_list break case MTI_TYPE_RECORD elem_list mti_GetSignalSubelements sigid 0 for i 0 i lt mti GetNumRecordElements sigtypeid i elem sigid elem list i elem typeid mti GetSignalType elem sigid forceSignal elem sigid elem typeid mti GetTypeKind elem typeid state mti_VsimFree elem_list break case MTI_TYPE_ENUM if mti TickLength sigtypeid 9 ASSUME std logic switch state case 0 result mti ForceSignal sigid W 1 MTI FORCE FREEZE 1 1 break case 2 result mti ForceSignal sigid O 1 MTI FORCE FREEZE 7 1 break case 4 result mti ForceSignal sigid H 1 MTI FORCE DEPOSIT 1 2 break else switch state ASSUME bit case 0 result mti ForceSignal sigid 0 1 MTI FORCE FREEZE 1 1 break case 2 result mti ForceSignal sigid 1 1 MTI FORCE F
219. LI 535 top recl 1 0 1 0 0 0 0 0 1 0 1 0 0 1 X 1 2 0 0 3 1 0 42 W 1 43 L 0 44 H 1 45 120 0 121 1 122 Z 123 W 777 H 777 H 778 777 H 777 H 777 H 778 779 U ModelSim FLI Reference FLI 536 FLI function definitions mti RemoveEnvCBY Removes an environment change callback Syntax mti RemoveEnvCB func param Returns Nothing Arguments Type Description mtiEnvCBFuncPtrT A pointer to a function being called whenever the simulation environment changes The parameter that was specified in the call to mti_AddEnvCB when the callback was created Description mti_RemoveEnvCB removes the specified function from the environment change callback list The param parameter must be the same parameter that was specified in the call to mti_AddEnvCB when the callback was created Related functions mti_AddEnvCB FLI 57 Example FLI code include mti h void envCallback void param void context mtiRegionIdT region mtiRegionIdT param mti_PrintFormatted Foreign Arch in Region s the current region is now s n mti_GetRegionName region mti GetRegionName mti GetCurrentRegion if mti Now gt 20 mti RemoveEnvCB envCallback param ModelSim FLI Reference void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports
220. LI Reference mti PrintMessage nHierarchy for regid mti GetTopRegion regid regid mti NextRegion regid printHierarchy regid 1 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 y foreign attribute x7 mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is generic delay port a in bit lx ro out bit i end inv time architecture b of inv is begin b lt a after delay end b entity mid is end mid architecture a of mid is signal sl bit 0 signal s2 brt p VOTE signal s3 bit Vs signal s4 bit Ts component for model is end component for all component inv is generic delay port a in bit hv gut Dit time architecture is A list of generics for the foreign model A list of ports for the foreign model EJ initForeign for model sl ov nse Ji for_model use entity work for_model a So AS gt Vi end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top
221. LO oo oOo co FP FP HL iiu g0 UD OUO C C C C IO IO IO INO INO IND IE FS dH E FS FS EA jj E b OO COO Oo C CO C0 C0 CO CO 9 I lo NEFF OO Oo synchProcess1 normalProcess1 immedProcess1 siglImmedProc testProcess postponedProcess5 postponedProcess4 postponedProcess3 postponedProcess2 postponedProcess1 siglImmedProc immedProcess4 immedProcess3 immedProcess2 immedProcess1 normalProcess4 normalProcess3 normalProcess2 normalProcess1 immedProcess2 normalProcess2 synchProcess4 synchProcess3 synchProcess2 synchProcess1 immedProcess3 normalProcess3 synchProcess3 nbaProcess4 nbaProcess3 nbaProcess2 nbaProcess1 immedProcess4 normalProcess4 synchProcess4 nbaProcess4 postponedProcess4 postponedProcess3 postponedProcess2 postponedProcess1 immedProcess5 normalProcess5 synchProcess5 nbaProcess5 postponedProcess5 testProcess sigimmedProc immedProcess1 normalProcess1 immedProcess2 normalProcess2 synchProcess2 synchProcess1 immedProcess3 normalProcess3 synchProcess3 nbaProcess3 nbaProcess2 nbaProcess1 mti CreateProcessWithPriority FLI 137 Scheduling processes ending in 3 Scheduling processes ending in 2 Scheduling processes ending in 5 Scheduling processes ending in 2 Scheduling processes ending in 3 Scheduling processes ending in 4 Scheduling p
222. Length vartype elem type mti GetArrayElementType vartype elem typekind mti GetTypeKind elem type switch elem typekind case MTI TYPE ENUM char enum_values enum values mti GetEnumValues elem type ModelSim FLI Reference mti GetArrayVarValue FLI 235 if mti TickLength elem type 256 mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted s enum_values val i else char val array val for i 0 i lt num elems i mti PrintFormatted s enum_values val i break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted d val i break case MTI_TYPE_ARRAY mti_PrintMessage ARRAY break case MTI_TYPE_RECORD mti PrintMessage RECORD break case MTI TYPE REAL double val array_val for i 0 i lt num elems i mti PrintFormatted g val i break case MTI TYPE TIME mtiTime64T val array_val for i 0 i lt num_elems i mti_PrintFormatted d d MTI TIME64 HI32 val i MTI TIME64 LO32 val il break default break mti_PrintFormatted n break case MTI_TYPE_RECORD int i mtiVariableIdT elem list mtilInt32T num elems elem list mti GetVarSubelements varid 0 num elems mti GetNumRecordEleme
223. M 6 quit mti RestoreChar FLI 565 ModelSim FLI Reference FLI b66 FLI function definitions mti RestoreLong Syntax Returns Arguments Description Gets sizeof long bytes of data from the checkpoint file value mti RestoreLong Description Sizeof long bytes of data None mti RestoreLong returns sizeof long bytes of data from the checkpoint file This function should be called only from a restore callback function It should not be called from an initialization procedure Related functions Example ModelSim FLI Reference mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveShort FLI 589 mti SaveString FLI 592 FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char tmp char Z char tmp str Howdy long tmp long 123456 short tmp short 587 mti PrintFormatted mti SaveBlock mti PrintFormatted mti SaveChar tmp char mti PrintFormatted Saving mti SaveLong tmp long mti PrintFormatted Saving mti SaveShort tmp short mti PrintFormatted Saving mti SaveString tmp str mti PrintFormatted n nSaving instance info s n char amp instance info
224. MTI TYPE RECORD default elem list mti GetSignalSubelements sigid 0 for i 0 i lt mti TickLength sigtype i setValue elem list i mti GetSignalType elem list i mti_VsimFree elem_list break case MTI_TYPE_ENUM if mti TickLength elem type lt 256 char array val mti GetArraySignalValue sigid 0 for i 0 i lt mti TickLength sigtype i array val i if array val i mti TickLow elem type array val i gt mti TickHigh elem type array val i mti TickLeft elem type mti_SetSignalValue sigid long array_val mti VsimFree array val else mtilnt32T array val mti GetArraySignalValue sigid 0 for i 0 i lt mti TickLength sigtype i array val i if array val i mti TickLow elem type array val i gt mti TickHigh elem type array val i mti TickLeft elem type mti_SetSignalValue sigid long array_val mti VsimFree array val break case MTI_TYPE_REAL double array_val mti_GetArraySignalValue sigid 0 for i 0 i lt mti TickLength sigtype i array_val i array_val i 1 1 mti_SetSignalValue sigid long array_val mti VsimFree array val break case MTI_TYPE_TIME mtiTime64T array_val mti_GetArraySignalValue sigid 0 for i 0 i lt mti TickLength sigtype i MTI_TIME64_ASGN array val i MTI TIME
225. ModelSim FLI Reference mti RemoveRestoreCB FLI 549 void restoreCallback void param char inst info char param if param strcpy inst info mti RestoreString mti PrintFormatted Restored instance info s n instance info else mti PrintMessage Restore in progress n void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 J foreign attribute mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model instance info malloc strlen param 1 strcpy instance info param mti AddSaveCB saveCallback instance info mti AddRestoreCB restoreCallback instance info mti AddRestoreCB restoreCallback 0 mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info if strcmp param for model 0 mti RemoveRestoreCB restoreCallback 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 for model begin end a entity top is end top architecture a of top is signal sl bit Q j component for model is
226. NowlIndirect FLI 505 Gets the upper and lower 32 bits of the 64 bit current simulation time ModelSim FLI Reference FLI 50 FLI functions by category Table 10 FLI time and event functions Function Action mti GetNextEventTime FLI 287 Gets the next event time from a foreign subprogram or callback mti GetNextNextEventTime FLI 291 Gets the next event time from a VHDL process mti GetResolutionLimit FLI 348 Gets the simulator resolution limit mti GetRunStopTime FLI 352 Gets the stop time of the current simulation run Table 11 FLI communication and command functions Function Action mti AddCommand FLI 54 Adds a user defined simulator command mti AddTclCommand FLI 91 Adds a user defined Tcl style simulator command mti Interp FLI 467 Gets the Tcl Interp pointer used in the simulator mti Command FLI 105 Executes a simulator command Executes a simulator command with Tcl return status and no transcribing mti Cmd FLI 102 mti AskStdin FLI 96 Prompts the user for an input string mti PrintMessage FLI 517 Prints a message to the main transcript window mti PrintFormatted FLI 514 Prints a formatted message to the main transcript window mti Break FLI 99 Requests the simulator to halt mti FatalError FLI 164 Requests the simulator to halt with a fatal error mti Quit FLI 520 Requests the simu
227. OGIC X break case STD LOGIC X sigval STD LOGIC 0 break case STD LOGIC 0 sigval STD LOGIC 1 break case STD LOGIC 1 sigval STD LOGIC 2 break case STD LOGIC Z2 sigval STD LOGIC W break D D D D case STD LOGIC W sigval STD LOGIC L break LOGIC L sigval STD LOGIC H break LOGIC H sigval STD LOGIC D break case S LOGIC D sigval STD LOGIC U break default sigval STD LOGIC U break case ST case ST mti_ScheduleDriver inst gt drvid sigval 5 MTI_INERTIAL void saveCallback void param mti SaveBlock char amp inst info sizeof inst info void restoreCallback void param mti_RestoreBlock char amp inst_info mti_RestoreProcess inst_info gt procid sigDriver driveSignal inst info void initForeign mtiRegionIdT region The ID of the region in which this y foreign architecture is instantiated char param The last part of the string in the ur foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model if mti_IsFirstInit inst info instanceInfoT mti Malloc sizeof instanceInfoT inst info sigid mti FindSignal top s1l inst info drvid mti CreateDriver inst info sigid inst info procid mti CreateProcess sigDriver ModelSim FLI Reference FLI 572 FLI function definition
228. PrintFormatted C called Afuncl which returned d n retval Compilation instructions gcc c IS MTI HOME include src A c ld G B symbolic o libA so A o gcc c ISMTI HOME include src C c ld G B symbolic o C so C o ldl The following commands illustrate how to compile the files on Solaris See Compiling and linking FLI C applications FLI 25 for instructions on other platforms Shared library dependency FLI 39 Simulation output setenv LD LIBRARY PATH vsim c test do test do foreign initForeign C so Reading modeltech tcl vsim pref tcl vsim do test do foreign initForeign C so c test Loading sunos5 std standard Loading work test a Loading C so Shared lib C initialized Afuncl was called with parameter C calling Afuncl C called Afuncl which returned 17 do test do gt Note The initForeign function in library A is not called by ModelSim because ModelSim does not load library A as a foreign library ModelSim FLI Reference FLI 40 Introduction FLI tracing The foreign interface tracing feature is available for tracing user foreign language calls made to the MTI VHDL FLI Foreign interface tracing creates two kinds of traces a human readable log of what functions were called the value of the arguments and the results returned and a set of C language files to replay what the foreign interface side did The purpose of tracing files The purpose of the logfile is
229. PrintFormatted Time d u Mn mti NowUpper mti Now for siginfo inst data sig info siginfo siginfo siginfo gt next mti PrintFormatted Signal s s n siginfo name mti Signallmage siginfo gt sigid mti ScheduleWakeup inst data proc 500000000 static signallnfoT setupSignal mtiSignalIdT sigid signalInfoT siginfo siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo next ems return siginfo static void initInstance void param instanceInfoT inst_data mtiSignalIdT sigid signalInfoT curr icbtnto signalInfoT eiginfoj inst data mti Malloc sizeof instanceInfoT inst data sig info 0 for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 600000000 void initForeign mtiRegionIdT region The ID of the region in which this E foreign architecture is instantiated char param The last part of the string in the k foreign attribute x mtilnterf
230. Process3 immedProcess3 nbaProcess2 synchProcess2 normalProcess2 immedProcess2 nbaProcess1 architecture is initForeign for model sl for model a Scheduling processes ending in 4 Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time Time O O G O GOG O D NON ON ON ON OM ON ON ON ON OM OM OM ON ON OS oS oS oM NON ON ON ON OS ON ON ON ON OM OM OM ON ON ON oS oS oM CO Oc cccocccooocococcococooccoococcooccocococozcoccoozcococococzcozcocozcococzcococococ5zocccc Per PrP ee ee 0590 C CY tO OOO OS OSS OO Ome CO OO OS CO 0 CO CO C 00 Oo C NON ON ON OS ON ON ON ON oS oS oS oM eO oco ocococococooccoccococo3oocgc OTOT AT AN OOT A GOT UT O1 oa O1 delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta delta O O D
231. ProcessIdT procid mtiSignalIdT il_sigid mtisSignalldT tl sigid mtiDriverIdT il drvid mtiDriverIdT tl drvid long il last value long tl last value instanceInfoT static long invertBit long value if value 0 return 1 else return 0 void driveSignal void param instanceInfoT inst instanceInfoT param mtiTime64T curr_time mti_PrintFormatted Time s Executing driveSignal n mti Image mti NowIndirect amp curr time mti CreateTimeType inst il last value invertBit inst il last value mti ScheduleDriver inst il drvid inst il last value 5 MTI INERTIAL inst tl1 last value invertBit inst gt tl last value mti ScheduleDriver inst gt tl_drvid inst tl last value 5 MTI TRANSPORT mti ScheduleWakeup64 inst procid inst delay MTI TIME64 ASGN inst delay MTI TIME64 HI32 inst delay MTI TIME64 LO32 inst delay 1 void cleanupCallback void param mti_PrintMessage Cleaning up n free param void loadDoneCallback void param instanceInfoT inst instanceInfoT param inst il last value mti GetSignalValue inst il sigid inst tl last value mti GetSignalValue inst gt tl_sigid ModelSim FLI Reference FLI 612 FLI function definitions void initForeign mtiRegionIdT region The ID of the region in which this foreign architecture is instantiated
232. REEZE 7 1 break case 4 result mti ForceSignal sigid 0 1 MTI FORCE DEPOSIT 1 2 ModelSim FLI Reference FLI 530 FLI function definitions break break default break if I result 4 fprintf stderr Error in signal force n static void releaseSignal mtiSignalIdT sigid mtiTypeldT sigtypeid mtiTypeKindT sigtypekind int i mtiSignalIdT elem list mtiSignalIdT elem sigid mtiTypeIdT elem typeid switch sigtypekind case MTI TYPE SCALAR case MTI TYPE ENUM case MTI TYPE TIME if mti ReleaseSignal sigid fprintf stderr Error in signal release n break case MTI_TYPE_ARRAY elem_typeid mti_GetArrayElementType sigtypeid if mti_GetTypeKind elem_typeid MTI_TYPE_ENUM if mti ReleaseSignal sigid fprintf stderr Error in signal release n else elem_list mti_GetSignalSubelements sigid 0 for i 0 i lt mti TickLength sigtypeid i elem sigid elem_list i elem_typeid mti_GetSignalType elem_sigid releaseSignal elem_sigid elem_typeid mti_GetTypeKind elem_typeid mti_VsimFree elem_list break case MTI_TYPE_RECORD elem_list mti_GetSignalSubelements sigid 0 for i 0 i lt mti GetNumRecordElements sigtypeid i elem sigid elem_list i elem_typeid mti_GetSignalType elem_sigid releaseSignal elem_sigid elem_typeid mti_GetTypeKind elem_typeid
233. Read returned 1 Read amp Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read 0 Read returned 1 Read 1 Read returned 1 Read 2 Read returned 1 Read 3 Read returned 1 Read 4 Read returned 1 Read 5 Read returned 1 Read 6 Read returned 1 Read 7 Read returned 1 Read 8 Read returned 1 Read 9 Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read gt Read returned 1 Read Read returned 1 Read Read returned 1 Read A Read returned 1 Read B Read returned 1 Read C Closing socket VSIM 1 quit ModelSim FLI Reference mti AddLoadDoneCBY Adds an elaboration done callback mti AddLoadDoneCB FLI 65 Syntax mti AddLoadDoneCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function to be called at the end of elaboration void A parameter to be passed to the function OPTIONAL can be NULL Description mti_AddLoadDoneCB adds the specified function to the elaboration done callback list The same function can be added multiple times with possibly a different parameter each time At the end of elaboration all callbacks in the list are called with their respective param
234. SIM 2 checkpoint cp file Saving instance info for model VSIM 3 run 30 VSIM 4 restore cp file Loading checkpoint restore data from file cp file Checkpoint created Thu Apr 27 15 52 32 2000 Restoring state at time 20 ns iteration 1 Restored instance info for model VSIM 5 run 10 VSIM 6 quit Cleaning up mti AddRestoreDoneCB FLI 77 mti AddRestoreDoneCBY Adds a simulator warm restore done callback Syntax mti AddRestoreDoneCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function to be called after the simulator completes a warm restore void A parameter to be passed to the function OPTIONAL can be NULL Description mti_AddRestoreDoneCB adds the specified function to the simulator warm restore done callback list The same function can be added multiple times with possibly a different parameter each time After a warm restore is completed but before control is returned to the user all callbacks in the list are called with their respective parameters mti_AddRestoreDoneCB must be called from a foreign initialization function in order for the callback to take effect A foreign initialization function is specified either in the foreign attribute string of a foreign architecture or in the foreign string option of a vsim command For cold restores i e vsim restore restore done callbacks are not called at the end of the restore
235. STD LOGIC VECTOR ARG INTEGER SIZE INTEGER return STD LOGIC VECTOR is variable result STD LOGIC VECTOR SIZE 1 downto 0 variable temp integer begin temp ARG for i in 0 to SIZE 1 loop if temp mod 2 1 then result i 1 else result i 0 end if if temp 0 then temp temp 2 else temp temp 1 2 simulate ASR end if end loop return result ModelSim FLI Reference FLI 336 FLI function definitions ModelSim FLI Reference end function CONV INTEGER ARG STD LOGIC VECTOR return INTEGER is variable result INTEGER begin assert ARG length 32 report ARG is too large in CONV INTEGER severity FAILURE result 0 for i in ARG range loop if i ARG left then result result 2 if tbl BINARY ARG i 1 then result result 1 end if end if end loop return result end end std logic util set vhd library ieee use ieee std logic 1164 all use work std logic util all entity cache set is generic addr size integer 8 set size integer 5 word size integer 16 i port addr fe1n std logic vector addr size 1 downto 0 data inout std logic vector word size 1 downto 0 hit out std logic oen z i std logic wen to un std logic i end cache_set architecture only of cache_set is constant size integer 2 set_size constant dly time 5 ns subtype word t is std_logic_vector word_size 1 downto 0 subtype addr t is s
236. ScheduleWakeup inst data proc 6 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 f foreign attribute Xy mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB initInstance 0 ModelSim FLI Reference FLI 454 FLI function definitions 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 a11 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 bit b integer e real d std logic e 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 instl for model pl process variable bitsig bit r 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 i
237. Signal FLI 149 mti CreateSignal Syntax Returns Arguments Description Creates a new VHDL signal signal id mti CreateSignal name region type Name Type Description signal id mtiSignalIdT A handle to the new VHDL signal or NULL if there is an error Type Description char The name of the new VHDL signal OPTIONAL can be NULL region mtiRegionIdT The design region into which the new signal is to be placed type mtiTypeldT The type of the new signal mti CreateSignal creates a new VHDL signal of the specified type in the specified region If the name is not NULL then the signal will appear in the simulator s Signals window All signal names that do not start and end with a V are converted to lower case Signal names starting and ending with Y are treated as VHDL extended identifiers and are used unchanged mti CreateSignal allows you to create a signal with an illegal HDL name This can be useful for integrators who provide shared libraries for use by end customers as this is an easy way to avoid potential name conflicts with HDL signals We recommend the following naming style PREFIX name where PREFIX is 3 or 4 characters that denote your software to avoid name conflicts with other integration software and name is the name of the signal Enclosing the entire name in angle brackets makes it an illegal HDL name For example MTI siga We strongly recom
238. Signal timesig 5 ns Signal stdlogicsig H Signal bitarr 0110 Signal stdlogicarr 01LH Signal intarr 10 11 12 Signal realarr 1 160000e 01 1 012200e 02 Signal timearr 15 ns 6 ns Signal rec 0 1 3 700000e 00 H 1001 Time 0 10 Signal bitsig 0 Signal intsig 22 Signal realsig 1 745000e 01 Signal timesig 6 ns Signal stdlogicsig Signal bitarr 1001 Signal stdlogicarr 1ZH Signal intarr 11 12 13 Signal realarr 1 270000e 01 1 023200e 02 Signal timearr 16 ns 7 ns Signal rec 1 2 4 800000e 00 0110 Time 0 15 Signal bitsig 1 Signal intsig 23 Signal realsig 1 855000e 01 Signal timesig 7 ns Signal stdlogicsig U Signal bitarr 0110 Signal stdlogicarr ZW U Signal intarr 12 13 14 Signal realarr 1 380000e 01 1 034200e 02 Signal timearr 17 ns 8 ns Signal rec 0 3 5 900000e 00 U 1001 VSIM 2 gt quit mti_SetSignalValue FLI 627 ModelSim FLI Reference FLI 628 FLI function definitions mti SetVarValue Sets the value of a VHDL variable Syntax mti SetVarValue variable id value Returns Nothing Arguments Name Type Description variable id mtiVariableIdT A handle to a VHDL variable value long void For a variable of scalar type the value to be set for a variable of real time or array type a pointer to the value to be set D
239. Sim Advanced Verification and Debugging SE Foreign Language Interface Version 6 0b Published 15 Nov 04 4 Al K i A t m F4 NIU in v 270901 our eg p TT jim li ModelSim FLI Reference This document is for information and instruction purposes Mentor Graphics reserves the right to make changes in specifications and other information contained in this publication without prior notice and the reader should in all cases consult Mentor Graphics to determine whether any changes have been made The terms and conditions governing the sale and licensing of Mentor Graphics products are set forth in written agreements between Mentor Graphics and its customers No representation or other affirmation of fact contained in this publication shall be deemed to be a warranty or give rise to any liability of Mentor Graphics whatsoever MENTOR GRAPHICS MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIAL INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OR MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE MENTOR GRAPHICS SHALL NOT BE LIABLE FOR ANY INCIDENTAL INDIRECT SPECIAL OR CONSEQUENTIAL DAMAGES WHATSOEVER INCLUDING BUT NOT LIMITED TO LOST PROFITS ARISING OUT OF OR RELATED TO THIS PUBLICATION OR THE INFORMATION CONTAINED IN IT EVEN IF MENTOR GRAPHICS CORPORATION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES RESTRICTED RIGHTS LEGEND 03 97 U S Government Restricted Rights The SOFTWARE and documen
240. SocketOutputReadyCB FLI 90 Adds or removes a socket output ready callback mti RemoveEnvCBY FLI 536 Removes an environment change callback mti_RemoveLoadDoneCB FLI 539 Removes an elaboration done callback mti RemoveQuitCB FLI 542 Removes a simulator exit callback mti RemoveRestartCB FLI 545 Removes a simulator restart callback mti RemoveRestoreCB FLI 548 Removes a simulator restore callback mti RemoveRestoreDoneCB FLI 551 Removes a simulator restore done callback mti RemoveSaveCBY FLI 554 Removes a simulator checkpoint callback mti_RemoveSimStatusCB FLI 557 Removes a simulator run status change callback Table 8 FLI memory management functions Function Action mti Malloc FLI 482 Allocates simulator managed memory mti Realloc FLI 523 Re allocates simulator managed memory mti Free FLI 219 ModelSim FLI Reference Frees simulator managed memory FLI 49 Table 8 FLI memory management functions Function Action mti VsimFree FLI 667 Frees memory allocated by an FLI function that would normally be freed with the free C library function Table 9 FLI checkpoint restore functions Function Action mti GetCheckpointFilename FLI 245 Gets the name of the current checkpoint file mti IsRestore FLI 476 Determines if a restore operation is in progress
241. T generics mtilnterfaceListT ports mtiProcessIdT procid mtiSignalldT sigid fk mti GetSignalName sigid The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute E E A list of generics for the foreign model A list of ports for the foreign model sigid mti FindSignal top sl1 procid mti CreateProcess sigMonitor monitorSignal sigid mti Sensitize procid sigid MTI EVENT 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 a11 entity top is y end top architecture a of top is std logic 0 signa L s1 component for model is end component for all for model use entity work for model a begin il for model pl process begin El x TIT wait for 5 ns sl lt 0 wait for O0 ns Sl e tgi wait for 0 ns sl lt 0 wait for 5 ns end process end a Simulation output vsim c top Reading modeltech 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 20 Time 0 0 delta 0 Signal top sl is 0 Time
242. T ERROR perror Getting socket status else int ctlValue statusFlags O NONBLOCK ctlValue fcntl sock F SETFL statusFlags if ctlValue SOCKET ERROR perror Setting socket status endif mti AddLoadDoneCB mtiVoidFuncPtrT loadDoneCB void sock HDL code entity top is end top architecture a of top is signal sl bit 0 begin sl lt not sl after 5 ns end a EL Simulation output mti AddSocketlnputReadyCB FLI 89 vsim c foreign initForeign for model sl top Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading work top a Loading for_model sl Load Done Adding socket callback Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read f Read returned 1 Read Read returned 1 Read Read returned 1 Read amp Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read 0 Read returned 1 Read 1 Read returned 1 Read 2 Read returned 1 Read 3 Read returned 1 Read 4 Read returned 1 Read 5 Read returned 1 Read 6 Read returned 1 Read 7 Read returned 1 Read 8 Read returned 1 R
243. T elem type fullname mti GetSignalNameIndirect sigid 0 0 sig type mti GetSignalType sigid mti PrintFormatted n cSignal s is of type s n indent fullname getTypeStr sig type mti VsimFree fullname elem type mti GetArrayElementType sig type if elem type mti PrintFormatted cIts subelements are of type s n indent getTypeStr elem type else if mti GetTypeKind sig type MTI TYPE RECORD mti PrintFormatted cThe record subelements are Mn indent elem list mti GetSignalSubelements sigid 0 num elems mti GetNumRecordElements sig type for i 0 i lt num elems i printSignalInfo elem list i indent 2 mti_VsimFree elem_list else mti PrintFormatted cThere are no array subelements n indent p d static void initInstance void param mtiSignalIdT sigid for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal printSignalInfo sigid 1 void initForeign mtiRegionIdT region The ID of the region in which this E foreign architecture is instantiated char param The last part of the string in the k foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model ModelSim FLI Reference FLI 224 FLI function definitions mti
244. TIAL break case STD LOGIC X region name mti GetRegionFullName mti GetSignalRegion inst sigid2 mti PrintFormatted Time d d delta d Signal s s is UNKNOWN Mn mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid2 mti VsimFree region name break default region name mti GetRegionFullName mti GetSignalRegion inst sigid2 mti PrintFormatted Time d d delta d Unexpected value d on signal s s n mti NowUpper mti Now mti Delta sigval region name mti GetSignalName inst gt sigid2 mti VsimFree region name break void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 E foreign attribute Kl mtiInterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model x instanceInfoT inst mtiProcessIdT procid mtiTypeIdT enum type inst instanceInfoT malloc sizeof instanceInfoT enum type mti CreateEnumType 1 9 std logic lits inst gt sigidl mti CreateSignal mySigl region enum type inst drvidl mti CreateDriver inst gt sigidl procid mti CreateProcess mySiglDriver driveSignall inst mti Sensitize pr
245. Type typedef struct mtiDelayT delay mtiProcessIdT procid mtiSignallIdT il sigid mtiSignalIdT i2_sigid mtiSignalIdT i3_sigid mtiSignalIdT tl_sigid mtiSignalIdT t2_sigid mtiSignalIdT t3_sigid mtiDriverIdT il_drvid mtiDriverIdT i2_drvid mtiDriverIdT i3_drvid mtiDriverIdT tl drvid mtiDriverIdT t2 drvid mtiDriverIdT t3 drvid long il last value long i2 last value void i3 last value long tl last value long t2 last value void t3 last value mtilnt32T i3 value length mtilInt32T t3 value length instanceInfoT define NS EXPONENT 9 mtiDelayT convertToNS mtiDelayT delay int exp NS EXPONENT mti GetResolutionLimit if exp lt 0 Simulator resolution limit is coarser than ns Cannot represent delay accurately so truncate it while exptt delay 10 else Simulator resolution limit is finer than ns while exp delay 10 mti ScheduleDriver FLI 597 return delay static long invertBit long value if value 0 return 1 else return 0 static void invertBitArray char value mtiInt32T length int i for i 0 i lt length i if value i 0 value i 1 else value i 0 static long incrStdLogic mtiInt32T value switch value case STD_LOGIC_U return STD LOGIC X case STD LOGIC X return STD LOGIC 0 case STD LOGIC 0 return STD LOGIC 1 case STD LOGIC 1 r
246. UMERATION ERATIO ERATIO ERATIO ERATIO ERATIO ERATIO ERATIO ERATIO E t pd Ld tu Ltd Lud Lu cGadacaadaac Y ARRAY type ENUMERATION type ENUMERATION type ENUMERATION ARRAY type ENUMERATION type ENUMERATION type ENUMERATION GER mti GetTypeKind FLI 407 ModelSim FLI Reference FLI 408 FLI function definitions mti GetVarAddr Syntax Returns Arguments Description ModelSim FLI Reference Gets a pointer to a VHDL variable s value space value mti GetVarAddr var name Description A pointer to the value space of the specified variable Description The name of a VHDL variable mti GetVarAddr returns a pointer to the value space of a VHDL variable of any type except record The variable name must be specified according to the following rules t can be either a full hierarchical name or a relative name A relative name is relative to the region set by the environment command The top level region is the default t must include the process label if the object is declared in a process It must not include a slice specification NULL is returned if the variable is not found or if the variable is of a record type The value pointer must not be freed The value of the variable can be read and written at any time directly via the value pointer The value pointer is interpreted as follows For a scalar variable or an array The value sho
247. Upper checkTime static void checkRegion void mti PrintFormatted Time d d mti NowUpper checkTime static void initInstance void param mtiProcessIdT procid mtiSignalIdT sigid No pending events Pending events Next time is d d n next_time next_time Next time is d d n next_time next_time Pending postponed processes sd n next_time next_time doProc n mti_Now checkRegion n mti_Now mti GetNextNextEventTime FLI 293 sigid mti FindSignal top sl procid mti CreateProcess Test Process checkRegion 0 mti Sensitize procid sigid MTI EVENT 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 kf foreign attribute uA mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT 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 package for pkg is procedure test proc attribute foreign of test proc procedure is doProc for model sl end for pkg package body for pkg is procedure test proc is begin end end for pkg
248. Variable top pl intarr Variable top pl realarr Variable top pl timearr Variable top pl rec 3 VSIM 2 quit pref tcl std standard ieee std logic 1164 body r v 22 1 745000e 01 6 ns ig 0 9017 rr 1010 Il I2y 13 1 270000e 01 16 ns 7 ns 300000e 00 1 1 023200e 02 0110 qp ar 23 1 855000e 01 7 ns ig v 0110 rr 0101 12 13 14 1 380000e 01 17 ns 400000e 00 1 034200e 02 8 ns Q 1001 mti GetVarlmageByld mti GetVarlmageByld FLI 421 Gets the string image of a VHDL variable s value by ID Syntax image mti GetVarImageById variable id Returns Description A string image of the specified variable s value Arguments Name Type Description variable id mtiVariableIdT A handle to a VHDL variable Description mti GetVarImageBylId 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 mti GetVarlImage FLI 416 mti GetVarValue FLI 442 Example FLI code include mti h typedef struct varInfoT tag struct varInfoT tag next char name mtiTypeIdT typeid mtiVariableIdT varid varInfoT typedef struct va
249. Variable timearr 17 ns 8 ns VSIM 2 gt quit Loading modeltech sunos5 ieee std_logic_1164 body mti Interp FLI 467 mti Interp Gets the Tcl Interp pointer used in the simulator Syntax interp mti Interp Returns Type Description Tcl Interp The Tcl interp pointer used in the simulator Arguments None Description mti Interp returns the Tcl interp pointer used in the simulator There is only one Tcl interp pointer in the simulator and it exists and does not change throughout the execution life of the simulator This pointer is needed in most Tcl calls and can also be used in conjunction with mti Cmd to obtain the command results Related functions None Example FLI code include tcl h include mti h typedef enum STD_LOGIC_U LEVIS ef STD_LOGIC_X X STD LOGIC O0 JE Pt ve STD LOGIC 1 fe Ey RT STD LOGIC Z Z STD LOGIC W Wl STD_LOGIC_L LY STD_LOGIC_H H STD LOGIC D ER hat Pf StdLogicT void monitorSignal void param char buffer 256 char region_name ModelSim FLI Reference FLI 468 FLI function definitions char signal name int status mtiSignallIdT sigid mtiSignalIdT param Tcl Interp interp switch mti GetSignalValue sigid case STD LOGIC X case STD LOGIC W signal name mti GetSignalName sigid region name mti GetRegionFullName mti GetSignalRegion sigid
250. VsimFree signame switch mti GetTypeKind sigtype case MTI TYPE ARRAY elem list mti GetSignalSubelements sigid 0 switch mti GetTypeKind mti GetArrayElementType sigtype case MTI TYPE ARRAY case MTI TYPE RECORD for i 0 i lt mti TickLength sigtype i printSignalInfo elem list i indent 2 break default for i 0 i lt mti TickLength sigtype i signame mti GetSignalNameIndirect elem list i 0 0 mti PrintFormatted c s is of type s n indent signame getTypeName mti GetSignalType elem list i mti VsimFree signame break mti_VsimFree elem_list break case MTI_TYPE_RECORD elem_list mti_GetSignalSubelements sigid 0 for i 0 i lt mti GetNumRecordElements sigtype i switch mti GetTypeKind mti_GetSignalType elem list i case MTI TYPE ARRAY case MTI TYPE RECORD printSignallInfo elem list i indent 2 break default signame mti GetSignalNameIndirect elem list i 0 0 mti PrintFormatted c s is of type s n indent signame getTypeName mti GetSignalType elem list i mti VsimFree signame break mti_VsimFree elem_list break default break void loadDoneCB void param mti_PrintMessage nComposite Signals n mti PrintMessage Signal top sl printSignalInfo mti FindSignal top s1 4 mti PrintMessage Signal top s2
251. _VsimFree elem_list break default break void loadDoneCB void param ModelSim FLI Reference FLI 378 FLI function definitions mti mti mti mti Tu mti mtis printSig printSig printSig printSig printSig PrintMessage PrintMessage nalIn PrintMessage nalIn PrintMessage nalIn PrintMessage nalIn PrintMessage naiin printSig PrintMessage naiin void initForeign nComposite Signals n Signal top s1 fo mti FindSignal Signal top s2 fo mti FindSignal Signal top s3 fo mti FindSignal Signal top s4 fo mti FindSignal Signal top s5 Fo mti FindSignal Signal top s6 fo mti FindSignal mtiRegionIdT region fX char param AR mtilnterfaceListT generics mtilnterfaceListT ports Ps mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity top is type rectype is record a b e type rectype2 is record fl bit 2 rectype end record type al is array 2 downto 0 type a2 is array 3 downto 2 type a3 is array 1 to 2 0 to end top architecture a of top is signal sl bit r 0 signal s2 rectype 42 1 ModelSim FLI Reference integer bit bit vector 3 downto 0 end record 0 architecture is top sl 4 MM E Vera gt pole Ys 4 33
252. _info void saveCallback void param char tmp_char Z char tmp_str Howdy long tmp_long 123456 short tmp_short 587 mti_PrintFormatted mti SaveBlock char amp instanc mti PrintFormatted Saving cha mti SaveChar tmp char mti PrintFormatted Saving lon mti SaveLong tmp long mti PrintFormatted Saving sho mti SaveShort tmp short mti PrintFormatted Saving str mti SaveString tmp str mti PrintFormatted n nSaving instance info s n g instance_info i sizeof instance_info tmp char e info r SONN g ld n tmp long rt d n tmp short ing s n tmp str void restoreCallback void param mti_RestoreBlock char amp inst nRestorin Restoring Restoring Restoring mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted Restoring mti PrintFormatted Mn void initForeign mtiRegionIdT region JE char param fR mtilnterfaceListT generics mtilnterfaceListT ports y instance info mti Malloc str strcpy instance info param mti AddSaveCB saveCallback mti AddRestoreCB restoreCallba in HDL code entity for model is end for model architecture a of for model is ModelSim FLI Reference ance info instance info g instance info VW SV Yn char c n mti RestoreChar long ld n mti RestoreLong shor
253. aceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model ModelSim FLI Reference FLI 512 FLI function definitions ModelSim FLI Reference 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 begin end a library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal intsig integer 42 signal realsig real 10 2 component for model end component initForeign for model sl for all for model use entity work for model a begin instl for model intsig lt intsig 1 after 5000000 sec realsig lt realsig 1 1 after 5000000 sec end a Simulation output 9 vsim c t sec top Reading modeltech tcl vsim pref tcl 5 4b vsim c t sec top Loading work top a Loading work for_model a Loading for model sl VSIM 1 run 10000000000 Time 0 600000000 Signal intsig 162 Signal realsig 1 422000e 02 Time 0 1100000000 Signal intsig 262 Signal realsig 2 522000e 02 Time 0 1600000000 Signal intsig 362 Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Time 0 2100000000 Signal intsig 462 Time 0 2600000000 Signal intsig 562 Time 0 3100000000 Signal intsig 662 Time 0 3
254. ack FLI 80 simulator exit callback FLI 69 simulator iteration count FLI 157 simulator restart callback FLI 71 simulator version FLI 323 simulator warm restore callback FLI 74 simulator warm restore done callback FLI 77 socket input ready callback FLI 85 socket output ready callback FLI 90 Software updates FLI iii Standard Developer s Kit User Manual FLI iv stopping the simulator FLI 99 FLI 164 FLI 520 subprograms foreign FLI 13 Support FLI iii ModelSim FLI Reference T Tcl Interp pointer FLI 467 Technical support FLI iii Technical support and updates FLI iii time and event functions FLI 49 time step FLI 157 tracing foreign language calls FLI 40 type functions FLI 47 types array FLI 108 enumeration FLI 118 real FLI 139 scalar FLI 146 U Updates FLI iii user input FLI 96 user defined command FLI 54 FLI 91 V variable finding FLI 187 setting the value FLI 628 shared objects MGC HOME and MGC WD FLI 12 variable functions FLI 46 Variables shared objects LD LIBRARY PATH and SHLIB PATH FLI 11 Verilog region accessing objects in FLI 177 FLI 191 FLI 240 FLI 459 FLI 489 version finding FLI 323 VHDL data types mapping to FLI 18 W waveform logfile FLI 457 wlf file FLI 457
255. ading modeltech tcl vsim pref tcl vsim c top Loading modeltech sunos5 std standard modeltech sunos5 ieee std logic 1164 body Loading work typepkg Loading work top a Loading work for model a Loading for_model sl add list w 1 top bitsigl add list w 3 top intsigl add list w 1 top stdlogicsigl add list w 4 top bitarrl add list w 4 top stdlogicarrl add list w 15 top intarrl add list w 10 top recl run 70 write list list out 10 quit f VSIM 1 VSIM 2 VSIM 3 VSIM 4 VSIM 5 VSIM 6 VSIM 7 VSIM 8 VSIM 9 VSIM ns delta 0 0 5 ox 0 10 0 11 0 zd o PL 26 0 31 0 32 0 38 CEL 43 0 48 0 5d xu 53 0 56 0 5f o 58 0 59 0 61 1 66 0 cat list out top bitsigl top intarrl top intsigl top stdlogicsigl top bitarrl top stdlogicarrl 21 H 0110 X0OU 10 ll I2 0 22 1001 001 11 12 13 23 U 0110 X120 12 13 14 0 42 W 0011 ZW1H 42 42 42 43 L 1100 WLZ 43 43 43 0 44 H 0011 LHWU 44 44 44 45 1100 H LX 45 45 45 120 0 1000 LLLL 120 120 120 O0 121 1 0111 HHHH 121 121 121 122 Z2 1000 41 22 1122 11227 0 123 W 0111 UUUU I23 I23 1237 O0 777 H 0010 1 1 777 777 777 0 777 H 0010 1 1 777 777 777 0 778 1101 ZUZU 778 778 778 Q TTE ORTE 1L 1 ADEE TED LES 1 777 H 0010 1 1 CREE EET RUE O 777 H 0010 1 1 TED FIT TELA 1 778 1101 ZUZU 778 778 778 0 779 U 0010 WXWX 779 779 779 mti_ReleaseSignal F
256. after 5 ns timesig lt timesig 2 ns after 5 ns stdlogicsig lt not stdlogicsig after 5 ns stdlogicarr lt not stdlogicarr after 5 ns rec a lt not rec a after 5 ns rec b lt rec b 1 after 5 ns rec c lt not rec c after 5 ns end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl M 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 18 Time 0 6 Signal bitsig rot Il ws WwW Signal intsig Signal physsig 4 hour Signal realsig 1 130000e 01 Signal timesig 5 ns Signal stdlogicsig 0 Signal stdlogicarr 1010 Signal rec 1 1 0110 Time 0 11 Signal bitsig nET Signal intsig 44 Signal physsig 5 hour Signal realsig 1 240000e 01 Signal timesig 7 ns Signal stdlogicsig 1 Signal stdlogicarr 0101 Signal rec 0 2 1001 Time 0 16 Signal bitsig 0 Signal intsig 45 Signal physsig 6 hour Signal realsig 1 350000e 01 Signal timesig 9 ns Signal stdlogicsig 0 Signal stdlogicarr 1010 Signal rec 1 3 0110 VSIM 2 quit ModelSim FLI Reference mti SignallsResolved FLI 639 mti SignallsResolved Syntax Returns Arguments Description Indicates whether or not the specified signal is resolved resolved mti SignallIsReso
257. akeup64 FLI 610 mti Sensitize FLI 614 mti SetDriverOwner FLI 617 mti SetSignalValue FLI 621 mti SetVarValue FLI 628 mti Signallmage FLI 635 mti TickDir FLI 647 mti TickHigh FLI 651 mti TickLeft FLI 654 mti TickLength FLI 657 mti TickLow FLI 661 mti TickRight FLI 664 mti VsimFree FLI 667 mti WriteProjectEntry FLI 670 O output ready callback FLI 68 P port signal FLI 170 ports restrictions on FLI 12 process creating FLI 123 desensitizing FLI 160 first in region FLI 195 next in region FLI 485 prioritizing FLI 128 sensitizing FLI 614 waking up FLI 606 FLI 610 process functions FLI 44 project file finding an entry FLI 173 writing an entry FLI 670 ModelSim FLI Reference Index R real type creating FLI 139 region creating FLI 142 finding FLI 177 getting next FLI 489 getting parent FLI 459 top level FLI 399 region functions FLI 44 region handle using with PLI functions FLI 177 FLI 191 FLI 240 FLI 459 FLI 489 Restart effect on FLI application code FLI 23 retore FLI 476 run status change callback FLI 83 S scalar type creating FLI 146 sensitizing a process FLI 614 shared object files location of FLI 11 signal creating FLI 149 find a port signal FLI 170 finding FLI 182 forcing a value FLI 208 releasing a force FLI 527 setting a value FLI 621 subelements FLI 376 type FLI 381 value FLI 386 FLI 392 signal functions FLI 45 simulator checkpoint callb
258. al 42 Loading for model sl Simulation has been restarted test global 15 Setting test global to 3 VSIM 3 run 45 VSIM 4 quit Cleanup callback Freeing param for model test global 3 mti IsFirstlnit FLI 475 ModelSim FLI Reference FLI 476 FLI function definitions mti IsRestore Determines if a restore operation is in progress Syntax status mti IsRestore Returns Description 1 during a restore operation 0 otherwise Arguments None Description mti IsRestore returns 1 when a restore operation is in progress otherwise it returns 0 Related functions mti IsColdRestore FLI 470 mti IsFirstInit FLI 473 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info 0 void saveCallback void param char inst_info char param mti PrintFormatted Saving instance info s n inst info mti SaveString inst info void restoreCallback void param char inst_info char param strcpy inst info mti RestoreString mti PrintFormatted Restored instance info s n instance info void cleanupCallback void param mti_PrintMessage Cleaning up n ModelSim FLI Reference mti IsRestore FLI 477 free param void initForeign mtiRegionIdT region The ID of the region in which this m foreign architecture is instantiated char param The
259. al a Signal b Signal count Region top instl il Region top instl toggle Signal a Signal b Signal count VSIM 1 run 10 VSIM 2 quit ModelSim FLI Reference mti FirstVar FLI 203 mti FirstVar Syntax Returns Arguments Description Gets the first VHDL variable generic or constant visible to a process variable id mti FirstVar process id Name Type Description variable id mtiVariableIdT A handle to the first VHDL variable generic or constant visible to a process or NULL if none of these objects are visible to the process Name Type Description process_id mtiProcessIdT A handle to a VHDL process mti FirstVar returns a handle to the first VHDL variable generic or constant visible to the specified process mti NextVar can be used to get the subsequent VHDL variables generics and constants visible to the specified process All generics of an entity are visible to every process within the associated architecture mti FirstVar resets the process used by previous calls to mti FirstVar and mti NextVar therefore mti NextVar always uses the process set by the latest call to mti FirstVar Related functions Example mti FindVar FLI 187 mti NextVar FLI 497 FLI code include lt mti h gt void printVariables mtiProcessIdT process int indent mtiVariableIdT varid ModelSim FLI Reference FLI 204 FLI function definition
260. al rec 1 1 0110 ModelSim FLI Reference Signal Signal Signal Signal Signal Signal Signal Signal Time 0 11 butsrge Tl intsig 44 physsig 5 hour realsig 1 240000e 01 timesig 7 ns stdlogicsig 1 stdlogicarr 0101 rec O 2 1001 VSIM 2 quit mti Nowlndirect FLI 509 ModelSim FLI Reference FLI 510 FLI function definitions mti NowUpper Gets the high order 32 bits of the 64 bit current simulation time Syntax high time mti NowUpper Returns Name Type Description high time mtiInt32T The high order 32 bits of the current simulation time Arguments None Description mti NowUppetr returns the high order 32 bits of the current simulation time The time units are equivalent to the current simulator time unit setting Related functions mti Delta FLI 157 mti GetResolutionLimit FLI 348 mti Now FLI 501 mti NowlIndirect FLI 505 Example FLI code include lt mti h gt typedef struct signalInfoT tag struct signalInfoT tag next char name mtiSignalldT sigid mtiTypeIdT typeid signalInfoT typedef struct signallInfoT sig info List of signals mtiProcessIdT proc Test process id instanceInfoT static void checkValues void inst info ModelSim FLI Reference mti NowUpper FLI 511 instanceInfoT inst data instanceInfoT inst info signallInfoT eiginfo mti
261. alName inst bitsig mti GetSignalValue inst bitsig mti PrintFormatted s d n mti GetSignalName inst intsig mti GetSignalValue inst intsig void mti GetSignalValueIndirect inst realsig amp real val mti PrintFormatted s g n mti GetSignalName inst realsig real val mti ScheduleWakeup inst procid 5 void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 x foreign attribute xf mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model instanceInfoT inst inst instanceInfoT malloc sizeof instanceInfoT inst intsig mti FindPort ports PORT2 inst bitsig mti FindPort ports pl inst realsig mti FindPort ports rPort inst procid mti CreateProcess ValueChecker checkValues inst mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst HDL code entity for model is port pl Bit port2 integer rport real i end for_model architecture a of for_model is attribute foreign of a architecture is initForeign for model sl begin end a entity top is end top ar
262. alar 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 GetVarValuelIndirect for variables Using the VHDL FLI FLI 19 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 50 Se T vor 2 LT gt 3 Z1 4 UE mo 8 EL 6 H 7 1 1 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 GetVarValuelIndirect 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
263. allback void param mti_RestoreBlock mti_PrintFormatted char amp instance info nRestoring instance info s n char c n mti RestoreChar long ld n short d n mti PrintFormatted mti PrintFormatted Restoring Restoring mti PrintFormatted Restoring instance info instance info mti RestoreLong mti RestoreShort mti SaveBlock FLI 581 mti PrintFormatted Restoring string s n mti RestoreString mti PrintFormatted Mn void initForeign mtiRegionIdT region The ID of the region in which this Ay foreign architecture is instantiated char param The last part of the string in the J foreign attribute EL mtilnterfaceListT generics mtilnterfaceListT ports instance info strcpy instance info mti AddSaveCB saveCallback mti AddRestoreCB restoreCallback HDL code entity for model is end for model architecture a of for model is attribute foreign of a initForeign for model sl begin end a entity top is end top architecture a of top is bit signal sl VT mti Malloc strlen param param A list of generics for the foreign model A list of ports for the foreign model x Tod or instance info instance info architecture is my for model ModelSim FLI Reference FLI 582 FLI function definitions component for model is end component for all begin il
264. alling region Arguments None Description During elaboration mti GetCallingRegion returns the region ID of the current elaboration region During simulation mti GetCallingRegion returns the region ID of the currently active process or signal resolution function context If there is currently no active process or signal resolution function mti GetCallingRegion returns the region ID of the current environment set by the environment command A foreign subprogram can call mti GetCallingRegion to determine the region in which the process containing the subprogram call resides The region ID returned by mti GetCallingRegion can be a VHDL Verilog or SystemC region A handle to a Verilog region can be used with PLI functions to obtain information about or access objects in the Verilog region At the beginning of time zero and during the time that the Load Done callback functions are called the calling region is the last non foreign region that was elaborated Related functions mti GetCurrentRegion FLI 248 mti GetRegionKind FLI 328 Example FLI code include mti h void doProc void char region_name mtiRegionIdT regid ModelSim FLI Reference regid mti GetCallingRegion region name mti PrintFormatted mti GetCallingRegion FLI 241 mti GetRegionFullName regid Time d d doProc Procedure Calling region is s n mti NowUpper mti VsimFree region name stati
265. am foreign region mtiRegionIdT param parent regid void mti CreateRegion foreign region reg under for arch post elab parent mti HigherRegion foreign region ModelSim FLI Reference FLI 144 FLI function definitions void mti CreateRegion parent region under parent post elab for regid mti GetTopRegion regid regid mti NextRegion regid printRegionInfo regid 1 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 iA mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model f mtiRegionIdT parent region under foreign arch region under parent void mti CreateRegion region parent mti HigherRegion region void mti CreateRegion parent void mti CreateRegion region 0 mti AddLoadDoneCB loadDone HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is std logic signal sl component for model is end component for all begin il for model end a ModelSim FLI Reference architecture is 0 Region with no name
266. ame normal name Sync nba name post brea n name Ky case 1 immed_func normal_fun synch_func nba_func postponed_ immed_name normal_name synch_name ModelSim FLI Reference poned_ poned region The ID of the region in which this foreign architecture is instantiated param The last part of the string in the ER foreign attribute x A list of generics for the foreign model A list of ports for the foreign model EL T generics T ports immed name normal name synch name nba name postponed name inst i procid sigid immed func normal func synch func nba func postponed func ceInfoT malloc sizeof instanceInfoT dSignal top s1 ateProcessWithPriority TestProcess testProcess inst MTI PROC IMMEDIATE rocid sigid MTI EVENT i FindSignal top s2 ateProcessWithPriority siglImmedProc sigImmedProc inst MTI PROC IMMEDIATE rocid inst gt sig02 MTI EVENT Be ft fe d immedProcess1l G normalProcess1 synchProcess1 nbaProcess1 postponedProcess1 immedProcessl1 normalProcess1 func synchProcess1 nbaProcess1 name postponedProcess1 immedProcess2 c normalProcess2 synchProcess2 nbaProcess2 func postponedProcess2 immedProcess2 normalProcess2 synchProcess2 nba name postponed name break case 2 immed func normal func synch func nba func
267. ame Type Description stop time mtiTime64T Returns the stop time of the current simulation run mti_GetRunStopTime returns the stop time of the current simulation run in the stop time parameter Related functions Example ModelSim FLI Reference mti GetNextEventTime FLI 287 mti GetNextNextEventTime FLI 291 mti Now FLI 501 mti NowlIndirect FLI 505 mti NowUpper FLI 510 FLI code include lt mti h gt static void checkStopTime void param mtiTime64T stop_time mti GetRunStopTime amp stop time mti PrintFormatted Time d d Run stop time is d d n mti NowUpper mti Now MTI TIME64 HI32 stop time MTI TIME64 LO32 stop time static void initInstance void param mtiProcessIdT procid procid mti CreateProcess mti Sensitize procid void initForeign mtiRegionIdT region AF char param AE mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB initInstance HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity top is end top architecture a of top is component for model end component for all signal sl bit 0 begin sl lt not sl after 5 ns for model finst end a Test Process mti FindSignal architecture is mti GetRunStopTime FLI 353 checkStopTime 0 top si MTI
268. anceInfoT inst mti_PrintFormatted Time d d delta d normalProcess3 n mti_NowUpper mti_Now mti_Delta void synchProcess3 instanceInfoT inst mti_PrintFormatted Time d d delta d synchProcess3 n mti_NowUpper mti_Now mti_Delta void nbaProcess3 instanceInfoT inst mti PrintFormatted Time d d delta d nbaProcess3 n mti NowUpper mti Now mti Delta void postponedProcess3 instanceInfoT inst mti PrintFormatted Time d d delta d postponedProcess3 n mti NowUpper mti Now mti Delta Processes scheduled by nbaProcess1 void immedProcess4 void param mti_PrintFormatted Time d d delta d immedProcess4 n mti_NowUpper mti_Now mti_Delta mti CreateProcessWithPriority FLI 133 void normalProcess4 instanceInfoT inst mti_PrintFormatted Time d d delta d normalProcess4 n mti_NowUpper mti_Now mti_Delta void synchProcess4 instanceInfoT inst mti_PrintFormatted Time d d delta d synchProcess4 n mti_NowUpper mti_Now mti_Delta void nbaProcess4 instanceInfoT inst mti PrintFormatted Time d d delta d nbaProcess4 n mti NowUpper mti Now mti Delta void postponedProcess4 instanceInfoT inst mti_PrintFormatted Time d d delta d postponedProcess4 n mti_NowUpper mti_Now mti_Delta Processes
269. anceInfoT inst data mtiProcessIdT procid ModelSim FLI Reference mti GetArrayVarValue FLI 237 mtiVariableIdT varid varlInfoT Gurr info varlInfoT varinfo inst data mti Malloc sizeof instanceInfoT inst data var info 0 for procid mti FirstProcess mti GetTopRegion 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 gt next curr_info varinfo inst_data gt proc mti_ScheduleWakeup inst_data gt proc void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB initInstance HDL code entity for model is end for model architecture a of for model is architecture is attribute foreign of a begin end a library ieee use ieee std logic 1164 a11 entity top is varinfo mti CreateProcess fk Test Process checkValues void inst data j 6 The ID of the region in which this 7 foreign architecture is instantiated The last part of the string in the El foreign attribute xy A list of generics for the foreign model A list of ports for the foreign model p 0 initForeign for model sl type bitarray is array 3 downto 0 of bit type intarray is array
270. anceInfoT inst data instanceInfoT inst info signallInfoT siginfo mti PrintFormatted Time d d Mn mti NowUpper mti Now for siginfo inst data sig info siginfo siginfo siginfo gt next mti PrintFormatted Signal s s n siginfo gt name mti Signallmage siginfo gt sigid mti ScheduleWakeup inst data proc 5 static signallnfoT setupSignal mtiSignalIdT sigid signallInfoT siginfo siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo next mcg return siginfo static void initInstance void param instanceInfoT inst data mtiSignalldT sigid signalInfoT Curr into signallInfoT siginfoj inst data inst data sig info mti Malloc sizeof instanceInfoT 0 for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 6 void initForeign mtiRegionIdT region The ID of the region in which this foreign architecture is instantiated ModelSim FLI Reference
271. ar retval switch sigval case STD LOGIC U retval U break case STD LOGIC X retval X break case STD LOGIC 0 retval O break case STD LOGIC 1 retval 1 break case STD LOGIC 2 retval Z break case STD LOGIC W retval W break case STD LOGIC L retval L break case STD LOGIC H retval H break case STD LOGIC D retval break default retval break return retval void monitorSignal void param char region_name instanceInfoT inst instanceInfoT param mtilInt32T sigval region name mti GetRegionFullName mti GetSignalRegion inst gt sigid sigval mti GetSignalValue inst sigid mti PrintFormatted Time d d delta d Signal s s is s n mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid convertStdLogicValue sigval if mti Now gt 20 mti PrintFormatted Desensitizing process s n mti GetProcessName inst procid mti Desensitize inst gt procid mti VsimFree region name void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 y foreign attribute v mtilnterfaceListT generics A list of generics
272. aram ModelSim FLI Reference FLI b64 FLI function definitions char tmp char Z char tmp str Howdy long tmp long 123456 short tmp short 587 mti PrintFormatted mti SaveBlock mti PrintFormatted mti SaveChar tmp char mti PrintFormatted mti SaveLong tmp long Formatted hort tmp short Formatted mti Print mti SaveS mti Print mti SaveString tmp str An mti PrintFormatted nSaving instance info s n char amp instance info Saving char c n Saving long ld n Saving short d n Saving string s n instance info i sizeof instance_info tmp char tmp long tmp short tmp str void restoreCallback void param mti_RestoreBlock mti_PrintFormatted mti PrintFormatted mti PrintFormatted mti PrintFormatted mti PrintFormatted In mti PrintFormatted ae void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports instance info strcpy instance info mti AddSaveCB saveCallback mti AddRestoreCB restoreCallback HDL code entity for model is end for model architecture a of for model is attribute foreign of a initForeign for model sl begin end a entity top is end top architecture a of top is ModelSim FLI Reference nRestoring instance info s n Restoring Restoring Restoring Restoring fk
273. arrl ModelSim FLI Reference mti SignallsResolved FLI 641 Elements of arrays of resolved subelements printSignalInfo top rbitarrl 6 printSignalInfo top rintarrl 4 printSignalInfo top rrealarrl 1 printSignalInfo top rtimearrl 1 printSignalInfo top rphysarrl1 3 printSignalInfo top stdlogicarrl 1 Unresolved records printSignalInfo top recl printSignalInfo top recl a printSignalInfo top recl b printSignalInfo top recl c printSignalInfo top recl d printSignalInfo top recl e printSignalInfo top recl f printSignalInfo top recl g Records of resolved elements printSignalInfo top rec2 printSignalInfo top rec2 b printSignalInfo top rec2 i printSignalInfo top rec2 r printSignalInfo top rec2 t printSignalInfo top rec2 s printSignalInfo top rec2 p Records of mixed resolution printSignalInfo top rec3 printSignalInfo top rec3 f1 printSignalInfo top rec3 f2 printSignalInfo top rec3 f2 a printSignalInfo top rec3 f2 b printSignalInfo top rec3 f2 c printSignalInfo top rec3 f2 d printSignalInfo top rec3 f2 e printSignalInfo top rec3 f2 f printSignalInfo top rec3 f2 g printSignalInfo top rec3 f3 printSignalInfo top rec3 f4 printSignalInfo top rec3 f4 b printSi
274. art of the string in the J foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model instanceInfoT inst inst instanceInfoT mti Malloc sizeof instanceInfoT inst gt sigid mti FindSignal top sl1 inst procid mti CreateProcess sigWatcher watchSignal inst HDL code entity for model is end for model architecture a of for model is mti VsimFree FLI 669 attribute foreign of a architecture is initForeign for model sl begin end a library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal sl std logic 0 component for model is end component for all for model use entity work for model a begin sl lt not sl after 5 ns il for model end a Simulation output 9 vsim c top Reading modeltech 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 50 Time 0 0 delta 0 Signal top sl is 0 Time 0 5 delta 0 Signal top sl is 1 Time 0 10 delta Signal top sl is 0 Time 0 15 delta Signal top sl is 1 Time 0 20 delta Signal top sl is 0 Time 0 25 delta Signal top sl is 1 Time 0 30 delta 0 Signal top
275. at will be driven creates one or more processes a C function that can be called when a signal changes sensitizes each process to a list of signals The declaration of an initialization function is app init mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports The function specified in the foreign attribute is called during elaboration The first parameter is a region ID that can be used to determine the location in the design for this instance The second parameter is the last part of the string in the foreign attribute The third parameter is a linked list of the generic values for this instance The list will be NULL if there are no generics The last parameter is a linked list of the ports for this instance The typedef mtiInterfaceListT in mti h describes the entries in these lists Restrictions on generics RECORD generics are not supported in the foreign language interface Using the VHDL FLI FLI 13 Using the VHDL FLI with foreign subprograms Declaring a foreign subprogram in VHDL To call a foreign C subprogram you must write a VHDL subprogram declaration that has the equivalent VHDL parameters and return type Then use the FOREIGN attribute to specify which C function and module to load The syntax of the FOREIGN attribute is almost identical to the syntax used for foreign architectures For instance procedure in params vhdl integer IN integer vhdl enum IN severity
276. bout to run Time 0 10 Region il the simulator just completed a run Time 0 10 Region il the simulator is about to run Time 0 25 Region il the simulator just completed a run mti AddSocketlnputReadyCB FLI 85 mti AddSocketlnputReadyCB Adds or removes a socket input ready callback Syntax mti AddSocketInputReadyCB socket desc func param Returns Nothing Arguments Name Type Description socket desc int A socket descriptor func mtiVoidFuncPtrT A pointer to a function to be called whenever there is data available for reading on the socket descriptor A parameter to be passed to the function OPTIONAL can be NULL Description mti_AddSocketInputReadyCB puts a watch on the specified socket descriptor Whenever the socket descriptor has data available for reading the specified function is called along with its parameter To remove a previously added callback call mti_AddSocketInputReadyCB with the same socket descriptor but with a NULL function pointer mti_AddSocketInputReadyCB and mti_AddSocketOutputReadyCB are useful in setting up cosimulation environments where FLI code uses sockets to communicate with other processes In the course of initialization a cosimulation application typically would use standard system library routines to create or open a socket and obtain a socket descriptor and then call mti_AddSocketInputReadyCB and mti_AddSocketOutputReadyCB to set up the callback functi
277. break static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info variInfoT varinfo mti PrintFormatted Time d d Mn mti NowUpper mti Now for varinfo inst data var info varinfo varinfo varinfo next mti PrintFormatted Variable s varinfo name printValue varinfo varid varinfo gt typeid 4 mti ScheduleWakeup inst data proc 5 ModelSim FLI Reference mti GetVarValuelndirect FLI 453 static varInfoT setupVariable mtiVariableIdT varid varinfoT varinfo varinfo varInfoT mti Malloc sizeof varInfoT varinfo varid varid varinfo name mti GetVarName varid varinfo gt typeid mti GetVarType varid varinfo next 0 return varinfo static void initInstance void param instanceInfoT inst_data mtiProcessIdT procid mtiVariableIdT varid varlInfoT curr info varlInfoT varinfo inst data mti Malloc sizeof instanceInfoT inst data var info 0 for procid mti FirstProcess mti GetTopRegion 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 gt next varinfo curr_info varinfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti
278. by the corresponding mti SaveBlock call This function should be called only from a restore callback function It should not be called from an initialization procedure Related functions ModelSim FLI Reference mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveShort FLI 589 mti SaveString FLI 592 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char tmp_char Z char tmp_str Howdy 123456 long tmp_long mti_RestoreBlock FLI 561 short tmp_short 587 mti PrintFormatted nSaving instance info s n instance info mti SaveBlock char amp instance info sizeof instance info mti PrintFormatted Saving cha mti SaveChar tmp char mti PrintFormatted Saving lon mti SaveLong tmp long mti PrintFormatted Saving sho mti SaveShort tmp short mti PrintFormatted Saving str mti SaveString tmp str mti PrintFormatted Mn r Zon tmp enar J g Sld n tmp long rt d n tmp short ing s n tmp str void restoreCallback void param mti_RestoreBlock char amp inst mti_PrintFormatted nRestorin mti_PrintFormatted Restoring mti_PrintFormatted Restoring mti_Pr
279. c fetch fulltype can be used on the region id to get the fulltype of the region If the region id is a handle to a Verilog region then it can be used with PLI functions to obtain information about and access objects in the Verilog region Related functions None Example FLI code include acc user h include acc vhdl h include mti h Static void printFullType handle region int fulltype acc_fetch_fulltype region switch fulltype case accArchitecture mti_PrintFormatted of fulltype accArchitecture break case accArchVitalLevelO0 mti PrintFormatted of fulltype accArchVitalLevelO break ModelSim FLI Reference void print case accArchVitalLevell mti_PrintFormatted break case acc break case acc break case acc break case accFunction break case accModuleInstance break case accPackage break case accShadow break case accTask break default break char mtiRegionIdT regid region name mti PrintFormatted switch EntityVitalLevel0 mti PrintFormatted ForeignArch mti PrintFormatted ForeignArchMixed mti PrintFormatted mti PrintFormatted mti PrintFormatted mti PrintFormatted mti PrintFormatted mti PrintFormatted mti PrintFormatted of fulltype of fulltype of fulltype of fulltype fulltype fulltype fulltype fulltype fulltype
280. c vector 15 downto 0 after 20 ns map clk paddr pdata prw pstrb map clk paddr pdata prw pstrb saddr sdata map clk saddr sdata srw sstrb el Simulation output 9 vlog cache v me ModelSim FLI Reference mory v proc v prdy prdy srw sstrb srdy srdy mti GetRegionKind FLI 339 Model Technology ModelSim SE EE vlog 5 4b Compiler 2000 06 Jun 9 2000 Compiling module cache Compiling module memory Compiling module proc Top level modules cache memory proc vcom util vhd set vhd Model Technology ModelSim SE EE vcom 5 4b Compiler 2000 06 Jun 9 2000 Loading package standard Loading package std logic 1164 Compiling package std logic util Compiling package body std logic util Loading package std logic util Loading package std logic util Compiling entity cache set Compiling architecture only of cache set vcom 93 top vhd Model Technology ModelSim SE EE vcom 5 4b Compiler 2000 06 Jun 9 2000 Loading package standard Compiling entity for model Compiling architecture a of for model Loading package std logic 1164 Compiling entity top Compiling architecture only of top Loading package vl types Loading entity proc Loading entity cache Loading entity memory Loading entity for model vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading
281. c void checkEnv void char region name mtiRegionIdT regid regid mti GetCallingRegion region name mti PrintFormatted Time mti Now region name mti GetRegionFullName regid d d checkEnv Function Calling region is s n mti NowUpper mti VsimFree region name static void checkRegion void char region name mtiRegionIdT regid regid mti GetCallingRegion region name mti PrintFormatted mti Now region name mti GetRegionFullName regid Time d d checkRegion Function Calling region is s n mti NowUpper mti VsimFree region name mti Now region name static void initInstance void param char region_name mtiProcessIdT procid mtiRegionIdT regid regid mti GetCallingRegion region name mti GetRegionFullName regid mti PrintFormatted Load Done Callback Function Calling region is s n region name mti VsimFree region name procid mti CreateProcess Test Process checkRegion 0 mti ScheduleWakeup procid 10 void initForeign mtiRegionIdT region The ID of the region in which this EU foreign architecture is instantiated char param The last part of the string in the xy foreign attribute a mtilnterfaceListT generics mtilnterfaceListT ports char region name A list of generics for the foreign model A list of ports for the foreign
282. callback functions for sockets under Windows The following functions work specifically with sockets While these functions are required for use with Windows they are optional for use on UNIX platforms e mti AddSocketInputReadyCB FLI 85 e mti_AddSocketOutputReadyCB FLI 90 VHDL FLI examples ModelSim FLI Reference Included in the ModelSim installation are a header file that must be included with foreign C code and several examples that illustrate how to use the foreign language interface The header file is install dir modeltech include mti h The examples are located in install dir modeltech examples foreign in the following directories example one This example illustrates how to create processes and sensitize them to signals and how to read and drive signals from these processes example two This example illustrates traversal of the design hierarchy creation of a simple gate function creation and sensitization of a process and loading of multiple foreign shared libraries example three This example illustrates how to read a testvector file and use it to stimulate and test a design via FLI function calls example four This example illustrates how to create and use foreign subprograms Compiling and linking FLI C applications FLI 25 Compiling and linking FLI C applications The following platform specific instructions show you how to compile and link your FLI applications so they can be loaded
283. ce info void cleanupCallback void param mti_PrintMessage Cleaning up n free param void loadDoneCallback void param if int param 1 mti_RemoveSaveCB saveCallback 0 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 y foreign attribute UA mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model instance info malloc strlen param 1 strcpy instance info param mti AddSaveCB saveCallback instance info mti AddSaveCB saveCallback 0 mti AddRestoreCB restoreCallback instance info mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info if mti IsFirstInit mti AddLoadDoneCB loadDoneCallback 0 else mti AddLoadDoneCB loadDoneCallback void 1 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 for model begin end a entity top is end top architecture a of top is signal s1 i beth re 10r ModelSim FLI Reference FLI b56 FLI function definitions ModelSim FLI Reference component for model is end component for all for model use entity work for model a begin il f
284. cess mySigDriver driveSignal inst mti ScheduleWakeup procid mti SetDriverOwner inst drvid procid mti AddQuitCB cleanupCallback mti AddRestartCB cleanupCallback inst HDL code entity top is end top architecture a of top is signal sl bit Q begin sl lt not sl after 5 ns end a mySig region real type inst sigid MTI EVENT 0 inst Jg Simulation output 9 modeltech tcl vsim pref tcl Sp Qt HD REN DS Signal top mysig is 0 vsim foreign initForeign for model sl Signal top mysig is 1 5 Signal Signal Signal Signal Signal Signal Signal Signal Signal Reading 5 4b Loading Loading work top a Loading for model sl VSIM 1 run 50 Time 0 0 delta 1 Time 0 5 delta O0 Time 0 10 delta Time 0 15 delta Time 0 20 delta Time 0 25 delta Time 0 30 delta Time 0 35 delta Time 0 40 delta Time 0 45 delta Time 0 50 delta VSIM 2 quit Cleaning up top mysig top mysig top mysig top mysig top mysig top mysig top mysig top mysig top mysig is is S is is is is ES is 10 HQ V CU 10 12 lg 15 vsim c top foreign initForeign for model sl c top modeltech sunos5 std standard ol ol mti_CreateRealType FLI 141 ModelSim FLI Reference FLI 142 FLI function definitions mti CreateRegion Creates a new VHDL region
285. ch sunos5 ieee std logic 1164 body Loading work top a Loading work for model a Loading for model sl Setting a watch on phys sigl Physical Units are hour 1 hour day 24 hour 24 hour week 168 hour 7 day month 672 hour 4 week year 8064 hour 12 month Setting a watch on phys sig2 Physical Units are hour 1 hour day 24 hour 24 hour week 168 hour 7 day month 672 hour 4 week year 8064 hour 12 month Setting a watch on phys sig3 Physical Units are hour 1 hour day 24 hour 24 hour week 168 hour 7 day month 672 hour 4 week year 8064 hour 12 month VSIM 1 run 20 Time 0 4 Signal phys sigl 72 3 day Signal phys sig2 168 1 week Signal phys sig3 8064 1 year Time 0 9 Signal phys sigl 96 4 day Signal phys sig2 208 1 week and 1 day and 16 hour Signal phys sig3 8144 1 year and 3 day and 8 hour Time 0 14 Signal phys sigl 120 5 day Signal phys sig2 248 1 week and 3 day and 8 hour Signal phys sig3 8224 1 year and 6 day and 16 hour Time 0 19 Signal phys sigl 144 6 day Signal phys sig2 288 1 week and 5 day Signal phys sig3 8304 1 year and 1 week and 3 day VSIM 2 quit ModelSim FLI Reference mti GetPrimaryName FLI 311 mti GetPrimaryName Gets the primary name of a region entity package or module Syntax primary name mti GetPrimaryName region id Returns Na
286. ch synthesis tools behavior Explicit 1 vlog Turn on converting regular Verilog identifiers to uppercase Allows case insensitivity for module names Default is no conversion UpCase 1 Turns on incremental compilation of modules Incremental 1 vsim Simulator resolution Set to fs ps ns us ms or sec with optional prefix of 1 10 or 100 Resolution ns User time unit for run commands Set to default fs ps ns us ms or sec The default is to use the unit specified for Resolution For example if Resolution is 100ps then UserTimeUnit defaults to ps UserTimeUnit default Default run length RunLength 100 Maximum iterations that can be run without advancing simulation time IterationLimit 5000 Stop the simulator after an assertion message 0 Note 1 Warning 2 Error 3 Failure 4 Fatal BreakOnAssertion 3 Default radix for all windows and commands Set to symbolic ascii binary octal decimal hex unsigned DefaultRadix symbolic ModelSim FLI Reference FLI 176 FLI function definitions ModelSim FLI Reference VSIM Startup command Startup do startup do File for saving command transcript TranscriptFile transcript Specify whether paths in simulator commands should be described in VHDL or Verilog format For VHDL PathSeparator for Verilog PathSeparator PathSeparator Specify the dataset separator for fully rooted
287. chitecture a of top is ModelSim FLI Reference FLI 172 FLI function definitions signal sl bit Ot signal s2 integer 42 signal s3 real 1 57 component for model is port pl BIE port2 integer rport real i end component for all for model use entity work for_model a begin il for model port map sl s2 s3 sl lt not sl after 5 ns S2 lt s2 1 after 5 ns s3 lt s3 1 5 after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for_model a Loading for model sl VSIM 1 run 15 Time 0 0 delta 0 sl 0 s2 42 s3 1 57 Time 0 5 delta 0 sl 1 s2 43 s3 3 07 Time 0 10 delta 0 sl 0 s2 44 s3 4 57 Time 0 15 delta 0 sl 1 s2 45 s3 6 07 VSIM 2 gt quit Cleaning up gt Note mti_GetSignalName returns the name of the top level signal connected to each port because of standard simulator optimization that collapses hierarchical port connections wherever possible ModelSim FLI Reference mti FindProjectEntry FLI 173 mti FindProjectEntry Gets the value of an entry in the project ini file Syntax value mti FindProjectEntry section name expand Returns Description The value of the specified entry or NULL if the entry is not found Arg
288. cket and obtain a socket descriptor and then call mti AddSocketInputReadyCB and mti_AddSocketOutputReadyCB to set up the callback functions During simulation FLI code may initiate a non blocking I O operation on the socket again using standard system library routines and immediately return control to the simulator When the I O is completed the simulator invokes the callback function which could check for errors handle received data or initiate another non blocking I O operation before returning to the simulator Related functions mti AddInputReadyCB FLI 60 mti_AddOutputReadyCB FLI 68 mti AddSocketInputReadyCB FLI 85 ModelSim FLI Reference mti AddTclCommand FLI 91 mti AddTclCommand Syntax Returns Arguments Description Adds a user defined Tcl style simulator command mti AddTclCommand cmd name cmd func cmd param func delete cb Nothing Name Type Description cmd name char The name of the command being added cmd func Tcl CmdProc A pointer to a function that will be called whenever the command is recognized by the command interpreter cmd param A parameter to be passed to the command function OPTIONAL can be NULL func delete cb mtiVoidFuncPtrT A pointer to a function that will be called if the command is redefined or deleted OPTIONAL can be NULL mti_AddTclCommand adds the specified Tcl command to the simulator The case of the command name i
289. code If is used as in the example below the VHDL will be elaborated first If is used the VHDL will be elaborated after the foreign initialization function is called UNIX environment variables can also be used within the string as in this example ATTRIBUTE foreign OF arch name ARCHITECTURE IS app init SCAE app so Location of shared object files The simulator searches for object files in the following order MGC_WD lt so gt or so If MGC WD is not set then it will use e lt so gt within SLD LIBRARY PATH SHLIB PATH on HP only ModelSim FLI Reference FLI 12 Introduction ModelSim FLI Reference MGC HOMH lib so e MODEL TECH so MODEL_TECH lt so gt In the search information above lt so gt refers to the shared library path specified in the FOREIGN attribute string MGC WD and MGC HOME are user definable environment variables MODEL TECH is set internally by vsim to the directory where the vsim executable resides Note The so extension will work on all platforms it is not necessary to use the s extension on HPs The C initialization function This is the entry point into the foreign C model The initialization function typically allocates memory to hold variables for the instance registers a callback function to free the memory when the simulator is restarted saves the handles to the signals in the port list creates drivers on the ports th
290. ctions operate on Verilog instances as indicated mti GetTopRegion FLI 399 Gets the first top level module Use mti NextRegion to get additional top level modules mti GetPrimaryName FLI 311 Gets the module name mti GetSecondaryName FLI 355 Returns NULL for normally compiled Verilog modules or the secondary name used for Verilog modules compiled with fast The following functions operate on Verilog instances in the same manner as they operate on VHDL instances mti CreateRegion FLI 142 mti GetRegionFullName FLI 325 mti FindRegion FLI 177 mti GetRegionName FLI 341 mti FirstLowerRegion FLI 191 mti_GetRegionSourceName FLI 344 ModelSim FLI Reference FLI 24 Introduction mti GetCurrentRegion FLI 248 mti HigherRegion FLI 459 mti_GetLibraryName FLI 283 mti NextRegion FLI 489 All other FLI functions operate only on VHDL instances and objects Specifically the functions that operate on VHDL signals and drivers cannot be used on Verilog nets and drivers For example a call to mti FirstSignal on a Verilog region always returns NULL You must use the PLI or VPI functions to operate on Verilog objects Support for Windows platforms Under Windows sockets are separate objects from files and pipes which require the use of different system calls There is no way to determine if a given descriptor is for a file or a socket This necessitates the use of different
291. d customers as this is an easy way to avoid potential name conflicts with HDL processes We recommend the following naming style lt PREFIX_name gt ModelSim FLI Reference FLI 124 FLI function definitions where PREFIX is 3 or 4 characters that denote your software to avoid name conflicts with other integration software and name is the name of the process Enclosing the entire name in angle brackets makes it an illegal HDL name For example MTI foreign architecture We strongly recommend that you do not use characters in the name that will cause Tcl parsing problems This includes spaces the path separator normally or square brackets and dollar signs If you must use these characters then create an escaped name by putting a backslash V at both ends of the name Related functions Example mti CreateProcessWithPriority FLI 128 mti Desensitize FLI 160 mti GetProcessName FLI 315 mti RestoreProcess FLI 569 mti ScheduleWakeup FLI 606 mti ScheduleWakeup64 FLI 610 mti Sensitize FLI 614 FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC Z STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType typedef struct mtiSignalIdT sigid mtiDriverIdT drvid instanceInfoT char convertStdLogicValue mtilnt32T sigval char retva
292. d logic 1164 body Loading work top a Loading work lower a Loading for model sl VSIM 1 gt run 1 Time 0 1 delta O0 Signal sl is TIT Drivers 1 top instl pO LF top p2 VHF top pl VSIM 2 drivers top sl Drivers for top sl 1 Signal top s1 1 Driver top inst1 p0 ModelSim FLI Reference FLI 266 FLI function definitions ModelSim FLI Reference 1 Driver top p2 H Driver top pl VSIM 3 run 5 Time 0 6 delta 0 Signal si is 0 Drivers L top instl p0 0 top p2 L top pl VSIM 4 drivers top sl Drivers for top sl 0 Signal top s1 L Driver top inst1 p0 0 Driver top p2 L Driver top pl VSIM 5 run 5 Time 0 11 delta O0 Signal sl is X Drivers W top instl pO W top p2 IXY top pl VSIM 6 drivers top sl Drivers for top sl X Signal top s1 W Driver top inst1 p0 W Driver top p2 X Driver top pl VSIM 7 quit Cleaning up mti GetDrivingSignals mti GetDrivingSignals FLI 267 Gets a handle to all of the VHDL or SystemC signals driving a signal Syntax signal list mti GetDrivingSignals signal name Returns Name Type Description signal list mtiSignalIdT A NULL terminated array of driving signal IDs for the specified signal or NULL if there is an error or no drivers are found Arguments Name Description signal name The name of the signal for which the driving signal
293. d mtiSignalldT A handle to a VHDL signal Description mti_GetSignalMode returns the direction or port mode of the specified VHDL signal The direction is one of the following MTI INTERNAL MTI_DIR_IN MTI_DIR_OUT or MTI DIR INOUT MTI INTERNAL indicates that the signal is not a port Related functions None Example FLI code include lt mti h gt static char convertDirection mtiDirectionT direction switch direction case MTI_INTERNAL case MTI_DIR_IN case MTI_DIR_OUT return return return case MTI_DIR_INOUT return default return INTERNAL n IN n OUT H INOUT UNKNOWN void printSignals mtiRegionIdT region int indent mtiSignalIdT sigid ModelSim FLI Reference FLI 360 FLI function definitions ModelSim FLI Reference for sigid mti FirstSignal region sigid sigid mti NextSignal if sigid mti PrintFormatted cSignal s Direction is s n indent mti GetSignalName sigid convertDirection mti GetSignalMode sigid void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s n indent region name indent 2 printSignals region indent for regid mti FirstLowerRegion region regid regid mti NextRegion regid printHierarchy regid indent mti VsimFree regi
294. dT region int indent mtiProcessIdT procid for procid mti FirstProcess if procid 4 mti PrintFormatted cProcess s n indent mti GetProcessName procid region procid procid mti NextProcess ModelSim FLI Reference FLI 196 FLI function definitions void printHierarchy mtiRegionIdT region char mtiRegionIdT regid region_name region_name mti_PrintFormatted indent 2 printProcesses region regid regid regid printHierarchy regid for mti VsimFree region name void loadDoneCB void param mti_PrintMessage printHierarchy mti_GetTopRegion void initForeign mtiRegionIdT region se char param Jr mtilnterfaceListT generics mtilnterfaceListT ports pE mti AddLoadDoneCB loadDoneCB mti PrintMessage printHierarchy mti GetTopRegion HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is generic delay port a in bit b out bit i end inv time architecture b of inv is begin b lt a after delay pl process ModelSim FLI Reference cRegion s n architecture is int indent mti GetRegionFullName region roy indent region name indent mti_FirstLowerRegion region mti_NextRegion regid indent nLoad Done phase n 1 The ID of the region in wh
295. de include lt mti h gt void printHierarchy mtiRegionIdT region int indent ModelSim FLI Reference FLI 490 FLI function definitions char region name mtiRegionIdT regid region name mti PrintFormatted mti VsimFree region name indent 2 for regid regid regid printHierarchy regid indent void loadDoneCB void param mtiRegionIdT regid mti PrintMessage cRegion s n AnHierarchy Mn mti GetRegionFullName region indent region name mti FirstLowerRegion region mti NextRegion regid for regid mti GetTopRegion regid regid mti NextRegion regid printHierarchy regid 1 void initForeign mtiRegionIdT region The ID of the region in which this m foreign architecture is instantiated char param The last part of the string in the XI foreign attribute EL mtiInterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is generic delay port a in bit b out bit i end inv time architecture b of inv is begin b lt a after delay end b entity mid is end mid ModelSim FLI Reference architecture is initForeign for m
296. del Restoring char Z Restoring long 123456 Restoring short 587 Restoring string Howdy VSIM 5 run 10 VSIM 6 quit mti RestoreString FLI 577 mti RestoreString Gets a null terminated string from the checkpoint file Syntax value mti RestoreString Returns Description A null terminated string Arguments None Description mti RestoreString returns a null terminated string from the checkpoint file If the size of the string is less than or equal to 1024 bytes including the NULL then the string must be copied if it is to be used later because it will be overwritten on the next call to mti RestoreString If the size of the string is greater than 1024 bytes mti RestoreString allocates memory to hold the string mti RestoreString is designed to handle unlimited size strings The returned pointer must not be freed This function should be called only from a restore callback function It should not be called from an initialization procedure Related functions mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveShort FLI 589 mti SaveString FLI 592 ModelSim FLI Reference FLI 578 FLI function definitions Example FLI code include lt stdlib h gt include lt mti h gt static char instance
297. deltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading for model sl VSIM 1 run 42 Time 0 ns delta 1 Signal top s1 is 0 Time 0 ns delta 1 Signal top s2 is UXO1 Time 5 ns delta 0 Signal top s2 is X012 Time 5 ns delta 0 Signal top sl is 1 Time 10 ns delta 0 Signal top sl is Z Time 10 ns delta 0 Signal top s2 is O01ZW Time 15 ns delta 0 Signal top s2 is 1ZWL Time 15 ns delta 0 Signal top sl is W Time 20 ns delta 0 Signal top sl is L Time 20 ns delta 0 Signal top s2 is ZWLH Time 25 ns delta 0 Signal top s2 is WLH Time 25 ns delta 0 Signal top sl is H Time 30 ns delta 0 Signal top sl is Time 30 ns delta 0 Signal top s2 is LH U Time 35 ns delta 0 Signal top s2 is H UX Time 35 ns delta 0 Signal top sl is U ModelSim FLI Reference X X Time 40 ns delta O0 Time 40 ns delta O0 VSIM 2 drivers top s1 Drivers for top sl Signal top s1 Driver top sigDriverl 0 at 45 ns VSIM 3 drivers top s2 Drivers for top s2 3 0 Signal top s2 3 Driver top sigDriver2 U at 45 ns Signal top s2 2 Driver top sigDriver2 X at 45 ns Signal top s2 1 Driver top sigDriver2 0 at 45 ns Signal top s2 0 Driver top sigDriver2 L at 45 ns VSIM 4 quit Signal top sl is Signal top s2 is UXO mti CreateDriver FLI 117 ModelSim FLI R
298. dlogicarr1 3 0 after 5 ns when stdlogicarrl 3 l after 5 ns when stdlogicarr1 3 Z after 5 ns when stdlogicarrl 3 W after 5 ns when stdlogicarrl 3 L after 5 ns when stdlogicarrl 3 H after 5 ns stdlogicarrl1 4 lt after 5 ns when stdlogicarrl 4 U after 5 ns when stdlogicarrl 4 X after 5 ns when stdlogicarrl 4 O after 5 ns when stdlogicarrl 4 l after 5 ns when stdlogicarrl 4 Z after 5 ns when stdlogicarrl 4 W after 5 ns when stdlogicarrl 4 L after 5 ns when stdlogicarrl 4 H after 5 ns recl a not recl a after 5 ns recl b lt recl b 1 after 5 ns recl c lt after 5 ns when recl c H else U after 5 ns when recl c else X after 5 ns when recl c U else ModelSim FLI Reference else else else else else else else else H U x QO V R ZU W H U X Q 1 7 W H U ty QO qr 7 W H U X Q yt A W else else else else else else else else else else else else else else else else else else else else else else else else else else else else eise eise eise eise end a O after 5 ns when recl c X else 1 after 5 ns when recl c 0 else Z after 5 ns when recl c 1 else W after 5 ns when recl c Z else L after 5 ns when recl c W else rH after 5 ns Simulation output vsim c top Reading 53 4b Lo
299. duleDriver break inst gt drvidl case STD LOGIC X ModelSim FLI Reference STD LOGIC 0 STD LOGIC 1 STD LOGIC 0 nip mr H u 0 MTI INERTIAL 5 MTI INERTIAL 5 MTI INERTIAL mti CreateSignal FLI 151 region name mti GetRegionFullName mti GetSignalRegion inst sigidl mti PrintFormatted Time d d delta d Signal s s is UNKNOWN Wn mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigidl mti VsimFree region name break default region name mti GetRegionFullName mti GetSignalRegion inst sigidl mti PrintFormatted Time d d delta d Unexpected value d on signal s s n mti NowUpper mti Now mti Delta sigval region name mti GetSignalName inst gt sigidl mti VsimFree region name break This function inverts mySig2 every 10 ns void driveSignal2 void param char region name instanceInfoT inst instanceInfoT param mtiInt32T sigval sigval mti GetSignalValue inst sigid2 switch sigval case STD LOGIC U mti ScheduleDriver inst drvid2 STD LOGIC O0 break case STD LOGIC 0 mti ScheduleDriver inst drvid2 STD LOGIC 1 10 MTI INERTIAL break case STD LOGIC 1 mti ScheduleDriver inst drvid2 STD LOGIC 0 10 MTI INERTIAL break case STD LOGIC X region name mti GetRegionFullName mti GetSignalRegion inst sigid2 mti
300. e 64 ns signal resphyssigl resphys 1 day signal stdlogicsigl std logic H Resolved scalars with unresolved types signal bitsigr resolve bit bit EL signal intsigr resolve_int integer 17 signal realsigr resolve_real real 6 25 signal timesigr resolve time time 2 ns signal physsigr resolve phys bigtime 2 week signal stdulogicsigr resolved std ulogic 1 Unresolved 1D arrays signal bitarrl bitarray 0110 signal intarrl intarray 10 11 12 signal realarrl realarray 7 7 3 2 8 1 signal timearrl timearray 4 ns 5 ns 6 ns ModelSim FLI Reference mti SignallsResolved FLI 645 signal physarrl hourarray 40 hour 50 hour signal stdulogicarrl std ulogic vector 3 downto 0 HLO1 1D Arrays of resolved subelements signal rbitarrl rbitarray 10110110 signal rintarrl rintarray 30 41 52 signal rrealarrl rrealarray 17 6 43 8 9 1 signal rtimearrl rtimearray 1 ns 3 ns 5 ns signal rphysarrl rhourarray 1 day 10 hour 2 week signal stdlogicarrl std logic vector 1 to 4 X0U Unresolved records signal recl t rectypel O 1l l l Il ns X l hour L j Records of resolved elements signal rec2 rectype2 1 5 2 01 3 ns H 2 hour Records of mixed resolution signal rec3 rectype3 1 QOUDUS o 47 8 54 19 5 168 50 SL 6 25 T ns begin
301. e VSIM 1 printSigs printSigs top sl top sl Signal top sl 0 printSigs top s2 top s2 The type of signal top s2 is not supported printSigs top s3 top s3 Signal top s3 not found printSigs quit quit VSIM 2 gt run 5 VSIM 3 gt quit mti Break Requests the simulator to halt Syntax mti Break Returns Nothing Arguments None Description mti Break FLI 99 mti Break requests the simulator to halt the simulation and issue an assertion message with the text Simulation halt requested by foreign interface The break request is satisfied after the foreign code returns control to the simulator The simulation can be continued by the user after it has been halted with mti Break mti Break cannot be called during elaboration Related functions mti FatalError FLI 164 mti Quit FLI 520 Example FLI code include mti h typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC Z STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D StdLogicT yg X ro 11 ig Ww Tr t r x7 ei Xu Ef xy E xy void monitorSignal void param mtiSignalIdT sigid switch mti_GetSignalValue case STD LOGIC X case STD LOGIC W mtiSignalIdT param sigid ModelSim FLI Reference FLI 100 FLI function definitions mti PrintFormatted Time d
302. e to use the system math library libm specify Im to the ld command gcc c fPIC I install dir modeltech include math app c ld shared Bsymbolic E allow shlib undefined o math app so math app o lm 32 bit Solaris platform ModelSim FLI Reference If your foreign module uses anything from a system library you ll need to specify that library when you link your foreign module For example to use the standard C library specify Ic to the Id command gcc compiler gcc c I install dir modeltech include app c ld G B symbolic o app so app o 1c cc compiler cc c I install dir modeltech include app c ld G B symbolic o app so app o lc When using B symbolic with ld all symbols are first resolved within the shared library at link time This will result in a list of undefined symbols This is only a warning for shared libraries and can be ignored Compiling and linking FLI C applications FLI 27 If app so is not in your current directory you must tell Solaris where to search for the shared object You can do this one of two ways Add a path before app so in the foreign attribute specification The path may include environment variables Put the path in a UNIX shell environment variable LD LIBRARY PATH library path without filename 64 bit Solaris platform gcc compiler gcc c ISMTI HOME include m64 fpic app c gcc shared o examplel sl m64 app o This was tested with gcc
303. e Description mtiVoidFuncPtrT A pointer to a function to be called when the simulator restarts void A parameter to be passed to the function OPTIONAL can be NULL Description mti_AddRestartCB adds the specified function to the simulator restart callback list The same function can be added multiple times with possibly a different parameter each time When the simulator restarts all callbacks in the list are called with their respective parameters before the simulator is restarted The callback function should do a cleanup operation including freeing any allocated memory and resetting global static variables When the quit sim command is given to vsim restart callbacks are called because the simulator is not completely quitting but may be restarting the previous design or loading a new design Related functions mti_RemoveRestartCB FLI 545 Example FLI code include lt stdlib h gt include lt mti h gt void restartCallback void param mti_PrintFormatted Cleaning up s for simulator restart n char param free param void initForeign ModelSim FLI Reference FLI 72 FLI function definitions ModelSim FLI Reference mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports char instance info The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute wy x
304. e k de X de ko e o X x a a ELE Example 2 2 3 209 owe nos ee X Uy e e a ook 0 ce es a x ELES PETENS 2 0 20 x Eo X9 A ce G0 d ode ee ee a ec ae a deo o LEO Debugging FLI application code FLI 42 FLI functions by category FLI 43 FLI region DUDSCHODS o eos e vo wok ee SR TEE GRO RO RIED RO m a a a ek ew ac bled FLI process functions rc sr rc sr sr n n n s FLI 44 FLI signal fonctions o 2 2 25 220 9 09 omo omo X 9o 9 ee mo ee ww s e ELAS FLI driver functions c c rrr rc rc rc rcs n nr n n s FLI 46 FLI variable functions 2 2 2 2 2 2 2 2 2 2 2 FLI 46 FLI type f nchons 2 s s dox o wok doc cw X e we xoc RC ook cw vec aw ae x ELAT FL callback functions o e 2 oe a oek poroa Rom m of o m Room Rom os oe V BLISAS FLI memory management functions 5 l l s FLEAS FLI checkpoint restore functions o a s l l c c FLI 49 FLItimeandeventfunctions s s e s l l 2 6 FLE FLI communication and command functions FLI 50 FLI miscellaneous functions 5 l l lll ls rr s rn n s FLI 50 ModelSim FLI Reference Table of Contents FLI function definitions FLI 53 mti AddCommand FLI 54 mti AddEnvCB FLI 57 mti AddInputReadyCB FLI 60 mti AddLoadDoneCB FLI 65 mti AddOutputReadyCB FLI 68 mti AddQuitCB FLI 69 mti AddRestartCB FLI 71 mti AddRestoreC
305. e no pending events current time 1 There are pending events maturity time of the next pending event 2 There are pending postponed maturity time of the next pending processes for the last delta of the current time event which is the current time if there are no future pending events ModelSim FLI Reference FLI 288 FLI function definitions Related functions mti GetNextNextEventTime FLI 291 mti GetRunStopTime FLI 352 mti Now FLI 501 mti NowlIndirect FLI 505 mti NowUpper FLI 510 Example FLI code include mti h static void checkTime void int status mtiTime64T next time status mti GetNextEventTime amp next time switch status case 0 mti PrintFormatted No pending events Next time is d d n MTI TIME64 HI32 next time MTI TIME64 LO32 next time break case 1 mti PrintFormatted Pending events Next time is d d n MTI TIME64 HI32 next time MTI TIME64 LO32 next time break case 2 mti PrintFormatted Pending postponed processes Next time is d d n MTI TIME64 HI32 next time MTI TIME64 LO32 next time break void doProc void mti PrintFormatted Time d d doProc n mti_NowUpper mti Now checkTime static void checkEnv void mti PrintFormatted Time d d checkEnv n mti_NowUpper mti_Now checkTime static void checkRegion void mti PrintFormatted T
306. e not to use the MTI provided memory allocation functions you will have to explicitly save and restore your allocated memory structures as well You must code your model assuming that the code could reside in a different memory location when restored This requires that you update all process pointers during a restore and re register all callback functions either in the init function or after the restore is complete Example The following is a C model of a two input AND gate taken from lt install_dir gt modeltech examples foreign example two gates c It has been adapted for checkpoint restore and the added lines are marked as comments Note that this example addresses only one of the foreign architectures in the example file If you plan to use the file from the installation directory you should comment out the instantiation of the two foreign architectures that aren t used For example dump dump_design a monit monitor This program creates a process sensitive to two signals and whenever one or both of the signals change it does an AND operation and drives the value onto a third signal EY include lt stdio h gt include mti h typedef struct mtiSignalIdT inl mtiSignalIdT in2 mtiDriverIdT outl mtiProcessIdT proc new inst rec void do and void param inst_rec ip inst_rec param Using the VHDL FLI FLI 21 mtilnt32T vall val2 mtiInt32T result vall mti GetSignalVal
307. ead 9 Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read A Read returned 1 Read B Read returned 1 Read C Closing socket VSIM 1 quit ModelSim FLI Reference FLI 90 FLI function definitions mti AddSocketOutputReadyCB Adds or removes a socket output ready callback Syntax mti AddSocketOutputReadyCB socket desc func param Returns Nothing Arguments Name Type Description socket desc int A socket descriptor func mtiVoidFuncPtrT A pointer to a function to be called whenever the socket descriptor is available for writing A parameter to be passed to the function OPTIONAL can be NULL Description mti_AddSocketOutputReadyCB puts a watch on the specified socket descriptor Whenever the socket descriptor is available for writing the specified function is called along with its parameter To remove a previously added callback call mti_AddSocketOutputReadyCB with the same socket descriptor but with a NULL function pointer mti_AddSocketInputReadyCB and mti AddSocketOutputReadyCB are useful in setting up cosimulation environments where FLI code uses sockets to communicate with other processes In the course of initialization a cosimulation application typically would use standard system library routines to create or open a so
308. eadyCB SOCKET sock mtiVoidFuncPtrT 0 0 mti PrintMessage Closing socket in close SOCKET sock void loadDoneCB void sock mti_PrintMessage Load Done Adding socket callback n mti AddSocketInputReadyCB SOCKET sock mtiVoidFuncPtrT sockCB sock void initForeign mtiRegionIdT region The ID of the region in which this ModelSim FLI Reference mti AddSocketInputReadyCB foreign architecture is instantiated char param The last part of the string in the y foreign attribute Er mtiInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model char hostname MAXHOSTNAMELEN localhost int statusFlags int server_length int status int retry_cnt 0 short portNum 0 struct sockaddr_in server struct hostent hp SOCKET sock INVALID SOCKET ifdef WIN32 WORD wVersionRequested WSADATA wsaData int err wVersionRequested MAKEWORD 1 1 err WSAStartup wVersionRequested amp wsaData if err 0 mti PrintMessage Cannot find a usable winsock dll n return Confirm that the Windows Sockets DLL supports 1 1 Note that if the DLL supports versions greater than 1 1 in addition to 1 1 it will still return 1 1 in wVersion since that is the version we requested 47 if LOBYTE wsaData wVersion 1 HIBYTE wsaData wVersion 1 m
309. earr timearray 15 ns 6 ns begin bitsig not bitsig initForeign for model sl OlLH ModelSim FLI Reference FLI 466 FLI function definitions ModelSim FLI Reference intsig intsig 1 realsig 7 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 wait for 5 ns end process end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl vsim c top Loading modeltech sunos5 std standard 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 1 745000e 01 Variable timesig 6 ns Variable stdlogicsig 0 Variable bitarr 1001 Variable stdlogicarr 1010 Variable intarr 11 12 13 Variable realarr 1 270000e 01 1 023200e 02 Variable timearr 16 ns 7 ns Time 0 9 Variable bitsig 1 Variable intsig 23 Variable realsig 1 855000e 01 Variable timesig 7 ns Variable stdlogicsig 1 Variable bitarr 0110 Variable stdlogicarr 0101 Variable intarr 12 13 14 Variable realarr 1 380000e 01 1 034200e 02
310. eat period Returns Name Description error code i 1 if successful 0 if there is an error Arguments Name Type Description signal id mtiSignalldT A handle to the VHDL signal to be forced value_string char The value to be forced specified as a string in the same format as would be provided to the simulator s force command delay mtiDelayT The time at which the force is to be applied relative to the current time specified in current simulator resolution units force_type mtiForceTypeT Indicates whether the force is to freeze drive deposit or use the default force type cancel_period mtiInt32T If non negative specifies the period after which the force is cancelled specified in current simulator resolution units repeat period mtiInt32T If non negative specifies the period in which the force is repeated specified in current simulator resolution units ModelSim FLI Reference mti ForceSignal FLI 209 Description mti ForceSignal forces the specified VHDL signal to the specified value using the specified force type and an optional delay cancel period and repeat period The value must be specified in a string in the same format as would be provided to the simulator s force command and the restrictions on the type of the value are the same as for the force command see ModelSim Command Reference for details If the delay parameter is non negative then the delay specifies the time at w
311. eateEnumType 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 sc
312. ech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 20 VSIM 2 checkpoint cp file Saving instance info for model VSIM 3 run 30 VSIM 4 restore cp file Loading checkpoint restore data from file cp file Checkpoint created Thu Apr 27 15 52 32 2000 Restoring state at time 20 ns iteration 1 Restored instance info for model VSIM 5 run 10 VSIM 6 quit Cleaning up mti AddSimStatusCB FLI 83 mti AddSimStatusCB Syntax Returns Arguments Description Adds a simulator run status change callback mti AddSimStatusCB func param Nothing Type Description mtiSimStatusCBFunc A pointer to a function to be called PtrT whenever the simulator run status changes void A parameter to be passed to the function OPTIONAL can be NULL mti AddSimStatusCB adds the specified function to the simulator run status change callback list The same function can be added multiple times with possibly a different parameter each time Whenever the simulator run status changes all callbacks in the list are called with their respective parameters plus a second parameter of type int which is 1 when the simulator is about to start a run and 0 when the run completes Related functions Example mti_RemoveSimStatusCB FLI 557 FLI code include mti h void simStatusCallback void param int run status mtiRegi
313. ecified according to the following rules e t can be either a full hierarchical name or a relative name A relative name is relative to the region set by the environment command The top level region is the default e It must include the process label if the object is declared in a process t must not include a slice specification mti GetVarImage can be called successfully only after elaboration is complete Related functions mti FindVar FLI 187 mti GetVarImageByld FLI 421 mti GetVarValue FLI 442 ModelSim FLI Reference mti GetVarlmage FLI 417 Example FLI code include lt stdio h gt include lt mti h gt define NAME_MAX 1024 typedef struct varInfoT tag struct varInfoT tag next char name mtiProcessIdT procid mtiRegionIdT regid mtiTypeIdT typeid mtiVariableIdT varid varInfoT typedef struct varlInfoT var info List of variables mtiProcessIdT proc Test process id instanceInfoT static void checkValues void inst info char region_name char var name NAME MAX instanceInfoT inst data instanceInfoT inst info varliInfoT varinfo mti PrintFormatted Time d d n mti NowUpper mti Now for varinfo inst data var info varinfo varinfo varinfo gt next region name mti GetRegionFullName varinfo gt regid sprintf var name s s s region name mti GetProcessName varinfo procid varinfo name mt
314. eduleDriver inst gt drvidl SIGVAL 0 5 MTI INERTIAL break case SIGVAL X signal name mti GetSignalNameIndirect inst sigid1 NULL region name mti GetRegionFullName mti GetSignalRegion inst sigid1 0 mti PrintFormatted Time d d delta d Signal s s is UNKNOWN n mti NowUpper mti Now mti Delta region name signal name mti VsimFree signal name mti VsimFree region name break default signal name mti GetSignalNameIndirect inst sigid1 NULL region name mti GetRegionFullName mti GetSignalRegion inst sigid1 mti PrintFormatted Time d d delta d Unexpected value d on signal s s n mti NowUpper mti Now mti Delta sigval region name signal name mti VsimFree signal name mti VsimFree region name 0 ModelSim FLI Reference FLI 110 FLI function definitions ModelSim FLI Reference break This function inverts mySig 1 every 10 ns void driveSignal2 void param char region_name char signal_name instanceInfoT inst instanceInfoT param mtiInt32T sigval sigval mti GetSignalValue inst gt sigid2 switch sigval case SIGVAL 0 mti ScheduleDriver inst drvid2 SIGVAL 1 10 MTI INERTIAL break case SIGVAL 1 mti ScheduleDriver inst drvid2 SIGVAL 0 10 MTI INERTIAL break case SIGVAL X signal name mti GetSignalNameIndirect inst sigid2 NULL 0 region name mt
315. ef struct varInfoT tag struct varInfoT tag next char name mtiVariableIdT varid mtiTypeIdT typeid varInfoT typedef struct varlInfoT var info List of variables mtiProcessIdT proc Test process id instanceInfoT static void printValue mtiVariableIdT varid mtiTypeIdT vartype int indent int print newline switch mti_GetTypeKind vartype case MTI_TYPE_ENUM char enum_values mtilnt32T scalar val enum values mti GetEnumValues vartype scalar val mti GetVarValue varid mti PrintFormatted s enum values scalar val break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val scalar val mti GetVarValue varid mti PrintFormatted d scalar val break case MTI_TYPE_ARRAY int T mtiVariableIdT elem list elem list mti GetVarSubelements varid 0 for i 0 i lt mti TickLength vartype i printValue elem list i mti GetVarType elem list il indent O0 mti_VsimFree elem_list break case MTI_TYPE_RECORD int i mtiVariableIdT elem_list mtilnt32T num elems elem list mti GetVarSubelements varid 0 ModelSim FLI Reference mti GetVarSubelements FLI 433 num elems mti GetNumRecordElements vartype mti PrintFormatted n for i 0 i lt num elems i mti PrintFormatted c indent printValue elem list i mti GetVarType elem list
316. eference FLI 118 FLI function definitions mti CreateEnumType Syntax Returns Arguments Description ModelSim FLI Reference Creates an enumeration type type id mti CreateEnumType size count literals Type Description mtiTypeldT A handle to the new enumeration type Type Description mtiInt32T The number of bytes to be used to store the values of the new enumeration type if the count parameter is greater than 256 then size must be 4 otherwise size should be 1 mtiInt32T The number of literals values in the new enumeration type literals char An array of strings that define the enumeration literals for the new enumeration type mti CreateEnumType creates a new type ID that describes a VHDL enumeration type The new type consists of the specified enumeration literals and its values are of the specified size The count parameter indicates the number of strings in the literals parameter The left most value of the enumeration type is 0 and is associated with the first literal string the next value is 1 and is associated with the next literal string and so on If there are more than 256 values in the enumeration type then 4 bytes must be used to store the values otherwise 1 byte should be used Related functions mti CreateArrayType FLI 108 mti CreateRealType FLI 139 mti CreateScalarType FLI 146 mti CreateTimeType FLI 154 mti GetEnumValues FLI 271
317. eference FLI 622 FLI function definitions Example FLI code include mti h typedef struct signalInfoT tag struct signalInfoT tag next char name mtiSignalldT sigid mtiTypeIdT typeid signalInfoT typedef struct signaliInfoT sig infos List of signals mtiProcessIdT proc Test process id instanceInfoT static void setValue mtiSignallIdT sigid mtiTypelIdT sigtype switch mti_GetTypeKind sigtype case MTI_TYPE_ENUM mtilnt32T scalar val Scalar val mti GetSignalValue sigid Scalar val t if scalar val mti TickLow sigtype l scalar val mti TickHigh sigtype Scalar val mti TickLeft sigtype mti SetSignalValue sigid long scalar val break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val Scalar val mti GetSignalValue sigid scalar_val t mti SetSignalValue sigid long scalar_val break case MTI_TYPE_ARRAY int gr mtiTypeldT elem type mtiSignalIdT elem list elem type mti GetArrayElementType sigtype switch mti GetTypeKind elem type case MTI TYPE SCALAR case MTI TYPE PHYSICAL mtilnt32T array val mti GetArraySignalValue sigid 0 for i 0 i lt mti TickLength sigtype i array val i mti_SetSignalValue sigid long array_val mti VsimFree array val break case MTI_TYPE_ARRAY ModelSim FLI Reference mti SetSignalValue FLI 623 case
318. egid indent mti VsimFree region name void loadDoneCB void param mtiRegionIdT regid mti_PrintMessage nDesign Regions n for regid mti_GetTopRegion regid regid mti_NextRegion regid printHierarchy regid 1 void initForeign mtiRegionIdT region The ID of the region in which this EL foreign architecture is instantiated char param The last part of the string in the y foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model Hf void mti_CreateRegion region my region mti AddLoadDoneCB loadDoneCB 0 HDL code cache v module cache clk paddr pdata prw pstrb prdy saddr sdata srw sstrb srdy input clk srdy paddr prw pstrb output prdy saddr srw sstrb inout sdata pdata define addr_size 8 define set size define word size 16 reg verbose reg word size 1 0 sdata r pdata r reg addr size 1 0 saddr r reg Srw r sstrb_r prdy r wire addr size 1 0 paddr ModelSim FLI Reference wire wire wire reg 3 0 wire 3 0 addr size 1 0 word size 1 0 oen hit wen mti GetRegionKind FLI 331 5 saddr saddr r 5 sdata sdata r pdata pdata r 5 srw srw_r sstrb sstrb_r prdy prdy_r RRR RK KR ke ke ke KR e e e ke Cache sets Ok ckok koe ko ke ke ke e e e e x x cache set cache
319. egion ES char param fie mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is generic delay port a in bit bo out bit i end inv time architecture b of inv is signal count integer Il o begin b lt a after delay pl process a cRegion s n nHierarchy n printHierarchy mti_GetTopRegion architecture is region int indent mti GetRegionFullName region indent region name mti FirstLowerRegion region mti NextRegion regid LE The ID of the region in which this x foreign architecture is instantiated The last part of the string in the x7 foreign attribute EJ A list of generics for the foreign model A list of ports for the foreign model x initForeign for model sl DnS pi ModelSim FLI Reference FLI 374 FLI function definitions begin count lt count 1 after 0 ns end process end b entity mid is end mid architecture a of mid is signal sl bit 0 signal 52 i bit r QO signal sS 2 bit ie EOT signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit b out bit i end compo
320. eign for model sl begin end a entity top is end top architecture a of top is bit signal sl Vots mti Malloc strlen param param A list of generics for the foreign model A list of ports for the foreign model x Tod or instance info instance info architecture is my for model ModelSim FLI Reference FLI 594 FLI function definitions component for model is end component for all begin il G S lt n end a for_model use entity work for_model a r_model ot sl after 5 ns Simulation output 9 vsim c Reading 5 4b vsim c Loading Loading Loading Loading VSIM 1 r Saving Saving Saving Saving Saving VSIM 3 r VSIM 4 gt r Loading Checkpo Restori Restori Restori Restori Restori Restori VSIM 5 gt r top modeltech tcl vsim pref tcl top modeltech sunos5 std standard work top a work for model a for model sl un 20 VSIM 2 checkpoint cpfile instance info my for model char Z long 123456 short 587 string Howdy un 40 estore cpfile checkpoint restore data from file cpfile int created Fri Jul 7 16 09 02 2000 ng state at time 20 ns iteration 1 ng instance info my for model ng char Z ng long 123456 ng short 587 ng string Howdy un 10 VSIM 6 quit ModelSim FLI Reference mti ScheduleDriver FLI 595 mti ScheduleDriver Schedules a driver to drive a value onto a VH
321. el region after elaboration is complete mti_FindRegion can be used to obtain a handle to either VHDL Verilog or SystemC region A handle to a Verilog region can be used with PLI functions to obtain information about or access objects in the Verilog region During elaboration design units that have not yet been instantiated will not be found by mti_FindRegion Related functions mti_FirstLowerRegion FLI 191 mti_GetCallingRegion FLI 240 mti_GetCurrentRegion FLI 248 mti_GetRegionKind FLI 328 mti_GetTopRegion FLI 399 mti_HigherRegion FLI 459 mti_NextRegion FLI 489 ModelSim FLI Reference FLI 178 FLI function definitions Example ModelSim FLI Reference FLI code include mti h void loadDoneCB void param char region_name mtiRegionIdT regid mti PrintMessage nLoad Done phase n regid mti FindRegion top if regid region name mti GetRegionFullName regid mti PrintFormatted Found region s n region name mti VsimFree region name regid mti FindRegion instl if regid region name mti GetRegionFullName regid mti PrintFormatted Found region s n region name mti VsimFree region name foreign attribute The il region is not found here because it is not a subregion of top which is the current context xf regid mti FindRegion il if regid region name mti GetRegionFullName regid mti Print
322. eldT A handle to the type ID of the specified variable Arguments Name Type Description variable id mtiVariableIdT A handle to a VHDL variable Description mti GetVarType returns a handle to the type of the specified VHDL variable Related functions None Example FLI code include lt mti h gt static char getTypeStr mtiTypeIdT typeid char typestr switch mti_GetTypeKind typeid case MTI_TYPE_SCALAR typestr Scalar break case MTI_TYPE_ARRAY typestr Array break case MTI_TYPE_RECORD typestr Record break case MTI_TYPE_ENUM typestr Enum break case MTI_TYPE_PHYSICAL typestr Physical break case MTI_TYPE_REAL typestr Real break case MTI_TYPE_ACCESS typestr Access break case MTI_TYPE_FILE typestr File break case MTI_TYPE_TIME typestr Time break default typestr UNKNOWN break ModelSim FLI Reference mti GetVarType FLI 439 return typestr static void printVarInfo mtiVariableIdT varid mti_PrintFormatted Variable 12s is of type s n mti_GetVarName varid getTypeStr mti_GetVarType varid static void initInstance void param mtiProcessIdT procid mtiRegionIdT regid mtiVariableIdT varid regid mti GetTopRegion for procid mti FirstProcess regid procid procid mti NextProcess for varid mti FirstVar procid varid varid mti NextVar printVarInfo varid void init
323. eltech tcl vsim pref tcl top modeltech sunos5 std standard work top a mid a work inv b work for_model a for model sl work Hierarchy top Parent region is top Parent region is instl Parent region is instl Parent region is instl1 standard VSIM 1 quit ModelSim FLI Reference mti PrintMessage FLI 517 mti PrintMessage Prints a message to the Main window transcript Syntax mti PrintMessage message Returns Nothing Arguments Name Description message The message to be printed Description mti PrintMessage prints a message in the Main simulator window and in the transcript file One or more newline characters can be included in the message string however a newline character is provided at the end of the message by default Related functions mti PrintFormatted FLI 514 Example FLI code include mti h void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT parent mtiRegionIdT regid region name mti GetRegionFullName region mti PrintMessage region name mti VsimFree region name parent mti HigherRegion region indent 2 for regid mti FirstLowerRegion region regid regid mti NextRegion regid printHierarchy regid indent void loadDoneCB void param mtiRegionIdT regid ModelSim FLI Reference FLI 518 FLI function definitions ModelSim F
324. end a Simulation output 9 vsim c top Reading modeltech 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 gt run 50 Time 0 0 delta 0 Signal top sl is 0 Time 0 5 delta 0 Signal top sl is 1 Time 0 10 delta Time 0 15 delta Time 0 20 delta Time 0 25 delta Time 0 30 delta Time 0 35 delta Time 0 40 delta Time 0 45 delta Signal top sl is Z Signal top sl is W Signal top sl is L Signal top sl is H Signal top sl is Signal top sl is U Signal top sl is X Signal top sl is 0 OO gt tQ O0 ModelSim FLI Reference mti CreateProcess FLI 127 Time 0 50 delta 0 Signal top sl is 1 VSIM 2 quit Cleaning up ModelSim FLI Reference FLI 128 FLI function definitions mti CreateProcessWithPriority Creates a new VHDL process with a specific priority Syntax process id mti CreateProcessWithPriority name func param priority Returns Name Type Description process id mtiProcessIdT A handle to the new VHDL process or NULL if there is an error Arguments Type Description char The name of the new VHDL process OPTIONAL can be NULL mtiVoidFuncPtrT A pointer to the function that will be executed as the body of the new proces
325. enerics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model instanceInfoT inst mtiProcessIdT procid mtiTypeIdT enum type inst instanceInfoT malloc sizeof instanceInfoT enum type mti CreateEnumType 1 9 std logic lits inst gt sigidl mti CreateSignal mySigl region enum type inst gt drvidl mti CreateDriver inst sigidl procid mti CreateProcess mySiglDriver driveSignall inst mti Sensitize procid inst gt sigidl MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvidl procid inst sigid2 mti CreateSignal mySig2 region enum type inst drvid2 mti CreateDriver inst sigid2 procid mti CreateProcess mySig2Driver driveSignal2 inst mti Sensitize procid inst gt sigid2 MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvid2 procid inst sigid3 mti CreateSignal mySig3 region enum type inst drvid3 mti CreateDriver inst sigid3 procid mti CreateProcess mySig3Driver driveSignal3 inst mti Sensitize procid inst gt sigidl MTI EVENT mti Sensitize procid inst gt sigid2 MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvid3 procid mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst HDL code entity top is end top architecture a of top is signal sl bit 0
326. entity work lower level end for mti_GetSecondaryName FLI 357 severity note ModelSim FLI Reference FLI 358 FLI function definitions for all use ent end for end for end cfg to for model ity work for model for arch p Simulation output 9 vsim c Reading 5 4b ysim C Loading Loading Loading Loading Loading Loading Loading Foreign Region for arch Load Don Region Region Region Region Region VSIM 1 qu ModelSim FLI Reference top modeltech tcl vsim pref tcl top modeltech sunos5 std standard modeltech sunos5 ieee std logic 1164 body work for pkg body work top beh work lower level work for model for arch for model sl Init Function parameter is top finst Primary name is for model Secondary name is e Callback Function top Primary name is top Secondary name is beh top linstl Primary name is lower Secondary name is level top linst2 Primary name is lower Secondary name is level top finst Primary name is for model Secondary name is for arch for pkg Primary name is for pkg Secondary name is NULL it mti GetSignalMode Gets the mode direction of a VHDL signal mti GetSignalMode FLI 359 Syntax direction mti GetSignalMode signal id Returns Name Type Description direction mtiDirectionT The port mode of the specified signal Arguments Name Type Description signal i
327. enum values val i else char val array_val for i 0 i lt num elems i mti PrintFormatted s enum values val i break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted d val i break case MTI_TYPE_ARRAY mti_PrintMessage ARRAY ModelSim FLI Reference FLI 444 FLI function definitions break case MTI TYPE RECORD mti PrintMessage RECORD break case MTI TYPE REAL double val array_val for i 0 i lt num elems i mti PrintFormatted g val i break case MTI_TYPE_TIME mtiTime64T val array_val for i 0 i lt num elems i mti_PrintFormatted d d MTI TIME64 HI32 val il MTI TIME64 LO32 val il break default break mti_PrintFormatted n break case MTI_TYPE_RECORD int i mtiVariableIdT elem list mtilnt32T num elems elem list mti GetVarSubelements varid 0 num elems mti GetNumRecordElements vartype mti PrintFormatted n for i 0 i lt num elems i mti PrintFormatted c indent printValue elem list i mti GetVarType elem list il indent 2 mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetVarValueIndirect varid amp real val mti PrintFormatted gYn real val brea
328. er Since initially the debugger recognizes only vsim s FLI function symbols when invoking the debugger directly on vsim you need to place a breakpoint in the first FLI function that is called by your application code An easy way to set an entry point is to put a call to mti GetProductVersion FLI 323 as the first executable statement in your application code Then after vsim has been loaded into the debugger set a breakpoint in this function Once you have set the breakpoint run vsim with the usual arguments e g run c top On HP UX you might see some warning messages that vsim doesn t have debugging information available This is normal If you are using Exceed to access an HP machine from Windows NT it is recommended that you run vsim in command line or batch mode because your NT machine may hang if you run vsim in GUI mode Click on the go button or use F5 or the go command to execute vsim in wdb When the breakpoint is reached the shared library containing your application code has been loaded In some debuggers you must use the share command to load the FLI application s symbols On HP UX you might see a warning about not finding ia flags in the object file This warning can be ignored You should see a list of libraries loaded into the debugger It should include the library for your FLI application Alternatively you can use share to load only a single library At this point all of the FLI application
329. er each call to mti Cmd Any command that changes the state of simulation such as run restart restore etc cannot be sent from a foreign architecture foreign subprogram or callback that is executing under the direct control of vsim Related functions Example ModelSim FLI Reference mti Command FLI 105 mti Interp FLI 467 FLI code include include include include typedef e STD_LOG STD_LOG lt stdio h gt lt stdlib h gt tcl h mti h num IC U Le pr cx TOX JE XT RY mti Cmd FLI 103 STD LOGIC 0 FE SOU xf STD LOGIC 1 FREE A STD LOGIC Z Z STD LOGIC W W STD LOGIC L qx VES ORL STD_LOGIC_H TH STD LOGIC D Fat NA StdLogicT void monitorSignal void param char buffer 256 char region name char signal name int status mtiSignallIdT sigid mtiSignalIdT param Tcl Interp interp switch mti GetSignalValue sigid case STD LOGIC X case STD LOGIC W signal name mti GetSignalName sigid region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Time d d delta d Signal s s is UNKNOWN Wn mti NowUpper mti Now mti Delta region name signal name sprintf buffer drivers s s region name signal name interp mti Interp status mti Cmd buffer if status TCL OK mti PrintMessage ERROR while executing drivers command n else mti Pr
330. er into which the value is to be placed OPTIONAL can be NULL mti GetArraySignalValue returns the value of an array type signal If the buffer parameter is NULL then mti GetArraySignalValue allocates memory for the value and returns a pointer to it The caller is responsible for freeing the returned pointer with mti VsimFree FLI 667 If the buffer parameter is not NULL then mti GetArraySignalValue copies the value into the buffer parameter and also returns a pointer to it The appropriate length of the buffer parameter can be determined by calling mti TickLength FLI 657 on the type of the array signal The array value is interpreted as follows For a subelement of type The value should be cast to Enum char if lt 256 values mtiInt32T if gt 256 values Physical mtiInt32T Real double Scalar Integer mtiInt32T Time mtiTime64T Related functions Example mti GetSignalValue FLI 386 mti GetSignalValueIndirect FLI 392 FLI code include mti h typedef struct signalInfoT tag struct signalInfoT tag next char name mtiSignalldT sigid mtiTypeIdT typeid signalInfoT typedef struct signallInfoT sig info List of signals mtiProcessIdT proc Test process id instanceInfoT mti GetArraySignalValue FLI 227 Ar xA static void printValue mtiSignalIdT sigid mtiTypeIdT sigtype int indent switch
331. erface definitions of virtuals contents of list and wave windows env sim top sim top VSIM 1 quit Cleaning up ModelSim FLI Reference mti IsFirstlnit mti IsFirstlnit FLI 473 Detects the first call to the initialization function Syntax status mti IsFirstInit Returns Description 1 during the first call to the initialization function 0 otherwise Arguments None Description mti IsFirstInit returns 1 during the first call to the initialization function or 0 if the simulation has been restarted Related functions mti IsColdRestore FLI 470 mti IsRestore FLI 476 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info static int test_global 15 void cleanupCallback void param mti_PrintMessage nCleanup callback n mti_PrintFormatted free param mti_PrintFormatted void initForeign mtiRegionIdT region char param mtilnterfaceListT generics Freeing param s test_global anty param sd n test global The ID of the region in which this EJ foreign architecture is instantiated The last part of the string in the S foreign attribute A list of generics for the foreign model ModelSim FLI Reference FLI A74 FLI function definitions mtilInterfaceListT ports A list of ports for the foreign model
332. erics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model char primary name char region name char secondary name mti PrintFormatted Foreign Init Function Mn region name mti GetRegionFullName region primary name mti GetPrimaryName region mti GetSecondaryName region secondary name mti PrintFormatted Region parameter is s Primary name is s Secondary name is s n region name primary name Secondary name secondary name lt NULL gt mti VsimFree region name mti AddLoadDoneCB initInstance 0 HDL code entity for model is end for model architecture for arch of for model is attribute foreign of for arch architecture is initForeign for model sl begin end for arch package for pkg is procedure test proc end for pkg package body for pkg is procedure test proc is begin assert false report I m in the test proc end end for pkg use work for pkg all entity lower is end lower architecture level of lower is begin pl process begin test proc wait for 20 ns end process end level library ieee use ieee std logic 1164 all entity top is end top architecture beh of top is component for model end component component lower end component begin linstl lower linst2 lower finst for_model end beh configuration cfg_top of top is for beh for all lower use
333. ertStdLogicValue mtiInt32T sigval char retval switch sigval case STD_LOGIC_U retval U break case STD LOGIC X retval X break case STD LOGIC 0 retval O break case STD LOGIC 1 retval 1 break case STD LOGIC 2 retval Z break case STD LOGIC W retval W break case STD_LOGIC_L retval L break case STD_LOGIC_H retval H break case STD LOGIC D retval break default retval break return retval void watchSignal void param char region_name instanceInfoT inst instanceInfoT param mtiInt32T sigval region name mti GetRegionFullName mti GetSignalRegion inst sigid sigval mti GetSignalValue inst sigid mti PrintFormatted Time d d delta d Signal s s is s n mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid convertStdLogicValue sigval mti VsimFree region name if mti Now gt 30 mti PrintMessage Turning off signal watcher n mti Free inst else mti_ScheduleWakeup inst procid 5 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 kil foreign attribute TE mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of
334. es int var val if var val gt mti TickHigh varinfo gt typeid var val mti TickLow varinfo gt typeid var val mti TickLeft varinfo gt typeid char varinfo var addr else var val ModelSim FLI Reference FLI 410 FLI function definitions mtilnt32T var val mtiInt32T varinfo var addr mti PrintFormatted s n enum values var val var val 1 if var val gt mti TickHigh varinfo gt typeid var val mti TickLow varinfo gt typeid var val mti TickLeft varinfo gt typeid mtiInt32T varinfo gt var_addr var val break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T var val mtiInt32T varinfo var addr mti PrintFormatted d n var val var val 1 mtilnt32T varinfo gt var_addr var val break case MTI_TYPE_ARRAY int i mtiInt32T num elems mtiTypeldT elem type mtiTypeKindT elem typekind void array val array val varinfo var addr num elems mti TickLength varinfo gt typeid elem type mti GetArrayElementType varinfo gt typeid elem typekind mti GetTypeKind elem type switch elem typekind case MTI TYPE ENUM char enum_values enum values mti GetEnumValues elem type if mti TickLength elem type 256 mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted s enum
335. escription mti SetVarValue sets the specified VHDL variable to the specified value immediately If the variable is of type array real or time then the value type is considered to be void instead of long mti SetVarValue cannot be used to set the value of a variable of type record but it can be used to set the values of the individual scalar or array subelements Related functions None Example FLI code include lt mti h gt typedef struct varInfoT tag struct varInfoT_tag next char name mtiVariableIdT varid mtiTypeIdT typeid varInfoT typedef struct varlInfoT var info List of variables mtiProcessIdT proc Test process id instanceInfoT ModelSim FLI Reference mti SetVarValue FLI 629 static void setVarValue mtiVariableIdT varid mtiTypeIdT vartype switch mti_GetTypeKind vartype case MTI_TYPE_ENUM mtilnt32T scalar val scalar val mti GetVarValue varid Scalar valtt if scalar val mti TickLow vartype scalar val mti TickHigh vartype Scalar val mti TickLeft vartype mti SetVarValue varid long scalar_val break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val scalar val mti GetVarValue varid Scalar valtti mti SetVarValue varid long scalar val break case MTI_TYPE_ARRAY int T mtiTypeIdT elem type mtiVariableIdT elem list elem type mti GetArrayElementType
336. ess objects in the Verilog region Related functions mti_FindRegion FLI 177 mti_FirstLowerRegion FLI 191 mti_GetRegionKind FLI 328 mti_HigherRegion FLI 459 mti_NextRegion FLI 489 Example FLI code include lt mti h gt void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s n indent region name indent 2 for regid mti FirstLowerRegion region regid regid mti NextRegion regid ModelSim FLI Reference FLI 400 FLI function definitions ModelSim FLI Reference printHierarchy regid mti VsimFree region name void loadDoneCB void param mtiRegionIdT regid indent mti PrintMessage nDesign Hierarchy n for regid mti GetTopRegion regid regid mti NextRegion regid printHierarchy regid 1 void initForeign mtiRegionIdT region The ID of the region in which this E foreign architecture is instantiated char param The last part of the string in the foreign attribute x7 mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB loadDoneCB HDL code top vhd entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv
337. estartCB restartCallback 0 void initForeign mtiRegionIdT region The ID of the region in which this x foreign architecture is instantiated char param The last part of the string in the J foreign attribute EL mtiInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model char instance info instance info malloc strlen param 1 strcpy instance info param mti AddRestartCB restartCallback instance info mti AddRestartCB restartCallback 0 if mti IsFirstInit mti AddLoadDoneCB loadDoneCallback 0 else mti_AddLoadDoneCB loadDoneCallback void 1 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 for_model begin end a entity top is end top architecture a of top is signal sl bit 0 component for_model is end component for all for model use entity work for_model a begin il for model sl lt not sl after 5 ns end a mti RemoveRestartCB FLI 547 Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 30 VSIM 2 restart f Restarting simulator Cleaning up for
338. etermined The mt IsRestore flag is checked for restore ModelSim FLI Reference FLI 22 Introduction Whena restore is being done mti RestoreBlock is used to restore the ip pointer because mti SaveBlock was used to save it Restores must be performed in the same order as saves The pointer is saved in this fashion because there are no mti SavePointer mti RestorePointer routines e mti RestoreProcess is used to update the process created by mti CreateProcess with the possibly new address of the do and function This is in case the foreign code gets loaded into a different memory location All processes must be restored in this manner All callbacks must be added with an mti Add call during first initialization restart and restore The restore does not restore callbacks because the routines might be located at different places after the restore operation ModelSim FLI Reference Using the VHDL FLI FLI 23 The effect of restart on FLI application code When a simulator restart command is given the simulator by default reloads shared libraries under the following conditions A shared library loaded due to a foreign attribute on a VHDL architecture is reloaded A shared library loaded due to the foreign option to vsim is reloaded A shared library loaded due to a foreign attribute on a VHDL subprogram is not reloaded even if the shared library also contains code for a foreign architecture T
339. eters These callbacks are also called at the end of a restart or a cold restore vsim restore mti_AddLoadDoneCB must be called from a foreign initialization function in order for the callback to take effect A foreign initialization function is specified either in the foreign attribute string of a foreign architecture or in the foreign string option of a vsim command Related functions mti_RemoveLoadDoneCB FLI 539 Example FLI code include lt mti h gt void loadDoneCallback void param mtiRegionIdT region mtiRegionIdT param mti_PrintFormatted Foreign Arch in Region s the top level region is s n mti_GetRegionName region mti_GetRegionName mti_GetTopRegion ModelSim FLI Reference FLI 66 FLI function definitions ModelSim FLI Reference 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 Ki x mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB loadDoneCallback region 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 entity bottom is end bottom architecture b of bottom is begin
340. eturn STD LOGIC Z7 case STD LOGIC 2 return STD LOGIC W case STD LOGIC W return STD LOGIC Ll case STD LOGIC L return STD LOGIC H case STD LOGIC H return STD LOGIC D case STD LOGIC D return STD LOGIC U default return STD LOGIC U void driveSignal void param instanceInfoT inst param inst il last value invertBit inst il last value mti ScheduleDriver inst gt il_drvid inst gt il last value convertToNS 5 MTI_INERTIAL inst i2 last value incrStdLogic inst i2 last value mti ScheduleDriver inst i2 drvid inst i2 last value convertToNS 5 MTI_INERTIAL invertBitArray inst i3 last value inst i3 value length mti ScheduleDriver inst i3 drvid long inst i3 last value convertToNS 5 MTI_INERTIAL inst tl last value invertBit inst tl last value mti ScheduleDriver inst gt tl_drvid inst gt tl last value convertToNS 5 MTI TRANSPORT inst 5t2 last value incrStdLogic inst 5t2 last value ModelSim FLI Reference FLI 598 FLI function definitions ModelSim FLI Reference mti ScheduleDriver inst 5t2 drvid inst t2 last value convertToNS 5 MTI TRANSPORT invertBitArray inst 5t3 last value inst 5t3 value length mti ScheduleDriver inst 5t3 drvid long inst t3 last value convertToNS 5 MTI TRANSPORT mti ScheduleWakeup inst procid inst delay inst delay convertToNS 1
341. etval wow oor void checkSignal void param instanceInfoT param char region_name instanceInfoT inst int i mtilnt32T sigv al mtiSignalIdT drv signals tyr iy r ror r wrqin r nign o m y v ip r igm LA Wren r break brea brea brea brea brea brea brea brea brea sigval mti GetSignalValue inst gt sigid delta d n Signal s is s n mti Delta mti PrintFormatted Time sd sd mti NowUpper inst signame mti PrintFormatted Driving Signals for s n convertStdLogicValue mti Now drv signals mti GetDrivingSignals inst signame for i 0 drv signals i i region_name mti GetRegionFullName mti GetSignalRegion drv signals i mti PrintFormatted s s n mti GetSignalName drv signals i mti VsimFree region name mti ScheduleWakeup inst procid void cleanupCallback void param 5 region name sigval inst gt signame mti PrintMessage free param void initForeign mtiRegionIdT region fE char param fE mtilnterfaceListT generics mtilnterfaceListT ports FE instanceInfoT inst inst inst signame top s1 inst sigid inst procid mti AddQuitCB cleanupCallback mti AddRestartCB cleanupCallback HDL code library ieee use ieee
342. events in zero delay MTI PROC NBA Non Blocking Assignment processes when triggered run after synchronized processes but before postponed processes They can run once per delta and can schedule events in zero delay MTI PROC POSTPONED Postponed processes when triggered run once at the end of the time step for which they are scheduled after all immediate normal synchronized and NBA processes They cannot schedule anything in zero delay In Verilog these types of processes are also known as read only synchronization processes or monitor processes If the process is created during elaboration from inside of a foreign architecture instance then the process is automatically executed once at time zero If the process is created either after elaboration is complete or from any other context such as from an initialization function that executes as a result of the loading of a foreign shared library by the foreign option to vsim then the process is not run automatically but must be scheduled or sensitized mti CreateProcessWithPriority allows you to create a process with an illegal HDL name This can be useful for integrators who provide shared libraries for use by end customers as this is an easy way to avoid potential name conflicts with HDL processes We recommend the following naming style PREFIX name where PREFIX is 3 or 4 characters that denote your software to avoid name conflicts with other integrati
343. f remainder printExtraUnits siginfo remainder static void checkValues void inst_info unit_name char unit_name instanceInfoT inst data instanceInfoT inst info mtilInt32T num units mtilInt32T position mtilnt32T remainder mtilnt32T sigval mtiPhysicalDataT pdp signallInfoT igi ares mti_PrintFormatted Time d d n for siginfo inst data gt sig info mti_PrintFormatted siginfo Signal s sigval mti_GetSignalValue siginfo gt sigid for pdp siginfo gt phys_data pdp pdp if sigval lt pdp gt position break unit name pdp gt unit name position pdp gt position num_units sigval position remainder sigval position mti PrintFormatted d d s sigval if remainder printExtraUnits siginfo mti_PrintFormatted remainder An mti ScheduleWakeup inst_data gt proc 5 mti NowUpper siginfo num units mti Now siginfo next siginfo gt name pdp gt next unit_name ModelSim FLI Reference FLI 308 FLI function definitions ModelSim FLI Reference static signallnfoT setupSignal mtiSignalIdT sigid char prev_unit_name mtilnt32T num units mtilInt32T prev position mtiPhysicalDataT pdp signallInfoT siginfo 0 if mti GetTypeKind mti GetSignalType sigid MTI TYPE PHYSICAL siginfo signallInfoT mti Ma
344. f a unit in the specified physical type Arguments Type Description mtiTypeldT A handle to a VHDL physical type Description mti GetPhysicalData returns a pointer to a linked list of structures each describing the name and position of a unit in the specified physical type The linked list is traversed by using the next pointer in each structure Traversal is terminated by a NULL pointer The caller is responsible for freeing each structure in the list with mti Free mti GetPhysicalData returns NULL if the specified type is not a physical type Related functions None Example FLI code include lt mti h gt typedef struct signalInfoT tag struct signalInfoT tag next char name mtiPhysicalDataT phys data mtiSignalldT sigid mtiTypeIdT typeid signalInfoT typedef struct signallInfoT sig infor List of signals ModelSim FLI Reference mtiProcessIdT proc instanceInfoT static void printExtraUnits signalInfoT siginfo char unit name mtilnt32T num units mtilInt32T position mtilnt32T remainder mtiPhysicalDataT pdp Test process id mti GetPhysicalData FLI 307 Ey mtilnt32T value for pdp siginfo phys data pdp pdp pdp next if value pdp position break unit name pdp unit name position pdp gt position num_units value position remainder value position mti PrintFormatted and d s num units i
345. fe ott STD LOGIC 1 1 STD LOGIC Z Z STD LOGIC W W STD LOGIC L fete STD_LOGIC_H H STD_LOGIC_D f v StdLogicT void monitorSignal void xy Ef x xy EJ param ModelSim FLI Reference FLI 106 FLI function definitions char buffer 256 char region name char signal name mtiSignalIdT sigid mtiSignalIdT param switch mti GetSignalValue sigid case STD LOGIC X case STD LOGIC W signal name mti GetSignalName sigid region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Time d d delta d Signal s s is UNKNOWN Wn mti NowUpper mti Now mti Delta region name signal name sprintf buffer drivers s s region name signal name mti Command buffer mti VsimFree region name break default break 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 E7 foreign attribute Ki mtiInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model mtiProcessIdT procid mtiSignallIdT sigid sigid mti FindSignal top sl1 procid mti CreateProcess SignalMonitor mti Sensitize procid sigid MTI EVENT HDL code library ieee use ieee std logic 1164 a11 entity
346. ffer Returns Name Type Description elem list mtiSignalIdT An array containing the signal IDs of the subelements of the specified signal Arguments Name Type Description signal id mtiSignalldT A handle to a VHDL composite signal buffer mtiSignalldT A buffer into which the subelement signal IDs are to be placed OPTIONAL can be NULL Description mti GetSignalSubelements returns an array containing the signal IDs of the subelements of the specified VHDL or SystemC composite signal If the buffer parameter is NULL mti GetSignalSubelements allocates memory for the array and returns a pointer to it The caller is responsible for freeing this memory with mti VsimFree If the buffer parameter is not NULL then mti GetSignalSubelements copies the subelement signal IDs into the buffer and also returns the buffer parameter The length for the buffer parameter and the return value can be determined by calling mti TickLength on the type of the signal id mti GetSignalSubelements returns NULL if the signal id parameter is not a handle to a VHDL composite signal gt Note The internal representation of multi dimensional arrays is the same as arrays of arrays For example array a x y z is accessed in the same manner as a x y z In order to get to the scalar subelements of an array of arrays mti GetSignalSubelements must be used on each level of the array until reaching the scalar subelements Related functions None Mode
347. file Loading checkpoint restore data from file cpfile Checkpoint created Wed Jul 5 14 04 26 2000 Restoring state at time 40 ns iteration 1 Restore in progress Restored instance info for model VSIM 5 echo now 40 VSIM 6 run 10 VSIM 7 quit Cleaning up vsim c top restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Wed Jul 5 14 04 26 2000 Restoring state at time 40 ns iteration 1 Reading modeltech tcl vsim pref tcl 5 4b Loading checkpoint restore data from file cpfile Checkpoint created Wed Jul 5 14 04 26 2000 Restoring state at time 40 ns iteration 1 Loading for model sl Restore in progress Restored instance info for model Simulation kernel restore completed Restoring graphical user interface definitions of virtuals and wave windows env sim top sim top VSIM 1 run 25 VSIM 2 quit Cleaning up contents of list mti KeepLoaded FLI 479 mti KeepLoaded Syntax Returns Arguments Description Requests that the current shared library not be unloaded on restart or load of a new design mti KeepLoaded Nothing None mti KeepLoaded marks the current shared library as not to be reloaded when a restart or load of a new design occurs mti KeepLoaded must be called from the initialization function of a foreign architecture Normally the reloading of shared libraries is determined by the following A shared library l
348. fo 0 inst data 5sig info siginfo else curr_info gt next siginfo curr_info siginfo mti CreateProcess Test Process testForce void inst data 11 inst data proc mti ScheduleWakeup inst data proc void initForeign ModelSim FLI Reference mtiRegionIdT region p char param mtilnterfaceListT generics mtilnterfaceListT ports p mti AddLoadDoneCB initInstance HDL code library ieee use ieee std logic 1164 a11 package typepkg is type bitarray type intarray is array 1 to 3 type rectype is record a bitty b integer Cc Std logic end record end package typepkg entity for model is end for model architecture a of for model is attribute foreign of a begin end a library ieee use ieee std logic 1164 a11 use work typepkg all entity top is end top architecture a of top is is array 3 downto 0 architecture is mti ForceSignal FLI 215 The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute wy x 7 A list of generics for the foreign model A list of ports for the foreign model 0 of bit of integer initForeign for model sl signal bitsigl bit p Lt signal intsigl integer 21 signal stdlogicsigl std_logic H signal bitarrl bitarray 0110 signal stdlogicarrl std logic vector 1 to 4
349. foT siginfo siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo next 0 return siginfo static void initInstance void param ModelSim FLI Reference instanceInfoT inst data mtiSignalldT signallInfoT E sigid curr info signaliInfoT siginfo inst data mti_SetSignalValue FLI 625 mti Malloc sizeof instanceInfoT inst data 5sig info 0 for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti_ScheduleWakeup inst_data gt proc void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB initInstance HDL code entity for model is end for model architecture a of for model is architecture is attribute foreign of a begin end a library ieee use ieee std logic 1164 a11 entity top is mti CreateProcess Test Process checkValues void inst data 5 The ID of the region in which this 7 foreign architecture is instantiated The last part of the string in the El foreign at
350. foreign initForeign libA so foreign initForeign B so Reading modeltech tcl vsim pref tcl c test Loading sunos5 std standard Loading work test a Loading libA so Shared lib A initialized Loading B so Shared lib B initialized B called Afuncl which returned 17 B called Afunc2 which returned 211 do test do Afuncl was called with parameter B calling Afuncl Afunc2 was called with parameter B calling Afunc2 vsim do test do foreign initForeign libA so foreign initForeign B so ModelSim FLI Reference FLI 38 Introduction Example 2 ModelSim FLI Reference In this example there are two shared libraries A and C ModelSim dynamically loads library C which in turn dynamically loads library A Library A is the same as in Example 1 above FLI code include dlfcn h include lt mti h gt typedef int funcPtrT char void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports int retval funcPtrT funcH void libH mti PrintFormatted Shared lib C initialized n libH dlopen libA so RTLD LAZY af 1 libH mti PrintMessage ERROR Failed to load library libA else 1 funcH dlsym libH Afuncl if funcH mti PrintMessage ERROR Failed to find function in library libA so n else retval funcH C calling Afuncl 8o n F Afuncl mti
351. foreign model mtilnterfaceListT ports A list of ports for the foreign model instance_info malloc strlen param 1 strcpy instance info param mti AddSaveCB saveCallback instance info mti AddRestoreCB restoreCallback instance info mti AddRestoreDoneCB restoreDoneCallback instance info mti AddRestoreDoneCB restoreDoneCallback 0 mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info if strcmp param for model 0 mti RemoveRestoreDoneCB restoreDoneCallback 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 sl1 for model begin end a entity top is end top architecture a of top is mti RemoveRestoreDoneCB FLI 553 signal sl gt bit O component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info for model VSIM 3 run 45 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7
352. fter 5 ns when recl c 0 else Z after 5 ns when recl c 1 else W after 5 ns when recl c Z else L after 5 ns when recl c W else H after 5 ns end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work typepkg Loading work top a Loading work for model a Loading for model sl VSIM 1 add list w 1 top bitsigl VSIM 2 add list w 3 top intsigl VSIM 3 add list w 1 top stdlogicsigl VSIM 4 add list w 4 top bitarrl VSIM 5 add list w 4 top stdlogicarrl VSIM 6 add list w 15 top intarrl VSIM 7 add list w 10 top recl VSIM 8 run 70 VSIM 9 write list list out VSIM 10 quit f cat list out ns top bitsigl top intarrl top recl delta top intsigl top stdlogicsigl top bitarrl top stdlogicarrl U 0 21 H 0110 XOU Or IL T23 01X 5 0 0 22 1001 UO1X 11 12 13 12 0 10 0 23 U 0110 X120 12 13 14 0 3 Ij 11 0 O 42 W 0011 ZW1H 42 42 42 10 42 W 21 1 43 L 1100 WLZ 43 43 43 1 43 L 26 0 O 44 H 0011 LHWU 44 44 44 0 44 H 31 0 45 1100 H LX 45 45 45 1 45 32 40 120 0 1000 LLLL 120 120 120 1 120 0 38 41 0 121 1 0111 AHHH 121 121 121 t0 121 1l 43 0 122 4 1000 2 122 122 122 CD 0122 Z1 48 0 0 123 W 0111 UUUU 123 123 123 0 123 W ModelSim FLI Reference FLI 218 FLI function definitions ModelSim
353. ght 1 intsig type Scalar left 2147483648 right physsig type Physical left 0 right 2147483647 realsig type Real left 0 right 0 timesig type Time left 0 right 0 ogicsig type Enumeration left 0 right 8 bitarr type Array left 2 right 5 ogicarr type Array left 3 right 0 uparray type Array left 1 right 4 rec type Record left 0 right 0 uit 2147483647 mti VsimFree Frees simulator allocated memory mti VsimFree pointer mti VsimFree FLI 667 Description Syntax Returns Nothing Arguments Name pointer Description A pointer to memory previously allocated with malloc by an FLI function mti VsimFree returns the specified block of memory allocated with malloc by an FLI function to the general memory pool mti VsimFree can be used neither for memory allocated by calls to mti Malloc nor for memory allocated with malloc by a user written application The documentation for each FLI function that allocates memory indicates whether that memory should be freed with mti Free or mti VsimFree or whether it should not be freed Related functions mti Free FLI 219 Example FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC Z STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType ModelSim
354. ginfo gt typekind case MTI TYPE ARRAY switch mti GetTypeKind mti GetArrayElementType siginfo 5typeid case MTI TYPE ARRAY case MTI TYPE RECORD siginfo granulate 1 break default siginfo granulate 0 break break ModelSim FLI Reference FLI 532 FLI function definitions case MTI TYPE RECORD siginfo gt granulate 1 break default siginfo gt granulate 0 break if siginfo gt granulate signalInfoT eleminfo signalInfoT currinfo int i mtiSignalIdT subelem subelem mti GetSignalSubelements siginfo gt sigid 0 for i 0 i lt mti_TickLength siginfo gt typeid i eleminfo setupSignal subelem i if siginfo gt child 0 siginfo gt child eleminfo else currinfo gt next eleminfo currinfo eleminfo mti_VsimFree subelem return siginfo static void initInstance void param instanceInfoT inst_data mtiRegionIdT region mtiSignalldT sigid signallnfoT curr info signalInfoT siginfo inst data mti Malloc sizeof instanceInfoT inst data 5sig info 0 inst data state 0 region mti GetTopRegion for sigid mti FirstSignal region sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig info 0 inst data sig info siginfo else curr info next siginfo curr_info siginfo inst_data gt proc mti CreateProcess Test Process
355. gion None mti_NextSignal returns a handle to the next signal in the region set by the latest call to mti FirstSignal mti NextSignal returns NULL if there are no more signals Related functions Example mti FirstSignal FLI 199 FLI code include lt mti h gt void printSignals mtiRegionIdT region int indent mtiSignalIdT sigid for sigid mti FirstSignal region sigid sigid mti NextSignal mti PrintFormatted cSignal s n indent mti GetSignalName sigid void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s n indent region name mti VsimFree region name indent 2 ModelSim FLI Reference FLI 494 FLI function definitions printSignals region indent for regid regid regid printHierarchy regid indent void loadDoneCB void param mti_PrintMessage printHierarchy mti_GetTopRegion void initForeign mtiRegionIdT region Je char param PE x mtiInterfaceListT generics mtilnterfaceListT ports fX mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is nHierarchy n architecture is mti_FirstLowerRegion region mti_NextRegion regid
356. gionFullName region indent region name indent mti FirstLowerRegion region mti NextRegion regid indent nLoad Done phase n 1 The ID of the region in which this Auf foreign architecture is instantiated The last part of the string in the foreign attribute x A list of generics for the foreign model A list of ports for the foreign model xy 0 nElaboration phase Mn 1 initForeign for model sl generic delay time 5 ns port a in bit b out bit i end inv architecture b of inv is begin b lt a after delay pl process variable count integer 0 begin count count 1 wait on a end process end b ModelSim FLI Reference entity top is end top architecture a of top is signal sl 2 bit e tOr signal s2 bit 0 signal 33 2 bit ie tot signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a ins Bit b rr out bit i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 procl process variable count integer 0 begin wait on sl count count 1 end process procl end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim
357. gnal s4 VSIM 1 quit mti GetSignalNamelndirect FLI 367 mti GetSignalNamelndirect Gets the full simple name of a VHDL signal including array indices and record subelement names Syntax signal name mti GetSignalNameIndirect signal id buffer length Returns Name Description signal name The full simple name of the specified signal Arguments Name Type Description signal id mtiSignalldT A handle to a VHDL signal buffer char A buffer into which the signal name is to be placed OPTIONAL can be NULL length i The length of the buffer parameter Description mti_GetSignalNamelIndirect returns the full simple name of the specified VHDL signal including array indices and record fields If the buffer parameter is NULL then mti_GetSignalNamelIndirect allocates memory for the name and returns a pointer to it The caller is responsible for freeing this memory with mti_VsimFree If the buffer parameter is not NULL then mti GetSignalNamelndirect copies the name into the buffer parameter up to the length specified by the length parameter and also returns a pointer to the buffer parameter Related functions mti_GetSignalName FLI 363 ModelSim FLI Reference FLI 368 FLI function definitions Example FLI code include mti h static void printSignalInfo mtiSignalIdT sigid int indent char signame int i mtiSignalIdT elem list mtiTypeIdT sigtype sigtype mt
358. gnalInfo top rec3 f4 i printSignalInfo top rec3 f4 r printSignalInfo top rec3 f4 t printSignalInfo top rec3 f4 s printSignalInfo top rec3 f4 p void initForeign mtiRegionIdT region The ID of the region in which this Ay foreign architecture is instantiated char param The last part of the string in the f foreign attribute if mtiInterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model of mti AddLoadDoneCB loadDoneCB 0 ModelSim FLI Reference ModelSim FLI Reference FLI 642 FLI function definitions HDL code library ieee use ieee std logic 1164 a11 package typepkg is type bigtime is range 0 to integer high units hour day 24 hour week 7 day month 4 week year 12 month end units type int vector is array natural range lt gt of integer type real vector is array natural range lt gt of real type time vector is array natural range lt gt of time type phys vector is array natural range lt gt of bigtime FUNCTION resolve bit s bit vector RETURN bit FUNCTION resolve int s int vector RETURN integer FUNCTION resolve real s real vector RETURN real FUNCTION resolve time s time vector RETURN time FUNCTION resolve phys s phys vector RETURN bigtime type bitarray is array 3 downto 0 of bit type intarray is a
359. grow to 64 bits all other data types are unchanged from the 32 bit world C long and pointer types don t fit in a C int functions with no visible prototype are assumed to return int C long and pointer values are truncated to 32 bits when returned as an int type assigned to an int type cast to an int type printf d or x formats are used instead of ld or lx ints are zero or sign extended to 64 bits when returned as a long or pointer type assigned to a long or pointer type cast to a long or pointer type Using 64 bit ModelSim with 32 bit FLI Applications FLI 35 64 bit time values in the FLI 64 bit time values in the FLI are represented by the type mtiTime64T which is defined in mti h As of ModelSim version 5 4 this type is defined as a 64 bit C long type on 64 bit systems and as a C union type with 64 bit storage alignment on 32 bit systems Because the syntax for referencing mtiTime64T objects has changed C preprocessor macros have been provided in mti h to deal with mtiTime64T references and to make FLI code portable between 32 and 64 bit systems The macros MTI TIME64 INIT MTI TIME64 ASGN MTI TIME64 HI32 and MTI TIME64 LO22 support initialization assignment and reference to mtiTime64T objects as a 32 bit signed high order component and a 32 bit unsigned low order component Here is a small example include mti h mtiTime64T t1 MTI TIME64 INIT 0 1 fF 1 X mtiTime64T t2 32 MTI TIME64 INIT 1 0
360. gth parameter If there is an error or if the signal is in a nodebug region or if the type of the signal is not a scalar enumeration type then the length parameter is set to zero and no values are returned The values in the array are overwritten on each call to mti_GetDriverValues mti GetDriverValues can be used in conjunction with mti_GetDriverNames since the arrays returned from each function are in the same order therefore each driver value can be associated with a name mti GetDriverValues returns the same information as the driver value part of the output of the drivers command Related functions ModelSim FLI Reference mti GetDriverNames FLI 253 mti GetDrivingSignals FLI 267 Example FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC 4 STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType typedef struct char signame mtiProcessIdT procid mtiSignalIdT sigid instanceInfoT char convertStdLogicValue char sigval char retval switch sigval case STD_LOGIC_U retval U break case STD_LOGIC_X retval X break case STD LOGIC 0 retval Q break case STD LOGIC 1 retval 1 break case STD LOGIC 2 retval Z break case STD_LOGIC_W retval W break case STD_LOGIC_L retval L break case STD_LOG
361. h glp gt type mtiTypeldT elem type mti GetArrayElementType glp gt type switch mti GetTypeKind elem type case MTI TYPE PHYSICAL case MTI TYPE SCALAR mtilnt32T val glp gt u generic array value for i 0 i lt num elems i mti PrintFormatted d val i break case MTI_TYPE_ARRAY mti_PrintFormatted ARRAY of ARRAYs break case MTI_TYPE_RECORD mti PrintFormatted ARRAY of RECORDs break case MTI TYPE ENUM char enum_values mti_GetEnumValues elem_type char array_val glp u generic array value for i 0 i lt num elems i mti PrintFormatted s enum values array val i break case MTI_TYPE_REAL double val glp u generic array value for i 0 i lt num elems 144 mti PrintFormatted g valli break case MTI_TYPE_TIME mtiTime64T val glp gt u generic array value for i 0 i lt num elems i mti PrintFormatted d d MTI TIME64 HI32 val il MTI TIME64 LO32 val il ModelSim FLI Reference mti GetGenericList FLI 279 break default break mti_PrintFormatted n break default mti PrintFormatted n break glp next glp gt nxt if free it mti Free glp void printRegionInfo char region_name mtilnterfaceListT generic list mtiRegionIdT regid regid mti FindRegion region name if regid region
362. he last part of the string in the AU foreign attribute DA A list of generics for the foreign model A list of ports for the foreign model Xi 0 is initForeign for model sl of of of of bit integer real time mti GetVarName FLI 429 for all for model use entity work for model a begin instl for_model pl 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 O1LH variable intarr intarray C LO le EB Ng variable realarr realarray 11 6 101 22 variable timearr timearray 15 ns 6 ns variable rec rectype Em q13 TOV WEQOLT ys begin bitsig not bitsig intsig intsig 1 realsig realsig 1 1 timesig timesig 1 ns stdlogicsig not stdlogicsig bitarr not bitarr not stdlogicarr stdlogicarr intarr 1 intarr 1 1 intarr 2 intarr 2 1 intarr 3 r wntarr 3 l realarr 1 realarr 1 1 1 realarr 2 realarr 2 1 1 timearr 1 timearr 0 timearr 1 timearr 0 Tol ns t1ns rec a rec a 1 1 rec b not rec b rec c not rec c wait for 5 ns end process end a ModelSim FLI Reference FLI A430 FLI function definitions Simulation output 9 vsim c top Reading
363. he next simulation event will occur See below for details Description mti GetNextNextEventTime returns the next simulation event time when called from within a VHDL process The current run command s stop time is considered to be a pending event as is the stop time of a step command The return value and next time parameter are set as follows Status Description next time 0 There are no pending events current time 1 There are pending events maturity time of the next pending event 2 There are pending postponed maturity time of the next pending processes for the last delta of the event which is the current time if current time there are no future pending events ModelSim FLI Reference FLI 292 FLI function definitions Related functions Example ModelSim FLI Reference mti GetNextEventTime FLI 287 mti GetRunStopTime FLI 352 mti Now FLI 501 mti NowlIndirect FLI 505 mti NowUpper FLI 510 FLI code include mti h static void checkTime void int status mtiTime64T next time status mti GetNextNextEventTime amp next time switch status case 0 mti PrintFormatted MTI TIME64 HI32 MTI TIME64 LO32 break case 1 mti PrintFormatted MTI TIME64 HI32 MTI TIME64 LO32 break case 2 mti PrintFormatted 9 Next time is d MTI TIME64 HI32 MTI TIME64 LO32 break void doProc void mti_PrintFormatted Time d d mti Now
364. heduling processes ending in 4 n mti NowUpper mti Now mti Delta ScheduleProcesses inst 3 0 void postponedProcess1 instanceInfoT inst mti PrintFormatted Time d d delta d postponedProcess1 Scheduling processes ending in 5 n mti NowUpper mti Now mti Delta ScheduleProcesses inst 4 1 Processes scheduled by normalProcess1 void immedProcess2 void param mti_PrintFormatted Time d d delta d immedProcess2 n mti_NowUpper mti_Now mti_Delta void normalProcess2 instanceInfoT inst ModelSim FLI Reference FLI 132 FLI function definitions ModelSim FLI Reference mti PrintFormatted Time d d delta d normalProcess2 n mti NowUpper mti Now mti Delta void synchProcess2 instanceInfoT inst mti_PrintFormatted Time d d delta d synchProcess2 n mti_NowUpper mti_Now mti_Delta void nbaProcess2 instanceInfoT inst mti_PrintFormatted Time d d delta d nbaProcess2 n mti_NowUpper mti_Now mti_Delta void postponedProcess2 instanceInfoT inst mti PrintFormatted Time d d delta d postponedProcess2 n mti NowUpper mti Now mti Delta Processes scheduled by synchProcess1 void immedProcess3 void param mti PrintFormatted Time d d delta d immedProcess3 n mti NowUpper mti Now mti Delta void normalProcess3 inst
365. hether or not the specified signal is resolved Table 4 FLI driver functions Function Action mti CreateDriver FLI 113 Creates a driver on a VHDL signal mti FindDriver FLI 167 Finds out if a VHDL signal has any drivers on it mti GetDriverNames FLI 253 Gets the names of all drivers on a VHDL signal mti GetDriverSubelements FLI 258 Gets the subelements of a composite driver mti GetDriverValues FLI 262 Gets the values of all drivers on a VHDL signal mti ScheduleDriver FLI 595 Schedules a driver to drive a value onto a VHDL signal mti ScheduleDriver64 FLI 601 Schedules a driver to drive a value onto a VHDL signal with a 64 bit delay mti SetDriverOwner FLI 617 Table 5 Sets the owning process of a driver FLI variable functions Function Action mti FindVar FLI 187 Finds a VHDL variable generic or constant by name mti FirstVar FLI 203 Gets the first VHDL variable generic or constant in a process mti NextVar FLI 497 Gets the next VHDL variable generic or constant in a process mti GetArray VarValue FLI 233 Gets the value of a VHDL variable of type array mti GetVarAddr FLI 408 Gets a pointer to a VHDL variable s value space mti GetVarlImage FLI 416 ModelSim FLI Reference Gets the string image of the value of a VHDL constant generic or variable by name
366. hich the force is to be applied relative to the current time If the delay parameter is negative then the force is applied immediately If the cancel period parameter is non negative then the force is cancelled after the specified period If the cancel period parameter is negative then the force is not automatically cancelled If the repeat period parameter is non negative then the force is repeated for the specified period If the repeat period parameter is negative then the force is not automatically repeated To force records or arrays that are not one dimensional arrays of character enumerations use mti GetSignalSubelements FLI 376 to get a handle to each element and force each element individually mti ForceSignal cannot force a port if the port has values coming into it from a higher level or if the port has a conversion function on it although in some cases you might be able to force the port using the MTI FORCE DRIVE force type with mti ForceSignal Related functions mti ReleaseSignal FLI 527 mti ScheduleDriver FLI 595 mti ScheduleDriver64 FLI 601 mti SetSignalValue FLI 621 Example FLI code include lt stdio h gt include lt stdlib h gt include string h ifndef WIN32 include lt unistd h gt endif include lt mti h gt typedef struct signalInfoT tag struct signalInfoT tag next struct signallInfoT tag child char name void last value mtiSignalldT
367. his default behavior can be overridden in two ways First an FLI application can prevent reloading of the shared library in which it is contained by calling mti KeepLoaded during execution of its foreign architecture initialization function Second the reloading of all shared libraries can be controlled by the vsim options keeploaded and keeploadedrestart both of which prevent any shared libraries from being reloaded during a restart When a shared library is reloaded the internal state of any FLI application which it contains is automatically reset to its initial state But when a shared library is not reloaded if any FLI application which it contains does not specifically check for a restart and reset its internal state to its initial state then the internal state of that FLI application will remain in its last simulation state even though time has been reset to zero Because FLI shared libraries might or might not be reloaded during a restart it is wise to always include a restart callback function see mti AddRestartCB FLI 71 in your FLI application that frees any memory that your code has allocated and resets the internal state of your application It is also a good idea to avoid the use of static local variables Support for Verilog instances The FLI functions are designed to work with VHDL designs and VHDL objects However the functions for traversing the design hierarchy also recognize Verilog instances The following fun
368. ht 0 ogicsig type Enumeration left 0 right 8 bitarr type Array left 2 right 5 ogicarr type Array left 3 right 0 uparray type Array left 1 right 4 rec type Record left 0 right 0 uit 2147483647 mti TickLength FLI 657 mti TickLength Gets the length of a type Syntax length mti TickLength type id Returns Type Description mtiInt32T The length of the range of the specified type the number of fields for record types 0 for real and time types Arguments Type Description mtiTypeldT A handle to a VHDL type Description mti TickLength returns the value of type LENGTH type HIGH type LOW 1 For record types the number of fields is returned For real and time types 0 is returned 0 is returned if the length of the range is greater than will fit in a 32 bit integer Related functions mti TickDir FLI 647 mti TickHigh FLI 651 mti TickLeft FLI 654 mti TickLow FLI 661 mti TickRight FLI 664 ModelSim FLI Reference FLI 658 FLI function definitions Example ModelSim FLI Reference FLI code include mti h static char getTypeStr mtiTypeIdT typeid switch mti_GetTypeKind typeid case MTI_TYPE_SCALAR case MTI_TYPE_ARRAY case MTI_TYPE_RECORD case MTI_TYPE_ENUM case MTI_TYPE_PHYSICAL case MTI_TYPE_REAL case MTI_TYPE_TIME default return Scalar return Array return Record
369. i GetRegionFullName mti GetSignalRegion inst sigid2 mti PrintFormatted Time d d delta d Signal s s is UNKNOWN Mn mti NowUpper mti Now mti Delta region name signal name mti VsimFree signal name mti VsimFree region name break default signal name mti GetSignalNameIndirect inst sigid2 NULL 0 region name mti GetRegionFullName mti GetSignalRegion inst sigid1 mti PrintFormatted Time d d delta d Unexpected value d on signal s s n mti NowUpper mti Now mti Delta sigval region name signal name mti VsimFree signal name mti VsimFree region name break This function drives mySig 0 with the values of mySig 2 and mySig 1 void driveSignal3 void param instanceInfoT inst instanceInfoT param mtiInt32T sigvall mtilInt32T sigval2 sigvall mti GetSignalValue inst gt sigidl sigval2 mti GetSignalValue inst gt sigid2 if sigvall sigval2 mti ScheduleDriver inst drvid3 sigvall 0 MTI INERTIAL else mti ScheduleDriver inst drvid3 SIGVAL X 0 MTI_INERTIAL Er void cleanupCallb mti_PrintMessag free param void initForeign mtiRegionIdT char mtilnterfaceLis mtilnterfaceLis instanceInfoT mtiProcessIdT mtiSignalIdT mtiSignalldT mtiTypeIdT mtiTypeIdT inst enum_type array_type sigid elem_list inst sigidl inst gt drvidl procid mti Sensi
370. i GetSignalType sigid signame mti GetSignalNameIndirect sigid 0 0 mti PrintFormatted c s n indent signame mti VsimFree signame switch mti GetTypeKind sigtype case MTI TYPE ARRAY elem list mti GetSignalSubelements sigid 0 switch mti GetTypeKind mti GetArrayElementType sigtype case MTI TYPE ARRAY case MTI TYPE RECORD for i 0 i lt mti TickLength sigtype i printSignalInfo elem list i indent 2 break default for i 0 i lt mti TickLength sigtype i signame mti GetSignalNameIndirect elem list i 0 0 mti PrintFormatted c s n indent signame mti_VsimFree signame break mti_VsimFree elem_list break case MTI_TYPE_RECORD elem_list mti_GetSignalSubelements sigid 0 for i 0 i lt mti GetNumRecordElements sigtype i switch mti_GetTypeKind mti_GetSignalType elem_list i case MTI_TYPE_ARRAY case MTI_TYPE_RECORD printSignalInfo elem list i indent 2 break default signame mti GetSignalNameIndirect elem list i 0 0 mti PrintFormatted c s n indent signame mti VsimFree signame break mti_VsimFree elem_list break default break void loadDoneCB void param ModelSim FLI Reference mti_PrintMessage mti PrintMessage printSignal mti PrintMessage printSignal mti PrintMessage printSignal mti Pr
371. i PrintFormatted Variable s s n var name mti GetVarImage var name mti VsimFree region name mti ScheduleWakeup inst data proc 5 static varInfoT setupVariable mtiVariableIdT varid mtiRegionIdT regid mtiProcessIdT procid varlInfoT varinfo varinfo varInfoT mti Malloc sizeof varInfoT varinfo gt varid varid varinfo gt name mti_GetVarName varid varinfo gt typeid mti_GetVarType varid varinfo gt regid regid varinfo procid procid varinfo next 0 return varinfo ModelSim FLI Reference FLI 418 FLI function definitions static void initInstance void param instanceInfoT inst data mtiProcessIdT procid mtiRegionIdT regid mtiVariableIdT varid varlInfoT curr info varlInfoT varinfo inst data mti Malloc sizeof instanceInfoT inst data var info 0 regid mti GetTopRegion for procid procid procid for varid varinfo if inst data var info else curr_info gt next curr_info varinfo inst_data gt proc mti_ScheduleWakeup inst_data gt proc void initForeign mt iRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB initInstance HDL code entity for model is end for model architecture a of for model is architecture is attribute foreign of a begin end a library ieee use ieee std logic 1164 a11
372. iable IDs of the subelements of the specified variable Arguments Name Type Description variable id mtiVariableIdT A handle to a VHDL variable buffer mtiVariableIdT A buffer into which the subelement variable IDs are to be placed OPTIONAL can be NULL Description mti GetVarSubelements returns an array containing the variable IDs of the subelements of the specified VHDL composite variable If the buffer parameter is NULL mti GetVarSubelements allocates memory for the array and returns a pointer to it The caller is responsible for freeing this memory with mti VsimFree If the buffer parameter is not NULL then mti GetVarSubelements copies the subelement variable IDs into the buffer and also returns the buffer parameter The length for the buffer parameter and the return value can be determined by calling mti TickLength on the type of the variable id mti GetVarSubelements returns NULL if the variable id parameter is not a handle to a VHDL composite variable gt Note The internal representation of multi dimensional arrays is the same as arrays of arrays For example array a x y z is accessed in the same manner as a x y z In order to get to the scalar subelements of an array of arrays mti GetVarSubelements must be used on each level of the array until reaching the scalar subelements Related functions None ModelSim FLI Reference FLI 432 FLI function definitions Example FLI code include mti h typed
373. ich this Y foreign architecture is instantiated The last part of the string in the xf foreign attribute x A list of generics for the foreign model A list of ports for the foreign model x7 0 nElaboration phase Vn 1 initForeign for model sl 5 Tis variable count integer 0 begin count count 1 wait on a end process end b entity mid is end mid architecture a of mid is signal sl Dit ie tOu signal s2 bit 0 signal s3 bit re Q s signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit i ouk bib i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin insti mid end a mti FirstProcess FLI 197 ModelSim FLI Reference FLI 198 FLI function definitions Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for_model sl Elaboration phase Region top Region top instl Region top instl il Region top instl flip
374. id regid mti NextRegion regid printHierarchy regid indent mti VsimFree region name void loadDoneCB void param mtiSignalIdT elem list mtiSignallIdT sigid mti PrintMessage nLoad Done phase Mn printHierarchy mti GetTopRegion 1 mti PrintMessage nTesting names of composite subelements n sigid mti FindSignal top instl s3 elem list mti GetSignalSubelements sigid 0 mti PrintFormatted Signal s n mti GetSignalName elem list 1 mti VsimFree elem list sigid mti FindSignal top instli s4 elem list mti GetSignalSubelements sigid 0 mti PrintFormatted Signal s n mti GetSignalName elem list 0 mti VsimFree elem list 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 wg foreign attribute d mtilnterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model x mti AddLoadDoneCB loadDoneCB 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 entity inv is generic delay time 5 ns port a in bit amp Pout bit i end inv architecture b of inv is signal count integer
375. id initForeign mtiRegionIdT region fE x char param fE mtilnterfaceListT generics mtilnterfaceListT ports FE mtiProcessIdT procid mtiSignalIdT sigid sigid procid mti FindSignal mti CreateProcess mti Sensitize procid HDL code library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal sl std logic 0 begin pl process begin e case sl is when U gt sl lt X after when X gt sl lt 0 after when 0 gt sl lt 1 after when l gt sl lt Z after when Z gt sl lt W after when W gt sl lt L after when L gt sl lt H after when H gt sl lt after when gt sl lt U after end case cl wait for 5 ns end process end a mti_Quit FLI 521 The ID of the region in which this x7 foreign architecture is instantiated The last part of the string in the x7 foreign attribute A list of generics for the foreign model A list of ports for the foreign model uA top sil 4 SignalMonitor sigid MTI EVENT monitorSignal sigid ns ns ns ns ns ns ns ns CAVE O1 O1 01 O1 O1 Oi non ns ModelSim FLI Reference FLI 522 FLI function definitions Simulation output 9 vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for_model sl c top Loading
376. id initInstance void param instanceInfoT inst data mtiProcessIdT procid mtiRegionIdT regid mtiVariableIdT varid varlInfoT curr info varlInfoT 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 ModelSim FLI Reference mti GetVarAddr FLI 413 varinfo setupVariable varid regid procid if inst data var info 0 inst data var info varinfo else curr_info gt next varinfo curr_info varinfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 5 void initForeign mtiRegionIdT region The ID of the region in which this A foreign architecture is instantiated char param The last part of the string in the x foreign attribute DA mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT 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 a11 entity top is type bitarray is array 3 downto
377. igidl mti VsimFree region name break This function inverts mySig2 every 10 ns void driveSignal2 void param char region_name instanceInfoT inst instanceInfoT param mtiInt32T sigval sigval mti GetSignalValue inst sigid2 switch sigval case SIGVAL 0 mti ScheduleDriver inst drvid2 SIGVAL 1 10 MTI_INERTIAL break case SIGVAL 1 mti ScheduleDriver inst drvid2 SIGVAL 0 10 MTI_INERTIAL break case SIGVAL X region name mti GetRegionFullName mti GetSignalRegion inst sigid2 mti PrintFormatted Time d d delta d Signal s s is UNKNOWN Wn mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid2 mti VsimFree region name break default region name mti GetRegionFullName mti GetSignalRegion inst sigid2 mti PrintFormatted Time d d delta d Unexpected value d on signal s s n mti NowUpper mti Now mti Delta sigval region name mti GetSignalName inst gt sigid2 mti VsimFree region name break This function drives mySig3 with the values of mySigl and mySig2 void driveSignal3 void param instanceInfoT inst instanceInfoT param mtiiInt32T sigvall mtilInt32T sigval2 sigvall mti GetSignalValue inst gt sigidl sigval2 mti GetSignalValue inst sigid2 if sigvall sigval2 mti ScheduleDriver inst drvid3 sigvall 0 MTI INERT
378. ignal s2 rectype 42 1 1100 ModelSim FLI Reference FLI 370 FLI function definitions signal s3 bit vector 7 downto 0 10001111 signal s4 rectype2 r 1 16 O 1111 signal s5 a2 q TOI QIlI signal s6 a3 Hello there component for model is end component for all begin il for model sl lt not sl after 5 ns end a Simulation output vsim c top Reading 5 4b vsim c top Loading work top a work for model a for model sl Loading Loading Loading Composite Signals Signal top s1 sl Signal S s2 a s2 b S2 C s2 c 3 s2 c 2 s2 c 1 s2 c 0 Signal top s3 s3 top s2 Signal top s4 s4 s4 fl s4 f 2 s4 f2 a s4 f 2 b s4 f2 c s4 f2 c 3 ModelSim FLI Reference for_model use entity work for_model a modeltech tcl vsim pref tcl modeltech sunos5 std standard mti GetSignalNamelndirect FLI 371 s4 f2 c 2 s4 f2 c 1 s4 2 c 0 Signal top s5 s5 s5 3 s5 3 2 s5 3 1 s5 3 0 s5 2 s5 2 2 S5 2 1 s5 2 0 Signal top s6 s6 s6 1 1 0 1 1 s6 1 2 1 3 1 4 2 0 2 1 s6 2 2 2 3 2 4 VSIM 1 gt quit ModelSim FLI Reference FLI 372 FLI function definitions mti GetSignalRegion Gets the region in which a VHDL or SystemC signal is declared Syntax region id mti GetSignalRegion
379. ignalSubelements sigid 0 num elems mti GetNumRecordElements sigtype mti PrintFormatted n for i 0 i lt num elems i mti PrintFormatted c indent printValue elem list i mti GetSignalType elem list il indent 2 mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetSignalValueIndirect sigid amp real val mti PrintFormatted g n real val break case MTI_TYPE_TIME mtiTime64T time_val mti GetSignalValueIndirect sigid amp time val mti PrintFormatted d d Wn MTI TIME64 HI32 time val MTI TIME64 LO32 time val break default mti PrintMessage Mn break static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info signallInfoT siginfo mti PrintFormatted Time d d n mti NowUpper mti Now for siginfo inst data sig info siginfo siginfo siginfo gt next mti PrintFormatted Signal s siginfo gt name printValue siginfo gt sigid siginfo gt typeid 4 mti ScheduleWakeup inst data proc 5 static signallnfoT setupSignal mtiSignalIdT sigid signaliInfoT siginfo ModelSim FLI Reference FLI 396 FLI function definitions siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType
380. ignallIdT sigid mtiSignalldT param switch mti GetSignalValue sigid case STD LOGIC X case STD LOGIC W mti PrintFormatted Time d d delta d Signal s is UNKNOWN Mn mti NowUpper mti Now mti Delta ModelSim FLI Reference mti FatalError FLI 165 mti GetSignalName sigid mti FatalError break default break 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 KI foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model f mtiProcessIdT procid mtiSignalIdT sigid sigid mti FindSignal top s1 procid mti_CreateProcess SignalMonitor monitorSignal sigid mti_Sensitize procid sigid MTI_EVENT HDL code library ieee use ieee std_logic_1164 all entity top is end top architecture a of top is signal sl std logic 0 begin pl process begin cl case sl is when U gt sl lt X after 5 ns when X gt sl lt 0 after 5 ns when 0 gt sl lt 1 after 5 ns when l gt sl lt Z after 5 ns when Z gt sl lt W after 5 ns when W gt sl lt L after 5 ns when L gt sl lt H after 5 ns when H gt sl lt after 5 ns when gt sl lt U after 5 ns
381. igtime 40 hour g9 bigtimearray end component g6 realarray begin instl mid generic map 1 42 end a Didn t say 11 6 2 100 ns 8 hour 101 2 for model use entity work for model a 1 34 16 hour 101101 9 ns mti GetGenericList FLI 281 32 hour ModelSim FLI Reference FLI 282 FLI function definitions Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work my pkg Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for model sl Elaboration phase Foreign function generics whoami i n s t j j Load Done phase Region top Region top instl gl 1 g2 42 g3 101 2 ga SN ON SE ES erem rpr g5 7911 g6 8 1 6 2 1 34 g7 0 212 0 100 0 9 g8 40 g9 8 16 32 Region top instl il wheat SJ FA PS EB TS t tit tl Region top instl flip min delay 0 3 max delay 0 8 Region top instil toggle min delay 0 5 max delay 0 10 VSIM 1 run 10 VSIM 2 quit ModelSim FLI Reference mti GetLibraryName FLI 283 mti GetLibraryName Gets the physical name of the library that contains a region Syntax lib name mti GetLibraryName region id Returns Name Description lib name The phy
382. ime 0 0 0 0 0 5 0 5 0 5 0 10 0 15 0 15 0 15 0 20 delta delta delta delta delta delta delta delta delta delta Ww Nee oO wneer 1 Desensitizing process sigMonitor VSIM 2 run 10 VSIM 3 quit Cleaning up Signal Signal Signal Signal Signal Signal Signal Signal Signal Signal top s1 top s1 top s1 top s1 top s1 top s1 top s1 top s1 top s1 top s1 is is is is is is is is is is ro 11 to 11 ro mq 10 11 ro 11 mti Desensitize FLI 163 ModelSim FLI Reference FLI 164 FLI function definitions mti FatalError Requests the simulator to halt with a fatal error Syntax mti FatalError Returns Nothing Arguments None Description mti FatalError causes the simulator to immediately halt the simulation and issue an assertion message with the text Fatal Foreign module requested halt A call to mti FatalError does not return control to the caller The simulation cannot be continued after being halted with mti FatalError Related functions mti Break FLI 99 mti Quit FLI 520 Example FLI code include mti h typedef enum STD_LOGIC_U fe TOY STD_LOGIC_X X STD LOGIC O0 fe Hr y STD LOGIC 1 JE 111 RY STD LOGIC Z Z STD LOGIC W W STD LOGIC L L STD LOGIC H H STD LOGIC D px 3x Xy StdLogicT void monitorSignal void param mtiS
383. ime d d checkRegion Nn mti NowUpper mti Now ModelSim FLI Reference mti GetNextEventTime FLI 289 NOTE mti_GetNextEventTime will always return the current al time when called from inside of a VHDL process EJ checkTime static void initInstance void param mtiProcessIdT procid mtiSignalIdT sigid sigid mti FindSignal top sl procid mti CreateProcess Test Process checkRegion 0 mti Sensitize procid sigid MTI EVENT 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 wy foreign attribute EL mtiInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model f mti AddLoadDoneCB initInstance 0 mti AddEnvCB checkEnv 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 package for pkg is procedure test proc attribute foreign of test proc procedure is doProc for model sl end for pkg package body for pkg is procedure test proc is begin end end for pkg use work for pkg all entity top is end top architecture a of top is component for model end component for all for model use entity work for model a
384. in flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin instl mid end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for model sl Elaboration phase Region top Region top instl Region top inst1 il Region top inst1 flip Load Done phase Region top Region top instl Region top inst1 flip Region top inst1 il Region top inst1 toggle VSIM 1 gt quit for model use entity work for_model a mti GetRegionFullName FLI 327 ModelSim FLI Reference FLI 328 FLI function definitions mti GetRegionKind Gets the type of a region VHDL Verilog or SystemC Syntax region kind mti GetRegionKind region id Returns Name Description region kind i The kind of the region Arguments Name Type Description region id mtiRegionIdT A handle to a VHDL or Verilog region Description mti GetRegionKind returns the kind of the specified VHDL Verilog or SystemC region The value returned is one of the type not fulltype values defined in acc user h or acc vhdl h The PLI routine ac
385. info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 6 void initForeign ModelSim FLI Reference FLI 390 FLI function definitions 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 wy x 7 x mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT 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 a11 entity top is type bitarray is array 3 downto 0 of bit type rectype is record a 3 bit b integer C bitarray end record type bigtime is range 0 to integer high units hour day 24 hour week 7 day month 4 week year 12 month end units end top architecture a of top is signal bitsig bit 1 signal intsig integer 42 signal physsig bigtime 3 hour signal realsig real 10 2 signal timesig time 3 ns signal stdlogicsig std_logic H signal stdlogicarr std
386. inst data 5sig info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 6 void initForeign mtiRegionIdT region The ID of the region in which this EU foreign architecture is instantiated char param The last part of the string in the xy foreign attribute a mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model aA mti AddLoadDoneCB initInstance 0 ModelSim FLI Reference mti GetNumRecordElements FLI 299 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 a11 entity top is type bitarray is array 3 downto 0 of bit type rectype is record amp i bits b integer C real d std logic vector 7 downto 0 e bitarray end record end top architecture a of top is signal rec rectype i TO Ly 3 7 I0010011 1001 component for model end component for all for model use entity work for model a begin instl for model rec a lt not rec a after 5 ns rec b lt rec b 1 after 5 ns rec c lt rec c 2 5 after 5 ns rec d
387. intFormatted Restoring mti_PrintFormatted Restoring mti_PrintFormatted n void initForeign mtiRegionIdT region JE char param fR mtilnterfaceListT generics mtilnterfaceListT ports y instance info mti Malloc str strcpy instance info param mti AddSaveCB saveCallback in mti AddRestoreCB restoreCallba HDL code entity for model is end for model architecture a of for model is ance info g instance info Ss n instance info char c n mti RestoreChar long ld n mti RestoreLong short d n mti RestoreShort string s n mti RestoreString The ID of the region in which this foreign architecture is instantiated The last part of the string in the x foreign attribute Er A list of generics for the foreign model A list of ports for the foreign model A len param 1 stance info Ck instance info ModelSim FLI Reference FLI 562 FLI function definitions ModelSim FLI Reference attribute foreign of a architecture is initForeign for model sl my for model begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model S lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading
388. intFormatted The drivers of s s are Mn sWMn region name signal name interp result Tcl ResetResult interp mti VsimFree region name break default break 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 J foreign attribute TE mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model mtiProcessIdT procid mtiSignalIdT sigid sigid mti FindSignal top sl1 procid mti CreateProcess SignalMonitor monitorSignal sigid mti Sensitize procid sigid MTI EVENT ModelSim FLI Reference FLI 104 FLI function definitions ModelSim FLI Reference HDL code library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal sl std logic 0 begin pl process begin Cl case sl is when U gt sl lt X after 5 ns when X gt s1 lt 0 after 5 ns when 0 gt sl lt 1 after 5 ns when 1 gt s1 lt Z after 5 ns when Z gt sl lt W after 5 ns when W gt sl lt L after 5 ns when L gt sl lt H after 5 ns when H gt sl lt after 5 ns when gt sl lt U after 5 ns end case cl wait for 5 ns end process end a Simulation output 9 vsim c t
389. intMessage printSignal mti PrintMessage printSignal mti PrintMessage printSignal void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports nComposite Signals n Signal top s1 nfo mti FindSignal Signal top s2 nfo mti FindSignal Signal top s3 nfo mti FindSignal Signal top s4 nfo mti FindSignal Signal top s5 nfo mti FindSignal Signal top s6 nfo mti FindSignal mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is architecture is attribute foreign of a begin end a entity top is type rectype is record a integer b bit C bit vector 3 downto O0 end record type rectype2 is record 1 bit 2 rectype end record mti GetSignalNamelndirect FLI 369 top sl 4 E R ee ae MEE ye dy SR an u AR 3 verum Jy ae er 4 The ID of the region in which this 374 foreign architecture is instantiated The last part of the string in the Ey foreign attribute zy A list of generics for the foreign model A list of ports for the foreign model Ry initForeign for model sl type al is array 2 downto 0 of bit type a2 is array 3 downto 2 of al type a3 is array 1 to 2 0 to 4 of character end top architecture a of top is signal sl bit r 0 s
390. integer 21 variable realsig real 16 35 variable timesig time 5 ns ModelSim FLI Reference K variable stdlogicsig variable bitarr variable stdlogicarr variable intarr variable realarr variable timearr variable rec begin bitsig intsig realsig timesig stdlogicsig bitarr intarr 1 intarr 2 intarr 3 realarr 1 realarr 2 timearr 1 timearr 0 stdlogicarr rec rec rec rec 00 009 rec wait for 5 ns end process end a Simulation output vsim c top Reading 5 4b vsim c top Loading Loading mti GetVarValue FLI 447 std logic H bitarray 0110 std logic vector 1 to 4 O1LH intarray 10 11 12 realarray 11 6 101 22 timearray 15 ns 6 ns rectype ime TOU Ly 9 27 HU 1001 7 not bitsig intsig 1 realsig 1 5 timesig 1 ns not stdlogicsig not bitarr intarr 1 1 ous Eois intarr 2 intarr 3 realarr 1 0 5 realarr 2 0 5 timearr 1 1 ns timearr 0 1 ns not stdlogicarr not rec a rec b 1 rec c 2 5 not rec d not rec e modeltech tcl vsim pref tcl modeltech sunos5 std standard 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 6 Variable bitsig 1 Variable intsig 23 ModelSim FLI Reference FLI 448 FLI function defi
391. ions procid procid mti PrintFormatted itf mti GetProcessName procid indent 2 printVariables procid void printHierarchy mtiRegionIdT region char mtiRegionIdT regid region_name region_name mti_PrintFormatted indent 2 printProcesses region for regid regid regid printHierarchy regid mti VsimFree region name indent void loadDoneCB void param mti PrintMessage printHierarchy mti GetTopRegion void initForeign mtiRegionIdT region y char param mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is mti NextProcess cProcess s n cRegion s n nHierarchy n architecture is d indent int indent mti GetRegionFullName region indent region name indent mti FirstLowerRegion region mti NextRegion regid diy The ID of the region in which this Af foreign architecture is instantiated The last part of the string in the A foreign attribute id A list of generics for the foreign model A list of ports for the foreign model Ef initForeign for model sl generic delay time 5 ns port a in bit b out bit i end inv architecture b of
392. ir modeltech include app C CC G xarch v9 o app so app o lCstd lCrun ModelSim FLI Reference FLI 32 Introduction 32 bit HP UX platform C shared libraries are supported only on HP UX 11 0 and later operating system versions HP C version 3 25 aCC c DAportable Z o app o I install dir modeltech include app C aCC v b o app so app o lstd lstream lCsup HP C version 3 3 or later For I O streams such as cout to work correctly within shared objects HP s new iostream library must be used Access the library by compiling all C source files with the AA option When building the shared object use Istd v2 instead of Istd and use ICsup v2 instead of ICsup See the release notes in opt aCC newconfig for more details acC c DAportable Z AA o app o I install dir modeltech include app C aCC y b o app so app o lstd v2 lstream lCsup v2 GNU C version 2 95 3 or later c c fPIC I install dir modeltech include app C c shared fPIC o app so app o Exceptions are not supported When ModelSim loads GNU C shared libraries on HP UX it calls the constructors and destructors only for the shared libraries that it loads directly Libraries loaded as a result of ModelSim loading a shared library do not have their constructors and destructors called 64 bit HP UX platform HP C version 3 25 or later acC c DA2 0W z o app o I install dir modeltech include app C aCC v DA2 0W b o a
393. is indent mti_FirstLowerRegion region mti_NextRegion regid 1 The ID of the region in which this E7 foreign architecture is instantiated The last part of the string in the Ef foreign attribute x7 A list of generics for the foreign model A list of ports for the foreign model Ef initForeign for model sl generic delay time 5 ns port a in bit b out bit i end inv architecture b of inv is begin b lt a after delay pl process variable count integer 0 begin count count 1 wait on a end process end b entity mid is end mid architecture a of mid is ModelSim FLI Reference signal sl X bit 2 OT signal s2 bit 0 signal s3 bit 0 signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit b out bit i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin instl mid end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b
394. itForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports p mti AddLoadDoneCB initInstance HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a library ieee use ieee std logic 1164 a11 entity top is type bigtime is range 0 to units hour day 24 hour week 7 day month 4 week year 12 month end units end top architecture a of top is architecture is mti GetPhysicalData FLI 309 The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute A list of generics for the foreign model A list of ports for the foreign model 0 initForeign for model sl integer high signal phys sigl bigtime 3 day signal phys sig2 bigtime 1 week signal phys sig3 bigtime 1 year component for model end component for all begin instl for_model for model use entity work for_model a phys sigl lt phys sigl 1 day after 5 ns phys sig2 lt phys sig2 40 hour after 5 ns phys sig3 lt phys sig3 80 hour after 5 ns end a EL ModelSim FLI Reference FLI 310 FLI function definitions Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading modelte
395. k 7 day month 4 week year 12 month end units end top ModelSim FLI Reference FLI 508 FLI function definitions architecture a of top is signal bitsig DLE moTLU signal intsig integer 42 signal physsig bigtime 3 hour signal realsig real 10 2 signal timesig time 3 ns signal stdlogicsig std_logic H signal stdlogicarr std logic vector 1 to 4 O1LH signal rec rectype smog tQ tuo LOO Jer component for model end component for all for model use entity work for model a begin instl for model bitsig lt not bitsig after 5 ns intsig lt intsig 1 after 5 ns physsig lt physsig 1 hour after 5 ns realsig lt realsig 1 1 after 5 ns timesig lt timesig 2 ns after 5 ns stdlogicsig lt not stdlogicsig after 5 ns stdlogicarr lt not stdlogicarr after 5 ns rec a lt not rec a after 5 ns rec b lt rec b 1 after 5 ns rec c lt not rec c after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 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 gt run 14 Time 0 6 Signal bitsigi 0 Signal intsig 43 Signal physsig 4 hour Signal realsig 1 130000e 01 Signal timesig 5 ns Signal stdlogicsig 0 Signal stdlogicarr 1010 Sign
396. k case MTI_TYPE_TIME mtiTime64T time_val mti GetVarValueIndirect varid amp time val mti PrintFormatted d d n MTI TIME64 HI32 time val MTI TIME64 LO32 time val break default ModelSim FLI Reference mti GetVarValue FLI 445 mti PrintMessage Mn break static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info variInfoT 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 varinfo name printValue varinfo varid varinfo gt typeid 4 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 gt typeid mti GetVarType varid varinfo next 0 return varinfo static void initInstance void param instanceInfoT inst_data mtiProcessIdT procid mtiVariableIdT varid varInfoT curr_info varlInfoT varinfo inst data mti Malloc sizeof instanceInfoT inst data var info 0 for procid mti FirstProcess mti GetTopRegion procid procid mti NextProcess for varid mti FirstVar procid varid varid mti NextVar varinfo setupVariable varid
397. k mid a for model inv mid top 9 2000 mti GetRegionSourceName FLI 347 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for_model sl Elaboration phase Foreign architecture region is in File for model vhd Load Done phase Region top is in File top vhd Region top instl is in File mid vhd Region top instl il is in File for model vhd Region top instl flip is in File inv vhd Region top instl toggle is in File inv vhd VSIM 1 quit ModelSim FLI Reference FLI 348 FLI function definitions mti GetResolutionLimit Syntax Returns Arguments Description ModelSim FLI Reference Gets the simulator resolution limit limit mti GetResolutionLimit Description The simulator resolution limit in log10 seconds None mti GetResolutionLimit returns the simulator resolution limit in log10 seconds In other words mti GetResolutionLimit returns n from the expression time scale 1 10 n seconds The values returned by mti GetResolutionLimit are as follows limit time scale 2 100 sec 1 10 sec 0 1 sec 1 100 ms 2 10 ms 3 1 ms 4 100 us 5 10 us 6 us 7 100 ns 8 10 ns 9 1 ns limit time scale 10 100 ps
398. keup FLI 609 ModelSim FLI Reference FLI 610 FLI function definitions mti ScheduleWakeup64 Schedules a VHDL process to wake up at a specific time using a 64 bit delay Syntax mti ScheduleWakeup64 process id delay Returns Nothing Arguments Name Type Description process id mtiProcessIdT A handle to a VHDL process delay mtiTime64T The delay to be used in terms of the current simulator resolution limit Description mti ScheduleWakeup64 0 schedules the specified process to be called after the specified 64 bit delay A process can have no more than one pending wake up call A call to mti ScheduleWakeup64 cancels a prior pending wake up call for the specified process regardless of the delay values The specified delay value is multiplied by the current simulator resolution limit For example if vsim was invoked with t 10ns and the delay was specified as 5 then the actual delay would be 50 ns The process id must be a handle to a process that was created by mti CreateProcess or mti CreateProcessWithPriority Related functions mti CreateProcess FLI 123 mti CreateProcessWithPriority FLI 128 mti Desensitize FLI 160 mti GetResolutionLimit FLI 348 mti ScheduleWakeup FLI 606 mti Sensitize FLI 614 ModelSim FLI Reference Example mti ScheduleWakeup64 FLI 61 1 FLI code include lt stdlib h gt include lt mti h gt typedef struct mtiTime64T delay mti
399. ksig lt not packsig after 5 ns toggle inv port map sl s2 end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl vsim c top Loading modeltech sunos5 std standard Loading work mypkg Loading work top a Loading work for_model a Loading for_model sl Elaboration phase Found signal top il pl Found signal mypkg packsig Found signal top s2 Found signal top s3 4 Loading work inv b Load Done phase Found signal top s1 Found signal mypkg packsig Found signal top s2 Found signal top s3 0 Found signal top toggle a VSIM 1 run 10 VSIM 2 quit mti FindVar FLI 187 mti FindVar Finds a VHDL variable generic or constant by name Syntax variable id mti FindVar name Returns Name Type Description variable id mtiVariableIdT A handle to the VHDL variable generic or constant or NULL if the object is not found Arguments Description The name of a VHDL variable generic or constant Description mti FindVar returns a handle to the specified VHDL variable generic or constant The name can be either a full hierarchical name or a relative name A relative name is relative to the current region set by the simulator s environment command The default current region is the top level region For objects declared in a process the name must include the process label mti FindVar can be called successfully on
400. l ModelSim FLI Reference switch sigval case STD LOGIC U retval U U break case STD LOGIC X retval wees break case STD LOGIC 0 retval otra bregk case STD LOGIC 1 retval TJT break case STD LOGIC 2 retval U Z break mti CreateProcess FLI 125 case STD LOGIC W retval W break case STD LOGIC L retval L break case STD LOGIC H retval H break case STD LOGIC D retval break default retval break return retval void driveSignal void param char region_name instanceInfoT inst instanceInfoT param mtiiInt32T sigval region name mti GetRegionFullName mti GetSignalRegion inst sigid sigval mti GetSignalValue inst gt sigid mti PrintFormatted Time d d delta d Signal s s is s n mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid convertStdLogicValue sigval switch s case STD LOGIC U sigval STD LOGIC X break case STD LOGIC X sigval STD LOGIC 0 break case STD LOGIC 0 sigval STD LOGIC 1 break case STD LOGIC 1 sigval STD LOGIC 2 break case STD LOGIC Z2 sigval STD LOGIC W break case STD D D D case ST LOGIC W sigval STD LOGIC L break LOGIC L sigval STD LOGIC H break LOGIC H sigval STD LOGIC D break case STD LOGIC D sigval STD LOGIC U break default sigval STD LOGIC U break case 51 mti_Schedu
401. l Arch in Region il il n 8 v top bot Arch in Region i1 bot n 5 v top il Arch in Region il il n 2 v top uit the the the the std standard current current current current region region region region is is is is now now now now top il bot il mti RemoveLoadDoneCB FLI 539 mti RemoveLoadDoneCB Removes an elaboration done callback Syntax mti RemoveLoadDoneCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function being called at the end of elaboration void The parameter that was specified in the call to mti_AddLoadDoneCB when the callback was created Description mti_RemoveLoadDoneCB removes the specified function from the end of elaboration callback list The param parameter must be the same parameter that was specified in the call to mti_AddLoadDoneCB when the callback was created mti_RemoveLoadDoneCB must be called from a foreign initialization function in order for the callback removal to take effect A foreign initialization function is specified either in the foreign attribute string of a foreign architecture or in the foreign string option of a vsim command Related functions mti_AddLoadDoneCB FLI 65 Example FLI code include mti h void loadDoneCallback void param mtiRegionIdT region mtiRegionIdT param mti_PrintFor
402. l end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work for_pkg body Loading for model sl Loading work top a Loading work lower level Loading work for model a Foreign Init Function Region parameter is top finst Calling region is top finst Time 0 0 checkEnv Function Calling region is top linst2 Load Done Callback Function Calling region is top linst2 VSIM 1 gt run 0 Time 0 0 doProc Procedure Calling region is top linst2 Time 0 0 doProc Procedure Calling region is top linstl VSIM 2 gt env sim top VSIM 3 gt env finst Time 0 0 checkEnv Function Calling region is top finst sim top finst VSIM 4 gt run 10 Time 0 10 checkRegion Function Calling region is top VSIM 5 gt env sim top finst VSIM 6 gt env top Time 0 10 checkEnv Function Calling region is top sim top VSIM 7 gt run 10 ModelSim FLI Reference FLI 244 FLI function definitions Time 0 15 Time 0 15 VSIM 8 env sim top VSIM 9 env Time 0 20 VSIM 10 run Time 0 30 0 30 Time doProc Procedure Calling region is top linst2 doProc Procedure Calling region is top linstl linstl checkEnv Function Calling region is top linstl sim top linstl 15 doProc Procedure Calling region is top linst2 doPr
403. l when gt sl end case cl wait for 5 ns end process end a Simulation output X ro 1 wg Ww Ln H U wwwww www ow fter fter fter fter fter fter fter fter fter onnon wo ns ns ns ns ns ns ns ns ns vsim c top foreign initForeign for model sl Reading 5 4b Loading Loading Loading Time 0 15 Time 0 40 Time 0 60 VSIM 2 quit delta 0 L top sl W Driver top pl Drivers for top sl W Signal delta 0 top sl X Driver top pl Drivers for top sl X Signal delta 0 L top sl W Driver top pl Drivers for top sl W Signal modeltech tcl vsim pref tcl vsim foreign initForeign for model sl c top modeltech sunos5 std standard modeltech sunos5 ieee std logic 1164 body Loading work top a for model sl VSIM 1 run 60 Signal top sl is UNKNOWN The drivers of top sl are Signal top sl is UNKNOWN The drivers of top sl are Signal top sl is UNKNOWN The drivers of top sl are mti Interp FLI 469 ModelSim FLI Reference FLI A70 FLI function definitions mti IsColdRestore Determines if a cold restore operation is in progress Syntax status mti IsColdRestore Returns Description 1 when a cold restore operation is in progress 0 otherwise Arguments None Description mti IsColdRestore returns 1 when a cold re
404. l 2 W after 5 ns when stdlogicarrl 2 L after 5 ns when stdlogicarrl 2 H after 5 ns stdlogicarr1 3 lt after 5 ns when stdlogicarrl 3 U after 5 ns when stdlogicarr1 3 X after 5 ns when stdlogicarr1 3 0O after 5 ns when stdlogicarr1 3 l after 5 ns when stdlogicarr1 3 Z after 5 ns when stdlogicarr1 3 W after 5 ns when stdlogicarr1 3 L after 5 ns when stdlogicarr1 3 H after 5 ns stdlogicarrl1 4 lt after 5 ns when stdlogicarrl 4 U after 5 ns when stdlogicarrl 4 X after 5 ns when stdlogicarrl 4 0O after 5 ns when stdlogicarrl 4 ModelSim FLI Reference else else else else else else else else H else else U else X else 0 else 1 else Z else W else H else else U else X else 0 else 1 else Z else W else H else else U else X else 0 else 1 else Z else W else H else else U else X else mti ForceSignal FLI 217 1 after 5 ns when stdlogicarrl 4 0 else Z after 5 ns when stdlogicarrl 4 1 else W after 5 ns when stdlogicarrl 4 Z else L after 5 ns when stdlogicarrl 4 W else H after 5 ns recl a not recl a after 5 ns recl b lt recl b 1 after 5 ns recl c lt after 5 ns when recl c H else U after 5 ns when recl c else X after 5 ns when recl c U else 0 after 5 ns when recl c X else l a
405. l after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl pl process begin ptio lt U wait for 1 ns ptio lt Z wait for 30 ns end process end a library ieee use ieee std logic 1164 a11 mti GetSignalMode FLI 361 ModelSim FLI Reference FLI 362 FLI function definitions ModelSim FLI Reference entity top is end top architecture a of top is component mid is port ptio inout std logic end component signal sls std logic 0 begin instl mid port map sls Sls lt std logic val std logic pos sls 1 after 5 ns end a Simulation output 9 vsim c top Reading modeltech 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 mid a Loading work inv b Loading work for model a Loading for_model sl Load Done phase Region top Signal sls Direction is INTERNAL Region top instl Signal ptio Direction is INOUT Signal sl Direction is INTERNAL Signal s2 Direction is INTERNAL Signal s3 Direction is INTERNAL Signal s4 Direction is INTERNAL Region top instl flip Signal a Direction is IN Signal b Direction is OUT Signal count Direction is INTERNAL Region top inst1 il Region top inst1 toggle Signal a Direction is IN Signal b Direction is OUT Signal count Direction is INTERNAL VSIM 1 gt quit
406. lSim FLI Reference FLI 580 FLI function definitions mti SaveBlock Saves a block of data to the checkpoint file Syntax mti SaveBlock ptr size Returns Nothing Arguments Type Description char A pointer to a block of data unsigned long The size of the data to be saved Description mti SaveBlock saves the specified block of data to the checkpoint file Related functions mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveShort FLI 589 mti SaveString FLI 592 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param ModelSim FLI Reference char tmp char Z char tmp str Howdy long tmp long 123456 short tmp short 587 mti PrintFormatted nSaving instance info s n mti SaveBlock char amp instance info sizeof instance info mti PrintFormatted Saving char c n tmp char mti SaveChar tmp char mti PrintFormatted Saving long ld n tmp long mti SaveLong tmp long mti PrintFormatted Saving short d n tmp short mti SaveShort tmp short mti PrintFormatted Saving string s n tmp str mti SaveString tmp str mti PrintFormatted An void restoreC
407. lSim FLI Reference mti GetSignalSubelements FLI 377 Example FLI code include mti h static void printSignalInfo mtiSignalIdT sigid int indent char signame int i mtiSignalIdT elem list mtiTypeIdT sigtype sigtype mti GetSignalType sigid signame mti GetSignalNameIndirect sigid 0 0 mti PrintFormatted c s n indent signame mti VsimFree signame switch mti GetTypeKind sigtype case MTI TYPE ARRAY elem list mti GetSignalSubelements sigid 0 switch mti GetTypeKind mti GetArrayElementType sigtype case MTI TYPE ARRAY case MTI TYPE RECORD for i 0 i lt mti TickLength sigtype i printSignallInfo elem list i indent 2 break default for i 0 i lt mti TickLength sigtype i signame mti GetSignalNameIndirect elem list i 0 0 mti PrintFormatted c s n indent signame mti VsimFree signame break mti_VsimFree elem_list break case MTI_TYPE_RECORD elem_list mti_GetSignalSubelements sigid 0 for i 0 i lt mti GetNumRecordElements sigtype i switch mti GetTypeKind mti_GetSignalType elem list i case MTI TYPE ARRAY case MTI TYPE RECORD printSignallInfo elem list i indent 2 break default signame mti GetSignalNameIndirect elem list i 0 0 mti PrintFormatted c s n indent signame mti VsimFree signame break mti
408. lValue inst gt sigid mti PrintFormatted Time d d delta d Yn Signal s is s n mti NowUpper mti Now mti Delta inst signame convertStdLogicValue sigval mti PrintFormatted Drivers n drv names mti GetDriverNames inst sigid amp names length mti GetDriverNames FLI 255 drv values mti GetDriverValues inst gt sigid amp values length for i 0 i lt names length i mti PrintFormatted s s n convertStdLogicValue drv values il drv names i mti ScheduleWakeup inst procid 5 void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 x foreign attribute DA mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model instanceInfoT inst inst instanceInfoT malloc sizeof instanceInfoT inst sigid mti FindSignal top s1 inst signame mti GetSignalName inst gt sigid inst procid mti CreateProcess checkSignal checkSignal inst mti ScheduleWakeup inst procid 1 mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst HDL code library ieee use ieee std logic 1164 a11 entity
409. last part of the string in the Ey foreign attribute x mtilInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model EL if instance info instance info malloc strlen param 1 if mti IsRestore mti PrintMessage Restore in progress n else strcpy instance info param mti_AddSaveCB saveCallback instance_info mti_AddRestoreCB restoreCallback instance_info mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info 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 for model begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a ModelSim FLI Reference FLI 478 FLI function definitions ModelSim FLI Reference Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 40 VSIM 2 checkpoint cpfile Saving instance info for model VSIM 3 run 30 VSIM 4 restore cp
410. lator to exit immediately Table 12 FLI miscellaneous functions Function Action mti GetProductVersion FLI 323 Gets the name and version of the simulator mti GetWlfFilename FLI 457 Gets the name of the waveform logfile wlf mti FindProjectEntry FLI 173 Gets the value of an entry in the project ini file mti WriteProjectEntry FLI 670 Writes an entry to the project ini file mti IsFirstInit FLI 473 ModelSim FLI Reference Detects the first call to the initialization function FLI 51 Table 12 FLI miscellaneous functions Function Action mti KeepLoaded FLI 479 Requests that the current shared library not be unloaded on restart or load of a new design ModelSim FLI Reference FLI 52 FLI functions by category ModelSim FLI Reference FLI 53 FLI function definitions This chapter describes the FLI functions in detail explaining their purpose syntax and usage For information on creating and using foreign architectures and subprograms see Introduction FLI 9 For a categorical listing of FLI functions see FLI functions by category FLI 43 Keep in mind the following caveats which are described further in the appropriate function descriptions There are several FLI functions that work only during certain simulator phases e g mti GetVarlImage FLI 416 or only when called from a certain context e g from either inside of
411. ldT A handle to a VHDL type Description mti GetTypeKind returns the kind of the specified VHDL type The returned value is one of the following type kind VHDL type MTI TYPE SCALAR Integer MTI TYPE ARRAY Array MTI TYPE RECORD Record MTI TYPE ENUM Enumeration MTI TYPE PHYSICAL Physical MTI TYPE REAL Real MTI TYPE ACCESS Access MTI TYPE FILE File MTI TYPE TIME Time Related functions None ModelSim FLI Reference Example mti GetTypeKind FLI 405 FLI code include mti h static void printSignalInfo mtiSignalIdT sigid int indent char signame int TS mtiSignalIdT elem list mtiTypeIdT sigtype sigtype mti GetSignalType sigid signame mti GetSignalNameIndirect sigid 0 0 mti PrintFormatted c s indent signame mti VsimFree signame switch mti GetTypeKind sigtype case MTI TYPE SCALAR mti PrintFormatted is of type INTEGER n break case MTI TYPE ENUM mti PrintFormatted is of type ENUMERATION An break case MTI TYPE PHYSICAL mti PrintFormatted is of type PHYSICAL n break case MTI TYPE REAL mti PrintFormatted is of type REAL n break case MTI TYPE TIME mti PrintFormatted is of type TIME n break case MTI TYPE ARRAY mti PrintFormatted is of type ARRAY n elem list mti GetSignalSubelements sigid 0 for i 0 i lt mti TickLength sigtype i printSigna
412. le an architecture with the FOREIGN attribute The string value of the attribute is used to specify the name of a C initialization function and the name of an object file to load When the simulator elaborates the architecture the initialization function is called Parameters to the function include a list of ports and a list of generics See Mapping to VHDL data types FLI 18 Declaring the FOREIGN attribute Starting with VHDL93 the FOREIGN attribute is declared in package STANDARD With the 1987 version you need to declare the attribute yourself You can declare it in a separate package or you can declare it directly in the architecture This will also work with VHDL93 The FOREIGN attribute string The value of the FOREIGN attribute is a string containing three parts For the following declaration ATTRIBUTE foreign OF arch name ARCHITECTURE IS app init app so parameter the attribute string parses this way app init The name of the initialization function for this architecture This part is required See The C initialization function FLI 12 app so The path to the shared object file to load This part is required See Location of shared object files FLI 11 parameter A string that is passed to the initialization function This part is preceded by a semicolon and is optional If the initialization function has a leading or the VHDL architecture body will be elaborated in addition to the foreign
413. le to the new array type Name Type Description left mtiInt32T The left bound of the new array type right mtiInt32T The right bound of the new array type element type mtiTypeldT The type of the elements of the new array type mti_CreateArrayType creates a new type ID that describes a VHDL array type whose bounds are the specified left and right values and whose elements are of the specified element type Related functions ModelSim FLI Reference mti CreateEnumType FLI 118 mti CreateRealType FLI 139 mti CreateScalarType FLI 146 mti CreateTimeType FLI 154 mti_GetArrayElementType FLI 222 mti TickLeft FLI 654 mti TickRight FLI 664 Example mti CreateArrayType FLI 109 FLI code include lt stdlib h gt include lt mti h gt typedef enum SIGVAL O0 SIGVAL 1 SIGVAL X mySigType char enum lits 3 O 1 X typedef struct mtiSignalIdT sigidl mtiSignallIdT sigid2 mtiSignalIdT sigid3 mtiDriverIdT drvidl mtiDriverIdT drvid2 mtiDriverIdT drvid3 instanceInfoT This function inverts mySig 2 every 5 ns void driveSignall void param char region name char signal name instanceInfoT inst instanceInfoT param mtilnt32T sigval sigval mti GetSignalValue inst gt sigidl switch sigval case SIGVAL 0 mti ScheduleDriver inst drvidl1 SIGVAL 1 5 MTI INERTIAL break case SIGVAL 1 mti Sch
414. leDriver inst drvid sigval 5 MTI_INERTIAL mti VsimFree region name void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 EZ foreign attribute EY mtiInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model instanceInfoT inst mtiProcessIdT procid inst instanceInfoT malloc sizeof instanceInfoT inst gt sigid mti FindSignal top sl inst drvid mti CreateDriver inst gt sigid procid mti CreateProcess sigDriver driveSignal inst ModelSim FLI Reference FLI 126 FLI function definitions mti Sensitize procid inst gt sigid MTI EVENT mti SetDriverOwner inst drvid procid mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst 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 a11 entity top is end top architecture a of top is signal sl std logic 0 component for model is end component for all for model use entity work for model a begin il for model
415. lect Technotes dropdown on www model com support ModelSim FLI Reference vi ModelSim FLI Reference FLI 5 Table of Contents Technical support and updates s s es 2 soos oo oe or ooo os oe sos FL Where to find our documentation 2 2 2 2 2 FLLEiv FLI v Introduction FLI 9 Using the VHDL FLI boh oboe emo dox ee ms ege sdbLI0 Using the VHDL FLI with fondai metido s ee dom OE ow eum oy x ee 4 PETI Using the VHDL FLI with foreign che So es 2 Gd es ES e xo3osEbIS Mapping to VHDL datatypes ee Boge ed om ECR Boe ete oo oe cog BEETS Using checkpoint restore withthe FLI FLE20 The effect of restart on FLI application code FLI23 Support for Verilog instances s s es 2s ro os w os o og o s s os s S ELI 23 Support for Windows pm Shao ege Wu ee a EUR eos e y ae one ge group EE 24 VHDL FLI examples Eo odo wok he og X 9 oso X959 wow be x xL 24 Compiling and linking FLI C applications FLI25 Compiling and linking FLI C applications 2 2 2 2 2 FLI 30 Using 64 bit ModelSim with 32 bit FLI Applications 2 FLE34 Porting C code to the LP64 data model FLE34 64 bit time values in the FLI lt e s s sos sam oos o o oo o o ov s vy FLI 35 Shared library dependency s FLI 36 Example l o 2 s SS oeoa pa RE p
416. level vhdl real IN real vhdl array IN string attribute FOREIGN of in params procedure is in params app so You must also write a subprogram body for the subprogram but it will never be called For instance procedure in params vhdl integer IN integer vhdl enum IN severity level vhdl real IN real vhdl array IN string is begin report ERROR foreign subprogram in params not called end Matching VHDL parameters with C parameters Use the table below to match the C parameters in your foreign C subprogram to the VHDL parameters in your VHDL package declaration The parameters must match in order as well as type Parameters of class Parameters of class CONSTANT OR VARIABLE SIGNAL VHDL Type IN INOUT OUT IN Integer int int mtiSignalldT Enumeration int char if lt 256 values mtiSignalldT int if gt 256 values Real double double mtiSignalldT Time mtiTime64T mtiTime64T mtiSignalldT Array mtiVariableIdT mtiVariableIdT mtiVariableIdT Record mtiVariableIdT mtiVariableIdT mtiVariableIdT File Not supported Access Integer int int Not supported ModelSim FLI Reference FLI 14 Introduction Parameters of class Parameters of class CONSTANT OR VARIABLE SIGNAL VHDL Type IN INOUT OUT IN Access Enumeration int int Not supported Access Real double double Not supported Access Array mtiVariable
417. link to a C model that can communicate to the rest of the design through the ports of the foreign architecture Normally a C model creates processes and reads and drives signal values in essence behaving in the same manner as VHDL code but with the advantage of the power of C and the ease of reading and writing files and communicating with other system processes Foreign subprogram A foreign subprogram is a VHDL function or procedure that is implemented in C as opposed to VHDL A foreign subprogram reads its in and inout parameters performs some operation s which may include accessing simulator information through FLI function calls writes its inout and out parameters and returns a value in the case of a function Callback A callback is a C function that is registered with the simulator for a specific reason The registered function is called whenever the reason occurs Callback functions generally perform special processing whenever certain simulation conditions occur Process A process is a VHDL process that is created through the FLI It can either be scheduled for a specific time or be made sensitive to one or more signals that trigger the process to run Using the VHDL FLI FLI 11 The process is associated with a C function and the C function is executed whenever the process is run by the simulator Using the VHDL FLI with foreign architectures To use the foreign language interface with C models you first create and compi
418. llInfo elem list i indent 2 mti_VsimFree elem_list break case MTI_TYPE_RECORD mti PrintFormatted is of type RECORD n elem list mti GetSignalSubelements sigid 0 for i 0 i lt mti GetNumRecordElements sigtype i printSignallInfo elem list i indent 2 mti_VsimFree elem_list break default mti PrintFormatted is of type UNKNOWN n break void loadDoneCB void param mtiRegionIdT regid mtiSignalIdT sigid ModelSim FLI Reference FLI 406 FLI function definitions mti PrintFormatted for regid for sigid printSignalInfo sigid void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports sigid mti FirstSignal regid mti NextSignal 2 mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is architecture is attribute foreign of a begin end a entity top is type rectype is record a integer b cot C bit vector 3 downto O0 end record AnSrgna amp le rXn y mti GetTopRegion regid sigid regid mti NextRegion regid The ID of the region in which this x foreign architecture is instantiated The last part of the string in the EJ foreign attribute EL A list of generics for the foreign model A list of ports for the foreign model ur i
419. llback void param mti_PrintMessage Cleaning up n free param 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 EL mtiInterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model 4 instance info malloc strlen param 1 strcpy instance info param mti AddSaveCB saveCallback instance info mti AddRestoreCB restoreCallback instance info mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info 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 for model begin end a entity top is end top architecture a of top is ModelSim FLI Reference FLI 76 FLI function definitions ModelSim FLI Reference signal sl gt bit O component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 20 V
420. lloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo gt phys_data mti_GetPhysicalData siginfo gt typeid siginfo next zd mti PrintFormatted Setting a watch on s n siginfo name mti PrintFormatted Physical Units are n for pdp siginfo phys data pdp pdp pdp next mti PrintFormatted 10s Sd Ss pdp gt unit_name pdp gt position siginfo gt phys_data gt unit_name if pdp siginfo gt phys_data num_units pdp gt position prev_position mti PrintFormatted d s num units prev unit name mti PrintFormatted n prev unit name pdp unit name prev position pdp gt position return siginfo static void initInstance void param instanceInfoT inst_data mtiSignalIdT sigid signalInfoT curr info signallInfoT siginto inst data mti Malloc sizeof instanceInfoT inst data 5sig info 0 for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if siginfo if inst data 5sig info 0 inst data 5sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 4 void in
421. lower is port pt INOUT std logic 0 end lower architecture a of lower is begin pO process begin ptem Mg wait for 5 ns pt lt L wait for 5 ns pt W wait for 5 ns end process end a library ieee use ieee std logic 1164 a11 ModelSim FLI Reference FLI 256 FLI function definitions ModelSim FLI Reference entity top is end top architecture a of top is signal sl std logic 0 component lower port pt INOUT std logic end component begin pl process begin sl lt H wait for 5 ns sl lt L wait for 5 ns sl lt X wait for 5 ns end process p2 process begin sl lt 1 wait for 5 ns sl lt 0 wait for 5 ns sl lt W wait for 5 ns end process instl lower port map sl end a Simulation output vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading work lower a Loading for model sl VSIM 1 gt run 1 Time 0 1 delta O0 Signal sl is TIT Drivers 1 top instl pO LF top p2 VHF top pl VSIM 2 drivers top sl Drivers for top sl 1 Signal top s1 1 Driver top inst1 p0 1 Driver top p2 H Driver top pl VSIM 3 run 5 Time 0 6 delta 0 Signal si is 0
422. lsig 17 45 Variable timesig 1 6 Variable stdlogicsig ua Variable bitarr LY ON vgr Flyv Varrable stdlogicarrs L TZP FHF te Variable intarr 11 12 13 Variable realarr 12 7 102 32 Variable timearr 0 16 0 7 Time 0 15 Variable bitsig 1 Variable intsig 23 ModelSim FLI Reference Varia Varia Varia Varia Varia Varia Oe DD Ax IE 0 0 000000 Varia Variabl VSIM 2 quit realsig 18 55 timesig 25 4 stdlogicsig u buitarr 0 ULT ULT B stdlogkcarre 2 wt cer xg intarr 12 13 14 realarr 13 8 103 42 timearr 0 17 0 8 mti_GetVarAddr FLI 415 ModelSim FLI Reference FLI 416 FLI function definitions mti GetVarlmage Gets the string image of the value of a VHDL constant generic or variable by name Syntax image mti GetVarImage var name Returns Description A string image of the value of the specified constant generic or variable Arguments Description The name of a VHDL constant generic or variable Description mti GetVarImage returns a pointer to a buffer containing the string image of the value of the specified VHDL constant generic or variable The image is the same as would be returned by the VHDL 1076 1993 attribute IMAGE NULL is returned if the object is not found The returned string is valid only until the next call to any FLI function The returned pointer must not be freed The name must be sp
423. lved signal Name Description resolved i 1 if the signal is resolved 0 otherwise Name Description mtiSignalldT A handle to a VHDL signal mti_SignallsResolved returns a 1 meaning a signal is considered to be resolved if the signal meets one of the following criteria The signal is of a resolved type e g std_logic The declaration of the signal includes a resolution function specification The signal is a composite of an unresolved type but all of its subelements are resolved e g std logic vector The signal is of an unresolved type but it is a subelement of a composite that is either of a resolved type or whose declaration contains a resolution function specification Related functions Example mti FindDriver FLI 167 FLI code include lt stdio h gt include lt mti h gt static void printSignalInfo char name char signame int resolved mtiSignalIdT sigid ModelSim FLI Reference FLI 640 FLI function definitions sigid mti FindSignal name rt sigid y 4 signame mti GetSignalNameIndirect sigid 0 0 resolved mti SignallIsResolved sigid mti PrintFormatted Signal s is sresolved Mn signame resolved not mti VsimFree signame else mti PrintFormatted Signal s not found n static void loadDoneCB void param Unresolved scalars printSignalInfo top bitsigl printSignalInfo
424. ly after elaboration is complete mti FindVar cannot be used to find slices of arrays mti FindVar cannot be used to find a process variable when mti FindVar is called from a foreign subprogram that is called from the process where the variable is declared Related functions mti FirstVar FLI 203 mti NextVar FLI 497 ModelSim FLI Reference FLI 188 FLI function definitions Example ModelSim FLI Reference FLI code include mti h static void printVarInfo mtiVariableIdT varid if varid mti PrintFormatted void loadDoneCB void param mti_PrintMessage printVar printVar printVar printVar printVar printVar printVar printVar nfo nfo nfo nfo nfo nfo nfo nfo void initForeign mtiRegionIdT char mtilnterfaceListT generics mtilnterfaceListT ports Found variable s n mti GetVarName varid nLoad Done phase n mti FindVar TOP pl v1l mti FindVar pl constl mti FindVar cl mti FindVar top svl mti FindVar top TOGGLE procl count mti FindVar toggle delay mti FindVar top toggle myconst mti FindVar my pkg psvl region The ID of the region in which this foreign architecture is instantiated param The last part of the string in the foreign attribute mti AddLoadDoneCB loadDoneCB 0 mti PrintMessage nElaboration phase n printVarInfo mti Fi
425. m instanceInfoT inst data mtiSignalldT sigid signallnfoT gurr info signallInfoT sioinfo inst data mti Malloc sizeof instanceInfoT inst data 5sig info 0 for sigid mti FirstSignal mti GetTopRegion ModelSim FLI Reference mti Nowlndirect FLI 507 sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 6 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 Kop foreign attribute DA mtilnterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model KJ 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 a11 entity top is type bitarray is array 3 downto 0 of bit type rectype is record a c bitty b integer Cc bitarray end record type bigtime is range 0 to integer high units hour day 24 hour wee
426. m Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function to be called when the simulator does a checkpoint void A parameter to be passed to the function OPTIONAL can be NULL Description mti_AddSaveCB adds the specified function to the simulator checkpoint callback list The same function can be added multiple times with possibly a different parameter each time During a checkpoint operation all callbacks in the list are called with their respective parameters The callback function should save its state at this time mti_AddSaveCB should be called from a foreign initialization function A foreign initialization function is specified either in the foreign attribute string of a foreign architecture or in the foreign string option of a vsim command Related functions mti_AddRestoreCB FLI 74 mti_GetCheckpointFilename FLI 245 mti_RemoveSaveCB FLI 554 mti_SaveBlock FLI 580 mti_SaveChar FLI 583 mti_SaveLong FLI 586 mti_SaveShort FLI 589 mti_SaveString FLI 592 ModelSim FLI Reference Example mti AddSaveCB FLI 81 FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char inst_info char param mti PrintFormatted Saving instance info s n inst info mti SaveString inst info void restoreCallback void param char inst info char param strcpy inst
427. matted Foreign Arch in Region s the top level region is s n mti_GetRegionName region mti_GetRegionName mti_GetTopRegion ModelSim FLI Reference FLI b40 FLI function definitions ModelSim FLI Reference void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB loadDoneCallback if mti IsFirstInit mti RemoveLoadDoneCB loadDoneCallback HDL code entity for model is end for model architecture a of for model is The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute ay El KJ A list of generics for the foreign model A list of ports for the foreign model attribute foreign of a architecture is initForeign for model sl begin end a entity bottom is end bottom architecture b of bottom is begin end b entity top is end top architecture a of top is signal sl bit 0 component for model is end component region region for all for model use entity work for model a component bottom is end component begin bot bottom il for model S lt not sl after 5 ns end a E mti RemoveLoadDoneCB FLI 541 Simulation output 9 vsim c Reading 5 4b vsim c Loading Loading Loading Loading Loading Foreign Loading top
428. matted Time d d n mti NowUpper mti Now for varinfo inst data var info varinfo varinfo varinfo gt next mti PrintFormatted Variable s s n varinfo name mti GetVarImageById varinfo varid setVarValue varinfo varid varinfo gt typeid mti ScheduleWakeup inst data proc 5 static varInfoT setupVariable mtiVariableIdT varid variInfoT varinfo varinfo varInfoT mti Malloc sizeof varInfoT varinfo varid varid varinfo name mti GetVarName varid varinfo gt typeid mti GetVarType varid varinfo next 0 return varinfo static void initInstance void param instanceInfoT inst data mtiProcessIdT procid mtiVariableIdT varid varlInfoT curr info varInfoT varinfo inst data mti Malloc sizeof instanceInfoT inst data var info 0 for procid mti FirstProcess mti GetTopRegion 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 gt next varinfo curr_info varinfo ModelSim FLI Reference FLI 632 FLI function definitions inst data proc mti ScheduleWakeup inst data proc void initForeign mtiRegionIdT char mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB initInstance
429. me region name mti GetRegionFullName mti GetSignalRegion inst gt sigid ModelSim FLI Reference mti CreateTimeType FLI 155 curr time str mti Image mti NowIndirect amp curr time inst time type mti PrintFormatted Time s delta d Signal s s is s n curr time str mti Delta region name mti GetSignalName inst sigid mti Signallmage inst sigid MTI TIME64 ASGN inst gt sigval MTI TIME64 HI32 inst sigval MTI TIME64 LO32 inst sigval 1 mti ScheduleDriver inst drvid long amp inst sigval 5 MTI INERTIAL mti VsimFree region name void initForeign mtiRegionIdT region The ID of the region in which this xA foreign architecture is instantiated i char param The last part of the string in the Et foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtiInterfaceListT ports A list of ports for the foreign model instanceInfoT inst mtiProcessIdT procid inst instanceInfoT mti Malloc sizeof instanceInfoT inst time type mti CreateTimeType inst sigid mti CreateSignal mySig region inst time type inst drvid mti CreateDriver inst gt sigid procid mti CreateProcess mySigDriver driveSignal inst mti SetDriverOwner inst drvid procid mti Sensitize procid inst gt sigid MTI EVENT mti ScheduleWakeup procid 0 HDL code entity top is end top
430. me Description primary name The primary name of the specified region Arguments Name Type Description region id mtiRegionIdT A handle to a VHDL or Verilog region Description mti GetPrimaryNameY returns the primary name of the specified VHDL or Verilog region that is an entity package or module name If the region is not a primary design unit then the parent primary design unit is used The returned pointer must not be freed Related functions mti_GetLibraryName FLI 283 mti GetRegionFullName FLI 325 mti GetRegionName FLI 341 mti GetRegionSourceName FLI 344 mti GetSecondaryName FLI 355 Example FLI code include mti h static void printRegionInfo char region char primary_name char region_name mtiRegionIdT regid ModelSim FLI Reference FLI 312 FLI function definitions ModelSim FLI Reference mti FindRegion region mti GetRegionFullName regid primary name mti GetPrimaryName regid mti PrintFormatted Region s Primary name is s n region name primary name regid region name mti VsimFree region name static void initInstance void param mti_PrintFormatted Load Done Callback Function n printRegionInfo top printRegionInfo top linstl printRegionInfo top linst2 printRegionInfo top finst printRegionInfo for pkg void initForeign mtiRegionIdT region The ID of the region in which this
431. mend that you do not use characters in the name that will cause Tcl parsing problems This includes spaces the path separator normally or square brackets and dollar signs If you must use these characters then create an escaped name by putting a backslash V at both ends of the name ModelSim FLI Reference FLI 150 FLI function definitions Related functions Example mti FindSignal FLI 182 mti_GetSignalName FLI 363 mti GetSignalRegion FLI 372 mti GetSignalType FLI 381 FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD_LOGIC_X STD LOGIC 0 STD LOGIC 1 STD LOGIC Z STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D mySigType char std logic lits 9 ES s i GU TROP TEL Fi nigin niyin Z W nigin L typedef struct mtiSignalldT mtiSignalldT mtiSignalldT mtiDriverIdT mtiDriverIdT mtiDriverIdT sigidl sigid2 sigid3 drvidl drvid2 drvid3 instanceInfoT This function inverts mySigl every 5 ns void driveSignall void param char instanceInfoT inst mtilnt32T sigval switch case STD_ break case SI break mti region name instanceInfoT param sigval GetSignalValue inst gt sigidl sigval LOGIC_U mti_ScheduleDriver inst gt drvidl TD LOGIC 0 mti ScheduleDriver inst gt drvidl case STD LOGIC 1 mti Sche
432. ments returns the number of subelements in the specified VHDL record type Related functions mti GetSignalSubelements FLI 376 mti GetVarSubelements FLI 431 Example FLI code include lt mti h gt typedef struct signalInfoT tag struct signalInfoT tag next char mtiSignalIdT mtiTypeIdT signalInfoT ai typedef struct signallnfoT mtiProcessIdT instanceInfoT sig info proc name sigid typeid List of signals Test process id static void printValue mtiSignalIdT sigid mtiTypeIdT sigtype int indent ModelSim FLI Reference FLI 296 FLI function definitions switch mti GetTypeKind sigtype case MTI TYPE ENUM case MTI TYPE PHYSICAL case MTI TYPE SCALAR mtilnt32T scalar val Scalar val mti GetSignalValue sigid mti PrintFormatted d n scalar val break case MTI_TYPE_ARRAY int i mtilnt32T num elems mtiTypeIdT elem type mtiTypeKindT elem typekind void array val array val mti GetArraySignalValue sigid 0 num elems mti TickLength sigtype elem type mti GetArrayElementType sigtype elem typekind mti GetTypeKind elem type switch elem typekind case MTI TYPE ENUM char enum_values enum values mti GetEnumValues elem type if mti TickLength elem type 256 mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted s enum values val i
433. model architecture a of for model is attribute foreign of a architecture is t tinitForeign for model sl begin end a entity inv is generic min delay time 5 ns max delay time 10 ns port A aoi an bit b out bit end inv architecture b of inv is begin b lt a after min delay end b use work my pkg all entity mid is generic gl bit 0 g2 integer 11 g3 real 12 97 g4 bit vector 0010 g5 vr intarray t lp 2 4 3 y g6 realarray 10 5 16 8 21 39 g7 timearray 3 ns 18 ns 123 ns g8 bigtime 13 hour g9 bigtimearray 2 hour 4 hour 6 hour end mid architecture a of mid is signal sl t bit 0 signal s2 bit 0 signal s3 bit 0 signal s4 bit 0 component for model is ModelSim FLI Reference generic whoami string end component for all component inv is generic min delay time 5 ns max delay time 10 ns a in bit b out bit end component port begin flip inv generic map port map 3 ns S3 s4 8 ns sl lt not sl after 5 ns toggle inv port map sl s2 il for model generic map inst il end a use work my pkg all entity top is end top architecture a of top is component mid is generic gl bit 0 g2 integer 11 g3 real 12 97 g4 bit vector 101 g5 intarray 7 9 8 1 g7 timearray 212 ns g8 b
434. modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info my for model Saving char Z Saving long 123456 Saving short 587 Saving string Howdy VSIM 3 run 40 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 16 09 02 2000 Restoring state at time 20 ns iteration 1 Restoring instance info my for model Restoring char Z Restoring long 123456 Restoring short 587 Restoring string Howdy VSIM 5 run 10 VSIM 6 quit mti RestoreChar FLI 563 mti RestoreChar Gets a byte of data from the checkpoint file Syntax value mti RestoreChar Returns Description A byte of data Arguments None Description mti RestoreChar returns a byte of data from the checkpoint file This function should be called only from a restore callback function It should not be called from an initialization procedure Related functions mti RestoreBlock FLI 560 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveShort FLI 589 mti SaveString FLI 592 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void p
435. mti Signallmage FLI 637 char param The last part of the string in the x foreign attribute Eg mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT 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 a11 entity top is type bitarray is array 3 downto 0 of bit type rectype is record a bit b integer Cc bitarray end record type bigtime is range 0 to integer high units hour day 24 hour week 7 day month 4 week year 12 month end units end top architecture a of top is signal bitsig BE 1 signal intsig integer 42 signal physsig bigtime 3 hour signal realsig real 10 2 signal timesig time 3 ns signal stdlogicsig std logic H signal stdlogicarr std logic vector 1 to 4 signal rec rectype seo o 7107 0 T1001 component for model end component for all for model use entity work for model a OlLH ModelSim FLI Reference FLI 638 FLI function definitions begin instl for model bitsig lt not bitsig after 5 ns intsig lt intsig 1 after 5 ns physsig lt physsig 1 hour after 5 ns realsig lt realsig 1 1
436. n mti GetSignalName sigid getTypeStr typeid mti TickLow typeid mti TickHigh typeid 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 y foreign attribute wa mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model L 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 a11 entity top is type bitarray is array 2 downto 5 of bit type rectype is record a t bit b integer c bitarray end record type bigtime is range 0 to integer high units hour day 24 hour week 7 day month 4 week year 12 month end units end top architecture a of top is signal bitsig bit 1 signal intsig integer 42 signal physsig bigtime 3 hour signal realsig real 10 2 signal timesig time 3 ns signal stdlogicsig std logic H signal bitarr bitarray 1100 signal stdlogicarr std logic vector 3 downto 0 OILH signal uparray bit vector 1to 4 0101 signal rec rectype Lm FOT 0 ST DTE pa component for model end component for all for model use en
437. n top flip region top toggle is in region top toggle mti GetProductVersion FLI 323 mti GetProductVersion Gets the name and version of the simulator Syntax prod ver mti GetProductVersion Returns Name Description prod ver The name and version of the product Arguments None Description mti GetProductVersion returns the name and version of the product The returned pointer must not be freed Related functions None Example FLI code include mti h 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 x foreign attribute xf mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model x mti PrintFormatted The version of the simulator is n s n mti GetProductVersion ModelSim FLI Reference FLI 324 FLI function definitions ModelSim FLI Reference HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity top is end top architecture a of top is bit s 0 s signal sl component for model is end component for all for model use entity work begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading 5 4b vsim c
438. n in which this foreign architecture is instantiated char param The last part of the string in the x foreign attribute a mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB loadDoneCB HDL code library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal sl std logic 0 signal s2 std logic 0 signal s3 std logic vector 3 downto 0 0110 signal s4 std_logic_vector 3 downto 0 1010 begin S4 lt not s4 after 5 ns pl Process begin Cl case sl is when U gt sl lt X after 5 ns when X gt sl lt 0 after 5 ns when 0 gt s1 lt 1 after 5 ns when l gt sl lt Z after 5 ns when Z gt sl lt W after 5 ns when W gt sl lt L after 5 ns when L gt sl lt H after 5 ns when H gt s1 lt after 5 ns when gt s1 lt U after 5 ns end case cl s3 3 lt not s3 3 after 5 ns wait for 5 ns end process end a Simulation output vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading for model sl Driver found f
439. n in which this Ay foreign architecture is instantiated char param The last part of the string in the J foreign attribute EL mtiInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model instanceInfoT inst mtiDriverIdT drvid mtiProcessIdT procid inst instanceInfoT malloc sizeof instanceInfoT inst sigid mti FindSignal top s1 drvid mti CreateDriver inst sigid inst drv elems mti GetDriverSubelements drvid 0 inst num elems mti TickLength mti GetSignalType inst gt sigid inst index 0 procid mti CreateProcess sigDriver driveSignal inst mti Sensitize procid inst gt sigid MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner drvid procid mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst ModelSim FLI Reference mti GetDriverSubelements FLI 261 HDL code library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal sl std logic vector 3 downto 0 0000 begin end a Simulation output 9 vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work to
440. n name mti VsimFree region name regid mti FindRegion flip if regid region name mti GetRegionFullName regid mti PrintFormatted Found region s n region name mti VsimFree region name The toggle instance is not found here because it has not yet been instantiated if regid mti FindRegion top inst1l toggle if regid region_name mti_GetRegionFullName regid mti_PrintFormatted Found region s n region_name mti VsimFree region name 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 entity inv is generic delay time 5 ns port a in bit b out bit i ModelSim FLI Reference FLI 180 FLI function definitions end inv architecture b of inv is begin b lt a after delay end b entity mid is end mid architecture a of mid is signal sl Dit tOu signal s2 bit 0 signal s3 bit re Q s signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port ait ln bit i rout bi i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top i
441. nalIdT sigid mti AddLoadDoneCB loadDoneCB 0 mti PrintMessage nElaboration phase n Signal sl is not found here because the current context during elaboration is the context of the foreign architecture and sl exists in the context top E sigid mti FindSignal s1 if sigid region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Found signal s s n region name mti GetSignalName sigid mti VsimFree region name sigid mti FindSignal pl if sigid region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Found signal s s n region name mti GetSignalName sigid mti VsimFree region name sigid mti FindSignal mypkg packsig if sigid region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Found signal s s n region name mti GetSignalName sigid mti VsimFree region name sigid mti FindSignal top s2 if sigid region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted Found signal s s n region name mti GetSignalName sigid mti VsimFree region name sigid mti FindSignal top s3 4 if sigid char signal name mti GetSignalNameIndirect sigid 0 0 region name mti GetRegionFullName mti PrintFormatted mti VsimFree region name mti VsimFree signal name Found signal
442. ndVar top pl vl printVarInfo mti FindVar top pl consti printVarInfo mti FindVar top c1l printVarInfo mti FindVar top svl printVarInfo mti FindVar top toggle procl count printVarInfo mti FindVar top toggle delay printVarInfo mti FindVar top toggle myconst HDL code package my_pkg is shared variable psvl bit 1 end my pkg entity for model is end for model architecture a of for model is attribute foreign of a architecture is initForeign for model sl begin A list of generics for the foreign model A list of ports for the foreign model y 5g 54 5g end a entity inv is generic delay time 5 ns port a in bit D 3 oU bit i end inv architecture b of inv is constant myconst real 13 78 begin b lt a after delay procl process variable count integer 0 begin count count 1 wait on a end process end b use work my pkg all entity top is end top architecture a of top is constant cl integer 42 shared variable svl integer signal sl bit 0 signal s2 t bit Q component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port s in bit bf Out Bit i end component begin il for model sl lt not sl after 5 ns toggle inv port map sl s2 pl
443. ndtask task write input addr_size 1 0 a input word size 1 0 d begin if verbose display t Writing data h to addr h addr r a rw r 0 strb_r 0 posedge clk data_r d strb_r 1 posedge clk while rdy 0 posedge clk data_r bz end endtask reg addr_size 1 0 a reg word size 1 0 d initial begin Set initial state of outputs addr_r 0 Reading from addr h time time d a a mti GetRegionKind FLI 335 data r bz rw r 0 strb r 1 verbose 1 forever begin Wait for first clock then perform read write test posedge clk if verbose display t Starting Read Write test time Write 10 locations for a 0 a lt 10 a a 1 write a a Read back 10 locations for a 0 a lt 10 a a 1 begin read a d if d a display t Read Write mismatch E h A h Stime a d end if verbose Sdisplay Read Write test done stop 1 end end endmodule util vhd library IEEE use IEEE std logic 1164 a1l1 package std logic util is function CONV STD LOGIC VECTOR ARG INTEGER SIZE INTEGER return STD LOGIC VECTOR function CONV INTEGER ARG STD LOGIC VECTOR return INTEGER end std logic util package body std logic util is type tbl type is array STD ULOGIC of STD ULOGIC constant tbl BINARY tbl type 0 v0 TOR taps TOU TROU TOP stus roms function CONV
444. nent begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin insti mid end a ModelSim FLI Reference mti GetSignalRegion FLI 375 Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for_model sl Hierarchy Region top Region top instl Signal sl is declared in region top instl Signal s2 is declared in region top instl Signal s3 is declared in region top instl Signal s4 is declared in region top instl Region top instl flip Signal a is declared in region top instl flip Signal b is declared in region top instl flip Signal count is declared in region top instl flip Region top inst1 il Region top instl toggle Signal a is declared in region top inst1 toggle Signal b is declared in region top inst1 toggle Signal count is declared in region top instl toggle VSIM 1 quit ModelSim FLI Reference FLI 376 FLI function definitions mti GetSignalSubelements Gets the subelements of a composite VHDL or SystemC signal Syntax elem list mti GetSignalSubelements signal id bu
445. nfo gt var_addr 1 1 break case MTI TYPE TIME mtiTime64T time val mtiTime64T varinfo gt var_addr mti PrintFormatted d d n MTI TIME64 HI132 time val MTI TIME64 LO32 time val MTI TIME64 ASGN mtiTime64T varinfo var addr MTI TIME64 HI32 time val 1 MTI TIME64 LO32 time val 1 break ModelSim FLI Reference FLI 412 FLI function definitions default mti PrintMessage Mn break static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info varlInfoT varinfo mti PrintFormatted Time d d n mti NowUpper mti Now for varinfo inst data var info varinfo varinfo varinfo gt next mti PrintFormatted Variable s varinfo name setValue varinfo 4 mti ScheduleWakeup inst data proc 5 static varInfoT setupVariable mtiVariableIdT varid mtiRegionIdT regid mtiProcessIdT procid char var name NAME MAX char region name varInfoT varinfo varinfo varInfoT mti Malloc sizeof varInfoT varinfo varid varid varinfo name mti GetVarName varid varinfo gt typeid mti GetVarType varid region name mti GetRegionFullName regid sprintf var name s s s region name mti GetProcessName procid varinfo name varinfo var addr mti GetVarAddr var name mti VsimFree region name varinfo next 0 return varinfo static vo
446. nitForeign for model sl type al is array 2 downto 0 of bit type a2 is array 3 downto 2 of al end top architecture a of top is signal sl bit r 0 signal s2 rectype 42 1 1100 signal s3 bit vector 7 downto 0 10001111 signal s5 a2 101 Oll signal s6 integer 42 signal s7 real 17 8 signal s8 time 11 ns component for model is end component for all for model begin ModelSim FLI Reference use entity work for model a il for model S lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b Signals s2 a s2 b S ne s2 s2 s2 s2 s3 is of type ARRAY vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl Sl is of type ENUMERATION S2 is of type RECORD is of type INTEGER is of type is of type c 3 is of c 2 is of c 1 is of c 0 xsa of VSIM 1 quit S3 7 is of type s3 6 is of type s3 5 is of type s3 4 is of type s3 3 is of type s3 2 is of type S3 1 is of type s3 0 is of type S5 is of type ARRA s5 3 is of type s5 3 2 is of s5 3 1 is of s5 3 0 is of s5 2 is of type s5 2 2 is of s5 2 1 is of s5 2 0 is of S6 is of type INTE S7 is of type REAL S8 is of type TIME ENUMERATION ARRAY type ENUMERATION type ENUMERATION type ENUMERATION type EN
447. nitions ModelSim FLI Reference Variable Variable Variable Variable Variable Variable Variable Variable Variable 10 3 8 7 Jbl 7 EE 9 Variabl Time b Variabl Variable Variabl Variabl Variable Variable Variable Variable Variable Variable nyt 4 V1 2 vol to VSIM 2 gt quit IJe realsig 19 35 timesig 0 7 stdlogicsig tS bitarr od ELT vie vor stdlogicarr Lo MS no ls intarr 12 13 14 realarr 12 6 102 22 timearr 0 17 0 8 rec Ora HOY eit bitsig Qt intsig 24 realsig 20 85 timesig 0 8 stdlogicsig Uo bitarr Ls n TQ LS stdlogicarr DN nos TIUS EQ intarr 13 14 15 realarr 13 1 102 72 timearr 0 18 0 79 rec LER urs O mti GetVarValuelndirect Syntax Returns Arguments Description mti GetVarValuelndirect FLI 449 Gets the value of a VHDL variable of any type except record value mti GetVarValueIndirect variable id buffer Description A pointer to the value of the specified variable Name Type Description variable id mtiVariableIdT A handle to a VHDL variable of any type except record buffer void A buffer into which the value is to be placed OPTIONAL can be NULL mti GetVarValueIndirect returns the value of a variable of any type except record mti GetVarValueIndirect must be used for scalar variables of type real and time If the buffer parameter is NULL mti Ge
448. nos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading work for model a Loading for model sl Design Signals bitsig type Enumeration low 0 high 1 intsig type Scalar low 2147483648 high physsig type Physical low 0 high 2147483647 realsig type Real low 0 high 0 timesig type Time low 0 high 0 stdlogicsig type Enumeration low 0 high 8 bitarr type Array low 5 high 2 stdlogicarr type Array low 0 high 3 uparray type Array low 1 high 4 rec type Record low 0 high 0 VSIM 1 quit mti TickHigh FLI 653 2147483647 ModelSim FLI Reference FLI 654 FLI function definitions mti TickLeft Gets the left value of a ranged type Syntax left mti TickLeft type id Returns Type Description mtiInt32T The left value of the range of the specified type 0 for real time and record types Arguments Type Description mtiTypeldT A handle to a VHDL type Description mti TickLeft returns the value of type LEFT for ranged types For real time and record types mti TickLeft returns 0 Related functions mti TickDir FLI 647 mti TickHigh FLI 651 mti TickLength FLI 657 mti TickLow FLI 661 mti TickRight FLI 664 Example FLI code include mti h static char getTypeStr mtiTypeIdT typeid switch mti_GetTypeKind typeid
449. nstantiated char param The last part of the string in the f foreign attribute x7 mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model LS mti AddLoadDoneCB loadDoneCB 0 mti PrintMessage nElaboration phase n printHierarchy mti GetTopRegion 1 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 entity inv is generic delay time 5 ns port a in bit b out bit i end inv architecture b of inv is begin b lt a after delay end b entity mid is end mid architecture a of mid is signal sl bit f 0 signal s2 bit 0 signal s3 bit 0 signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit br out bit i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin instl mid end a mti FirstLowerRegion FLI 193 ModelSim FLI Reference FLI 194 FLI function definitions Simulation output 9 vsim c
450. nstl sim top linstl VSIM 10 gt run 15 Time 0 30 doProc Procedure Current region is top linst1l ModelSim FLI Reference FLI 252 FLI function definitions Time 0 30 doProc Procedure Current region is top linstl1 VSIM 11 env sim top linstl VSIM 12 gt quit ModelSim FLI Reference mti GetDriverNames FLI 253 mti GetDriverNames Gets the names of all drivers on a VHDL signal Syntax driver names mti GetDriverNames signal id length Returns Name Description driver names A pointer to a NULL terminated array of the names of the signal s drivers Arguments Name Type Description signal id mtiSignalldT A handle to a VHDL signal length mtiInt32T Returns the number of names in the returned name array Description mti GetDriverNames returns a NULL terminated array of the names of the drivers that are driving values onto the specified signal The number of names in the array is returned in the length parameter If there is an error or if the signal is in a nodebug region or if the type of the signal is not a scalar enumeration type then the length parameter is set to zero and a NULL is returned The returned array and character strings must not be freed The driver names are valid only until the next call to mti GetDriverNames mti GetDriverNames can be used in conjunction with mti GetDriverValues since the arrays returned from each function are in the same
451. ntarr t 4 tarray re 10 11 12 variable realarr realarray 11 6 101 22 variable timearr timearray 15 ns 6 ns variable rec rectype ie NOt lm UB NLRI Oy begin bitsig not bitsig intsig intsig 1 ModelSim FLI Reference realsig timesig stdlogicsig bitarr intarr 1 intarr 2 intarr 3 realarr 1 realarr 2 mti GetVarValuelndirect FLI 455 realsig 1 5 timesig 1 ns not stdlogicsig not bitarr intarr 1 1 1 te 14 intarr 2 intarr 3 realarr 1 realarr 2 07 57 0547 timearr 1 timearr 1 1 ns timearr 0 timearr 0 1 ns stdlogicarr not stdlogicarr rec a not rec a rec b rec b 1 rec c rec c 2 5 rec d not rec d rec e s hot rece wait for 5 ns end process end a Simulation output 9 vsim c top Reading modeltech 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 gt run 12 Time 0 6 Variable bitsig 1 Variable intsig 23 Variable realsig 19 35 Variable timesig 0 7 Variable stdlogicsig ELY Variable bitarr Tod TES VI ToS Variable stdlogicarr mot CE TOT v Variable intarr 12 13 14 Variable realarr 12 6 102 22 Variable timearr 0 17 0 8 Variable rec ro 3 8 7 epa LD TOT dno TIT ModelSim
452. nts vartype mti PrintFormatted An for i 0 i lt num elems i ModelSim FLI Reference FLI 236 FLI function definitions mti PrintFormatted c indent printValue elem list i mti GetVarType elem list il indent 2 mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetVarValueIndirect varid amp real val mti PrintFormatted g n real val break case MTI_TYPE_TIME mtiTime64T time_val mti GetVarValueIndirect varid amp time val mti PrintFormatted d d Wn MTI TIME64 HI32 time val MTI TIME64 LO32 time val break default mti PrintMessage Mn break static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info varlInfoT varinfo mti PrintFormatted Time d d n mti NowUpper mti Now for varinfo inst data var info varinfo varinfo varinfo gt next mti PrintFormatted Variable s varinfo name printValue varinfo varid varinfo gt typeid 4 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 gt typeid mti GetVarType varid varinfo next 0 return varinfo static void initInstance void param inst
453. o L install dir WNmodeltechNwin32 lmtipli MinGW ecc is available on the ModelSim FTP site ModelSim FLI Reference FLI 26 Introduction 32 bit Linux platform If your foreign module uses anything from a system library you ll need to specify that library when you link your foreign module For example to use the standard C library specify Ic to the Id command gcc compiler gcc c I install dir modeltech include app c ld shared E Bsymbolic o app so app o 1c When using Bsymbolic with ld all symbols are first resolved within the shared library at link time This will result in a list of undefined symbols This is only a warning for shared libraries and can be ignored If you are using ModelSim on Redhat version 6 0 through 7 1 you also need to add the noinhibit exec switch when you specify Bsymbolic The compiler switch freg struct return must be used when compiling any FLI application code that contains foreign functions that return real or time values 64 bit Linux for IA64 platform 64 bit Linux is supported on RedHat Linux Advanced Workstation 2 1 for Itanium 2 gcc compiler gcc 3 2 or later gcc c fPIC I install dir modeltech include app c ld shared Bsymbolic E allow shlib undefined o app so app o If your FLI application requires a user or vendor supplied C library or an additional system library you will need to specify that library when you link your FLI application For exampl
454. o mti CreateProcess or mti CreateProcessWithPriority mtiVoidFuncPtrT The callback function as specified to mti_CreateProcess or mti_CreateProcessWithPriority The parameter as specified to mti_CreateProcess or mti_CreateProcessWithPriority Description mti_RestoreProcess restores a process that was created by mti_CreateProcess or mti CreateProcessWithPriority The first parameter is the handle to the process that was returned from the original call to mti CreateProcess or mti CreateProcessWithPriority The remaining parameters are the same parameters as in the original call to mti CreateProcess or mti CreateProcessWithPriority mti RestoreProcess must be called to restore each process that was created by mti CreateProcess or mti CreateProcessWithPriority as the callback function address may be different after a restore This function should be called only from a restore callback function It should not be called from an initialization procedure ModelSim FLI Reference FLI 570 FLI function definitions Related functions mti CreateProcess FLI 123 mti CreateProcessWithPriority FLI 128 mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveLong FLI 586 mti SaveShort FLI 589 mti SaveString FLI 592 Example
455. oT inst info ntFormatted Time d s n iginfo inst data sig info rintFormatted Signal s siginfo gt name mti_ScheduleWakeup inst_data gt proc new_time sS s mti Signallmage siginfo sigid 5 iginfo Am units siginfo static signalInfoT setupSignal mtiSignalIdT sigid signall siginfo siginfo siginfo siginfo siginfo return 0 mti GetResolutionLimit amp new time siginfo gt next 0 nfoT siginfo signalInfoT mti Malloc sizeof signalInfoT sigid sigid name mti GetSignalNameIndirect sigid typeid mti GetSignalType sigid next 0 siginfo static void initInstance void param instanceInfoT inst data mtiSign signall signall allIdT sigid nfoT curr info nfoT siginfo mti Now FLI 503 inst data mti Malloc sizeof instanceInfoT 0 inst data sig info for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig info 0 inst data sig info siginfo else curr_info gt next siginfo curr_info siginfo inst_data gt proc mti_CreateProcess Test Process checkValues void inst data mti ScheduleWakeup inst data proc 6 void initForeign mtiRegionIdT region The ID of the region in which this
456. oaded due to a foreign attribute on a VHDL architecture is reloaded A shared library loaded due to the foreign option to vsim is reloaded A shared library loaded due to a foreign attribute on a VHDL subprogram is not reloaded even if the shared library also contains code for a foreign architecture Related functions Example None FLI code include lt stdlib h gt include lt mti h gt static char instance_info static int test_global 15 void cleanupCallback void param mti_PrintMessage nCleanup callback n mti PrintFormatted Freeing param s n param free param mti PrintFormatted test global d n test global void restartCallback void param mti_PrintMessage nRestart callback n mti PrintFormatted Param is s n param ModelSim FLI Reference FLI 480 FLI function definitions mti PrintFormatted test global d n test global test global 15 mti PrintFormatted Setting test global to initial value of d n test global 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 kf foreign attribute uA mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model if mti_IsFirstInit mti_PrintMessage n
457. oc Procedure Calling region is top linstl VSIM 11 gt quit ModelSim FLI Reference mti GetCheckpointFilename FLI 245 mti GetCheckpointFilename Gets the name of the current checkpoint file Syntax filename mti GetCheckpointFilename Returns Name Description filename A pointer to the name of the current checkpoint file Arguments None Description mti_GetCheckpointFilename returns the filename specified with the most recent checkpoint or restore command A NULL is returned if no checkpoint or restore command has been given The returned pointer must not be freed Related functions None Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char inst_info char param mti PrintFormatted Saving instance info s n inst info mti SaveString inst info mti PrintFormatted Checkpoint filename is s n mti GetCheckpointFilename void restoreCallback void param char inst_info char param strcpy inst info mti RestoreString mti PrintFormatted Restored instance info s n instance info ModelSim FLI Reference FLI 246 FLI function definitions ModelSim FLI Reference mti PrintFormatted Checkpoint filename is s n mti GetCheckpointFilename void cleanupCallback void param mti_PrintMessage Cleaning up n free param
458. ocess id instanceInfoT static char convertTime mtilnt32T time int limit mtiInt32T new time ModelSim FLI Reference FLI 502 FLI function definitions ModelSim FLI Reference switch case case case case case case case case case case case case case case case case case case defau limit 2 new time iz new time 0 new time Le new time SAL new time 3 5 new_time 4 new_time 553 knew time 6 new time Soles new_time 8 new time H knew time 10 new time 11 new time 12 new time 13 new time 14 new time 15 new time its knew time time 100 time 10 time time 100 time T0 time time 100 time 10 time time 100 time 10 time time 100 time T0 time time 100 time 10 time time return return return return return return return return return return return return return return return return return return return static void checkValues void inst info char instanc mtilnt3 signall units mti Pri for s mti P units eInfoT inst data 2T new time nfoT siginfo convertTime mti Now sont ja sect ys MEG y ms ms ms us us us ns ns ns ps ps ps fs fs fs 220 9 instanceInf
459. ocessWithPriority FLI 128 Creates a new VHDL process with a specific priority mti FirstProcess FLI 195 Gets the first VHDL process in a region mti NextProcess FLI 485 ModelSim FLI Reference Gets the next VHDL process in a region FLI 45 Table 2 FLI process functions Continued Function Action mti GetProcessName FLI 315 Gets the name of a VHDL process mti GetProcessRegion FLI 319 Gets a handle to a process region mti Sensitize FLI 614 Sensitizes a VHDL process to a VHDL signal mti Desensitize FLI 160 Desensitizes a VHDL process to the VHDL signals to which it is sensitive mti ScheduleWakeup FLI 606 Schedules a VHDL process to wake up at a specific time mti ScheduleWakeup64 FLI 610 Schedules a VHDL process to wake up at a specific time using a 64 bit delay Table 3 FLI signal functions Function Action mti CreateSignal FLI 149 Creates a new VHDL signal mti FindPort FLI 170 Finds a port signal in a port interface list mti FindSignal FLI 182 Finds VHDL or SystemC signals by name mti FirstSignal FLI 199 Gets the first VHDL or SystemC signal in a region mti ForceSignal FLI 208 Forces a value onto a VHDL signal mti GetArraySignalValue FLI 226 Gets the value of a VHDL signal of type array mti GetDrivingSignals FLI 267 Gets a handle to all of
460. ocid inst gt sigidl MTI EVENT mti SetDriverOwner inst drvidl procid inst sigid2 mti CreateSignal mySig2 region enum type inst drvid2 mti CreateDriver inst sigid2 procid mti CreateProcess mySig2Driver driveSignal2 inst mti Sensitize procid inst gt sigid2 MTI EVENT Not setting driver owner for driver 2 mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst ModelSim FLI Reference FLI 620 FLI function definitions 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 entity top is end top architecture a of top is signal sl bit 0 component for model end component begin sl lt not sl after 5 ns forinst for model end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 5 VSIM 2 drivers top forinst mySigl Drivers for top forinst mysigl 1 Signal top forinst mysigl 1 Driver top forinst mySiglDriver 0 at 10 ns VSIM 3 drivers top forinst mySig2 Drivers for top forinst mysig2 0 Signal top forinst mysig2 0 Driver top forinst MTI foreign architecture 1 at 10 ns VSIM 4 quit Cleaning up ModelSim
461. odel restart VSIM 9 run 25 mti Realloc FLI 525 ModelSim FLI Reference FLI 526 FLI function definitions VSIM 10 restore cpf2 Loading checkpoint restore data from file cpf2 Checkpoint created Fri Jul 7 13 20 52 2000 Restoring state at time 15 ns iteration 1 Restore in progress Restored instance info my for model restart VSIM 11 run 35 VSIM 12 quit Cleaning up ModelSim FLI Reference mti ReleaseSignal Releases a force on a VHDL signal mti ReleaseSignal FLI 527 Syntax status mti ReleaseSignal signal id Returns Description 1 if successful 0 if there is an error Arguments Name Type Description signal id mtiSignalldT A handle to a VHDL signal Description mti_ReleaseSignal releases the specified signal from any active force mti ReleaseSignal returns 1 if the release is successful otherwise it returns 0 Related functions mti ForceSignal FLI 208 Example FLI code include lt stdio h gt include lt stdlib h gt include string h ifndef WIN32 include lt unistd h gt endif include lt mti h gt typedef struct signalInfoT tag struct signalInfoT tag next struct signallInfoT tag child char void mtiSignalldT mtiTypeIdT mtiTypeKindT name last value sigid typeid typekind ModelSim FLI Reference FLI 528 FLI function definitions mtiDirectionT char signalInfoT typedef struct
462. odel sl 780 architecture a of mid is signal sl bit 0 signal s2 bit 0 signal s3 bit re OT signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic delay time 5 ns port a in bit b out bit i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top is component mid is end component begin instl mid end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for_model sl Hierarchy Region top Region top instl Region top instl flip mti NextRegion FLI 491 ModelSim FLI Reference FLI 492 FLI function definitions Region top inst1 il Region top instl toggle Region standard VSIM 1 gt quit ModelSim FLI Reference mti NextSignal FLI 493 mti NextSignal Syntax Returns Arguments Description Gets the next VHDL or SystemC signal in a region signal id mti NextSignal Name Type Description signal id mtiSignalldT A handle to the next VHDL or SystemC signal in the current re
463. odeltech tcl vsim pref tcl vsim c top Loading modeltech sunos5 std standard Loading work top a Loading my mid lib mid a Loading my inv lib inv b Loading for model lib for model a Loading for model sl Elaboration phase Foreign architecture region is in Library for model lib Load Done phase Region top is in Library work Region top instl is in Library my mid lib Region top inst1 il is in Library for model lib Region top instl flip is in Library my inv lib Region top instl toggle is in Library my inv lib VSIM 1 run 10 VSIM 2 quit ModelSim FLI Reference mti GetNextEventTime Gets the next event time from a foreign subprogram or callback Syntax Returns Arguments Description status Name mti GetNextEventTime FLI 287 mti GetNextEventTime next time Description Status Name Type A number that indicates which type of events are pending see below for details Description next time mtiTime64T Returns the time at which the next simulation event will occur see below for details mti GetNextEventTime returns the next simulation event time when called from within a foreign subprogram or callback function It always returns the current simulation time when called from within a VHDL process The return value and next time parameter are set as follows Status Description next time 0 There ar
464. of the specified type O for real time and record types Description mtiTypeldT A handle to a VHDL type mti TickHigh returns the value of type HIGH for ranged types For real time and record types mti TickHigh returns 0 Related functions Example mti TickDir FLI 647 mti TickLeft FLI 654 mti TickLength FLI 657 mti TickLow FLI 661 mti TickRight FLI 664 FLI code include mti h Static char getTypeStr mtiTypeIdT switch mti GetTypeKind typeid case MTI TYPE SCALAR case MTI TYPE ARRAY case MTI TYPE RECORD case MTI TYPE ENUM return return return return typeid Scalar Array Record Enumeration ModelSim FLI Reference FLI 652 FLI function definitions ModelSim FLI Reference case MTI TYPE PHYSICAL return Physical case MTI TYPE REAL return Real case MTI TYPE TIME return Time default return UNKNOWN static void initInstance void param mtiSignalIdT sigid mtiTypeIdT typeid mti PrintMessage Design Signals n for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal typeid mti GetSignalType sigid mti PrintFormatted 14s type 12s low d high d n mti GetSignalName sigid getTypeStr typeid mti TickLow typeid mti TickHigh typeid void initForeign mtiRegionIdT region The ID of the region in which this
465. oid loadDoneCB void param mti_PrintMessage printHierarchy mti_GetTopRegion void initForeign mtiRegionIdT region 7 gt char param LE mtilnterfaceListT generics mtilnterfaceListT ports ZF mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is generic delay port a in bit Bi og bit i end inv time architecture b of inv is begin b lt a after delay end b entity mid is end mid architecture a of mid is signal sl bit re 0 signal s2 bit OT signal s3 bit 0 signal s4 BLE VOTE component for model is end component for all component inv is architecture is mti NextRegion regid nLoad Done phase n 1 The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute x EJ A list of generics for the foreign model A list of ports for the foreign model initForeign for model sl 2 5 ns for model use entity work for model a E generic delay time 5 ns port a in bit b out bit i end component begin flip inv port map s3 s4 il for model sl lt not sl after 5 ns S3 lt not s3 after 5 ns toggle inv port map sl s2 end a entity top is end top architecture a of top
466. oid testProcess void param instanceInfoT inst param mtiInt32T sigval mti PrintFormatted YnTime d d delta d testProcess Mn mti NowUpper mti Now mti Delta scheduleProcesses inst 0 0 Test immediate activation of immediate process sigval mti GetSignalValue inst sig02 if sigval 0 sigval 1 else sigval 0 ModelSim FLI Reference mti CreateProcessWithPriority FLI 131 mti SetSignalValue inst gt sig02 long sigval Immediate process sensitive to a signal in zero delay void sigImmedProc instanceInfoT inst mti PrintFormatted Time d d delta d sigImmedProc n mti NowUpper mti Now mti Delta Processes scheduled by testProcess void immedProcessl void param mti PrintFormatted Time d d delta d immedProcess1 n mti NowUpper mti Now mti Delta void normalProcessl instanceInfoT inst mti PrintFormatted Time d d delta d normalProcess1 Scheduling processes ending in 2 n mti NowUpper mti Now mti Delta scheduleProcesses inst 1 0 void synchProcessl instanceInfoT inst mti PrintFormatted Time d d delta d synchProcess1 Scheduling processes ending in 3 n mti_NowUpper mti_Now mti_Delta scheduleProcesses inst 2 0 void nbaProcessl1 instanceInfoT inst mti PrintFormatted Time d d delta d nbaProcess1 Sc
467. om support or in the following formats and locations Document Format How to get it ModelSim Installation amp Licensing Guide paper shipped with ModelSim PDF select Help Documentation also available from the Support page of our web site www model com ModelSim Quick Guide command and feature quick reference paper shipped with ModelSim PDF select Help Documentation also available from the Support page of our web site www model com ModelSim Tutorial PDF HTML select Help Documentation also available from the Support page of our web site www model com ModelSim User s Manual PDF HTML select Help Documentation ModelSim Command Reference PDF HTML select Help Documentation ModelSim GUI Reference PDF HTML select Help Documentation Foreign Language Interface Reference PDF HTML select Help Documentation Std DevelopersKit User s Manual PDF www model com support documentation BOOK sdk_um pdf The Standard Developer s Kit is for use with Mentor Graphics QuickHDL Command Help type help command name at the prompt in the Transcript pane Error message help type verror lt msgNum gt at the Transcript or shell prompt Tcl Man Pages Tcl manual select Help gt Tcl Man Pages or find contents htm in modeltech docs tcl_help_html Technotes ModelSim FLI Reference se
468. omplete Restart Quit EnvChanged SimStatus Save and Restore are traced during execution but not explicitly identified as being from a callback function gt Note Tracing does not work across checkpoint restore operations ModelSim FLI Reference FLI 42 Introduction Debugging FLI application code ModelSim FLI Reference ModelSim Versions 5 7 and later offer the optional C Debug feature This tool allows you to interactively debug C C source code with the open source gdb debugger See C Debug in the ModelSim User s Manual for details If you don t have access to C Debug continue reading for instructions on how to attach to an external C debugger In order to debug your FLI application code in a debugger your application code must be compiled with debugging information for example by using the g option You must then load vsim into a debugger Even though vsim is stripped most debuggers will still execute it You can invoke the debugger directly on vsimk the simulation kernel where your application code is loaded for example ddd which vsimk or you can attach the debugger to an already running vsim process In the second case you must attach to the PID for vsimk and you must specify the full path to the vsimk executable for example gdb MTI HOME sunos5 vsimk 1234 On Solaris AIX and Linux systems you can use either gdb or ddd On HP UX systems you can use the wdb debugger from HP You will need version 1 2 or lat
469. on The ID of the region in which this foreign architecture is instantiated char param The last part of the string in the J foreign attribute mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model char lib name mti AddLoadDoneCB loadDoneCB 0 mti PrintMessage nElaboration phase n lib name mti GetLibraryName region mti PrintFormatted Foreign architecture region is in Library s n lib name HDL code for model vhd 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 inv vhd entity inv is generic delay time 5 ns port a in bit h ro out bit i end inv architecture b of inv is begin b lt a after delay end b mid vhd library for model lib library inv lib entity mid is end mid architecture a of mid is signal sl bit 0 signal s2 bit 0 signal s3 r bit O signal s4 bit 0 component for model is end component mti GetLibraryName FLI 285 for all for model use entity for model lib for model a component inv is generic delay time 5 ns port a in bit by out bit i end component for all inv use entity inv_lib inv b begin flip inv port map s3 s4 il for model sl lt not sl afte
470. on name void loadDoneCB void param mti PrintMessage nLoad Done phase n printHierarchy mti GetTopRegion 1 void initForeign mtiRegionIdT region The ID of the region in which this Ef foreign architecture is instantiated char param The last part of the string in the xy foreign attribute x mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model E mti AddLoadDoneCB loadDoneCB 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 entity inv is generic delay time 5 ns port mw In HET b out bit i end inv architecture b of inv is signal count integer 0 begin b lt a after delay pl process a begin count lt count 1 after 0 ns end process end b library ieee use ieee std logic 1164 a11 entity mid is port ptio inout std logic end mid architecture a of mid is signal sl bit Q 3 signal s2 bit 0 signal s3 bit 0 signal s4 bit 0 component for model is end component for all for model use entity work for_model a component inv is generic delay time port a in bit b out bit i end component begin flip inv port map s3 s4 il for model sl lt not s
471. on name if regid region name Source name mti_GetRegionFullName regid mti_GetRegionSourceName regid mti GetRegionSourceName FLI 345 mti PrintFormatted Region s is in File s Mn region name source name mti VsimFree region name void loadDoneCB void param mti PrintMessage nLoad Done phase n printRegionInfo mti_FindRegion top printRegionInfo mti FindRegion instl printRegionInfo mti FindRegion instl il printRegionInfo mti FindRegion instl flip printRegionInfo mti FindRegion instl toggle void initForeign mtiRegionIdT region The ID of the region in which this E foreign architecture is instantiated char param The last part of the string in the foreign attribute x7 mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model char source name mti AddLoadDoneCB loadDoneCB 0 mti PrintMessage nElaboration phase n Source name mti GetRegionSourceName region mti PrintFormatted Foreign architecture region is in File s n Source name HDL code for model vhd 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 inv vhd entity inv is generic delay time 5 ns p
472. on software and name is the name of the process Enclosing the entire name in angle brackets makes it an illegal HDL name For example MTI foreign architecture ModelSim FLI Reference FLI 130 FLI function definitions We strongly recommend that you do not use characters in the name that will cause Tcl parsing problems This includes spaces the path separator normally or square brackets and dollar signs If you must use these characters then create an escaped name by putting a backslash V at both ends of the name Related functions mti CreateProcess FLI 123 mti Desensitize FLI 160 mti GetProcessName FLI 315 mti RestoreProcess FLI 569 mti ScheduleWakeup FLI 606 mti ScheduleWakeup64 FLI 610 mti Sensitize FLI 614 Example FLI code include lt stdlib h gt include lt mti h gt typedef struct mtiProcessIdT immed_procid 5 mtiProcessIdT normal_procid 5 mtiProcessIdT synch_procid 5 mtiProcessIdT nba_procid 5 mtiProcessIdT postponed procid 5 mtiSignalIdT sig02 instanceInfoT void scheduleProcesses instanceInfoT inst int i mtiDelayT delay mti ScheduleWakeup inst immed procid i delay mti ScheduleWakeup inst normal procid i delay mti ScheduleWakeup inst synch procid i delay mti ScheduleWakeup inst nba procid i delay mti ScheduleWakeup inst postponed procid i delay Main test process v
473. onIdT region mtiRegionIdT param mti_PrintFormatted Time d d Region s the simulator s n mti_NowUpper mti_Now mti_GetRegionName region run status 1 is about to run just completed a run void initForeign ModelSim FLI Reference FLI 84 FLI function definitions ModelSim FLI Reference mtiRegionIdT region p char param mtilnterfaceListT generics mtilnterfaceListT ports p The ID of the region in which this x foreign architecture is instantiated The last part of the string in the v foreign attribute x A list of generics for the foreign model A list of ports for the foreign model x mti AddSimStatusCB simStatusCallback region 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 for model begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model S lt not sl after 5 ns end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading work top a Loading work for model a Loading for model sl VSIM 1 run 10 VSIM 2 run 15 VSIM 3 quit Loading modeltech sunos5 std standard Time 0 0 Region il the simulator is a
474. onnect sock struct sockaddr amp server server length if status 0 if retry_cnt 1 mti PrintFormatted Error connecting to server s d n hostname portNum close sock else strcpy hostname map Put your hostname here ifdef WIN32 unsigned long non_blocking 1 status ioctlsocket sock FIONBIO amp non blocking if status SOCKET ERROR perror Setting socket status else statusFlags fcntl sock F GETFL if statusFlags SOCKET_ERROR perror Getting socket status else int ctlValue statusFlags O_NONBLOCK ctlValue fcntl sock F SETFL statusFlags if ctlValue SOCKET ERROR perror Setting socket status endif mti AddLoadDoneCB mtiVoidFuncPtrT loadDoneCB void sock ModelSim FLI Reference FLI 64 FLI function definitions HDL code entity top is end top architecture a of top is signal sl bit 0 begin sl lt not sl after 5 ns end a Simulation output 9 vsim c foreign initForeign for model sl top Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading work top a Loading for_model sl Load Done Adding socket callback Read returned 1 Read Read returned 1 Read Read returned 1 Read Read returned 1 Read f Read returned 1 Read Read returned 1 Read
475. ons During simulation FLI code may initiate a non blocking I O operation on the socket again using standard system library routines and immediately return control to the simulator When the I O is completed the simulator invokes the callback function which could check for errors handle received data or initiate another non blocking I O operation before returning to the simulator Related functions mti AddInputReadyCB FLI 60 mti AddOutputReadyCB FLI 68 mti AddSocketOutputReadyCB FLI 90 ModelSim FLI Reference FLI 86 FLI function definitions Example FLI code include mti h include stdio h include fcntl h include lt sys types h gt include stdlib h ifdef WIN32 include lt winsock h gt else include lt unistd h gt include lt sys time h gt include lt sys param h gt include sys socket h include lt netinet in h gt include netdb h gethostbyname endif ifdef HP700 include resolv h endif ifdef WIN32 define MAXHOSTNAMELEN MAXGETHOSTSTRUCT else define SOCKET_ERROR 1 define INVALID_SOCKET 1 typedef int SOCKET endif void sockCB void sock int j char buf 1 ifdef WIN32 i recv SOCKET sock buf sizeof buf 0 else i read SOCKET sock buf sizeof buf endif mti PrintFormatted Read returned d Read Sc n i buf 0 if i 0 buf 0 C Remove the callback mti AddSocketInputR
476. op foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for_model sl c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading for model sl VSIM 1 run 50 Time 0 15 delta 0 Signal top sl is UNKNOWN The drivers of top sl are Drivers for top sl W Signal top sl W Driver top pl Time 0 40 delta 0 Signal top sl is UNKNOWN The drivers of top sl are Drivers for top s1l X Signal top sl X Driver top pl VSIM 2 quit mti Command Executes a simulator command mti Command FLI 105 Syntax mti Command command Returns Nothing Arguments Description A simulator command Description mti Command causes the specified command to be executed by the simulator The string must contain the command just as it would be typed at the VSIM prompt The results of the command are transcribed in the vsim transcript Any command that changes the state of simulation such as run restart restore etc cannot be sent from a foreign architecture foreign subprogram or callback that is executing under the direct control of vsim Related functions mti Cmd FLI 102 Example FLI code include lt stdio h gt include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U y TU STD_LOGIC_X X STD LOGIC 0
477. op ml il a sigb mti FindSignal top ml il b sigc mti FindSignal top ml il c printSignalInfo siga printSignalInfo sigb printSignalInfo sigc 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 mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB loadDoneCB 0 ER 5 t Ef HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a library ieee use ieee std logic 1164 a11 entity inv is generic delay time 5 ns port a in bit b out bit coc in stud logic i end inv architecture b of inv is signal count integer 0 begin b lt a after delay pl process c begin count lt count 1 after 0 ns end process end b library ieee use ieee std logic 1164 a11 entity mid is generic delay time 5 ns port midin in bit midout out bit vector 3 downto 0 midslv in std logic vector 7 downto 4 i end mid architecture a of mid is component inv is generic delay time 5 ns port a in bit b out bit exo Xm etd logic i end component begin il inv port map midin midout 2 midslv 7 end a library ieee use
478. or top s1 Driver not found for top s2 Driver not found for top s3 Driver found for top s4 VSIM 1 run 10 VSIM 2 quit mti FindDriver FLI 169 ModelSim FLI Reference FLI 170 FLI function definitions mti FindPort Finds a VHDL or SystemC port signal in a port interface list mti FindPort list name Type Description mtiSignalldT Type A handle to a VHDL or SystemC port signal or NULL if the signal is not found Description mtiInterfaceListT A pointer to a list of interface objects Syntax signal id Returns Name signal id Arguments Name list name Description char The name of the signal to be found in the list mti FindPort searches linearly through the specified interface list and returns a handle to the VHDL or SystemC port signal whose name matches the specified name The search is not case sensitive Related functions mti FindSignal FLI 182 Example FLI code include lt mti h gt typedef struct mtiProcessIdT mtiSignalldT mtiSignalldT mtiSignalldT instanceInfoT em procid bitsig intsig realsig void checkValues void param double instanceInfoT ModelSim FLI Reference real val inst instanceInfoT param mti FindPort FLI 171 mti PrintFormatted Time d d delta d n mti NowUpper mti Now mti Delta mti PrintFormatted s dWM mti GetSign
479. or even a standard simulator command but only the command added last has any effect Related functions mti AddTclCommand FLI 91 mti Cmd FLI 102 mti Command FLI 105 Example FLI code include lt mti h gt void printSigInfo void param char cp char command param ModelSim FLI Reference mti AddCommand FLI 55 mtiSignalIdT sigid mti PrintFormatted Time d d delta d Mn mti NowUpper mti Now mti Delta mti PrintFormatted Command s n command for cp command cp amp amp cp NO cpt 5 for p BOD SET ie RED tS NOTYLRIEptt LOEO if cp NO mti PrintMessage Usage printSig lt signame gt n else sigid mti_FindSignal cp Tf A sigirda 4 mti PrintFormatted Signal s not found n cp else switch mti GetTypeKind mti GetSignalType sigid case MTI TYPE SCALAR case MTI TYPE ENUM case MTI TYPE PHYSICAL mti PrintFormatted Signal s d n cp mti_GetSignalValue sigid break default mti_PrintFormatted The type of signal s is not supported n cp break void initForeign mtiRegionIdT region The ID of the region in which this VIA foreign architecture is instantiated char param The last part of the string in the Kl foreign attribute mtilnterfaceListT generics A list of generics for the foreign ia model Sy mtiInterfaceListT ports
480. or model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 35 VSIM 2 checkpoint cpfile Saving instance info for model Save in progress VSIM 3 run 40 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 15 31 29 2000 Restoring state at time 35 ns iteration 1 Restored instance info for model VSIM 5 run 15 VSIM 6 restart f Cleaning up Loading for model sl VSIM 7 run 50 VSIM 8 checkpoint cp2 Saving instance info for model VSIM 9 run 35 VSIM 10 restore cp2 Loading checkpoint restore data from file cp2 Checkpoint created Fri Jul 7 15 31 48 2000 Restoring state at time 50 ns iteration 1 Restored instance info for model VSIM 11 run 10 VSIM 12 quit Cleaning up mti RemoveSimStatusCB Removes a simulator run status change callback mti RemoveSimStatusCB FLI 557 Syntax mti RemoveSimStatusCB func param Returns Nothing Arguments Type Description mtiSimStatusCBFuncPtrT A pointer to a function being called at simulator run status change void The parameter that was specified in the call to mti AddSimStatusCB when the callback was created Description mti Remo
481. oreign of a architecture is initForeign for model sl begin end a library ieee use ieee std logic 1164 a11 entity top is type bitarray is array 2 downto 5 of bit type rectype is record a t bit b integer c bitarray end record type bigtime is range 0 to integer high units hour day 24 hour ModelSim FLI Reference FLI 666 FLI function definitions wee mon yea end u end top architect signal signal signal signal signal signal signal signal signal signal compone end com for all begin instl end a k 7 day th 4 week r 12 month nits ure a of top is bitsig bit 1 intsig integer 42 physsig bigtime 3 hour realsig real 10 2 timesig time 3 ns stdlogicsig std logic H bitarr bitarray 1100 stdlogicarr std logic vector 3 downto 0 OILH uparray bit vector 1to 4 0101 rec rectype Lm FOT 0 ST DTE pa nt for model ponent for model use entity work for model a for model Simulation output 9 vsim c Reading 5 4b vsim c Loading Loading Loading Loading Loading Design stdl stdl VSIM 1 gt q ModelSim FLI Reference top modeltech tcl vsim pref tcl top modeltech sunos5 std standard modeltech sunos5 ieee std logic 1164 body work top a work for model a for model sl Signals bitsig type Enumeration left 0 ri
482. ork top a Loading work for model a Loading for_model sl VSIM 1 run 17 Time 6 ns Signal bitsig 0 Signal intsig 43 Signal realsig 1 130000e 01 Signal timesig 5 ns Signal stdlogicsig 0 Signal stdlogicarr 1010 Time 11 ns Signal bitsig 1 Signal intsig 44 Signal realsig 1 240000e 01 Signal timesig 7 ns Signal stdlogicsig 1 Signal stdlogicarr 0101 Time 16 ns Signal bitsig 0 Signal intsig 45 Signal realsig 1 350000e 01 Signal timesig 9 ns Signal stdlogicsig 0 Signal stdlogicarr 1010 VSIM 2 quit ModelSim FLI Reference mti NowiIndirect mti Nowlndirect FLI 505 Gets the upper and lower 32 bits of the 64 bit current simulation time Syntax curr time mti NowIndirect time buf Returns Name Type Description curr time mtiTime64T The upper and lower 32 bits of the current simulation time Arguments Name Type Description time buf mtiTime64T Returns the upper and lower 32 bits of the current simulation time OPTIONAL can be NULL Description mti NowlIndirect returns the upper and lower 32 bits of the 64 bit current simulation time The time units are equivalent to the current simulator time unit setting If the time buf parameter is NULL then mti NowIndirect allocates memory for the value and returns a pointer to it The caller is responsible for freeing this memory with mti VsimFree If the time buf parameter is not NULL then mti NowIndirect
483. ormatted cProcess s is in region s n indent mti GetProcessName procid region name ModelSim FLI Reference FLI 320 FLI function definitions ModelSim FLI Reference mti VsimFree region void printHierarchy mtiRegionIdT region mtiRegionIdT regid printProcesses region for regid printHierarchy regid void loadDoneCB void param mti_PrintMessage printHierarchy mti_GetTopRegion void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB loadDoneCB nElaboration phase Mn mti PrintMessage printHierarchy mti GetTopRegion HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is delay in bitj bit generic time 5 ns port a b out i end inv architecture b of inv is begin b lt a after delay pl process variable count begin architecture is name int indent indent regid mti FirstLowerRegion region regid mti NextRegion regid indent nLoad Done phase n 1 The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute A list of generics for the foreign model A list of ports for the foreign model 0 1 initForeign for model sl
484. ort a in bit b out bit i end inv architecture b of inv is begin b lt a after delay end b mid vhd entity mid is ModelSim FLI Reference FLI 346 FLI function definitions ModelSim FLI Reference end mid architecture a of mid is signal signal signal signal sl s2 s3 s4 bit 0 bat Et bit 0 bites EO Fe component for_model is end component for all for model use entity work for_model a component inv is generic port a b i delay time in bit out bit end component for all inv use entity wor begin flip inv port map s3 s4 il for_model sl lt not sl after 5 ns toggle inv port map sl end a top vhd entity top is end top architecture a of top is component mid is end component for all begin inst end a 1 mid use entity wor mid Simulation output vcom 93 for model vhd inv vhd mid vhd top vhd Model Technology ModelSim SE EE vcom 5 4b Compiler 2000 06 Jun Loading package standard Com Com Com Com Com Com pil pil pil pil pil pil ling ling ling ling ling ling entity for model architecture a of entity inv architecture b of entity mid architecture a of Loading entity for model Loading entity inv Com Com pil ling pil ling entity top architecture a of Loading entity mid p ms Sr k inv b s2
485. ow mti_Delta mti PrintMessage The printSigs command has been deactivated n return TCL OK void printSigInfo mtiSignalIdT sigid char printFullName char region_name mti PrintFormatted Signal if printFullName region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted s region name mti VsimFree region name mti_PrintFormatted s mti_GetSignalName sigid switch mti_GetTypeKind mti_GetSignalType sigid case MTI_TYPE_SCALAR case MTI_TYPE_ENUM case MTI_TYPE_PHYSICAL mti_PrintFormatted dWMn mti GetSignalValue sigid break default mti PrintFormatted Type not supported n break int printRegionInfo ClientData param Tcl Interp interp int argc char argv instanceInfoT inst info instanceInfoT param char printFullName 0 if argc 1 if stremp argv 1 full 0 ModelSim FLI Reference mti AddTclCommand FLI 93 printFullName 1 else Tcl SetResult interp printRegionInfo Unknown argument TCL STATIC return TCL ERROR mti_PrintFormatted Time ld ld delta d n mti_NowUpper mti_Now mti_Delta mti PrintFormatted Signal info for s n inst_info gt model_name printSigInfo inst info sigl printFullName printSigInfo inst info sig2 printFullName if mti Now gt 15 mti AddTclCommand printSigs noAction 0 0
486. own above DEBUG DEBUGTYPE COFF These switches add symbols to the d that the profiler can use in its report MinGW g 3 2 3 g c I lt install_dir gt modeltech include app c g shared o app dll app o L install dir WmodeltechNwin32 lmtipli MinGW g is available on the ModelSim FTP site Compiling and linking FLI C applications FLI 31 32 bit Linux platform GNU C version 2 95 3 or later c c fPIC I install dir modeltech include app C c shared fPIC o app so app o 64 bit Linux for IA64 platform 64 bit Linux is supported on RedHat Linux Advanced Workstation 2 1 for Itanium 2 GNU C version 3 2 or later c c fPIC I install dir include app C c shared fPIC o app sl app o If your FLI application requires a user or vendor supplied C library or an additional system library you will need to specify that library when you link your FLI application 32 bit Solaris platform Sun WorkShop version 5 0 or later CC c Kpic o app o I install dir modeltech include app C CC G o app so app o lCstd 1Crun GNU C version 2 95 3 or later c c fPIC I install dir modeltech include app C c shared fPIC o app so app o LD LIBRARY PATH must be set to point to the directory containing libstdc 4 so so that the simulator can find this shared object 64 bit Solaris platform Sun WorkShop version 5 0 or later CC c v xcode pic32 xarch v9 o app o I install d
487. p architecture a of top is mti Malloc strlen param param in char amp instance info instance info i mti_RestoreChar mti_RestoreLong mti RestoreShort mti RestoreString char Sc n long ld n short d n string s n The ID of the region in which this xy foreign architecture is instantiated The last part of the string in the f foreign attribute ER A list of generics for the foreign model A list of ports for the foreign model xy Roy stance info instance info architecture is my for model ModelSim FLI Reference FLI 576 FLI function definitions ModelSim FLI Reference signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info my for model Saving char Z Saving long 123456 Saving short 587 Saving string Howdy VSIM 3 run 40 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 16 09 02 2000 Restoring state at time 20 ns iteration 1 Restoring instance info my for mo
488. p a Loading for model sl VSIM 1 run 50 Time 0 0 delta 1 Signal top sl is O O ror rO Time 0 5 delta 0 Signal top sl is 1 O Tor ror Time 0 10 delta Signal top sl is CEP ALES rg TON Time 0 15 delta Signal top sl is Nae nlt OA Time 0 20 delta Signal top sl is Ee Ae LIOS Tl Time 0 25 delta Signal top sl is pop Id rs Time 0 30 delta Signal top sl is gt Age OE f Time 0 35 delta Signal top sl is UEM EE ES Time 0 40 delta Signal top sl is VU NE OC DEA Time 0 45 delta Signal top sl is TUT PZ vt cut Time 0 50 delta Signal top sl is W W CZ Z VSIM 2 quit Cleaning up Co CX Q Ix 0 c0 A aOR m mA eS cn cS cs DE TPEET OPUS Reds oe ModelSim FLI Reference FLI 262 FLI function definitions mti GetDriverValues Syntax Returns Arguments Description Gets the values of all drivers on a VHDL signal value mti GetDriverValues signal id length Description A pointer to a statically allocated array of std logic driver values Name Type Description signal id mtiSignalldT A handle to a VHDL signal length mtiInt32T Returns the number of elements in the returned value array mti_GetDriverValues returns the values of drivers for the specified signal The returned pointer is a pointer to statically allocated memory therefore this pointer must not be freed The array element count is returned in the len
489. p sl app o bE app exp bI install dir modeltech rs6000 mti exports bM SRE bnoentry lc The app exp file must export the C initialization functions named in all FOREIGN attributes ModelSim FLI Reference Compiling and linking FLI C applications FLI 29 64 bit IBM RS 6000 platform cc compiler cc c q64 I install dir modeltech include app c ld o app sl app o b64 bE app exports bI install dir modeltech rs64 mti exports bM SRE bnoentry lc A gcc 64 bit compiler is not available at this time Only version 4 3 of AIX supports the 64 bit platform See Using 64 bit ModelSim with 32 bit FLI Applications FLI 34 for more information on 64 bit platforms When using AIX 4 3 in 32 bit mode you must add the switch DUSE INTTYPES to the compile command lines This switch prevents a name conflict that occurs between inttypes h and mti h ModelSim FLI Reference FLI 30 Introduction Compiling and linking FLI C applications ModelSim does not have direct support for any language other than standard C however C code can be loaded and executed under certain conditions Since ModelSim s FLI functions have a standard C prototype you must prevent the C compiler from mangling the FLI function names This can be accomplished by using the following type of extern extern C lt FLI application function prototypes gt The header file mti h already includes this type of extern You must also
490. parameter to be passed to the function OPTIONAL can be NULL mti_AddEnvCB adds the specified function to the simulator environment change callback list The same function can be added multiple times with possibly a different parameter each time Whenever the simulator environment changes for example when the environment command is used all callbacks in this list are called with their respective parameters plus a second parameter that is a pointer to the current context Related functions Example mti_RemoveEnvCB FLI 536 FLI code include lt mti h gt void envCallback void param void context mtiRegionIdT region mtiRegionIdT param mti_PrintFormatted Foreign Arch in Region s the current region is now s n mti_GetRegionName region mti_GetRegionName context void initForeign mtiRegionIdT region The ID of the region in which this foreign architecture is instantiated ModelSim FLI Reference FLI 58 FLI function definitions ModelSim FLI Reference char param The last part of the string in the x foreign attribute EY mtiInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model mti AddEnvCB envCallback region 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
491. pdata r sdata posedge clk while srdy 0 posedge clk deassign prdy r prdy_r 1 deassign pdata r pdata r bz end endtask input Laddar size 1 0 a begin saddr r a srw_r 1 sstrb_r 0 G posedge clk sstrb r 1 assign prdy r srdy task syswrite posedge clk while srdy 0 posedge clk deassign prdy r prdy_r 1 deassign sdata r sdata r bz sdata r bz end endtask RR KKK ke ke ke KR ke e ke e k Cache control Ok ckck I e e e x x input addr size 1 0 a begin saddr r a srw_r 0 sstrb_r 0 posedge clk sstrb r 1 assign prdy_r srdy assign sdata_r pdata function 3 0 get_hit ModelSim FLI Reference input 3 0 hit integer setnum begin casez hit 4 p 1 setnum 0 4 p 1 setnum 1 4 b 1 setnum 2 4 b1 setnum 3 endcase if verbose begin if prw 1 display t Read hit to set 0d time else display t Write hit to set 0d time end get hit 4 b0001 lt lt setnum setnum setnum mti GetRegionKind FLI 333 end endfunction reg 3 0 setsel always posedge clk if pstrb 0 begin if prw 1 amp amp hit begin Read Hit setsel get hit hit oen setsel prdy r 0 G posedge clk prdy r 1 oen 4 b1111 end else begin Read Miss or Write Hit if hit setsel get_hit hit else setsel pick_set paddr wen se
492. pe Syntax Returns Arguments Description low mti TickLow type id Type mti TickLow FLI 661 Description Type mtiInt32T The low value of the range of the specified type O for real time and record types Description mtiTypeldT A handle to a VHDL type mti TickLow returns the value of type LOW for ranged types For real time and record types mti TickLow returns 0 Related functions Example mti TickDir FLI 647 mti TickHigh FLI 651 mti TickLeft FLI 654 mti TickLength FLI 657 mti TickRight FLI 664 FLI code include lt mti h gt static char getTypeStr mtiTypeIdT switch mti GetTypeKind typeid case MTI TYPE SCALAR case MTI TYPE ARRAY case MTI TYPE RECORD case MTI TYPE ENUM return return return return typeid Scalar Array Record Enumeration ModelSim FLI Reference FLI 662 FLI function definitions ModelSim FLI Reference case MTI TYPE PHYSICAL return Physical case MTI TYPE REAL return Real case MTI TYPE TIME return Time default return UNKNOWN static void initInstance void param mtiSignalIdT sigid mtiTypeIdT typeid mti PrintMessage Design Signals n for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal typeid mti GetSignalType sigid mti PrintFormatted 14s type 12s low d high d
493. per FLI 510 Example FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X STD LOGIC 0 STD LOGIC 1 STD LOGIC Z STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType char convertStdLogicValue mtilnt32T sigval char retval ModelSim FLI Reference FLI 158 FLI function definitions ModelSim FLI Reference switch LOGIC U retval LOGIC X retval LOGIC 0 retval case STD LOGIC 1 retval S case STD D D D case STD LOGIC 2 retval D D D D case ST case SI LOGIC W retval LOGIC L retval LOGIC H retval LOGIC D retval case SI case ST case ST case 5 U U break n U U U X break O break 1 break Z break w break U DL break n U U H break break default retval break return retval void monitorSignal void param char region name mtiSignalldT sigid mtiSignalIdT param mtiInt32T sigval region name mti GetRegionFullName mti GetSignalRegion sigid sigval mti GetSignalValue sigid mti PrintFormatted Time d d delta d Signal s s is s n mti NowUpper mti Now mti Delta region name convertStdLogicValue sigval mti VsimFree region name void initForeign mtiRegionIdT region char param mtilnterfaceList
494. pipe descriptor mtiVoidFuncPtrT A pointer to a function to be called whenever there is data available for reading on the file descriptor A parameter to be passed to the function OPTIONAL can be NULL Description mti_AddInputReadyCB puts a watch on the specified file descriptor Whenever the file descriptor has data available for reading the specified function is called along with its parameter In a UNIX environment mti AddInputReadyCB can be used with files pipes and sockets In a Windows environment it can be used only with pipes See mti AddSocketInputReadyCB FLI 85 To remove a previously added callback call mti AddInputReadyCB with the same file descriptor but with a NULL function pointer Related functions mti_AddOutputReadyCB FLI 68 mti AddSocketInputReadyCB FLI 85 mti AddSocketOutputReadyCB FLI 90 ModelSim FLI Reference Example mti AddInputReadyCB FLI 61 FLI code include mti h include stdio h include fcntl h include lt sys types h gt include stdlib h ifdef WIN32 include lt winsock h gt else include lt unistd h gt include lt sys time h gt include lt sys param h gt include sys socket h include lt netinet in h gt include netdb h gethostbyname endif ifdef HP700 include resolv h endif ifdef WIN32 define MAXHOSTNAMELEN MAXGETHOSTSTRUCT else define SOCKET_ERROR 1 define INVALID_SOCKET 1
495. pointer to it The appropriate length of the buffer parameter can be determined by calling mti TickLength FLI 657 on the type of the array variable The array value is interpreted as follows For a subelement of type The value should be cast to Enum char if lt 256 values mtiInt32T if gt 256 values Physical mtiInt32T Real double ModelSim FLI Reference FLI 234 FLI function definitions For a subelement of type The value should be cast to Scalar Integer mtiInt32T Time mtiTime64T Related functions mti GetVarValue FLI 442 mti GetVarValueIndirect FLI 449 Example FLI code include lt mti h gt typedef struct varInfoT tag struct varInfoT_tag next char name mtiSignalldT varid mtiTypeIdT typeid varInfoT typedef struct varlInfoT var info List of variables mtiProcessIdT proc Test process id instanceInfoT static void printValue mtiVariableIdT varid mtiTypeIdT vartype int indent switch mti_GetTypeKind vartype case MTI_TYPE_ENUM case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val scalar val mti GetVarValue varid mti PrintFormatted d n scalar val break case MTI_TYPE_ARRAY int i mtiiInt32T num_elems mtiTypeIdT elem type mtiTypeKindT elem typekind void array val array val mti GetArrayVarValue varid 0 num elems mti Tick
496. ports A list of ports for the foreign model KJ 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 a11 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 DB b integer e real d std logic e bitarray end record end top architecture a of top is signal bitsig t dut s 1 mti GetArraySignalValue FLI 231 signal intsig integer 21 signal realsig real 16 35 signal timesig time 5 ns signal stdlogicsig std logic H signal bitarr bitarray 0110 signal stdlogicarr std logic vector 1 to 4 O1LH signal intarr oxntarray 19 X104 1154 12 signal realarr realarray 11 6 101 22 signal timearr timearray 15 ns 6 ns signal rec rectype seb Op Ly Bake RY TLOOT jy component for_model end component for all for model use entity work for_model a begin instl for model bitsig lt not bitsig after 5 ns intsig lt intsig 1 after 5 ns realsig lt realsig 1 5 after 5 ns timesig lt timesig 1 ns after 5 ns stdlogicsig lt not stdlogicsig after 5 n
497. pp so app o lstd lstream lCsup 64 bit HP for IA64 platform HP C opt aCC bin aCC or later aCC c DD64 z o app o I install dir include app C aCC b DD64 z o app sl app o lstd v2 1Csup If your FLI application requires a user or vendor supplied C library or an additional system library you will need to specify that library when you link your FLI application 32 bit IBM RS 6000 platform IBM C version 3 6 or later xlC c o app o I install dir modeltech include app C makeC SharedLib o app sl V bI install dir modeltech rs6000 mti exports p 10 app o ModelSim FLI Reference Compiling and linking FLI C applications FLI 33 64 bit IBM RS 6000 platform IBM C version 3 6 or later xlC q64 c o app o I install dir modeltech include app C makeC SharedLib o app sl X64 bI install dir modeltech rs64 mti exports p 10 app o ModelSim FLI Reference FLI 34 Introduction Using 64 bit ModelSim with 32 bit FLI Applications If you have 32 bit FLI applications and wish to use 64 bit ModelSim you will need to port your code to 64 bits by moving from the ILP32 data model to the LP64 data model We strongly recommend that you consult the 64 bit porting guides for Sun and HP Porting C code to the LP64 data model The following list identifies some key points about porting C code to the LP64 data model ModelSim FLI Reference C long type grows to 64 bits C pointer types e g char
498. process constant constl integer 4 variable v1 integer 0 begin vl vl const1 svl svl 1 mti FindVar FLI 189 ModelSim FLI Reference FLI 190 FLI function definitions psvi not psvl wait for 5 ns end process p2 begin svl process svl E wait for 3 ns end process end a Simulation output 2 Reading Found Found Found Found Found Found Found Found VSIM 1 gt VSIM 2 ModelSim FLI Reference vsim c Loading Loading Loading Loading Loading Loading 5 vsim c top modeltech tcl vsim pref tcl top work work work WOIK varia varia b1 bl varia varia varia varia varia varia run 10 quit modeltech sunos5 std standard my pkg top a for model a for model sl Elaboration phase inv b Load Done phase le vl consti cil svl count delay myconst psvl mti FirstLowerRegion Gets the first subregion inside of a region mti FirstLowerRegion FLI 191 mti FirstLowerRegion region id Type Description mtiRegionIdT Type A handle to the first subregion inside a region or NULL if there are no subregions Description Syntax subregion id Returns Name subregion id Arguments Name region id Description mtiRegionIdT A handle to the region from which the first subregion is to be obtained mti_FirstLowerRegion returns
499. put any functions specified in a VHDL foreign attribute inside of this type of extern The following platform specific instructions show you how to compile and link your FLI C applications so that they can be loaded by ModelSim Microsoft Visual C is supported for creating Windows DLLs while GNU C and native C compilers are supported for creating UNIX shared libraries Although compilation and simulation switches are platform specific references to load shared libraries are the same for all platforms For information on loading libraries see Using the VHDL FLI with foreign architectures FLI 11 and Declaring a foreign subprogram in VHDL FLI 13 Windows platforms ModelSim FLI Reference Microsoft Visual C 4 1 or later cl c GX I lt install_dir gt modeltech include app cxx link dll export C init function app obj V lt install_dir gt modeltech win32 mtipli lib out app dll The GX option enables exception handling Multiple export options can be specified one for each different FOREIGN attribute function name C init function is the function name specified in the FOREIGN attribute When executing cl commands in a DO file use the NOLOGO switch to prevent the Microsoft C compiler from writing the logo banner to stderr Writing the logo causes Tcl to think an error occurred If you need to run the Performance Analyzer on a design that contains FLI code add these two switches to the linking command sh
500. r mti GetArraySignalValue inst gt sigid 0 mti PrintFormatted Time d d delta d Signal s s is mti NowUpper mti Now mti Delta region name mti GetSignalName inst gt sigid for i 0 i lt inst num elems i mti PrintFormatted s convertStdLogicValue sigval i mti PrintFormatted n ModelSim FLI Reference FLI 260 FLI function definitions switch sigval inst index case STD LOGIC U sigval inst gt index STD LOGIC X break case STD LOGIC X sigval inst gt index STD LOGIC 0 break case STD LOGIC 0 sigval inst gt index STD LOGIC 1 break case STD LOGIC 1 sigval inst index STD LOGIC 2 break case STD LOGIC 2 sigval inst gt index STD LOGIC W break case STD LOGIC W sigval inst index STD LOGIC L break case STD LOGIC L sigval inst gt index STD LOGIC H break case STD LOGIC H sigval inst gt index STD LOGIC D break case STD LOGIC D sigval inst gt index STD LOGIC U break default sigval inst index STD LOGIC U break mti_ScheduleDriver inst drv elems inst index sigval inst index 5 MTI INERTIAL inst index if inst gt index gt inst num elems inst index 0 mti VsimFree region name mti VsimFree sigval void cleanupCallback void param mti_PrintMessage Cleaning up n free param void initForeign mtiRegionIdT region The ID of the regio
501. r 5 ns toggle inv port map sl s2 end a top vhd library mid lib entity top is end top architecture a of top is component mid is end component for all mid use entity mid lib mid a begin insti mid end a ModelSim FLI Reference FLI 286 FLI function definitions Simulation output vlib for model lib vlib my inv lib vlib my mid lib vlib work oe o oP oe oe vmap c Copying modeltech sunos5 modelsim ini to modelsim ini vmap inv lib my inv lib Modifying modelsim ini vmap mid lib my mid lib Modifying modelsim ini vcom 93 for model vhd work for model lib Model Technology ModelSim SE vcom 5 5 Compiler 2000 10 Mar 2 2001 Loading package standard Compiling entity for model Compiling architecture a of for model vcom 93 inv vhd work inv lib Model Technology ModelSim SE vcom 5 5 Compiler 2000 10 Mar 2 2001 Loading package standard Compiling entity inv Compiling architecture b of inv vcom 93 mid vhd work mid lib Model Technology ModelSim SE vcom 5 5 Compiler 2000 10 Mar 2 2001 Loading package standard Compiling entity mid Compiling architecture a of mid Loading entity for model Loading entity inv vcom 93 top vhd Model Technology ModelSim SE vcom 5 5 Compiler 2000 10 Mar 2 2001 Loading package standard Compiling entity top Compiling architecture a of top Loading entity mid vsim c top Reading m
502. ray 15 ns 6 ns variable rec rectype i 1 2 0 TOOTT s 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 ModelSim FLI Reference FLI 420 FLI function definitions ModelSim FLI Reference 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 tcl vsim 23 1 vsim c top Loading modeltech sunos5 Loading modeltech sunos5 Loading work top a Loading work for model a Loading for model sl VSIM 1 run 12 Time 0 4 Variable top pl bitsig Variable top pl intsig Variable top pl realsig Variable top pl timesig Variable top pl stdlogics Variable top pl bitarr Variable top pl stdlogica Variable top pl intarr Variable top pl realarr Variable top pl timearr Variable top pl rec 2 Time 0 9 Variable top pl bitsig Variable top pl intsig Variable top pl realsig Variable top pl timesig Variable top pl stdlogics Variable top pl bitarr Variable top pl stdlogica
503. re Please check your system for available memory and swap space Related functions mti Free FLI 219 mti Malloc FLI 482 ModelSim FLI Reference FLI 5b24 FLI function definitions Example ModelSim FLI Reference FLI code include lt stdlib h gt include lt stdio h gt include lt mti h gt static char instance_info void saveCallback void param char inst info char param mti PrintFormatted Saving instance info pointer to s n inst_info mti_SaveBlock char amp inst_info sizeof inst_info void restoreCallback void param mti RestoreBlock char amp instance info mti PrintFormatted Restored instance info s n instance info void cleanupCallback void param mti_PrintMessage Cleaning up n NOTE Memory allocated by mti_Malloc and mti_Realloc will be freed by vsim T void initForeign mtiRegionIdT region The ID of the region in which this x foreign architecture is instantiated char param The last part of the string in the K foreign attribute EJ mtiInterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model KJ if mti IsRestore mti PrintMessage Restore in progress n else instance info mti Malloc strlen param 1 strcpy instance info param if mti IsFirstInit ins
504. reCB restoreCallback HDL code entity for model is end for model architecture a of for model is attribute foreign of a initForeign for model s1l begin end a entity top is end top architecture a of top is bit signal sl Mns component for model is ModelSim FLI Reference Restoring Restoring Restoring mti Malloc strlen param param char amp instance info nRestoring instance info s n Restoring instance_info mti RestoreLong mti RestoreShort mti RestoreString char c n mti RestoreChar long ld n short d n string s n The ID of the region in which this t4 foreign architecture is instantiated The last part of the string in the x foreign attribute x A list of generics for the foreign model A list of ports for the foreign model El aen FR E instance info instance info architecture is my for model end component for all for model use entity work for model a begin il for model S lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info my for model Saving char Z Saving long 123456 Saving short 5
505. reak case MTI_TYPE_TIME mtiTime64T array_val for i 0 i lt mti TickLength vartype array val i i lt mti TickLength vartype mti GetArrayVarValue varid jus HI mti_GetArrayVarValue varid 0 i E E R long array_val i MTI TIME64 ASGN array val i MTI TIME64 HI32 array val il MTI TIME64 L0O32 array val i mti_SetVarValue varid break break case MTI_TYPE_RECORD int ri mtiVariableIdT elem list elem list for i 0 setVarValue elem list i mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetVarValueIndirect varid real val 1 1 mti SetVarValue varid break case MTI TYPE TIME mtiTime64T time_val mti GetVarValueIndirect varid MTI TIME64 ASGN time val MTI TIME64 LO32 time val mti SetVarValue varid mti GetVarSubelements varid i lt mti TickLength vartype long array val 0 itt mti GetVarType elem list amp real val long amp real val amp time val MTI TIME64 H132 time val Toys long amp time val i i cod i 0 mti GetArrayVarValue varid 0 mti SetVarValue FLI 631 break default break static void checkValues void inst_info instanceInfoT inst data instanceInfoT inst info variInfoT varinfo mti PrintFor
506. region in which this KJ foreign architecture is instantiated char param The last part of the string in the J foreign attribute E mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model char instance info instance info malloc strlen param 1 strcpy instance info param mti AddQuitCB quitCallback instance info mti AddQuitCB quitCallback 0 if mti IsFirstInit 4 mti AddLoadDoneCB loadDoneCallback O0 else mti_AddLoadDoneCB loadDoneCallback void 1 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 for_model begin end a entity top is end top architecture a of top is bit 0 signal sl component for_model is end component for all for model use entity work for_model a begin il for model S lt not sl after 5 ns end a ModelSim FLI Reference FLI 5b44 FLI function definitions ModelSim FLI Reference Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 20 VSIM 2 quit Exiting simulator Cleaning up for model for simulator exit 9 vsim c top Reading
507. resolved Multiple drivers can be created for a resolved signal but no more than one driver can be created for an unresolved signal Alternatively an unresolved signal s value can be changed using mti SetSignalValue FLI 621 if that signal doesn t have any drivers When using mti CreateDriver it is necessary to follow up with a call to mti SetDriverOwner FLI 617 otherwise the vsim drivers command and the Dataflow window may give unexpected or incorrect information regarding the newly created driver A driver cannot be created on a signal of type record but drivers can be created on non record subelements of a record signal A driver cannot be created on a subelement of a resolved composite signal Drivers must be created at the resolution level or above mti CreateDriver cannot create a driver on a VHDL port that has not been collapsed with the connected signal A VHDL port is not collapsed when it is connected to a Verilog signal when a conversion function appears in a VHDL port map or when the vsim option nocollapse is used ModelSim FLI Reference FLI 114 FLI function definitions Related functions Example ModelSim FLI Reference mti FindDriver FLI 167 mti GetDriverSubelements FLI 258 mti ScheduleDriver FLI 595 mti ScheduleDriver64 FLI 601 mti SetDriverOwner FLI 617 FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD LOGIC X
508. rity level double xvhdl real OUT real EJ mtiVariableIdT vhdl array OUT string Ud char val int i len first vhdl integer 1 vhdl enum 1 if vhdl enum gt 3 vhdl enum 0 vhdl real 1 01 rotate the array val mti GetArrayVarValue vhdl array NULL len mti TickLength mti GetVarType vhdl array first val 0 for i 0 i lt len 1 i val i val i 1 val len 1 first Convert a VHDL String array into a NULL terminated string static char get string mtiVariableIdT id static char buf 1000 mtiTypeIdT type int len mti_GetArrayVarValue id buf type mti_GetVarType id len mti_TickLength type buf len 0 return buf Package pkg example The FOREIGN attribute specification links the C functions declared above to VHDL procedures in_params and out params in pkg package pkg is ModelSim FLI Reference procedure in params vhdl integer IN integer vhdl enum IN severity level vhdl real IN real vhdl array f IN string Using the VHDL FLI FLI 17 attribute foreign of in params procedure is in params test sl procedure out params vhdl integer OUT integer vhdl enum OUT severity level vhdl real OUT real vhdl array OUT string attribute foreign of out params procedure is out params test sl package body pkg is procedure in params vhdl integer IN integer
509. rlInfoT var info List of variables mtiProcessIdT proc Test process id instanceInfoT ModelSim FLI Reference FLI 422 FLI function definitions static void checkValues void inst info instanceInfoT inst data instanceInfoT inst info variInfoT varinfo mti_PrintFormatted Time d d n mti_NowUpper mti_Now for varinfo inst data var info varinfo varinfo varinfo gt next mti PrintFormatted Variable s s n varinfo name mti GetVarImageById varinfo gt varid mti ScheduleWakeup inst data proc 5 static varInfoT setupVariable mtiVariableIdT varid varinfoT varinfo varinfo varInfoT mti Malloc sizeof varInfoT varinfo gt varid varid varinfo gt name mti_GetVarName varid varinfo gt typeid mti_GetVarType varid 0 varinfo next return varinfo static void initInstance void param instanceInfoT inst data mtiProcessIdT procid mtiRegionIdT regid mtiVariableIdT varid varlInfoT Curr ante variInfoT 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
510. rmatted gYn real val break case MTI_TYPE_TIME mtiTime64T time_val mti GetSignalValueIndirect sigid amp time val mti PrintFormatted d d n MTI TIME64 H132 time val MTI TIME64 LO32 time val break default mti_PrintMessage n break static void checkValues void inst_info instanceInfoT inst data instanceInfoT inst info ModelSim FLI Reference FLI 298 FLI function definitions signallInfoT siginfo mti PrintFormatted Time d d n mti NowUpper mti Now for siginfo inst data sig info siginfo siginfo siginfo gt next mti PrintFormatted Signal s siginfo gt name printValue siginfo gt sigid siginfo gt typeid 4 mti ScheduleWakeup inst_data gt proc 5 static signallnfoT setupSignal mtiSignalIdT sigid signalInfoT siginfo siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo next 0 return siginfo static void initInstance void param instanceInfoT inst data mtiSignalldT sigid signallnfoT Gurr inte signaliInfoT siginfo inst_data mti Malloc sizeof instanceInfoT inst data 5sig info 0 for sigid mti FirstSignal mti GetTopRegion sigid sigid mti NextSignal siginfo setupSignal sigid if
511. rocesses ending in 5 Scheduling processes ending in 2 Scheduling processes ending in 3 Scheduling processes ending in 4 ModelSim FLI Reference FLI 138 FLI function definitions ModelSim FLI Reference Time Time Time Time Time Time Time Time Time Time Time Time Time VSIM 2 SONS NN os ON oS oS X0 3 a Cy C CY C OC C 0C Kes doser es RRS NES HAS BE 01 ou ce Oo quit delta delta delta delta delta delta delta delta delta delta delta delta delta Cleaning up oo o o oO 6 amp 6B amp 6 SF S i4 immedProcess4 normalProcess4 synchProcess4 nbaProcess4 postponedProcess4 postponedProcess3 postponedProcess2 postponedProcess1 immedProcess5 normalProcess5 synchProcess5 nbaProcess5 postponedProcess5 Scheduling processes ending in 5 mti CreateRealType FLI 139 mti CreateRealType Creates a real type Syntax type id mti CreateRealType Returns Type Description mtiTypeldT A handle to the new real type Arguments None Description mti CreateRealType creates a new type ID that describes a VHDL real type Related functions mti_CreateArrayType FLI 108 mti CreateEnumType FLI 118 mti CreateScalarType FLI 146 mti CreateTimeType FLI 154 Example FLI code include lt stdlib h gt include lt mti h gt typedef struct mtiSignalIdT sigid mti
512. rograms FLI 13 Using checkpoint restore with the FLI FLI 20 The effect of restart on FLI application code FLI 23 Support for Verilog instances FLI 23 Support for Windows platforms FLI24 Mapping to VHDL datatypes EFLLF18 VHDL FLI examples FLI 24 Compiling and linking FLI C applications FLI 25 Compiling and linking FLI C applications FLI 30 Using 64 bit ModelSim with 32 bit FLI Applications FLI 34 Porting C code to the LP64 data model FLI34 64 bit time values in the FLI FLI 35 Shared library dependency FLI 36 FLI tracing FLE 40 The purpose of tracing files FLI 40 Invoking a trace FLI 40 Debugging FLI application code FLI 42 This chapter introduces ModelSim s VHDL FLI Foreign Language Interface For a categorical listing of FLI functions see FLI functions by category FLI 43 For complete details on the functions including purpose syntax and usage see FLI function definitions FLI 53 gt Note The Tcl C interface is included in the FLI tcl h is found in the install dir modeltech include directory Tk and Tix are not included in the FLI because the FLI is in the kernel not the user interface You can
513. rray 1 to 3 of integer type realarray is array 3 to 1 of real type timearray is array 0 to 2 of time type hourarray is array 1 to 2 of bigtime subtype resbit is resolve bit bit subtype resint is resolve int integer subtype resreal is resolve real real subtype restime is resolve time time subtype resphys is resolve phys bigtime type rectypel is record a bit b integer real d time e std logic f bigtime g std ulogic end record type rectype2 is record b resbit i resint r resreal T restime S std logic p resphys end record type rectype3 is record f1 L2 resbit rectypel 3 integer 4 rectype2 end record rbitarray is array 7 downto 0 rintarray is array 2 to 4 rrealarray is type type type type type array 0 downto 2 rtimearray is rhourarray is array 1 to 3 array 1 to 3 end package typepkg package body typepkg is FUNCTION resolve bit VARIABLE result BEGIN IF bit vector Ts Cas bit s LENGTH 1 RETURN s s LOW ELSE FOR i IN s RANGE LOOP if s i 1 then result 1 end if END LOOP END IF RETURN END resolve bit THEN result FUNCTION resolve int s int vector VARIABLE result integer 0 BEGIN IF s LENGTH 1 THEN RETURN s s LOW ELSE FOR i IN s RANGE LOOP result result s i END LOOP END IF RETURN END resolve int result FUNCTION resolve
514. rrent simulator resolution limit mtiDriverModeT Indicates either inertial or transport delay Description mti_ScheduleDriver64 schedules a transaction on the specified driver using a 64 bit delay If the signal being driven is of an array real or time type then the value type is considered to be void instead of long The specified delay value is multiplied by the current simulator resolution limit For example if vsim was invoked with t 10ns and the delay was specified as 5 then the actual delay would be 50 ns The mode parameter can be either MTI INERTIAL or MTI TRANSPORT Related functions mti CreateDriver FLI 113 mti ForceSignal FLI 208 mti GetResolutionLimit FLI 348 mti ScheduleDriver FLI 595 mti SetSignalValue FLI 621 ModelSim FLI Reference FLI 602 FLI function definitions Example ModelSim FLI Reference FLI code include std include mti h typedef enum STD_LOGIC_U STD_LOGIC_X STD LOGIC 0 STD LOGIC 1 STD LOGIC Z STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D StdLogicType typedef struct mtiTime64T mtiProcessIdT mtiSignalIdT mtiSignalIdT mtiSignalIdT mtiSignalIdT mtiSignalIdT mtiSignalIdT mtiDriverIdT mtiDriverIdT mtiDriverIdT mtiDriverIdT mtiDriverIdT mtiDriverIdT long long void long long void mtilnt32T mtilnt32T instanceInfoT static long invertBit long value if valu retur else retur sta
515. rvid mti AddLoadDoneCB loadDoneCallback HDL code entity for model is end for model architecture a of for model is attribute foreign of a architecture begin end a inst procid inst is initForeign for model sl Eg Eg E Fl mti ScheduleDriver64 FLI 605 library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is signal il bit 0 signal i2 std logic 0 signal i3 bit vector 3 downto 0 1100 signal tl bit 0 signal t2 std logic 0 signal t3 bit vector 3 downto 0 1100 component for model end component begin forinst for model end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 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 add list top il top tl top i2 top t2 top i3 top t3 VSIM 2 run 30 sec VSIM 3 write list list out VSIM 4 quit 9 cat list out ns top il top i3 delta top tl top t3 top i2 top t2 0 0 0000 1100 1100 4294967298 0 1111 0011 0011 8589934624 0 0 0 Z Z 1100 1100 1288490195 0 1 1 WW 0011 0011 1717986927 0 0 O L L 1100 1100 2147483660 0 11HH 0011 0011 2576980392 0 0 0 1100 1100 ModelSim FLI Reference FLI 606 FLI function definition
516. s bitarr lt not bitarr after 5 ns intarr 1 lt intarr 1 1 after 5 ns intarr 2 lt intarr 2 1 after 5 ns intarr 3 lt intarr 3 1 after 5 ns realarr 1 lt realarr 1 0 5 after 5 ns realarr 2 lt realarr 2 0 5 after 5 ns timearr 1 lt timearr 1 1 ns after 5 ns timearr 0 lt timearr 0 1 ns after 5 ns stdlogicarr lt not stdlogicarr after 5 ns rec a lt not rec a after 5 ns rec b lt rec b 1 after 5 ns rec c lt rec c 2 5 after 5 ns rec d lt not rec d after 5 ns rec e lt not rec e after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 4 5 4b vsim c top Loading modeltech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a ModelSim FLI Reference FLI 232 FLI function definitions ModelSim FLI Reference VSIM 3 quit Loading work for model a Loading for_model sl VSIM 1 run 10 Time 0 6 Signal bitsig 0 Signal intsig 22 Signal realsig 17 85 Signal timesig 0 6 Signal stdlogicsig 2 Bleual bitar pL Dro org Up Signal Stdlogicarrz IS vor pto TO Signal intarr 11 12 13 Signal realarr 12 1 101 72 Signal timearr 0 16 05 7 Signal rec 1 2 6 2 2 Wo ipw cepa vatsgor VSIM 2 run 10 Time 0 11 Signal bitsig 1 Signal intsig 23 Signal realsig 19 35 Signal timesig 047 Signal s
517. s driveSignal inst info mti Sensitize inst info procid inst info sigid MTI EVENT mti SetDriverOwner inst info drvid inst info procid mti_AddSaveCB saveCallback 0 mti AddRestoreCB restoreCallback 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 a11 entity top is end top architecture a of top is signal sl std logic 0 component for model is end component for all for model use entity work for model a begin il for model end a Simulation output 9 vsim c top Reading modeltech 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 30 Time 0 0 delta 0 Signal top sl is 0 Time 0 5 delta 0 Signal top sl is 1 Time 0 10 delta Time 0 15 delta Time 0 20 delta Time 0 25 delta Time 0 30 delta Signal top sl is Z Signal top sl is W Signal top sl is L Signal top sl is H Signal top sl is CX OU C Tt ModelSim FLI Reference VSIM 2 checkpoint cpfile VSIM 3 run 20 Time Time Time Time Time Time Time Time Time 0 35 0 40 0 45 0 50 0 35 0 40
518. s for varid mti FirstVar process varid varid mti NextVar if varid mti PrintFormatted cVariable s n indent mti GetVarName varid void printProcesses mtiRegionIdT region int indent mtiProcessIdT procid for procid mti FirstProcess region procid procid mti NextProcess qf procida mti PrintFormatted cProcess s n indent mti GetProcessName procid printVariables procid indent 2 void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s n indent region name indent 2 printProcesses region indent for regid mti FirstLowerRegion region regid regid mti NextRegion regid printHierarchy regid indent mti VsimFree region name void loadDoneCB void param mti PrintMessage nLoad Done phase n printHierarchy mti GetTopRegion 1 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 f foreign attribute Xy mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB loadDoneCB 0 mti PrintMessage nElaboration phase n
519. s mti GetSignalValuelndirect Gets the value of a VHDL signal of any type except record Syntax value mti GetSignalValueIndirect signal id buffer Returns Description A pointer to the value of the specified signal Arguments Name Type Description signal id mtiSignalldT A handle to a VHDL signal of any type except record buffer void A buffer into which the value is to be placed OPTIONAL can be NULL Description mti GetSignalValueIndirect returns the value of a signal of any type except record mti GetSignalValueIndirect must be used for scalar signals of type real and time If the buffer parameter is NULL mti GetSignalValuelIndirect allocates memory for the value and returns a pointer to it The caller is responsible for freeing this memory with mti VsimFree If the buffer parameter is not NULL mti GetSignalValueIndirect copies the value into the buffer parameter and also returns the buffer parameter The returned value is interpreted as follows For a scalar signal or a subelement of The value should be cast to type Enum char if lt 256 values mtiInt32T if gt 256 values Physical mtiInt32T Real double Scalar Integer mtiInt32T ModelSim FLI Reference mti GetSignalValuelndirect FLI 393 For a scalar signal or a subelement of The value should be cast to type Time mtiTime64T gt Note
520. s mti ScheduleWakeup Schedules a VHDL process to wake up at a specific time Syntax mti ScheduleWakeup process id delay Returns Nothing Arguments Name Type Description process id mtiProcessIdT A handle to a VHDL process delay mtiDelayT The delay to be used in terms of the current simulator resolution limit Description mti ScheduleWakeup schedules the specified process to be called after the specified delay A process can have no more than one pending wake up call A call to mti ScheduleWakeup cancels a prior pending wake up call for the specified process regardless of the delay values The specified delay value is multiplied by the current simulator resolution limit For example if vsim was invoked with t 10ns and the delay was specified as 5 then the actual delay would be 50 ns The process id must be a handle to a process that was created by mti CreateProcess or mti CreateProcessWithPriority Related functions mti CreateProcess FLI 123 mti CreateProcessWithPriority FLI 128 mti Desensitize FLI 160 mti GetResolutionLimit FLI 348 mti ScheduleWakeup64 FLI 610 mti Sensitize FLI 614 ModelSim FLI Reference Example FLI code include lt stdlib h gt include lt mti h gt typedef struct mtiDelayT delay mtiProcessIdT procid mtiSignalIdT il_sigid mtiSignalIdT tl_sigid mtiDriverIdT il_drvid mtiDriverIdT tl drvid long il last value long tl la
521. s my for model ModelSim FLI Reference FLI b68 FLI function definitions ModelSim FLI Reference signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info my for model Saving char Z Saving long 123456 Saving short 587 Saving string Howdy VSIM 3 run 40 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 16 09 02 2000 Restoring state at time 20 ns iteration 1 Restoring instance info my for model Restoring char Z Restoring long 123456 Restoring short 587 Restoring string Howdy VSIM 5 run 10 VSIM 6 quit mti RestoreProcess FLI 569 mti RestoreProcess Restores a process that was created by mti CreateProcess or mti CreateProcessWithPriority Syntax mti RestoreProcess process id name func param Returns Nothing Arguments Name Type Description process id mtiProcessIdT A handle to a process created by mti CreateProcess or mti CreateProcessWithPriority The name of the process as specified t
522. s end process end a Simulation output 9 vsim c top Reading modeltech 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 6 Variable bitsig 1 Variable stdlogicsig 1 Variable bitarri WON LY vlt VOS Variable sbdlogicart Or 1PH go TI Variable intarr 12 13 14 Variable realarr 12 6 102 22 Variable timearr 0 17 0 8 Variable alarr rq Pie K Urt OE NOS UU EIE Varrable a2arr 0 AOT EQ Ip eg t ON ete cns MOT pe coss XT Variable rec ro 3 8 7 ZE ar TOt POP p Time 0 11 Variable bitsig TQ Variable stdlogicsig TORT Variable bitares CL ong to Lt Variable stdlogicarr VIS RM Nt HOT Variable intarr 13 14 15 VE VE 11 eti qt ro or 10 mti GetVarSubelements FLI 437 Variable realarr 13 1 102 72 Variable timearr 0 18 0 9 Variable alarri Oe OP TON MOU re STEN PLF WE ODAT OPPE Ow BOW xls Variable a2arr TEA EEE epr oO qt TuS 0 ES S ngt MPE cra WIS Choo e Rt AOT Variable rec EE 4 11 2 10 LOr Re t TOI VSIM 2 gt quit ModelSim FLI Reference FLI 438 FLI function definitions mti GetVarType Gets the type of a VHDL variable Syntax type id mti GetVarType variable id Returns Type Description mtiTyp
523. s component mid is end component begin insti mid end a ModelSim FLI Reference mti FindRegion FLI 181 Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for model sl Elaboration phase Found region top Found region top instl Found region top inst1 il Found region top instl flip Load Done phase Found region top Found region top instl Found region top instl flip Found region top instl toggle VSIM 1 run 10 VSIM 2 quit ModelSim FLI Reference FLI 182 FLI function definitions mti FindSignal Syntax Returns Arguments Description Finds a VHDL or SystemC signal by name signal id mti FindSignal name Name Type Description signal id mtiSignalldT A handle to the VHDL or SystemC signal or NULL if the signal is not found Description The name of a VHDL or SystemC signal mti_FindSignal returns a handle to the specified VHDL or SystemC signal The signal name can be either a full hierarchical name or a relative name A relative name is relative to the current region set by the simulator s environment command The default current region is the foreign architecture region during elaboration and the top level region after elaboration is complete
524. s elem type if mti TickLength elem type 256 mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted s enum values val i else char val array_val for i 0 i lt num elems i mti PrintFormatted s enum_values val i break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T val array val for i 0 i lt num elems i ModelSim FLI Reference mti GetEnumValues FLI 273 mti PrintFormatted d val i break case MTI_TYPE_ARRAY mti_PrintMessage ARRAY break case MTI_TYPE_RECORD mti PrintMessage RECORD break case MTI TYPE REAL double val array_val for i 0 i lt num_elems i mti PrintFormatted g val i break case MTI_TYPE_TIME mtiTime64T val array_val for i 0 i lt num_elems i mti PrintFormatted d d MTI TIME64 HI32 val il MTI TIME64 LO32 val il break default break mti_PrintFormatted n mti VsimFree array val break case MTI_TYPE_RECORD int i mtiSignalIdT elem_list mtiInt32T num_elems elem list mti GetSignalSubelements sigid 0 num elems mti GetNumRecordElements sigtype mti PrintFormatted n for i 0 i lt num elems i mti PrintFormatted c indent printValue elem list i mti GetSignalType elem list i indent 2
525. s param void A parameter to be passed to the function OPTIONAL can be NULL priority mtiProcessPriorityT The priority of the new process immediate normal synch NBA or postponed Description mti_CreateProcess WithPriority creates anew VHDL process with the specified name and priority If the name is non NULL then it appears in the simulator s Process window otherwise it does not The specified function is called along with its parameter whenever the process executes The process executes either at the time specified in a call to mti ScheduleWakeup FLI 606 or whenever one of the signals to which it is sensitive changes mti Sensitize FLI 614 ModelSim FLI Reference mti CreateProcessWithPriority FLI 129 The priority of the process can be one of the following MTI PROC IMMEDIATE All immediate processes run immediately after signal activation if triggered If any immediate process activates any signals then the signals are reevaluated and all immediate processes if triggered are run again in the same delta This cycle continues until no more signals are activated MTI PROC NORMAL Normal processes run when triggered after all immediate processes have run and settled They can run once per delta and can schedule events in zero delay MTI PROC SYNCH Synchronized processes when triggered run after immediate and normal processes but before NBA processes They can run once per delta and can schedule
526. s are to be found Description mti GetDrivingSignals returns a NULL terminated array of driving signal IDs for the specified signal The signal is specified by name using either a full hierarchical name or a relative name A relative name is relative to the region set by the environment command The default is the top level VHDL or SystemC region The caller is responsible for freeing the returned pointer with mti VsimFree mti GetDrivingSignals returns the same signal IDs as those used by the drivers command to generate the signal part of its output Related functions mti GetDriverNames FLI 253 mti GetDriverValues FLI 262 Example FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U ModelSim FLI Reference FLI 268 FLI function definitions ModelSim FLI Reference STD LOGIC X STD LOGIC 0 STD LOGICAL STD LOGIC 4 STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType typedef struct char signam mtiSignalIdT sigid mtiProcessIdT procid instanceInfoT e char convertStdLogicValue mtilnt32T sigval char retval switch sigval case STD_LOGIC_U case STD_LOGIC_X case STD LOGIC 0 case STD LOGIC 1 case STD LOGIC 2 case STD LOGIC W case STD LOGIC L case STD LOGIC H case STD LOGIC D default retval return retval retval retval retval retval retval retval retval retval r
527. s at the subelement level For scalars and arrays of scalars we want to set drive values at the top level Er switch siginfo gt typekind case MTI TYPE ARRAY switch mti GetTypeKind mti GetArrayElementType siginfo 5typeid case MTI TYPE ARRAY case MTI TYPE RECORD siginfo gt granulate 1 break default siginfo gt granulate 0 break ModelSim FLI Reference FLI 214 FLI function definitions break case MTI TYPE RECORD siginfo gt granulate 1 break default siginfo gt granulate 0 break it siginfo gt granulate signalInfoT eleminfo signalInfoT currinfo int i mtiSignalIdT subelem subelem for eleminfo if siginfo gt child else currinfo gt next currinfo mti_VsimFree subelem mti_GetSignalSubelements siginfo gt sigid 0 0 i lt mti_TickLength siginfo gt typeid i i setupSignal subelem i siginfo gt child 0 eleminfo eleminfo eleminfo return siginfo static void initInstance void param instanceInfoT inst data mtiRegionIdT region mtiSignalldT sigid signalInfoT Curr Ante signallInfoT siginfo mti Malloc sizeof instanceInfoT 0 0 inst data inst data sig info inst data state region mti GetTopRegion for sigid mti FirstSignal region sigid sigid mti NextSignal siginfo setupSignal sigid if inst data 5sig in
528. s id mtiProcessIdT A handle to the new VHDL process or NULL if there is an error Type Description char The name of the new VHDL process OPTIONAL can be NULL mtiVoidFuncPtrT A pointer to the function that will be executed as the body of the new process void A parameter to be passed to the function OPTIONAL can be NULL mti_CreateProcess creates anew VHDL process with the specified name If the name is non NULL then it appears in the simulator s Process window otherwise it does not The specified function is called along with its parameter whenever the process executes The process executes either at the time specified in a call to mti_ScheduleWakeup FLI 606 or whenever one of the signals to which it is sensitive changes see mti_Sensitize FLI 614 If the process is created during elaboration from inside of a foreign architecture instance then the process is automatically executed once at time zero after all signals have been initialized If the process is created either after elaboration is complete or from any other context such as from an initialization function that executes as a result of the loading of a foreign shared library by the foreign option to vsim then the process is not run automatically but must be scheduled or sensitized mti_CreateProcess allows you to create a process with an illegal HDL name This can be useful for integrators who provide shared libraries for use by en
529. s significant The simulator command interpreter subsequently recognizes the command and calls the command function along with its parameter and user supplied arguments whenever the command is recognized The command function must return a valid Tcl status for example TCL_OK or TCL_ERROR The command function prototype is int commandFuncName ClientData cmd_param Tcl_Interp interp int argc char argv A command can be added with the same name as a previously added command or even a standard simulator command but only the command added last has any effect If a command is readded or deleted the delete callback function is called along with the command parameter so that the old command information can be cleaned up The delete callback function prototype is void deleteCBname ClientData cmd_param To make the prototype of mti_AddTclCommand visible the header file tcl h must be included in the FLI application code before mti h ModelSim FLI Reference FLI 92 FLI function definitions Related functions mti AddCommand FLI 54 mti Cmd FLI 102 mti Command FLI 105 Example FLI code include lt stdlib h gt include lt tcl h gt include lt mti h gt typedef struct char model name 100 mtiSignalIdT sigl mtiSignalIdT sig2 instanceInfoT int noAction ClientData param Tcl Interp interp int argc char argv mti_PrintFormatted Time ld ld delta d n mti_NowUpper mti_N
530. s symbols should be visible You can now set breakpoints in and single step through your FLI application code FLI 43 FLI functions by category Chapter contents FLI region functions FLI 44 FLI process functions FLEMA FLI signal functions FLI 45 FLI driver functions FLI 46 FLI variable functions FLI 46 FLI type functions FLI 47 FLI callback functions FLES FLI memory management functions FLI 48 FLI checkpoint restore functions FLI 49 FLI time and event functions FLI 49 FLI communication and command functions EFLI 50 FLI miscellaneous functions FLI 50 This chapter lists the FLI functions by category and provides a brief description For information on creating and using foreign architectures and subprograms see Introduction FLI 9 For complete details on the functions including purpose syntax and usage see FLI function definitions FLI 53 ModelSim FLI Reference FLI 44 FLI functions by category Function Table 1 FLI region functions Action mti CreateRegion FLI 142 Creates a new region mti FindRegion FLI 177 Finds a region by name mti FirstLowerRegion FLI 191 Gets the first subregion
531. s1 is 0 Turning off signal watcher VSIM 2 quit o Cx OQ O ModelSim FLI Reference FLI 670 FLI function definitions mti WriteProjectEntry Writes an entry into the project ini file Syntax mti WriteProjectEntry key value Returns Nothing Arguments Description A string containing a keyword A string containing the value of the keyword Description mti WriteProjectEntry writes an entry into the modelsim ini project file in the form key value The new entry is written at the end of the vsim section Related functions mti FindProjectEntry FLI 173 Example FLI code include lt mti h gt void loadDoneCallback void param char entry entry mti FindProjectEntry vsim MyConfig 0 mti PrintFormatted MyConfig s n entry mti VsimFree entry entry mti FindProjectEntry vsim MyDesign 0 mti PrintFormatted MyDesign s n entry mti VsimFree entry entry mti FindProjectEntry vsim MyMemory 0 mti PrintFormatted MyMemory s n entry mti VsimFree entry ModelSim FLI Reference void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB loadDoneCallback mti WriteProjectEntry MyConfig mti WriteProjectEntry MyDesign mti WriteProjectEntry MyMemory HDL code entity for model is end for model architect
532. scheduled by postponedProcess1 void immedProcess5 void param mti_PrintFormatted Time d d delta d immedProcess5 n mti_NowUpper mti_Now mti_Delta void normalProcess5 instanceInfoT inst mti_PrintFormatted Time d d delta d normalProcess5 n mti_NowUpper mti_Now mti_Delta void synchProcess5 instanceInfoT inst mti PrintFormatted Time d d delta d synchProcess5 n mti NowUpper mti Now mti Delta void nbaProcess5 instanceInfoT inst mti_PrintFormatted Time d d delta d nbaProcess5 n mti_NowUpper mti_Now mti_Delta void postponedProcess5 instanceInfoT inst mti PrintFormatted Time d d delta d postponedProcess5 n mti NowUpper mti Now mti Delta void cleanupCallback void param mti_PrintMessage Cleaning up n ModelSim FLI Reference FLI 134 FLI function definitions free param void initForeign mtiRegionIdT char mtilnterfaceList mtilnterfaceList char char char char char instanceInfoT X X X int mtiProcessIdT mtiSignalldT mtiVoidFuncPtrT mtiVoidFuncPtrT mtiVoidFuncPtrT mtiVoidFuncPtrT mtiVoidFuncPtrT inst instan mti_Fin mti_Cre sigid procid mti Sensitize p mt mti Cre inst sig02 procid mti Sensitize p 0 case 0 immed func for i AD e switch E y normal fun synch func nba func post immed n
533. set cache set cache set s0 paddr sl paddr S2 paddr S3 paddr initial begin pdata hit pdata hit pdata hit pdata hit verbose 1 saddr r 0 sdata r bz pdata r bz srw_r 0 sstrb_r 1 prdy_r 1 oen 4 b1111 wen 4 b1111 end RR KKK KR ke ke ke ke e e ke ke e k Local MRU memory XCkckck ke ke ke ke ke ee e e x v kx reg 2 0 mru mem 0 1 set size 1 integer i initial for i 0 i lt 1 lt lt set size i i 1 mru_mem i 0 function integer hash input addr size 1 0 a hash a set size 1 0 endfunction task update mru input addr size 1 0 addr input 3 0 hit reg 2 0 mru begin mru mru mem hash addr mru 2 hit amp 4 b1100 0 if mru 2 mru 1 hit 3 else mru 0 hit 1 mru mem hash addr mru end endtask function 3 0 pick set input addr size 1 0 addr integer setnum begin casez mru mem hash addr 3 bl i setnum 0 3 b1 0 setnum 1 3 p01 setnum 2 3 b00 setnum 3 default setnum 0 endcase ModelSim FLI Reference FLI 332 FLI function definitions if verbose begin if prw 1 display t else display t Write miss picking set 0d end pick set 4 b0001 lt lt setnum end endfunction Read miss picking set 0d time setnum time setnum RRR KKK ke ke ke ke e e ke e System Bus interface Ck kck ko koe ke ke e e e e x x f task sysread assign
534. sical name of the library that contains the specified design unit region Arguments Name Type Description region id mtiRegionIdT A handle to a region Description mti_GetLibraryName returns the physical name of the library that contains the design unit identified by the specified region If the region is not a design unit then the parent design unit is used The returned pointer must not be freed mti_GetLibraryName can be used on both VHDL and Verilog regions Related functions mti_GetPrimaryName FLI 311 mti_GetRegionFullName FLI 325 mti_GetRegionName FLI 341 mti_GetRegionSourceName FLI 344 mti_GetSecondaryName FLI 355 Example FLI code include mti h static void printRegionInfo mtiRegionIdT regid char lib_name char region_name ModelSim FLI Reference FLI 284 FLI function definitions ModelSim FLI Reference if regid region name mti GetRegionFullName regid lib name mti GetLibraryName regid mti PrintFormatted region name Region s is in Library s n lib name mti VsimFree region name void loadDoneCB void param mti PrintMessage nLoad Done phase Mn printRegionInfo mti FindRegion top printRegionInfo mti FindRegion instl printRegionInfo mti FindRegion instl il printRegionInfo mti FindRegion instl flip printRegionInfo mti FindRegion instl toggle void initForeign mtiRegionIdT regi
535. sigid mtiTypeIdT typeid ModelSim FLI Reference FLI 210 FLI function definitions mtiTypeKindT typekind mtiDirectionT direction char granulate signalInfoT typedef struct signalInfoT sig info List of signals f mtiProcessIdT proc Test process id int state Current state of test x instanceInfoT static void forceSignal mtiSignalIdT sigid mtiTypeIdT sigtypeid mtiTypeKindT sigtypekind int state int i int result 1 mtiSignalIdT elem list mtiSignalIdT elem sigid mtiTypeIdT elem typeid switch sigtypekind case MTI TYPE SCALAR switch state case 0 result mti ForceSignal sigid 42 1 MTI FORCE FREEZE 1 1 break case 2 result mti ForceSignal sigid 120 1 MTI FORCE FREEZE 7 1 break case 4 result mti ForceSignal sigid 777 1 MTI FORCE DEPOSIT 1 break break case MTI_TYPE_ARRAY elem_typeid mti_GetArrayElementType sigtypeid if mti_GetTypeKind elem_typeid MTI_TYPE_ENUM NOTE ASSUMING ARRAY OF LENGTH 4 if mti TickLength elem_typeid 9 ASSUME std logic switch state case 0 result mti ForceSignal sigid ZW1H 1 MTI FORCE FREEZE 1 1 break case 2 result mti ForceSignal sigid LLLL 1 MTI FORCE FREEZE 7 1 break case 4 result mti ForceSignal sigid 1 1 1 MTI FORCE DEPOSIT 1 2 break else ASSUME bit switch
536. signal id Returns Name Type Description region id mtiRegionIdT A handle to the region in which the specified signal is declared Arguments Name Type Description signal id mtiSignalldT A handle to a VHDL signal Description mti_GetSignalRegion returns a handle to the region in which the specified VHDL or SystemC signal is declared If the signal is a port that has been collapsed a handle to the region of the connected upper level signal is returned The vsim option nocollapse can be used to disable the optimization of internal port map connections Related functions None Example FLI code include lt mti h gt void printSignals mtiRegionIdT region int indent char region_name mtiSignalIdT sigid for sigid mti FirstSignal region sigid sigid mti NextSignal region name mti GetRegionFullName mti GetSignalRegion sigid mti PrintFormatted cSignal s is declared in region s n indent mti GetSignalName sigid region name ModelSim FLI Reference mti GetSignalRegion FLI 373 mti VsimFree region name void printHierarchy mtiRegionIdT char region_name mtiRegionIdT regid region_name mti_PrintFormatted mti VsimFree region name indent 2 printSignals region for regid indent regid printHierarchy regid regid indent void loadDoneCB void param mti PrintMessage void initForeign mtiRegionIdT r
537. solved realarrl is not resolved timearrl is not resolved physarrl is not resolved stdulogicarrl is not resolved bitarr1 3 is not resolved intarrl 2 is not resolved realarrl1 3 is not resolved timearrl1 0 is not resolved physarrl 1 is not resolved rbitarrl is resolved rintarrl is resolved rrealarrl is resolved rtimearrl is resolved rphysarrl is resolved stdlogicarrl is resolved rbitarrl1 6 is resolved rintarrl 4 is resolved rrealarrl 1 is resolved rtimearrl 1 is resolved rphysarrl1 3 is resolved stdlogicarrl 1 is resolved recl is not resolved recl a is not resolved is not resolved is not resolved rec rec rec is not resolved is resolved is not resolved rec rec rec is not resolved rec2 b is resolved rec2 i is resolved is resolved is resolved rec2 rec2 rec2 s is resolved is resolved s not resolved b s d e f g rec2 is resolved b i r t S rec2 p rec3 i rec3 fl is resolved rec3 f2 is not resolved rec3 f2 a is not resolved rec3 f2 b is not resolved rec3 f2 c is not resolved rec3 f2 d is not resolved rec3 f2 e is resolved rec3 f2 f is not resolved rec3 f2 g is not resolved rec3 f3 is not resolved rec3 f4 is resolved rec3 f4 b is resolved rec3 f4 i is resolved rec3 f4 r is resolved rec3 f4 t is resolved rec3 f4 s is resolved rec3 f4 p is resolved VSIM 1 quit mti TickDir Gets the direction
538. specified function to the simulator restore callback list The same function can be added multiple times with possibly a different parameter each time During a restore all callbacks in the list are called with their respective parameters The callback function should restore its saved state at this time mti AddRestoreCB must be called from a foreign initialization function in order for the callback to take effect A foreign initialization function is specified either in the foreign attribute string of a foreign architecture or in the foreign string option of a vsim command Related functions mti AddRestoreDoneCBY FLI 77 mti AddSaveCB FLI 80 mti IsRestore FLI 476 mti IsColdRestore FLI 470 mti RemoveRestoreCB FLI 548 mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti RestoreProcess FLI 569 ModelSim FLI Reference Example mti AddRestoreCB FLI 75 FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char inst_info char param mti PrintFormatted Saving instance info s n inst info mti SaveString inst info void restoreCallback void param char inst info char param strcpy inst info mti RestoreString mti PrintFormatted Restored instance info s n instance info void cleanupCa
539. st of generics for the foreign model A list of ports for the foreign model cture is initForeign for model sl of bit of al 4 of character ky CLIGUM yi 0 10001111 l6 Q MILLIY ve ere E ModelSim FLI Reference FLI 384 FLI function definitions component for mode end component for all for mode begin il for model sl lt not sl after end a Simulation output 9 vsim c top Reading modeltec 5 4b vsim c top modelt work top a Loading Loading Loading Loading for_mode Composite Signals Signal top sl sl is of type Signal top s2 s2 is of type s2 m is of s2 b S2 C s2 S2 is of t ls Of t 3 is c 2 s2 c 1 s2 c 0 Signal top s3 s3 is of type s3 7 is o is is is is is is is is is o0000 0 is Signal top s4 s4 is of type o s4 fl is o s4 f2 is o s4 f2 a is s4 f2 b is s4 f2 c is s4 f2 c S4 58270 s4 f2 c s4 f2 c Signal top s5 s5 is of type ModelSim FLI Reference l is l use entity work for model a 5 ns h tcl vsim pref tcl ech sunos5 std standard work for model a l sl ENUM RECORD ype SCALAR ype ENUM ype ARRAY of type of type of type of type ENUM ENUM ENUM ENUM ARRAY type type type type type type type type td rz pd Ld tu Ltd Ld Lu cGadaadcaaacd RECORD type ENU type RECORD of type SCALAR of type ENUM
540. st value instanceInfoT static long invertBit long value if value 0 return 1 else return 0 void driveSignal void param instanceInfoT inst instanceInfoT param inst il last value invertBit inst il last value mti ScheduleDriver inst il drvid mti ScheduleWakeup FLI 607 inst il last value 5 MTI INERTIAL inst tl1 last value invertBit inst gt tl last value mti ScheduleDriver inst gt tl drvid mti ScheduleWakeup inst procid inst delay inst gt delay void cleanupCallback void param mti_PrintMessage Cleaning up free param s NIS Ses void loadDoneCallback void param inst tl last value 5 MTI TRANSPORT instanceInfoT inst instanceInfoT param inst il last value mti GetSignalValue inst gt il_sigid inst tl last value mti GetSignalValue inst gt tl_sigid void initForeign mtiRegionIdT region LE char param y mtilnterfaceListT generics mtilnterfaceListT ports Pea The ID of the region in which this EL foreign architecture is instantiated The last part of the string in the x foreign attribute kf A list of generics for the foreign model A list of ports for the foreign model EL ModelSim FLI Reference FLI 608 FLI function definitions instanceInfoT inst inst instanceInfoT malloc sizeof instanceInfoT inst procid
541. stT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model mti AddLoadDoneCB loadDoneCB 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 entity inv is generic delay time 5 ns port a in bit b v out bit i end inv architecture b of inv is begin b lt a after delay end b entity mid is end mid architecture a of mid is signal sl bit 0 signal s2 i bit re Q s Bl nal s3 bit q D s ModelSim FLI Reference FLI 516 FLI function definitions signal s4 bit 0 component for model is end component for all for model use entity work for model a component inv is generic port delay time in bit out bit Dons a b i end component begin flip il sl inv port map S3 S4 for model lt not sl after 5 ns S3 lt not s3 after 5 ns toggle end a inv port map sl s2 entity top is end top architecture a of top is component mid is end component begin insti end a mid Simulation output vsim c Reading 5 4b vsim c Loading Loading Loading Loading Loading Loading Region Region Region top instl Region top instl flip Region top inst1 il Region top instil toggle top mod
542. stance info mti AddRestoreCB restoreCallback instance info mti AddRestoreDoneCB restoreDoneCallback instance info mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info 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 for model begin end a entity top is end top architecture a of top is Blgnal sl s pit e tOr mti AddRestoreDoneCB component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for_model a Loading for_model sl VSIM 1 gt run 20 VSIM 2 gt checkpoint cp file Saving instance info for model VSIM 3 run 30 VSIM 4 restore cp file Loading checkpoint restore data from file cp file Checkpoint created Thu Apr 27 15 52 32 2000 Restoring state at time 20 ns iteration 1 Restored instance info for model for model Restore complete VSIM 5 run 10 VSIM 6 quit Cleaning up FLI 79 ModelSim FLI Reference FLI 80 FLI function definitions mti AddSaveCB Adds a simulator checkpoint callback Syntax mti AddSaveCB func para
543. std logic 1164 all entity lower is port ptl pt2 i end lower OUT std_logic IN std logic architecture a of lower is begin ptl lt pt2 after 5 ns end a library ieee use ieee std logic 1164 a11 entity top is end top architecture a of top is ror 0 EAT 0 signal sl std logic signal s2 std logic component lower port ptl pt2 i end component OUT std_logic IN std logic begin Cleaning up mti CreateProcess mti ScheduleWakeup inst procid mti GetDrivingSignals FLI 269 ENTIS Jr The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute 1 Ej ay A list of generics for the foreign model A list of ports for the foreign model instanceInfoT malloc sizeof instanceInfoT mti FindSignal inst gt signame checkSignal checkSignal inst 1 inst inst jy ModelSim FLI Reference FLI 270 FLI function definitions ModelSim FLI Reference S2 lt not s2 after 5 ns sl lt s2 after 5 ns pl process begin sl lt H wait for 5 ns sl lt L wait for 5 ns sl lt W wait for 5 ns end process instl lower port map sl s2 end a Simulation output vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading model
544. store operation is in progress otherwise it returns 0 A cold restore is when the simulator has been terminated and is re invoked with the restore argument Related functions mti IsFirstInit FLI 473 mti IsRestore FLI 476 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char inst_info char param mti PrintFormatted Saving instance info Ss n inst info mti SaveString inst info void restoreCallback void param char inst_info char param strcpy inst info mti RestoreString mti PrintFormatted Restored instance info s n instance info ModelSim FLI Reference mti IsColdRestore FLI 471 void cleanupCallback void param mti_PrintMessage Cleaning up n free param 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 f foreign attribute uA mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model instance info malloc strlen param 1 if mti IsColdRestore mti PrintMessage Cold Restore in progress n else strcpy instance info param mti_AddSaveCB saveCallback instance_info mti_AddRestoreCB
545. t Compiling module vertop Top level modules vertop vcom 93 top vhd Model Technology ModelSim SE EE vcom 5 4b Compiler 2000 06 Jun 9 2000 Loading package standard Compiling entity for model Compiling architecture a of for model Compiling entity inv Compiling architecture b of inv Compiling package my pkg Loading package my pkg Compiling entity mid Compiling architecture a of mid Loading entity for model Loading entity inv Compiling entity top Compiling architecture a of top Loading entity mid vsim c top vertop Reading modeltech tcl vsim pref tcl 5 4b vsim c top vertop Loading modeltech sunos5 std standard Loading work my pkg Loading work top a Loading work vertop Loading work verbot Loading work mid a Loading work inv b Loading work for model a Loading for model sl Design Hierarchy Region top Region top instl Region top instl flip Region top inst1 il Region top instl1 toggle Region vertop Region vertop verinstl Region standard mti GetTopRegion FLI 403 Region my pkg VSIM 1 quit ModelSim FLI Reference FLI 404 FLI function definitions mti_GetTypeKind Gets the kind of a type Syntax type_kind mti_GetTypeKind type_id Returns Name Type Description type_kind mtiTypeKindT The kind of the specified type Arguments Type Description mtiType
546. t FLI 589 mti SaveString FLI 592 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char tmp_char Z char tmp_str Howdy ModelSim FLI Reference FLI 584 FLI function definitions long tmp long 123456 short tmp short 587 mti PrintFormatted mti SaveBlock mti PrintFormatted mti SaveChar tmp char mti PrintFormatted mti SaveLong tmp long mti PrintFormatted hort tmp short Formatted mti SaveS mti Print mti SaveString tmp str Formatted Mn mti Print nSaving instance info s n char amp instance info Saving char c n Saving long ld n Saving short d n Saving string s n instance info sizeof instance info tmp char tmp long tmp short tmp str void restoreCallback void param mti_RestoreBlock mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted mti_PrintFormatted n mti_PrintFormatted VE void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports instance info strcpy instance info mti AddSaveCB saveCallback mti AddRestoreCB restoreCallback HDL code entity for model is end for model architecture a of for model is attribute foreign of a initForeign for model s1l begin end a enti
547. t d n mti RestoreShort string s n mti RestoreString The ID of the region in which this x foreign architecture is instantiated The last part of the string in the x foreign attribute Er A list of generics for the foreign model A list of ports for the foreign model A len param 1 stance info Ck instance info attribute foreign of a architecture is initForeign for model sl my for model begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model S lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info my for model Saving char Z Saving long 123456 Saving short 587 Saving string Howdy VSIM 3 run 40 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 16 09 02 2000 Restoring state at time 20 ns iteration 1 Restoring instance info my for model Restoring char Z Restoring long 123456 Restoring short 587 Restoring string Howdy VSIM 5 run 10 VSIM 6 quit mti RestoreString FLI 579 Mode
548. t time 20 ns iteration 1 Restoring instance info my for model Restoring char Z Restoring long 123456 Restoring short 587 Restoring string Howdy VSIM 5 run 10 VSIM 6 quit mti SaveChar FLI 585 ModelSim FLI Reference FLI b86 FLI function definitions mti SaveLong Saves sizeof long bytes of data to the checkpoint file Syntax mti SaveLong data Returns Nothing Arguments Description The data to be saved Description mti SaveLong saves the specified sizeof long bytes of data to the checkpoint file Related functions mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 mti RestoreShort FLI 574 mti RestoreString FLI 577 mti SaveBlock FLI 580 mti SaveChar FLI 583 mti SaveShort FLI 589 mti SaveString FLI 592 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char tmp_char Z char tmp_str Howdy ModelSim FLI Reference long tmp long 123456 short tmp short 587 mti PrintFormatted mti SaveBlock mti PrintFormatted mti SaveChar tmp char mti PrintFormatted mti SaveLong tmp long mti PrintFormatted hort tmp short Formatted mti SaveS mti Print mti SaveString tmp str Formatted Mn mti Print nSaving instance info s n char amp instance
549. tEntry FLI 173 mti FindRegion FLI 177 mti FindSignal FLI 182 mti FindVar FLI 187 mti FirstLowerRegion FLI 191 mti FirstProcess FLI 195 mti FirstSignal FLI 199 mti FirstVar FLI 203 mti ForceSignal FLI 208 mti Free FLI 219 mti GetArrayElementType FLI 222 mti GetArraySignalValue FLI 226 mti GetArrayVarValue FLI 233 mti GetCallingRegion FLI 240 mti GetCheckpointFilename FLI 245 mti GetCurrentRegion FLI 248 mti GetDriverNames FLI 253 mti GetDriverSubelements FLI 258 mti GetDriverValues FLI 262 mti GetDrivingSignals FLI 267 mti GetEnumValues FLI 271 mti GetGenericList FLI 277 mti GetLibraryName FLI 283 mti GetNextEventTime FLI 287 mti GetNextNextEventTime FLI 291 mti GetNumRecordElements FLI 295 mti GetParentSignal FLI 301 mti GetPhysicalData FLI 301 FLI 306 mti GetPrimaryName FLI 311 mti GetProcessName FLI 315 mti GetProductVersion FLI 323 mti GetRegionFullName FLI 325 mti GetRegionKind FLI 328 mti GetRegionName FLI 341 mti GetRegionSourceName FLI 344 mti GetResolutionLimit FLI 348 mti GetRunStopTime FLI 352 mti GetSecondaryName FLI 355 mti GetSignalMode FLI 359 mti GetSignalName FLI 363 mti GetSignalNamelIndirect FLI 367 mti GetSignalRegion FLI 372 mti GetSignalSubelements FLI 376 mti GetSignalType FLI 381 mti GetSignalValue FLI 386 mti GetSignalValueIndirect FLI 392 mti GetTopRegion FLI 399 mti Ge
550. tTypeKind FLI 404 mti GetVarAddr FLI 408 mti GetVarImage FLI 416 mti GetVarImageBylId FLI 421 mti GetVarName FLI 426 mti GetVarSubelements FLI 431 mti GetVarType FLI 438 mti GetVarValue FLI 442 mti GetVarValueIndirect FLI 449 mti GetWlfFilename FLI 457 mti HigherRegion FLI 459 mti Image FLI 463 mti Interp FLI 467 mti IsColdRestore FLI 470 mti IsFirstInit FLI 473 mti IsRestore FLI 476 mti KeepLoaded FLI 479 mti Malloc FLI 482 mti NextProcess FLI 485 mti NextRegion FLI 489 mti NextSignal FLI 493 mti NextVar FLI 497 mti Now FLI 501 mti NowIndirect FLI 505 mti NowUpper FLI 510 mti PrintFormatted FLI 514 mti PrintMessage FLI 517 mti Quit FLI 520 mti Realloc FLI 523 mti ReleaseSignal FLI 527 mti RemoveEnvCB FLI 536 mti RemoveLoadDoneCB FLI 539 mti RemoveQuitCB FLI 542 mti RemoveRestartCB FLI 545 mti RemoveRestoreCB FLI 548 mti RemoveRestoreDoneCB FLI 551 mti RemoveSaveCB FLI 554 mti RemoveSimStatusCB FLI 557 mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti RestoreLong FLI 566 mti RestoreProcess FLI 569 e FLI 675 mti_RestoreShort FLI 574 mti_RestoreString FLI 577 mti_SaveBlock FLI 580 mti_SaveChar FLI 583 mti_SaveLong FLI 586 mti_SaveShort FLI 589 mti_SaveString FLI 592 mti_ScheduleDriver FLI 595 mti_ScheduleDriver64 FLI 601 mti_ScheduleWakeup FLI 606 FLI 610 mti ScheduleW
551. tVarValueIndirect returns a pointer to the value which must be treated as read only data and must not be freed If the buffer parameter is not NULL mti GetVarValueIndirect copies the value in the buffer parameter and also returns the buffer parameter The returned value is interpreted as follows For a scalar variable or a subelement of type The value should be cast to Enum char if lt 256 values mtiInt32T if 256 values Physical mtiInt32T Real double Scalar Integer mtiInt32T ModelSim FLI Reference FLI 450 FLI function definitions For a scalar variable or a subelement of The value should be cast to type Time mtiTime64T Note In order to get the value of a record variable use mti GetVarSubelements to get handles to the variable subelements and then use mti GetVarValue mti GetVarValuelIndirect or mti GetArrayVarValue on each of the subelements Related functions mti GetArrayVarValue FLI 233 mti GetVarValue FLI 442 Example FLI code include lt mti h gt typedef struct varInfoT tag struct varInfoT tag next char name mtiVariableIdT varid mtiTypeIdT typeid varInfoT typedef struct varlInfoT var info List of variables mtiProcessIdT proc Test process id instanceInfoT static void printValue mtiVariableIdT varid mtiTypeIdT vartype int indent switch mti_GetTypeKind vartype
552. ta mti ScheduleWakeup inst data proc 4 ModelSim FLI Reference void initForeign mtiRegionIdT char region param mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB initInstance HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a library ieee use ieee std logic 1164 a11 entity top is type bitarray is type intarray is type realarray is type timearray is end top mti Image FLI 465 The ID of the region in which this foreign architecture is instantiated The last part of the string in the foreign attribute A list of generics for the foreign model EJ ay A list of ports for the foreign model 0 architecture is array 3 downto 0 array 1 to 3 array l te array 1 to 0 architecture a of top is component for model end component of bit of integer of real of time for all for model use entity work for model a begin instl for model pl 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 variable intarr intarray 10 11 12 variable realarr realarray 11 6 101 22 variable tim
553. ta mti Malloc sizeof instanceInfoT inst data var info 0 for procid mti FirstProcess mti GetTopRegion 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 gt next varinfo curr_info varinfo inst_data gt proc mti_CreateProcess Test Process checkValues void inst data jj mti ScheduleWakeup inst data proc 6 void initForeign mtiRegionIdT region The ID of the region in which this kf foreign architecture is instantiated char param The last part of the string in the y foreign attribute id mtilnterfaceListT generics A list of generics for the foreign model mtilnterfaceListT ports A list of ports for the foreign model f 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 a11 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 mti GetVarSubelements FLI 435 type timearray is array 1 to 0 of time type type 2 downto 0 iE lt t0 2 al is array of bitarray a2 is array 3
554. tance info mti Realloc instance info strlen param 9 sprintf instance info s restart param mti_AddSaveCB saveCallback instance_info mti_AddRestoreCB restoreCallback instance_info mti AddQuitCB cleanupCallback instance info mti AddRestartCB cleanupCallback instance info 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 my for model begin end a entity top is end top architecture a of top is signal sl bit 0 component for model is end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info pointer to my for model VSIM 3 run 30 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 13 20 28 2000 Restoring state at time 20 ns iteration 1 Restore in progress Restored instance info my for model VSIM 5 run 40 VSIM 6 restart f Cleaning up Loading for_model sl VSIM 7 run 15 VSIM 8 checkpoint cpf2 Saving instance info pointer to my for m
555. tation have been developed entirely at private expense and are commercial computer software provided with restricted rights Use duplication or disclosure by the U S Government or a U S Government subcontractor is subject to the restrictions set forth in the license agreement provided with the software pursuant to DFARS 227 7202 3 a or as set forth in subparagraph c 1 and 2 of the Commercial Computer Software Restricted Rights clause at FAR 52 227 19 as applicable Contractor manufacturer is Mentor Graphics Corporation 8005 S W Boeckman Road Wilsonville Oregon 97070 7777 This is an unpublished work of Mentor Graphics Corporation Contacting ModelSim Support Telephone 503 685 0820 Toll Free Telephone 877 744 6699 Website www model com Support www model com support Technical support and updates iii Technical support and updates Support Model Technology online and email technical support options maintenance renewal and links to international support contacts www model com support default asp Mentor Graphics support www mentor com supportnet Updates Access to the most current version of ModelSim www model com downloads default asp Latest version email Place your name on our list for email notification of news and updates www model com products informant asp ModelSim FLI Reference Where to find our documentation ModelSim documentation is available from our website at www model c
556. td logic vector addr size 1 downto 0 type mem t is array 0 to size 1 of word t subtype tag word t is std logic vector addr size 1 downto set size type tag t is array 0 to size 1 of tag word t type valid t is array 0 to size 1 of boolean signal data out word t begin data lt others gt Z after dly when oen 1 else data out after dly process wen addr SEE Er SELE SEERNE Local tag and data memories variable data mem mem t variable atag mem tag t variable valid mem valid t others gt false function hash constant a addr t begin mti GetRegionKind FLI 337 return integer is return conv integer a set size 1 downto 0 end procedure lookup cache constant a addr t is variable i integer variable found boolean begin i hash a found valid mem i and a tag word t range atag mem i if found then hit lt 1 after dly else hit lt 0 after dly end if end procedure update_cache constant a addr_t constant d word_t is variable i integer begin i hash a data_mem i d atag_mem i a tag word t range valid mem i true end begin if wen event and wen 1 then update cache addr data end if lookup cache addr data out lt data_mem hash addr end process end top vhd entity for model is end for model architecture a of for model is attribute foreign of a architecture is begin end a
557. tdlogicsig 3 Blgual Duta rre OF cut TlT tg Signal stdlogicarrs Qr FT cro TIF Signal intarr 12 13 14 Signal realarr 12 6 102 22 Signal timearr 0 17 0 8 Signal rec 0 3 8 7 3 Var nO JOE WII Time 0 16 Signal bitsig 0 Signal intsig 24 Signal realsig 20 85 Signal timesig 0 8 Signal stdlogicsig 2 Slgnal Pitari Cub CO Coe pA Sign l stdlogicarrt It EQ opto EGER Signal intarr 13 14 15 Signal realarr 13 1 102 72 Signal timearr 0 18 0 9 Signal rec 1 4 V2 2 KOT pr OPT TOT mti GetArrayVarValue FLI 233 mti GetArrayVarValue Gets the value of a VHDL variable of type array Syntax value mti GetArrayVarValue variable id buffer Returns Description A pointer to the value of the specified variable Arguments Name Type Description variable id mtiVariableIdT A handle to a VHDL variable of type array buffer void A buffer into which the value is to be placed OPTIONAL can be NULL Description mti_GetArray VarValue returns the value of an array type VHDL variable If the buffer parameter is NULL then mti GetArrayVarValue returns a pointer to the value which should be treated as read only data Changing the value pointed to by this pointer actually changes the variable s value This pointer must not be freed If the buffer parameter is not NULL then mti GetArrayVarValue copies the value into the buffer parameter and also returns a
558. tech sunos5 std standard Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading work lower a Loading for_model sl VSIM 1 gt run 1 Time 0 1 delta O0 Signal top s1l is 0 Driving Signals for top s1 top sl VSIM 2 drivers top s1 Drivers for top s1l 0 Signal top s1 0 Driver top instil line 14 H Driver top pl 0 Driver top line 39 VSIM 3 run 5 Time 0 6 delta 0 Signal top s1l is O Driving Signals for top sl top sl VSIM 4 drivers top s1 Drivers for top s1l 0 Signal top sl 0 Driver top instl line 14 1 at 10 ns Driver top pl 0 Driver top line 39 1 at 10 ns VSIM 5 quit Cleaning up mti GetEnumValues FLI 271 mti GetEnumValues Gets the values of an enumeration type Syntax enum values mti GetEnumValues type id Returns Name Description enum values A pointer to an array of enumeration literals for the specified enumeration type or NULL if the specified type is not an enumeration type Arguments Type Description mtiTypeldT A handle to an enumeration type Description mti GetEnumValues returns a pointer to an array of enumeration literals for the specified enumeration type or NULL if the specified type is not an enumeration type The returned pointer must not be freed The number of elements in the array can be found by calling mti TickLength on the enumeration type The first element in the
559. th sigtype mti GetArrayElementType sigtype mti GetTypeKind elem type elem typekind case MTI TYPE ENUM char enum values enum values mti GetEnumValues elem type if mti TickLength elem type 256 mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted s enum_values val i else char val for array_val i 0 i lt num elems i mti PrintFormatted s enum_values val i break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T val for break break break for array_val i 0 i lt num_elems i mti PrintFormatted d val i case MTI TYPE ARRAY mti PrintMessage ARRAY case MTI TYPE RECORD mti PrintMessage RECORD case MTI TYPE REAL double val array val i 0 i lt num elems i mti PrintFormatted g val i break case MTI_TYPE_TIME mtiTime64T val for 1 break default break ModelSim FLI Reference i 0 mti PrintFormatted array val itt d d MTI TIME64 HI32 val il MTI TIME64 LO32 val il i lt num elems mti GetSignalValuelndirect FLI 395 mti_PrintFormatted n mti VsimFree array val break case MTI_TYPE_RECORD int i mtiSignalIdT elem list mtiInt32T num elems elem list mti GetS
560. th files pipes and sockets In a Windows environment it can be used only with pipes See mti_AddSocketOutputReadyCB FLI 90 To remove a previously added callback call mti AddOutputReadyCB with the same file descriptor but with a NULL function pointer Related functions mti AddInputReadyCB FLI 60 mti AddSocketInputReadyCB FLI 85 mti AddSocketOutputReadyCB FLI 90 ModelSim FLI Reference mti AddQuitCB FLI 69 mti AddQuitCB Adds a simulator exit callback Syntax mti AddQuitCB func param Returns Nothing Arguments Type Description mtiVoidFuncPtrT A pointer to a function to be called when the simulator exits void A parameter to be passed to the function OPTIONAL can be NULL Description mti AddQuitCB adds the specified function to the simulator exit callback list The same function can be added multiple times with possibly a different parameter each time When the simulator exits all callbacks in the list are called with their respective parameters When the quit sim command is given to vsim quit callbacks are not called because the simulator is not quitting completely Instead restart callbacks are called Related functions mti RemoveQuitCB FLI 542 Example FLI code include lt stdlib h gt include lt mti h gt void quitCallback void param mti_PrintFormatted Cleaning up s for simulator exit n char param free param
561. the next VHDL process in the current region None mti NextProcess returns a handle to the next process in the region set by the latest call to mti FirstProcess mti NextProcess returns NULL if there are no more processes Related functions Example mti FirstProcess FLI 195 FLI code include lt mti h gt void printProcesses mtiRegionIdT region int indent mtiProcessIdT procid for procid mti_FirstProcess region procid procid mti_NextProcess if procid mti PrintFormatted cProcess s n indent mti GetProcessName procid void printHierarchy mtiRegionIdT region int indent char region_name mtiRegionIdT regid region name mti GetRegionFullName region mti PrintFormatted cRegion s n indent region name ModelSim FLI Reference FLI 486 FLI function definitions indent 2 printProcesses region for regid regid regid printHierarchy regid indent mti VsimFree region name void loadDoneCB void param mti PrintMessage printHierarchy mti GetTopRegion void initForeign mtiRegionIdT region ER x char param Jo mtilnterfaceListT generics mtilnterfaceListT ports 7 5 mti AddLoadDoneCB loadDoneCB HDL code entity for model is end for model architecture a of for model is attribute foreign of a begin end a entity inv is nHierarchy n architecture
562. the returned pointer with mti_VsimFree FLI 667 If the buffer parameter is not NULL then mti_GetDriverSubelements copies the value into the buffer parameter and also returns the buffer parameter Related functions mti_ScheduleDriver FLI 595 mti_ScheduleDriver64 FLI 601 ModelSim FLI Reference Example mti GetDriverSubelements FLI 259 FLI code include lt stdlib h gt include lt mti h gt typedef enum STD_LOGIC_U STD_LOGIC_X STD LOGIC 0 STD LOGIC 1 STD LOGIC 4 STD LOGIC W STD LOGIC L STD LOGIC H STD LOGIC D standardLogicType typedef struct mtiSignalIdT sigid mtiDriverIdT drv_elems int index int num_elems instanceInfoT char convertStdLogicValue char sigval char retval switch sigval case STD_LOGIC_U retval U break case STD LOGIC X retval X break case STD LOGIC 0 retval O break case STD_LOGIC_1 retval 1 break case STD LOGIC 2 retval Z break case STD LOGIC W retval W break case STD_LOGIC_L retval L break case STD_LOGIC_H retval H break case STD_LOGIC_D retval break default retval break return retval void driveSignal void param char region_name char sigval instanceInfoT inst instanceInfoT param int Q5 region name mti GetRegionFullName mti GetSignalRegion inst sigid sigval cha
563. ti GetVarValuelIndirect FLI 449 Example FLI code include mti h typedef struct varInfoT tag struct varInfoT tag next char name mtiVariableIdT varid mtiTypeIdT typeid varInfoT typedef struct varlInfoT var info List of variables mtiProcessIdT proc Test process id instanceInfoT ModelSim FLI Reference mti GetVarValue FLI 443 static void printValue mtiVariableIdT varid mtiTypeIdT vartype int indent switch mti GetTypeKind vartype case MTI TYPE ENUM char enum_values mtilnt32T scalar val enum values mti GetEnumValues vartype scalar val mti GetVarValue varid mti PrintFormatted s n enum values scalar val break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T scalar val scalar val mti GetVarValue varid mti PrintFormatted d n scalar val break case MTI_TYPE_ARRAY int i mtilInt32T num elems mtiTypeldT elem type mtiTypeKindT elem typekind void array val array val mti GetArrayVarValue varid O0 num elems mti TickLength vartype elem type mti GetArrayElementType vartype elem typekind mti GetTypeKind elem type switch elem typekind case MTI TYPE ENUM char enum_values enum values mti GetEnumValues elem type if mti TickLength elem type 256 mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted s
564. ti GetSignalType elem sigid releaseSignal elem sigid elem typeid mti GetTypeKind elem typeid mti_VsimFree elem_list break default break ModelSim FLI Reference dk mti ForceSignal FLI 213 static void testForce void inst info instanceInfoT inst data instanceInfoT inst info signallInfoT siginfo switch inst data state case 0 case 2 case 4 for siginfo inst data sig info siginfo siginfo siginfo gt next forceSignal siginfo gt sigid siginfo gt typeid siginfo gt typekind inst_data gt state break case 1 case 3 case 5 for siginfo inst data sig info siginfo siginfo siginfo gt next releaseSignal siginfo gt sigid siginfo gt typeid siginfo gt typekind break default break inst_data gt statett mti ScheduleWakeup inst_data gt proc 10 static signallnfoT setupSignal mtiSignalIdT sigid signallnfoT siginfo siginfo signalInfoT mti Malloc sizeof signalInfoT siginfo gt sigid sigid siginfo gt name mti GetSignalNameIndirect sigid 0 0 siginfo gt typeid mti GetSignalType sigid siginfo gt typekind mti_GetTypeKind siginfo gt typeid siginfo gt direction mti_GetSignalMode sigid siginfo gt last_value mti GetSignalValueIndirect sigid 0 siginfo gt child 0 siginfo next 0 For records and arrays of composites we want to set drive value
565. ti PrintMessage Cannot find a usable winsock dll n WSACleanup return The Windows Sockets DLL is acceptable Proceed dendif sock socket AF INET SOCK STREAM 0 if sock INVALID SOCKET ifdef WIN32 DWORD le GetLastError mti_PrintFormatted Error opening socket Error d n le else mti_PrintMessage Error opening socket n endif return while retry_cnt lt 2 memset char amp server 0 sizeof server server sin_family AF_INET if hp gethostbyname hostname 0 FLI 87 ModelSim FLI Reference FLI 88 FLI function definitions ModelSim FLI Reference mti PrintFormatted s Unknown host n hostname close sock return memcpy char amp server sin addr char hp gt h_addr hp gt h length portNum 19 chargen server sin port htons portNum Server length sizeof server Status connect sock struct sockaddr amp server server length if status lt 0 if retry_cnt 1 mti PrintFormatted Error connecting to server s d n hostname portNum close sock else strcpy hostname map Put your hostname here ifdef WIN32 unsigned long non_blocking 1 status ioctlsocket sock FIONBIO amp non blocking if status SOCKET ERROR perror Setting socket status else statusFlags fcntl sock F GETFL if statusFlags SOCKE
566. tic void invertBitArray char value lib e IN es n 0 h delay procid il_sigid i2_sigid i3_sigid tl_sigid t2_sigid t3_sigid il_drvid i2_drvid i3_drvid tl_drvid t2_drvid t3_drvid il_last_value i2_last_value i3_last_value tl last value t2 last value t3 last value i3 value length t3 value length int i for i 0 i length i if value i 0 value i 1 else value i 0 mtiInt32T length mti ScheduleDriver64 FLI 603 static long incrStdLogic mtiInt32T value switch value case STD_LOGIC_U return STD LOGIC X case STD LOGIC X return STD LOGIC 0 case STD LOGIC 0 return STD LOGIC 1 case STD LOGIC 1 return STD LOGIC Z7 case STD LOGIC 2 return STD LOGIC W case STD LOGIC W return STD LOGIC Ll case STD LOGIC L return STD LOGIC H case STD LOGIC H return STD LOGIC D case STD LOGIC D return STD LOGIC U default return STD LOGIC U void driveSignal void param instanceInfoT inst param mtiTime64T at time MTI TIME64 ASGN at time 1 2 inst il last value invertBit inst il last value mti ScheduleDriver64 inst gt il_drvid inst il last value at time MTI_INERTIAL inst i2 last value incrStdLogic inst i2 last value mti ScheduleDriver64 inst gt i2_drvid inst i2 last value at time MTI_INERTIAL invertBitArray inst i3 last value inst gt i3 value
567. tions FLI 34 for more information on 64 bit platforms 64 bit HP for IA64 platform cc compiler opt ansic bin cc usr ccs bin Id cc c DD64 I install dir modeltech include app c ld b o app sl app o If your FLI application requires a user or vendor supplied C library or an additional system library you will need to specify that library when you link your FLI application For example to use the system math library specify Im to the ld command cc c DD64 I install dir modeltech include math app c ld b o math app sl math app o lm 32 bit IBM RS 6000 platform ModelSim loads shared libraries on the IBM RS 6000 workstation The shared library must import ModelSim s C interface symbols and it must export the C initialization function ModelSim s export file is located in the ModelSim installation directory in modeltech rs6000 mti exports If your foreign module uses anything from a system library you ll need to specify that library when you link your foreign module For example to use the standard C library specify lc to the Id command The resulting object must be marked as shared reentrant using these gcc or cc compiler commands for AIX version 4 x gcc compiler gcc c I install dir modeltech include app c ld o app sl app o bE app exp bI install dir modeltech rs6000 mti exports bM SRE bnoentry lc cc compiler cc c I install dir modeltech include app c ld o ap
568. tity work for model a begin instl for_model end a Simulation output 9 vsim c top Reading modeltech 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 Design Signals bitsig type Enumeration low 0 high 1 intsig type Scalar low 2147483648 high physsig type Physical low 0 high 2147483647 realsig type Real low 0 high 0 timesig type Time low 0 high 0 stdlogicsig type Enumeration low 0 high 8 bitarr type Array low 5 high 2 stdlogicarr type Array low 0 high 3 uparray type Array low 1 high 4 rec type Record low 0 high 0 VSIM 1 quit mti TickLow FLI 663 2147483647 ModelSim FLI Reference FLI 664 FLI function definitions mti TickRight Gets the right value of a ranged type Syntax right mti TickRight type id Returns Type Description mtiInt32T The right value of the range of the specified type O for real time and record types Arguments Type Description mtiTypeldT A handle to a VHDL type Description mti TickRight returns the value of type RIGHT for ranged types For real time and record types mti TickRight returns 0 Related functions mti TickDir FLI 647 mti TickHigh FLI 651 mti TickLeft FLI
569. tize mti CreateArrayType FLI 111 ack void param e Cleaning up n region The ID of the region in which this Er foreign architecture is instantiated param The last part of the string in the xy foreign attribute x7 tT generics A list of generics for the foreign model tT ports A list of ports for the foreign model KR inst procid elem list sigid array type enum type instanceInfoT malloc sizeof instanceInfoT mti CreateEnumType 1 3 enum lits mti CreateArrayType 2 0 enum type mti CreateSignal mySig region array type mti GetSignalSubelements sigid NULL elem list 0 mti CreateDriver inst gt sigidl mti CreateProcess mySiglDriver driveSignall inst procid inst gt sigidl MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvidl procid inst sigid2 inst drvid2 procid mti Sensitize elem list 1 mti CreateDriver inst gt sigid2 mti CreateProcess mySig2Driver driveSignal2 inst procid inst sigid2 MTI EVENT mti ScheduleWakeup procid 0 mti SetDriverOwner inst drvid2 procid inst 5sigid3 inst drvid3 procid mti Sensitize mti Sensitize elem list 2 mti CreateDriver inst gt sigid3 mti CreateProcess mySig3Driver driveSignal3 inst procid inst gt sigidl MTI EVENT procid inst sigid2 MTI EVENT mti ScheduleWakeup
570. top Reading modeltech 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 Signal bitsigl is of type Enum There are no array subelements Signal stdlogicsigl is of type Enum There are no array subelements Signal bitarrl is of type Array Its subelements are of type Enum Signal stdlogicarrl is of type Array h QD Its subelements are of type Enum Signal intarrl is of type Array Its subelements are of type Scalar Signal strarrl is of type Array Its subelements are of type Enum Signal recl is of type Record The record subelements are Signal recl a is of type Real There are no array subelements Signal recl b is of type Enum There are no array subelements Signal recl c is of type Array ts subelements are of type Enum VSIM 1 run 10 VSIM 2 quit ModelSim FLI Reference FLI 226 FLI function definitions mti GetArraySignalValue Syntax Returns Arguments Description ModelSim FLI Reference Gets the value of a VHDL signal of type array value mti GetArraySignalValue signal id buffer Description A pointer to the value of the specified signal Name Type Description signal id mtiSignalldT A handle to a VHDL signal of type array buffer void A buff
571. top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work mid a Loading work inv b Loading work for model a Loading for_model sl Elaboration phase Region top Region top instl Region top instl il Region top instl flip Load Done phase Region top Region top instl Region top instl flip Region top instl il Region top instl toggle VSIM 1 run 20 VSIM 2 quit ModelSim FLI Reference mti FirstProcess Gets the first VHDL process in a region mti FirstProcess FLI 195 process id mti FirstProcess region id Type Description mtiProcessIdT Type A handle to the first VHDL process in a region or NULL if there are no processes in the region Description Syntax Returns Name process id Arguments Name region id Description mtiRegionIdT A handle to a VHDL region mti FirstProcess returns a handle to the first process in the specified region mti NextProcess can be used to get the subsequent processes in the specified region mti FirstProcess resets the region used by previous calls to mti FirstProcess and mti NextProcess therefore mti NextProcess always uses the region set by the latest call to mti FirstProcess Related functions mti NextProcess FLI 485 Example FLI code include lt mti h gt void printProcesses mtiRegionI
572. top is end top architecture a of top is signal sl std logic 0 begin pl process begin Cl case sl is when U gt sl lt X after 5 ns when X gt s1 lt 0 after 5 ns when 0 gt sl lt 1 after 5 ns when 1 gt sl lt Z after 5 ns when Z gt sl lt W after 5 ns when W gt sl lt L after 5 ns when L gt sl lt H after 5 ns ModelSim FLI Reference monitorSignal when H gt sl lt after 5 ns when gt sl lt U after 5 ns end case cl wait for 5 ns end process end a Simulation output 9 vsim c top foreign initForeign for model sl Reading modeltech tcl vsim pref tcl 5 4b vsim foreign initForeign for model sl c top Loading modeltech sunos5 std standard Loading work top a Loading for_model sl VSIM 1 run 50 Time 0 15 delta 0 Signal top sl is UNKNOWN Drivers for top s1l W Signal top sl W Driver top pl Time 0 40 delta 0 Signal top sl is UNKNOWN Drivers for top sl X Signal top s1 X Driver top pl VSIM 2 quit Loading modeltech sunos5 ieee std logic 1164 body mti Command FLI 107 ModelSim FLI Reference FLI 108 FLI function definitions mti CreateArrayType Syntax Returns Arguments Description Creates an array type type id mti CreateArrayType left right element type Type Description mtiTypeldT A hand
573. tor monitorSignal2 inst mti Sensitize procid inst gt sigid2 MTI ACTIVE mti AddQuitCB cleanupCallback inst mti AddRestartCB cleanupCallback inst 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 entity top is end top architecture a of top is ModelSim FLI Reference FLI 616 FLI function definitions signal sl bit Ory signal s2 bit 0 component for_model end component begin sl lt not sl after 5 ns forinst for model pl process begin wait for 2 ns s2 lt 0 wait for 5 ns S2 LETI wait for 3 ns S2 ibe wait for 4 ns s2 lt 0 end process end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for model sl VSIM 1 run 20 Time 0 0 s2 0 Time 0 0 sl 0 Time 0 2 s2 0 Time 0 5 sl 1 Time 0 7 s2 1 Time 0 10 sl 0 Time 0 10 s2 1 Time 0 14 s2 0 Time 0 15 sl 1 Time 0 16 s2 0 Time 0 20 sl 0 VSIM 2 gt quit Cleaning up ModelSim FLI Reference mti SetDriverOwner FLI 617 mti SetDriverOwner Sets the owning process of a driver Syntax mti SetDriverOwner driver id process id
574. tribute xy A list of generics for the foreign model A list of ports for the foreign model p 0 initForeign for model sl 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 amp bit b integer C real ModelSim FLI Reference FLI 626 FLI function definitions ModelSim FLI Reference d st e bi end reco end top d logic tarray rd architecture a of top is component for model end component for all for model use entity work for model a signal bitsig bit r tl signal intsig integer 21 signal realsig real 16 35 signal timesig time 5 ns signal stdlogicsig std_logic H signal bitarr bitarray 0110 signal stdlogicarr std logic vector 1 to 4 O1LH signal intarr intarray 10 11 12 signal realarr realarray 11 6 101 22 signal timearr timearray 15 ns 6 ns signal rec rectype seo 0t Ly 3 7 Ht LOOT begin instl for_model end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl Duel 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 15 Time 0 5 Signal bitsig 1 Signal intsig 21 Signal realsig 1 635000e 01
575. ts for the foreign model El aen FR E instance info instance info architecture is my for model ModelSim FLI Reference FLI 588 FLI function definitions ModelSim FLI Reference end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info my for model Saving char Z Saving long 123456 Saving short 587 Saving string Howdy VSIM 3 run 40 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 16 09 02 2000 Restoring state at time 20 ns iteration 1 Restoring instance info my for model Restoring char Z Restoring long 123456 Restoring short 587 Restoring string Howdy VSIM 5 run 10 VSIM 6 quit mti SaveShort FLI 589 mti SaveShort Saves sizeof short bytes of data to the checkpoint file Syntax mti SaveShort data Returns Nothing Arguments Description The data to be saved Description mti SaveShort saves the specified sizeof short bytes of data to the checkpoint file Related functions mti RestoreBlock FLI 560 mti RestoreChar FLI 563 mti
576. ts with other integration software and name is the name of the region Enclosing the entire name in angle brackets makes it an illegal HDL name For example lt MTI_regiona gt ModelSim FLI Reference mti CreateRegion FLI 143 We strongly recommend that you do not use characters in the name that will cause Tcl parsing problems This includes spaces the path separator normally or square brackets and dollar signs If you must use these characters then create an escaped name by putting a backslash V at both ends of the name Related functions Example mti FindRegion FLI 177 mti GetTopRegion FLI 399 FLI code include acc user h include acc vhdl h include mti h void printRegionInfo mtiRegionIdT regid int indent char regkind mtiRegionIdT subreg switch mti GetRegionKind regid case accArchitecture regkind break Architecture case accForeign regkind break Foreign case accModule regkind break Module case accPackage regkind break default regkind break mti_PrintFormatted cRegion s indent 2 for subreg subreg Package Unknown s n indent mti_GetRegionName regid regkind mti_FirstLowerRegion regid subreg mti_NextRegion subreg printRegionInfo subreg indent void loadDone mtiRegionIdT mtiRegionIdT mtiRegionIdT void par
577. tsel if prw 1 sysread paddr else syswrite paddr wen 4 b1111 end update_mru paddr setsel end endmodule memory v module memory clk addr data rw strb rdy input clk addr rw strb output rdy inout data define addr size 8 define word size 16 reg word size 1 0 data r reg rdy r initial begin data r bz rdy r 1 end wire addr size 1 0 addr wire word size 1 0 5 data data r wire 5 rdy rdy r reg word size 1 0 mem 0 1 lt lt addr size 1 integer i always posedge clk if strb 0 begin i addr repeat 2 posedge clk if rw 1 data r mem i rdy r 0 G posedge clk rdy_r 1 ModelSim FLI Reference FLI 334 FLI function definitions ModelSim FLI Reference if rw 0 mem i data else data r bz end endmodule proc v module proc clk addr data rw strb rdy input clk rdy output addr rw strb inout data define addr size 8 define word size 16 reg addr size 1 0 addr r reg word size 1 0 data r reg rwr SUtrbcr reg verbose wire addr size 1 0 5 addr addr r wire word size 1 0 5 data data r wire 5 rw rw r strb strb r task read input addr size 1 0 a output word size 1 0 d begin end if verbose display t addr r a rw r 1 strb_r 0 posedge clk posedge clk strb_r 1 while rdy 0 posedge clk data e
578. ty top is end top architecture a of top is bit signal sl Mns component for model is ModelSim FLI Reference Restoring Restoring Restoring mti Malloc strlen param param char amp instance info nRestoring instance info s n Restoring instance_info mti RestoreLong mti RestoreShort mti RestoreString char c n mti RestoreChar long ld n short d n string s n The ID of the region in which this t4 foreign architecture is instantiated The last part of the string in the x foreign attribute x A list of generics for the foreign model A list of ports for the foreign model El aen FR E instance info instance info architecture is my for model end component for all for model use entity work for model a begin il for model sl lt not sl after 5 ns end a Simulation output 9 vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 20 VSIM 2 checkpoint cpfile Saving instance info my for model Saving char Z Saving long 123456 Saving short 587 Saving string Howdy VSIM 3 run 40 VSIM 4 restore cpfile Loading checkpoint restore data from file cpfile Checkpoint created Fri Jul 7 16 09 02 2000 Restoring state a
579. typedef int SOCKET endif void sockCB void sock int j char buf 1 ifdef WIN32 i recv SOCKET sock buf sizeof buf 0 else i read SOCKET sock buf sizeof buf endif mti PrintFormatted Read returned d Read Sc n i buf 0 if i 0 buf 0 C Remove the callback ifdef WIN32 mti_AddSocketInputReadyCB SOCKET sock mtiVoidFuncPtrT 0 0 else mti_AddInputReadyCB SOCKET sock mtiVoidFuncPtrT 0 0 endif mti_PrintMessage Closing socket n Closet SOCKET sock void loadDoneCB void sock mti_PrintMessage Load Done Adding socket callback n ifdef WIN32 ModelSim FLI Reference FLI 62 FLI function definitions Sock mti AddSocketInputReadyCB SOCKET sock mtiVoidFuncPtrT sockCB else mti AddInputReadyCB SOCKET sock mtiVoidFuncPtrT sockCB sock endif void initForeign mtiRegionIdT region The ID of the region in which this A foreign architecture is instantiated char param The last part of the string in the wf foreign attribute uA mtilnterfaceListT generics A list of generics for the foreign model mtilInterfaceListT ports A list of ports for the foreign model char hostname MAXHOSTNAMELEN localhost int statusFlags int server_length int status int retry_cnt 0 short portNum 0 struct sockaddr_in server struct hostent hp SOCKET sock
580. ude lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char tmp char Z char tmp str Howdy long tmp long 123456 short tmp short 587 mti PrintFormatted mti SaveBlock mti PrintFormatted mti SaveChar tmp char mti PrintFormatted Saving mti SaveLong tmp long mti PrintFormatted Saving mti SaveShort tmp short mti PrintFormatted Saving mti SaveString tmp str mti PrintFormatted n nSaving instance info s n char amp instance info Saving char c n lon sho str mti RestoreShort FLI 575 instance info i sizeof instance_info tmp char g 1dWMn tmp long rt d n tmp short ing s n tmp str void restoreCallback void param mti_RestoreBlock mti_PrintFormatted nRestoring instance info s n mti_PrintFormatted Restoring mti_PrintFormatted Restoring mti_PrintFormatted Restoring mti_PrintFormatted Restoring mti_PrintFormatted n void initForeign mtiRegionIdT region JE char param KR fs mtiInterfaceListT generics mtilnterfaceListT ports 73 instance_info strcpy instance info mti_AddSaveCB saveCallback mti_AddRestoreCB restoreCallback HDL code entity for_model is end for_model architecture a of for_model is attribute foreign of a initForeign for_model sl begin end a entity top is end to
581. ue ip gt inl val2 mti GetSignalValue ip gt in2 result vall amp val2 mti ScheduleDriver ip gt outl result 0 MTI INERTIAL void save data void param new function inst rec ip inst rec param mti SaveBlock char amp ip sizeof ip void restore data void param new function inst_rec ip mti_RestoreBlock char amp ip mti_AddSaveCB save_data ip new mti_RestoreProcess ip gt proc pl do_and ip void and_gate_init mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports inst rec ip mtiSignalIdT outp if mti_IsRestore new ip inst rec mti_Malloc sizeof inst rec mti AddSaveCB save data ip new ip gt inl mti FindPort ports inl ip gt in2 mti FindPort ports in2 outp mti FindPort ports outl ip gt outl mti CreateDriver outp ip gt proc mti CreateProcess pl do and ip changed mti Sensitize ip gt proc ip gt inl MTI EVENT changed mti Sensitize ip gt proc ip in2 MTI EVENT changed mti AddRestoreCB restore data 0 new The above example displays the following features e mti Malloc is used instead of malloc e A callback is added using mti AddRestoreCB to restore the ip pointer and pl process Two callbacks are added using mti AddSaveCB to save the ip pointer each time its value is d
582. uld be cast to variable with a subelement of type Enum char if lt 256 values mtiInt32T if gt 256 values Physical mtiInt32T Real double For a scalar variable or an array variable with a subelement of type mti GetVarAddr FLI 409 The value should be cast to Scalar Integer mtiInt32T Time mtiTime64T The number of subelements of an array variable can be determined by calling mti TickLength on the type of the array variable mti GetVarAddtr can be called successfully only after elaboration is complete Related functions mti FindVar FLI 187 mti GetVarValue FLI 442 mti SetVarValue FLI 628 Example FLI code include lt stdio h gt include lt mti h gt define NAME_MAX 1024 typedef struct varInfoT tag struct varInfoT tag next char name void var_addr mtiVariableIdT varid mtiTypeIdT typeid varInfoT typedef struct variInfoT var_info mtiProcessIdT instanceInfoT proc List of variables Test process id static void setValue varInfoT varinfo int indent switch mti GetTypeKind varinfo gt typeid case MTI TYPE ENUM char enum_values enum values mti GetEnumValues varinfo gt typeid if mti TickLength varinfo gt typeid lt 256 char var val char varinfo var addr mti PrintFormatted var val 1 sWn enum valu
583. um values val i else char val array_val for i 0 i lt num elems i mti PrintFormatted s enum values val i break case MTI_TYPE_PHYSICAL case MTI_TYPE_SCALAR mtilnt32T val array val for i 0 i lt num elems i mti PrintFormatted d val i break case MTI_TYPE_ARRAY mti_PrintMessage ARRAY break ModelSim FLI Reference FLI 388 FLI function definitions case MTI TYPE RECORD mti PrintMessage RECORD break case MTI TYPE REAL double val array_val for i 0 i lt num elems i mti PrintFormatted g val i break case MTI_TYPE_TIME mtiTime64T val array_val for i 0 i lt num elems i mti_PrintFormatted d d MTI TIME64 HI32 val il MTI TIME64 LO32 val il break default break mti_PrintFormatted n mti VsimFree array val break case MTI_TYPE_RECORD int i mtiSignalIdT elem list mtiInt32T num elems elem list mti GetSignalSubelements sigid 0 num elems mti GetNumRecordElements sigtype mti PrintFormatted n for i 0 i lt num elems i mti PrintFormatted c indent printValue elem list i mti GetSignalType elem list il indent 2 mti_VsimFree elem_list break case MTI_TYPE_REAL double real_val mti GetSignalValueIndirect sigid amp real val mti PrintFormatted
584. uments Name Description section The name of the section in the project file in which the entry resides The name of the entry If this parameter is non zero then environment variables in the entry are expanded otherwise they are not Description mti FindProjectEntry returns the value of the specified entry from the specified section of the project file modelsim ini Expansion of environment variables in the entry s value is controlled by the expand parameter The comparison against the section and name strings is not case sensitive The caller is responsible for freeing the returned pointer with mti VsimFree FLI 667 Related functions mti WriteProjectEntry FLI 670 ModelSim FLI Reference FLI 174 FLI function definitions Example ModelSim FLI Reference FLI code include mti h void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports char entry entry mti FindProjectEntry mti PrintFormatted myconfi mti VsimFree entry entry mti FindProjectEntry mti PrintFormatted myconfi mti VsimFree entry entry mti FindProjectEntry The ID of foreign architecture is instantiated the region in which this The last part of the string in the foreign attribute A list of generics for the foreign model A list of ports for the foreign model myconfig g myentry
585. ure a of for model is architecture is attribute foreign of a begin end a entity top is end top architecture a of top is bit signal sl nos component for model is end component for all begin il for model S lt not sl after 5 ns end a Simulation output vsim c top mti WriteProjectEntry FLI 671 The ID of the region in which this Ey foreign architecture is instantiated The last part of the string in the x foreign attribute EY A list of generics for the foreign model A list of ports for the foreign model x 0 Solaris cpu H 4Meg n initForeign for model sl for model use entity work for model a modeltech sunos5 std standard Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading Loading work top a Loading work for_model a Loading for_model sl MyConfig Solaris MyDesign cpu ModelSim FLI Reference FLI 672 FLI function definitions MyMemory 4Meg VSIM 1 gt quit grep My modelsim ini MyConfig Solaris MyDesign cpu MyMemory 4Meg ModelSim FLI Reference Index FLI 673 Numerics 64 bit ModelSim time values FLI 35 using with 32 bit FLI apps FLI 34 A array type creating FLI 108 C C initialization function FLI 12 callback elaboration done FLI 65 environment change FLI 57 input ready FLI 60 output ready FLI 68 run status change FLI 83 simulator checkpoint FL
586. ure is for model use entity work for model a for model lt not bitsig after 5 ns mti GetEnumValues FLI 275 checkValues in which this is instantiated string in the Er initForeign for model sl ModelSim FLI Reference FLI 276 FLI function definitions ModelSim FLI Reference stdlogicsig bitarr stdlogicarr not lt not not ro ro mq qt 11 ro rec a lt not rec b lt not recsc not end a Simulation output vsim c top Reading 5 4b vsim c top Loading Loading Loading work top a Loading work for model a Loading for_model sl VSIM 1 run 15 Time 0 6 Signal bitsig TOF Signal stdlogicsig Signal bitarr I Signal stdlogicarr Signal rec Le en QT M M C Time 0 11 Signal bitsig 1 Signal stdlogicsig Signal bitarr 0 Signal stdlogicarr Signal rec 10 Y Uu Uu U os VOM VSIM 2 gt quit bitarr after 5 ns stdlogicarr after 5 ns rec a after 5 ns rec b after 5 ns rec c after 5 ns modeltech tcl vsim pref tcl ro 11 ro 11 11 ro 11 ro stdlogicsig after 5 ns modeltech sunos5 std standard modeltech sunos5 ieee std logic 1164 body 11 mti GetGenericList FLI 277 mti GetGenericList Gets a list of the VHDL generics defined for a region Syntax generic list mti GetGenericList region id Returns Name Type Description
587. use work for pkg all entity top is end top architecture a of top is component for model end component for all for model use entity work for model a signal sl s bit e 0r begin sl lt not sl after 4 ns ModelSim FLI Reference FLI 294 FLI function definitions finst for model pl postponed process begin wait for 16 ns test proc end process end a Simulation output vsim c top Reading modeltech tcl vsim pref tcl 5 4b vsim c top Loading modeltech sunos5 std standard Loading work for_pkg body Loading for model sl Loading work top a Loading work for model a VSIM 1 run 3 VSIM 2 run 4 Time 0 4 checkRegion Pending events Next time is 0 7 VSIM 3 run 9 Time 0 8 checkRegion Pending events Next time is 0 12 Time 0 12 checkRegion Pending events Next time is 0 16 Time 0 16 checkRegion Pending postponed processes Next time is 0 16 VSIM 4 quit ModelSim FLI Reference mti GetNumRecordElements mti GetNumRecordElements FLI 295 Gets the number of subelements in a VHDL record type num elems mti GetNumRecordElements type id Type Description mtiInt Type 32T The number of subelements in the specified record type Description mtiTy peldT A handle to a VHDL record type Syntax Returns Name num elems Arguments Description mti GetNumRecordEle
588. 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 ModelSim FLI Reference FLI 428 FLI function definitions varinfo setupVariable varid regid procid if inst data var info 0 inst data var info varinfo else curr_info gt next varinfo curr_info varinfo inst_data gt proc mti_ScheduleWakeup inst_data gt proc void initForeign mtiRegionIdT region char param mtilnterfaceListT generics mtilnterfaceListT ports mti AddLoadDoneCB initInstance HDL code entity for model is end for model architecture a of for model is architecture attribute foreign of a begin end a library ieee use ieee std logic 1164 a11 entity top is type is type type type bitarray array 3 intarray is array 1 is is realarray timearray array 1 array type rectype is record a real b std logic Cc bitarray end record end top architecture a of top is component for model end component ModelSim FLI Reference mti CreateProcess downto 0 o 35 to 2 1 to 0 Test Process checkValues void inst data 4 The ID of the region in which this X foreign architecture is instantiated T
589. veRestoreDoneCB must be called from a foreign initialization function in order for the callback to take effect A foreign initialization function is specified either in the foreign attribute string of a foreign architecture or in the foreign string option of a vsim command Related functions mti_AddRestoreDoneCB FLI 77 Example FLI code include lt stdlib h gt include lt mti h gt static char instance_info void saveCallback void param char inst_info char param mti PrintFormatted Saving instance info s n inst info mti SaveString inst info ModelSim FLI Reference FLI 552 FLI function definitions ModelSim FLI Reference void restoreCallback void param char inst info char param strcpy inst info mti RestoreString mti PrintFormatted Restored instance info s n inst info void restoreDoneCallback void param char inst info char param if param mti PrintFormatted s Restore complete n inst info else mti PrintMessage Restore is done n void cleanupCallback void param mti_PrintMessage Cleaning up n free param void initForeign mtiRegionIdT region The ID of the region in which this mU foreign architecture is instantiated char param The last part of the string in the KJ foreign attribute EL mtiInterfaceListT generics A list of generics for the
590. veSimStatusCB removes the specified function from the simulator run status change callback list The param parameter must be the same parameter that was specified in the call to mti AddSimStatusCB when the callback was created Related functions mti AddSimStatusCB FLI 83 Example FLI code include lt mti h gt void simStatusCallback void param int run_status mtiRegionIdT region mtiRegionIdT param mti_PrintFormatted Time ld ld Region s the simulator s n mti_NowUpper mti_Now mti_GetRegionName region run_status 1 is about to run just completed a run if mti Now gt 25 mti RemoveSimStatusCB simStatusCallback param ModelSim FLI Reference FLI 558 FLI function definitions 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 mtilnterfaceListT generics mtilnterfaceListT ports p mti AddSimStatusCB simStatusCallback foreign attribute region HDL code entity for model is end for model architecture a of for model is attribute foreign of a initForeign for model sl begin end a architecture is for model entity top is end top architecture a of top is signal sl bit r T01 component for_model is end component for all for_model use entity work for_model a begin il
591. ver inst gt t2_sigid inst procid Jtaop ti3 jy mti CreateDriver inst gt t3 sigid inst procid inst inst Jj inst mti ScheduleDriver FLI 599 is initForeign for model sl 1100 1100 modeltech sunos5 std standard ModelSim FLI Reference FLI 600 FLI function definitions HE Loading modeltech sunos5 ieee std logic 1164 body Loading work top a Loading work for model a de dE o Loading for model sl VSIM 1 add list top il top tl top i2 top t2 top i3 top t3 VSIM 2 run 35 VSIM 3 write list list out VSIM 4 quit Cleaning up 9 cat list out ns top il top i3 delta top tl top t3 top i2 top t2 O0 0 0000 00 1100 5 0 0101 00 0011 6 0 0002Z 00 1100 8 0 010W 00 0011 11 2 0 000L 00 1100 15 0 11HH 0011 0011 20 0 0 ttes om 00 1100 26 0 11 U 0011 0011 33 0 00x xX 00 1100 ModelSim FLI Reference mti ScheduleDriver64 FLI 601 mti ScheduleDriver64 Schedules a driver to drive a value onto a VHDL signal with a 64 bit delay Syntax mti ScheduleDriver64 driver id value delay mode Returns Nothing Arguments Name Type Description driver mtiDriverldT A handle to the driver value long void For a signal of scalar type the value to be driven for a signal of real time or array type a pointer to the value to be driven mtiTime64T The delay to be used in terms of the cu
592. 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 ModelSim FLI Reference FLI 20 Introduction Using checkpoint restore with the FLI ModelSim FLI Reference In order to use checkpoint restore with the FLI any data structures that have been allocated in foreign models and certain IDs passed back from FLI function calls must be explicitly saved and restored We have provided a number of features to make this as painless as possible The main feature is a set of memory allocation functions Memory allocated by such a function will be automatically restored for you to the same location in memory ensuring that pointers into the memory will still be valid The second feature is a collection of explicit functions to save and restore data You will need to use these functions for any pointers to your data structures and for IDs returned from FLI functions Pointers that you save and restore must point to memory allocated by ModelSim Objects in the shared library will no longer be valid if the shared library is reloaded into a different location during a restore If you choos
593. xtEventTime FLI 291 mti_GetNumRecordElements FLI 295 mti_GetParentSignal FLI 301 mti_GetPhysicalData FLI 306 mti_GetPrimaryName FLI 311 mti_GetProcessName FLI 315 mti_GetProcessRegion FLI 319 mti_GetProductVersion FLI 323 mti_GetRegionFullName FLI 325 mti_GetRegionKind FLI 328 mti_GetRegionName FLI 341 mti_GetRegionSourceName FLI 344 mti_GetResolutionLimit FLI 348 mti_GetRunStopTime FLI 352 mti_GetSecondaryName FLI 355 mti_GetSignalMode FLI 359 mti_GetSignalName FLI 363 mti GetSignalNamelndirect FLI 367 mti GetSignalRegion FLI 372 mti GetSignalSubelements FLI 376 mti GetSignalType FLI 381 mti GetSignalValue FLI 386 mti GetSignalValueIndirect FLI 392 mti GetTopRegion FLI 399 mti GetTypeKind FLI 404 mti GetVarAddr FLI 408 mti GetVarImage FLI 416 mti GetVarImageBylId FLI 421 mti GetVarName FLI 426 mti GetVarSubelements FLI 431 mti GetVarType FLI 438 mti GetVarValue FLI 442 mti GetVarValueIndirect FLI 449 mti GetWlfFilename FLI 457 mti HigherRegion FLI 459 mti Image FLI 463 mti Interp FLI 467 mti IsColdRestore FLI 470 mti IsFirstInit FLI 473 mti IsRestore FLI 476 mti KeepLoaded FLI 479 mti Malloc FLI 482 mti NextProcess FLI 485 mti NextRegion FLI 489 mti NextSignal FLI 493 mti NextVar FLI 497 mti Now FLI 501 mti NowlIndirect FLI 505 mti NowUpper FLI 510 mti PrintFormatted FLI 514 mti PrintMessage
594. ypeIdT typeid mtiVariableIdT varid varInfoT ModelSim FLI Reference mti GetVarName FLI 427 typedef struct varInfoT var info List of variables mtiProcessIdT proc Test process id instanceInfoT static void checkValues void inst info char region_name char var name NAME MAX instanceInfoT inst data instanceInfoT inst info varlInfoT varinfo mti PrintFormatted Time d d n mti NowUpper mti Now for varinfo inst data var info varinfo varinfo varinfo gt next region name mti GetRegionFullName varinfo regid sprintf var name s s s region name mti GetProcessName varinfo procid varinfo gt name mti PrintFormatted Variable s s n var name mti GetVarImageById varinfo varid mti VsimFree region name mti ScheduleWakeup inst_data gt proc 5 static varInfoT setupVariable mtiVariableIdT varid mtiRegionIdT regid mtiProcessIdT procid varinfoT varinfo varinfo varInfoT mti Malloc sizeof varInfoT varinfo varid varid mti GetVarName varid mti GetVarType varid varinfo regid regid varinfo name varinfo typeid varinfo procid procid varinfo next 0 return varinfo static void initInstance void param instanceInfoT inst data mtiProcessIdT procid mtiRegionIdT regid mtiVariableIdT varid varlInfoT curr info varlInfoT
595. zeof instance_info mti_PrintFormatted mti_SaveBlock Formatted Saving char c n har tmp_char char amp instance info mti Print tmp char mti SaveC mti PrintFormatted Saving long ld n tmp long mti SaveLong tmp long mti PrintFormatted Saving short d n tmp short mti SaveShort tmp short mti PrintFormatted Saving string s n tmp str mti SaveString tmp str Formatted Wn mti Print void restoreCallback void param mti_RestoreBlock mti_PrintFormatted char amp instance info nRestoring instance info s n instance info instance info mti PrintFormatted mti PrintFormatted mti PrintFormatted Restoring Restoring Restoring mti RestoreChar mti RestoreLong mti RestoreShort char cMn long ld n short d n mti PrintFormatted Restoring string s n mti RestoreString mti PrintFormatted Mn void initForeign mtiRegionIdT region The ID of the region in which this Ay foreign architecture is instantiated char param The last part of the string in the J foreign attribute EL mtilnterfaceListT generics mtilnterfaceListT ports instance info strcpy instance info mti AddSaveCB saveCallback mti AddRestoreCB restoreCallback HDL code entity for model is end for model architecture a of for model is attribute foreign of a initFor

Download Pdf Manuals

image

Related Search

Related Contents

APLICACION DE ORDENADORES - RUA  Manual de instruções  EN / ACSM1 Speed and Torque Control Program  超音波噴霧器  User Guide Laboratory Power Supply PS9600-15  MW0691 - CADEIRA VENEZA DESMONTADA  インフォメーション - Panasonic  Visit us at www.axxiommfg.com  design makes objects timeless, fashion corrupts them, fools copy  The Situation - Carnegie Mellon University  

Copyright © All rights reserved.
Failed to retrieve file