![]() |
![]() |
![]() |
![]() |
mti_GetNextEventTime()
Gets the next event time (from a foreign subprogram or callback).
Syntax
status = mti_GetNextEventTime( next_time )Returns
Name Type Description status int A number that indicates which type of events are pending (see below for details)Arguments
Name Type Description next_time mtiTime64T * Returns the time at which the next simulation event will occur (see below for details)Description
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:
Related functions
Example
FLI code
#include <mti.h> static void checkTime( void ) { int status; mtiTime64T next_time; status = mti_GetNextEventTime( &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( "Time [%d,%d]: checkRegion()\n", mti_NowUpper(), mti_Now() ); /* * NOTE: mti_GetNextEventTime() will always return the current * time when called from inside of a VHDL process. */ checkTime(); } static void initInstance( void ) { mtiProcessIdT procid; mtiSignalIdT sigid; sigid = mti_FindSignal( "/top/s1" ); 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 */ /* foreign attribute. */ mtiInterfaceListT *generics, /* A list of generics for the foreign model.*/ mtiInterfaceListT *ports /* A list of ports for the foreign model. */ ) { mti_AddLoadDoneCB( initInstance, 0 ); 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); signal s1 : bit := '0'; begin s1 <= not s1 after 7 ns; finst : for_model; p1 : postponed process begin wait for 15 ns; test_proc; end process; end a;Simulation output
% vsim -c top Reading .../modeltech/sunos5/../tcl/vsim/pref.tcl # 5.4b # vsim -c top # Loading .../modeltech/sunos5/../std.standard # Loading 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
![]() Model Technology Inc. Voice: (503) 641-1340 Fax: (503)526-5410 http://www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |