Table of Contents Previous page Next page Index

ModelSim

Model Technology Inc.


mti_Sensitize()

Sensitizes a VHDL process to a VHDL signal.

Syntax

mti_Sensitize( process_id, signal_id, trigger ) 

Returns

Nothing

Arguments

Name
Type
Description
process_id
mtiProcessIdT
A handle to a VHDL process
signal_id
mtiSignalIdT
A handle to a VHDL signal
trigger
mtiProcessTriggerT
Indicates either event-based or activity- based triggering

Description

mti_Sensitize() causes the specified process to be called when the specified signal is updated. If the trigger parameter is MTI_EVENT, then the process is called when the signal changes value. If the trigger parameter is MTI_ACTIVE, then the process is called whenever the signal is active.

Related functions

mti_CreateProcess()

mti_Desensitize()

mti_ScheduleWakeup()

Example

FLI code

#include <stdlib.h>
#include <mti.h>

typedef struct {
  mtiSignalIdT sigid1;
  mtiSignalIdT sigid2;
} instanceInfoT;

void monitorSignal1( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d]:", mti_NowUpper(), mti_Now() );
  mti_PrintFormatted( "  %s = %s\n", mti_GetSignalName( inst->sigid1 ),
                     mti_SignalImage( inst->sigid1 ) );
}

void monitorSignal2( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d]:", mti_NowUpper(), mti_Now() );
  mti_PrintFormatted( "  %s = %s\n", mti_GetSignalName( inst->sigid2 ),
                     mti_SignalImage( inst->sigid2 ) );
}

void cleanupCallback( void * param )
{
  mti_PrintMessage( "Cleaning up...\n" );
  free( param );
}

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;
  mtiProcessIdT   procid;

  inst         = (instanceInfoT *)malloc( sizeof(instanceInfoT) );

  inst->sigid1 = mti_FindSignal( "/top/s1" );
  procid       = mti_CreateProcess( "s1Monitor", monitorSignal1, inst );
  mti_Sensitize( procid, inst->sigid1, MTI_EVENT );

  inst->sigid2 = mti_FindSignal( "/top/s2" );
  procid       = mti_CreateProcess( "s2Monitor", monitorSignal2, inst );
  mti_Sensitize( procid, inst->sigid2, MTI_ACTIVE );

  mti_AddQuitCB( cleanupCallback, inst );
  mti_AddRestartCB( cleanupCallback, 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;

entity top is
end top;

architecture a of top is

  signal s1 : bit := '0';
  signal s2 : bit := '0';

  component for_model
  end component;

begin

  s1 <= not s1 after 5 ns;

  forinst : for_model;

  p1 : process
    begin
      wait for 2 ns;
      s2 <= '0';
      wait for 5 ns;
      s2 <= '1';
      wait for 3 ns;
      s2 <= '1';
      wait for 4 ns;
      s2 <= '0';
    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 work.top(a)
# Loading work.for_model(a)
# Loading ./for_model.sl
VSIM 1> run 20
# Time [0,0]:  s2 = '0'
# Time [0,0]:  s1 = '0'
# Time [0,2]:  s2 = '0'
# Time [0,5]:  s1 = '1'
# Time [0,7]:  s2 = '1'
# Time [0,10]:  s1 = '0'
# Time [0,10]:  s2 = '1'
# Time [0,14]:  s2 = '0'
# Time [0,15]:  s1 = '1'
# Time [0,16]:  s2 = '0'
# Time [0,20]:  s1 = '0'
VSIM 2> quit
# Cleaning up... 


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

ModelSim