![]() |
![]() |
![]() |
![]() |
mti_RestoreBlock()
Gets a block of data from the checkpoint file.
Syntax
mti_RestoreBlock( ptr )Returns
Arguments
Name Type Description ptr char * A pointer to the place where the block of data is to be restoredDescription
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 by the corresponding mti_SaveBlock() call.
Related functions
Example
FLI code
#include <stdlib.h> #include <mti.h> 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( "\nSaving instance info \"%s\"\n", instance_info ); mti_SaveBlock( &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( "\n" ); } void restoreCallback( void * param ) { mti_RestoreBlock( &instance_info ); mti_PrintFormatted( "\nRestoring instance info \"%s\"\n", instance_info ); mti_PrintFormatted( "Restoring char %c\n", mti_RestoreChar() ); mti_PrintFormatted( "Restoring long %ld\n", mti_RestoreLong() ); mti_PrintFormatted( "Restoring short %d\n", mti_RestoreShort() ); mti_PrintFormatted( "Restoring string %s\n", mti_RestoreString() ); mti_PrintFormatted( "\n" ); } 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. */ ) { instance_info = mti_Malloc( strlen(param) + 1 ); strcpy( instance_info, param ); mti_AddSaveCB( saveCallback, instance_info ); mti_AddRestoreCB( restoreCallback, 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 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 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
![]() Model Technology Inc. Voice: (503) 641-1340 Fax: (503)526-5410 http://www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |