Table of Contents Previous page Next page Index

ModelSim

Model Technology Inc.


mti_RestoreString()

Gets a null-terminated string from the checkpoint file.

Syntax

value = mti_RestoreString() 

Returns

Name
Type
Description
value
char *
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.

Related functions

mti_RestoreBlock()

mti_RestoreChar()

mti_RestoreLong()

mti_RestoreProcess()

mti_RestoreShort()

mti_SaveBlock()

mti_SaveChar()

mti_SaveLong()

mti_SaveShort()

mti_SaveString()

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
TOC PREV NEXT INDEX

ModelSim