Table of Contents Previous page Next page Index

ModelSim

Model Technology Inc.


mti_AddEnvCB()

Adds an environment change callback.

Syntax

mti_AddEnvCB( func, param ) 

Returns

Nothing

Arguments

Name
Type
Description
func
mtiEnvCBFuncPtrT
A pointer to a function to be called whenever the simulation environment changes
param
void *
A parameter to be passed to the function; OPTIONAL - can be NULL

Description

mti_AddEnvCB() adds the specified function to the simulator environment change callback list. The same function can be added multiple times, with possibly a different parameter each time. Whenever the simulator environment changes (for example, when the environment command is used), all callbacks in this list are called with their respective parameters plus a second parameter that is a pointer to the current context.

Related functions

mti_RemoveEnvCB()

Example

FLI code

#include <mti.h>
void envCallback( void * param, void * context )
{
  mtiRegionIdT region = (mtiRegionIdT)param;

  mti_PrintFormatted( "Foreign Arch in Region %s: "
                      "the current region is now %s.\n",
                      mti_GetRegionName( region ),
                      mti_GetRegionName( mti_GetCurrentRegion() ) );
}

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_AddEnvCB( envCallback, region );
} 

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;

entity bottom is
end bottom;

architecture b of bottom is
begin
end b;

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);

  component bottom is
  end component;

begin

  bot : bottom;

  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.bottom(b)
# Loading work.for_model(a)
# Loading ./for_model.sl
# Foreign Arch in Region i1: the current region is now top.
VSIM 1> env /top
# sim:/top
VSIM 2> env /top/i1
# Foreign Arch in Region i1: the current region is now i1.
# sim:/top/i1
VSIM 3> env /top/bot
# Foreign Arch in Region i1: the current region is now bot.
# sim:/top/bot
VSIM 4> env /top
# Foreign Arch in Region i1: the current region is now top.
# sim:/top
VSIM 5> quit 


Model Technology Inc.
Voice: (503) 641-1340
Fax: (503)526-5410
http://www.model.com
sales@model.com
TOC PREV NEXT INDEX

ModelSim