Table of Contents Previous page Next page Index

ModelSim

Model Technology Inc.


mti_KeepLoaded()

Requests that the current shared library not be unloaded on restart or load of a new design.

Syntax

mti_KeepLoaded() 

Returns

Nothing

Arguments

None

Description

mti_KeepLoaded() marks the current shared library as not to be reloaded when a restart or load of a new design occurs. mti_KeepLoaded() must be called from the initialization function of a foreign architecture.

Normally, the reloading of shared libraries is determined by the following:

Related functions

None

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 restartCallback( void * param )
{
  mti_PrintMessage( "\nRestart callback:\n" );
  mti_PrintFormatted( "  Param is \"%s\"\n", param );
  mti_PrintFormatted( "  test_global = %d\n", test_global );
  test_global = 15;
  mti_PrintFormatted( "  Setting test_global to initial value of %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 );
    mti_PrintFormatted( "  Shared library will NOT be reloaded.\n" );
    mti_KeepLoaded();
    instance_info = malloc( strlen(param) + 1 );
    strcpy( instance_info, param );
  } 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 );
  }
  mti_AddQuitCB( cleanupCallback, instance_info );
  mti_AddRestartCB( restartCallback, 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
#   Shared library will NOT be reloaded.
VSIM 1> run 30
VSIM 2> restart -f
# 
# Restart callback:
#   Param is "for_model"
#   test_global = 42
#   Setting test_global to initial value of 15
# 
# Simulation has been restarted.
#   test_global = 15
#   Setting test_global to 3
VSIM 3> run 100
VSIM 4> restart -f
# 
# Restart callback:
#   Param is "for_model"
#   test_global = 3
#   Setting test_global to initial value of 15
# 
# Simulation has been restarted.
#   test_global = 15
#   Setting test_global to 3
VSIM 5> 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
TOC PREV NEXT INDEX

ModelSim