Table of Contents Previous page Next page Index

ModelSim

Model Technology Inc.


mti_Delta()

Gets the simulator iteration count for the current time step.

Syntax

delta = mti_Delta() 

Returns

Name
Type
Description
delta
mtiUInt32T
The simulator iteration count for the current time step

Arguments

None

Description

mti_Delta() returns the simulator iteration count for the current time step.

Related functions

mti_Now()

mti_NowIndirect()

mti_NowUpper()

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;

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 monitorSignal( void * param )
{
  char         * region_name;
  mtiSignalIdT   sigid = (mtiSignalIdT)param;
  mtiInt32T      sigval;

  region_name = mti_GetRegionFullName( mti_GetSignalRegion( sigid ) );
  sigval = mti_GetSignalValue( sigid );
  mti_PrintFormatted( "Time [%d,%d] delta %d: Signal %s/%s is %s\n",
                     mti_NowUpper(), mti_Now(), mti_Delta(),
                     region_name, mti_GetSignalName( sigid ),
                     convertStdLogicValue( sigval ) );
  mti_VsimFree( region_name );
}

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.   */
)
{
  mtiProcessIdT   procid;
  mtiSignalIdT    sigid;

  sigid  = mti_FindSignal( "/top/s1" );
  procid = mti_CreateProcess( "sigMonitor", monitorSignal, sigid );
  mti_Sensitize( procid, sigid, MTI_EVENT );
} 

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

  i1 : for_model;

  p1 : process
  begin
    s1 <= '1';
    wait for 5 ns;
    s1 <= '0';
    wait for 0 ns;
    s1 <= '1';
    wait for 0 ns;
    s1 <= '0';
    wait for 5 ns;
  end process;

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 20
# Time [0,0] delta 0: Signal /top/s1 is '0'
# Time [0,0] delta 1: Signal /top/s1 is '1'
# Time [0,5] delta 1: Signal /top/s1 is '0'
# Time [0,5] delta 2: Signal /top/s1 is '1'
# Time [0,5] delta 3: Signal /top/s1 is '0'
# Time [0,10] delta 1: Signal /top/s1 is '1'
# Time [0,15] delta 1: Signal /top/s1 is '0'
# Time [0,15] delta 2: Signal /top/s1 is '1'
# Time [0,15] delta 3: Signal /top/s1 is '0'
# Time [0,20] delta 1: Signal /top/s1 is '1'
VSIM 2> quit 


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

ModelSim