![]() |
![]() |
![]() |
![]() |
mti_VsimFree()
Frees simulator-allocated memory.
Syntax
mti_VsimFree( pointer )Returns
Arguments
Name Type Description pointer void * A pointer to memory previously allocated with malloc() by an FLI functionDescription
mti_VsimFree() returns the specified block of memory allocated with malloc() by an FLI function to the general memory pool.
mti_VsimFree() can be used neither for memory allocated by calls to mti_Malloc() nor for memory allocated with malloc() by a user-written application.
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 { mtiSignalIdT sigid; mtiProcessIdT procid; } instanceInfoT; 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 watchSignal( 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 ); if ( mti_Now() >= 30 ) { mti_PrintMessage( "Turning off signal watcher.\n" ); mti_Free( inst ); } else { mti_ScheduleWakeup( inst->procid, 5 ); } } 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. */ ) { instanceInfoT * inst; inst = (instanceInfoT *) mti_Malloc( sizeof(instanceInfoT) ); inst->sigid = mti_FindSignal( "/top/s1" ); inst->procid = mti_CreateProcess( "sigWatcher", watchSignal, inst ); }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 s1 <= not s1 after 5 ns; 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 50 # 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 '0' # Time [0,15] delta 0: Signal /top/s1 is '1' # Time [0,20] delta 0: Signal /top/s1 is '0' # Time [0,25] delta 0: Signal /top/s1 is '1' # Time [0,30] delta 0: Signal /top/s1 is '0' # Turning off signal watcher. VSIM 2> quit
![]() Model Technology Inc. Voice: (503) 641-1340 Fax: (503)526-5410 http://www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |