Table of Contents Previous page Next page Index

ModelSim

Model Technology Inc.


mti_AskStdin()

Prompts the user for an input string.

Syntax

error_code = mti_AskStdin( buffer, prompt ) 

Returns

Name
Type
Description
error_code
int
-1 if the buffer parameter is NULL; 0 otherwise

Arguments

Name
Type
Description
buffer
char *
A pointer to a character buffer in which the user's input is returned
prompt
char *
A character string that will be used as the prompt to the user

Description

mti_AskStdin() gets input from the user by displaying the specified prompt on the vsim command line and returning what the user types. All characters entered up to, but not including, a newline character are returned in the character buffer. The character string is null-terminated. The caller is responsible for allocating the space for the buffer.

Related functions

None

Example

FLI code

#include <strings.h>
#include <mti.h>

void printSigInfo( char * command )
{
  char         buffer[128];
  int          done = 0;
  mtiSignalIdT sigid;

  while ( ! done ) {
    mti_AskStdin( buffer, "printSigs:" );
    if ( strcasecmp( buffer, "quit" ) == 0 ) {
        done = 1;
    } else {
        sigid = mti_FindSignal( buffer );
        if ( ! sigid ) {
            mti_PrintFormatted( "    Signal %s not found.\n", buffer );
        } 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", buffer,
                                     mti_GetSignalValue( sigid ) );
                  break;
                default:
                  mti_PrintFormatted( "    The type of signal %s "
                                     "is not supported.\n", buffer );
                  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( "printSigs", 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> printSigs
printSigs: /top/s1
/top/s1
#   Signal /top/s1 = 0
printSigs: /top/s2
/top/s2
#   The type of signal /top/s2 is not supported.
printSigs: /top/s3
/top/s3
#   Signal /top/s3 not found.
printSigs: quit
quit
VSIM 2> run 5
VSIM 3> quit 


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

ModelSim