![]() |
![]() |
![]() |
![]() |
mti_IsFirstInit()
Detects the first call to the initialization function.
Syntax
status = mti_IsFirstInit()Returns
Name Type Description status int 1 during the first call to the initialization function; 0 otherwiseArguments
Description
mti_IsFirstInit() returns 1 during the first call to the initialization function or 0 if the simulation has been restarted.
Related functions
Example
FLI code
#include <stdlib.h> #include <mti.h> 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 initForeign( mtiRegionIdT region, /* The ID of the region in which this */ /* foreign architecture is instantiated. */ char *param, /* The last part of the string in the */ /* foreign attribute. */ mtiInterfaceListT *generics, /* A list of generics for the foreign model.*/ mtiInterfaceListT *ports /* A list of ports for the foreign model. */ ) { if ( mti_IsFirstInit() ) { mti_PrintMessage( "\nFirst 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 ); } 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 s1 : bit := '0'; component for_model is end component; for all : for_model use entity work.for_model(a); begin i1 : for_model; s1 <= not s1 after 5 ns; end a;Simulation output
% vsim -c top Reading .../modeltech/sunos5/../tcl/vsim/pref.tcl # 5.4b # vsim -c top # Loading .../modeltech/sunos5/../std.standard # Loading 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_global = 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
![]() Model Technology Inc. Voice: (503) 641-1340 Fax: (503)526-5410 http://www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |