![]() |
![]() |
![]() |
![]() |
mti_AddCommand()
Adds a user-defined simulator command.
Syntax
mti_AddCommand( cmd_name, cmd_func )Returns
Arguments
Description
mti_AddCommand() adds the specified command to the simulator. The case of the command name is significant. The simulator command interpreter subsequently recognizes the command and calls the command function whenever the command is recognized. The entire command line (the command and any arguments) is passed to the command function as a single char * argument. The command function prototype is:
void commandFuncName( char * command )A command can be added with the same name as a previously added command (or even a standard simulator command), but only the command added last has any effect.
Related functions
Example
FLI code
#include <mti.h> void printSigInfo( char * command ) { char * cp; mtiSignalIdT sigid; mti_PrintFormatted( "Time [%d,%d] delta %d:\n", mti_NowUpper(), mti_Now(), mti_Delta() ); mti_PrintFormatted( " Command: %s\n", command ); for ( cp = command; (*cp != ' ') && (*cp != '\0'); cp++ ) { ; } for ( ; (*cp == ' ') && (*cp != '\0'); cp++ ) { ; } if ( *cp == '\0' ) { mti_PrintMessage( " Usage: printSig <signame>\n" ); } else { sigid = mti_FindSignal( cp ); if ( ! sigid ) { mti_PrintFormatted( " Signal %s not found.\n", cp ); } else { switch ( mti_GetTypeKind( mti_GetSignalType( sigid ))) { case MTI_TYPE_SCALAR: case MTI_TYPE_ENUM: case MTI_TYPE_PHYSICAL: mti_PrintFormatted( " Signal %s = %d\n", cp, mti_GetSignalValue( sigid ) ); break; default: mti_PrintFormatted( " The type of signal %s " "is not supported.\n", cp ); break; } } } } 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_AddCommand( "printSig", printSigInfo ); }HDL code
entity top is end top; architecture a of top is signal s1 : bit := '0'; signal s2 : real := 1.0; begin s1 <= not s1 after 5 ns; s2 <= s2 + 1.0 after 5 ns; end a;Simulation output
% vsim -c top -foreign "initForeign for_model.sl" Reading .../modeltech/sunos5/../tcl/vsim/pref.tcl # 5.4b # vsim -foreign {initForeign for_model.sl} -c top # Loading .../modeltech/sunos5/../std.standard # Loading work.top(a) # Loading ./for_model.sl VSIM 1> printSig # Time [0,0] delta 0: # Command: printSig # Usage: printSig <signame> VSIM 2> printSig /top/s2 # Time [0,0] delta 0: # Command: printSig /top/s2 # The type of signal /top/s2 is not supported. VSIM 3> printSig /top/s3 # Time [0,0] delta 0: # Command: printSig /top/s3 # Signal /top/s3 not found. VSIM 4> printSig /top/s1 # Time [0,0] delta 0: # Command: printSig /top/s1 # Signal /top/s1 = 0 VSIM 5> run 5 VSIM 6> printSig /top/s1 # Time [0,5] delta 1: # Command: printSig /top/s1 # Signal /top/s1 = 1 VSIM 7> quit
![]() Model Technology Inc. Voice: (503) 641-1340 Fax: (503)526-5410 http://www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |