![]() |
![]() |
![]() |
![]() |
mti_RestoreProcess()
Restores a process that was created by mti_CreateProcess().
Syntax
mti_RestoreProcess( process_id, name, func, param )Returns
Arguments
Description
mti_RestoreProcess() restores a process that was created by mti_CreateProcess(). The first parameter is the handle to the process that was returned from the original call to mti_CreateProcess(). The remaining parameters are the same parameters as in the original call to mti_CreateProcess().
mti_RestoreProcess() must be called to restore each process that was created by mti_CreateProcess() as the callback function address may be different after a restore.
Related functions
Example
FLI code
#include <stdlib.h> #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 } 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 = "'0'"; break; case STD_LOGIC_1: retval = "'1'"; break; case STD_LOGIC_Z: 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; 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->sigid ), convertStdLogicValue( sigval ) ); mti_VsimFree( region_name ); switch ( sigval ) { 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_Z; break; case STD_LOGIC_Z: sigval = STD_LOGIC_W; break; case STD_LOGIC_W: sigval = STD_LOGIC_L; break; case STD_LOGIC_L: sigval = STD_LOGIC_H; break; 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->drvid, sigval, 5, MTI_INERTIAL ); } void saveCallback( void * param ) { mti_SaveBlock( &inst_info, sizeof(inst_info) ); } void restoreCallback( void * param ) { mti_RestoreBlock( &inst_info ); mti_RestoreProcess(inst_info->procid, "sigDriver", driveSignal, inst_info); } 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() ) { inst_info = (instanceInfoT *)mti_Malloc( sizeof(instanceInfoT) ); inst_info->sigid = mti_FindSignal( "/top/s1" ); inst_info->drvid = mti_CreateDriver( inst_info->sigid ); inst_info->procid = mti_CreateProcess( "sigDriver", 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.all; entity top is end top; architecture a of top is signal s1 : std_logic := '0'; component for_model is end component; for all : for_model use entity work.for_model(a); begin i1 : for_model; end a;Simulation output
% vsim -c top Reading .../modeltech/sunos5/../tcl/vsim/pref.tcl # 5.4b # vsim -c top # Loading .../modeltech/sunos5/../std.standard # Loading .../modeltech/sunos5/../ieee.std_logic_1164(body) # Loading work.top(a) # Loading work.for_model(a) # Loading ./for_model.sl VSIM 1> run 30 # Time [0,0] delta 0: Signal /top/s1 is '0' # Time [0,5] delta 0: Signal /top/s1 is '1' # Time [0,10] delta 0: Signal /top/s1 is 'Z' # Time [0,15] delta 0: Signal /top/s1 is 'W' # Time [0,20] delta 0: Signal /top/s1 is 'L' # Time [0,25] delta 0: Signal /top/s1 is 'H' # Time [0,30] delta 0: Signal /top/s1 is '-' VSIM 2> checkpoint cpfile VSIM 3> run 20 # Time [0,35] delta 0: Signal /top/s1 is 'U' # Time [0,40] delta 0: Signal /top/s1 is 'X' # Time [0,45] delta 0: Signal /top/s1 is '0' # Time [0,50] delta 0: Signal /top/s1 is '1' VSIM 4> restore cpfile # Loading checkpoint/restore data from file "cpfile" # Checkpoint created Fri Jul 7 16:48:29 2000 # Restoring state at time 30 ns, iteration 1 VSIM 5> run 25 # Time [0,35] delta 0: Signal /top/s1 is 'U' # Time [0,40] delta 0: Signal /top/s1 is 'X' # Time [0,45] delta 0: Signal /top/s1 is '0' # Time [0,50] delta 0: Signal /top/s1 is '1' # Time [0,55] delta 0: Signal /top/s1 is 'Z' VSIM 6> quit
![]() Model Technology Inc. Voice: (503) 641-1340 Fax: (503)526-5410 http://www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |