Table of Contents Previous page Next page Index

ModelSim

Model Technology Inc.


mti_CreateProcessWithPriority()

Creates a new VHDL process with a specific priority.

Syntax

process_id = mti_CreateProcessWithPriority( name, func, param, priority ) 

Returns

Name
Type
Description
process_id
mtiProcessIdT
A handle to the new VHDL process or NULL if there is an error

Arguments

Name
Type
Description
name
char *
The name of the new VHDL process; OPTIONAL - can be NULL
func
mtiVoidFuncPtrT
A pointer to the function that will be executed as the body of the new process
param
void *
A parameter to be passed to the function; OPTIONAL - can be NULL
priority
mtiProcessPriorityT
The priority of the new process: immediate, normal, synch, NBA, or postponed

Description

mti_CreateProcessWithPriority() creates a new VHDL process with the specified name and priority. If the name is non-NULL, then it appears in the simulator's Process window; otherwise, it does not. The specified function is called along with its parameter whenever the process executes. The process executes either at the time specified in a call to mti_ScheduleWakeup() or whenever one of the signals to which it is sensitive changes (mti_Sensitize()).

The priority of the process can be one of the following:

MTI_PROC_IMMEDIATE
All immediate processes run immediately after signal activation (if triggered). If any immediate process activates any signals, then the signals are reevaluated and all immediate processes (if triggered) are run again in the same delta. This cycle continues until no more signals are activated.
MTI_PROC_NORMAL
Normal processes run (when triggered) after all immediate processes have run and settled. They can run once per delta and can schedule events in zero delay.
MTI_PROC_SYNCH
Synchronized processes (when triggered) run after immediate and normal processes, but before NBA processes. They can run once per delta and can schedule events in zero delay.
MTI_PROC_NBA
Non-Blocking Assignment processes (when triggered) run after synchronized processes, but before postponed processes. They can run once per delta and can schedule events in zero delay.
MTI_PROC_POSTPONED
Postponed processes (when triggered) run once at the end of the time step for which they are scheduled after all immediate, normal, synchronized, and NBA processes. They cannot schedule anything in zero delay. (In Verilog, these types of processes are also known as read-only synchronization processes or $monitor() processes.)

If the process is created during elaboration from inside of a foreign architecture instance, then the process is automatically executed once at time zero. If the process is created either after elaboration is complete or from any other context (such as from an initialization function that executes as a result of the loading of a foreign shared library by the -foreign option to vsim), then the process is not run automatically but must be scheduled or sensitized.

Related functions

mti_CreateProcess()

mti_Desensitize()

mti_GetProcessName()

mti_ScheduleWakeup()

mti_Sensitize()

Example

FLI code

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

typedef struct {
  mtiProcessIdT immed_procid[5];
  mtiProcessIdT normal_procid[5];
  mtiProcessIdT synch_procid[5];
  mtiProcessIdT nba_procid[5];
  mtiProcessIdT postponed_procid[5];
  mtiSignalIdT  sig02;
} instanceInfoT;

void scheduleProcesses( instanceInfoT * inst, int i, mtiDelayT delay )
{
  mti_ScheduleWakeup( inst->immed_procid[i],     delay );
  mti_ScheduleWakeup( inst->normal_procid[i],    delay );
  mti_ScheduleWakeup( inst->synch_procid[i],     delay );
  mti_ScheduleWakeup( inst->nba_procid[i],       delay );
  mti_ScheduleWakeup( inst->postponed_procid[i], delay );
}

/* Main test process */

void testProcess( instanceInfoT * inst )
{
  mtiInt32T sigval;
  mti_PrintFormatted( "\nTime [%d,%d] delta %d: testProcess()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
  scheduleProcesses( inst, 0, 0 );
  /* Test immediate activation of immediate process. */
  sigval = mti_GetSignalValue( inst->sig02 );
  if ( sigval == 0 ) {
    sigval = 1;
  } else {
    sigval = 0;
  }
  mti_SetSignalValue( inst->sig02, (long)sigval );
}

/* Immediate process sensitive to a signal in zero-delay */

void sigImmedProc( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: sigImmedProc()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

/* Processes scheduled by testProcess() */

void immedProcess1( void * param )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: immedProcess1()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void normalProcess1( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: normalProcess1():     "
                     "Scheduling processes ending in 2\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
  scheduleProcesses( inst, 1, 0 );
}

void synchProcess1( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: synchProcess1():      "
                     "Scheduling processes ending in 3\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
  scheduleProcesses( inst, 2, 0 );
}

void nbaProcess1( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: nbaProcess1():            "
                     "Scheduling processes ending in 4\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
  scheduleProcesses( inst, 3, 0 );
}

void postponedProcess1( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: postponedProcess1(): "
                   "Scheduling processes ending in 5\n",
                   mti_NowUpper(), mti_Now(), mti_Delta() );
  scheduleProcesses( inst, 4, 1 );
}

/* Processes scheduled by normalProcess1() */

void immedProcess2( void * param )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: immedProcess2()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void normalProcess2( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: normalProcess2()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void synchProcess2( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: synchProcess2()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void nbaProcess2( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: nbaProcess2()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void postponedProcess2( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: postponedProcess2()\n",
                       mti_NowUpper(), mti_Now(), mti_Delta() );
}

/* Processes scheduled by synchProcess1() */

void immedProcess3( void * param )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: immedProcess3()\n",
                      mti_NowUpper(), mti_Now(), mti_Delta() );
}

void normalProcess3( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: normalProcess3()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void synchProcess3( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: synchProcess3()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void nbaProcess3( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: nbaProcess3()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void postponedProcess3( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: postponedProcess3()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

/* Processes scheduled by nbaProcess1() */

void immedProcess4( void * param )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: immedProcess4()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void normalProcess4( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: normalProcess4()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void synchProcess4( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: synchProcess4()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void nbaProcess4( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: nbaProcess4()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void postponedProcess4( instanceInfoT * inst )
{ 
  mti_PrintFormatted( "Time [%d,%d] delta %d: postponedProcess4()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

/* Processes scheduled by postponedProcess1() */

void immedProcess5( void * param )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: immedProcess5()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void normalProcess5( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: normalProcess5()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void synchProcess5( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: synchProcess5()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void nbaProcess5( instanceInfoT * inst )
{
  mti_PrintFormatted( "Time [%d,%d] delta %d: nbaProcess5()\n",
                     mti_NowUpper(), mti_Now(), mti_Delta() );
}

void postponedProcess5( instanceInfoT * inst )
{
mti_PrintFormatted( "Time [%d,%d] delta %d: postponedProcess5()\n",
                   mti_NowUpper(), mti_Now(), mti_Delta() );
}

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.   */
)
{
  char          * immed_name;
  char          * normal_name;
  char          * synch_name;
  char          * nba_name;
  char          * postponed_name;
  instanceInfoT * inst;
  int             i;
  mtiProcessIdT   procid;
  mtiSignalIdT    sigid;
  mtiVoidFuncPtrT immed_func;
  mtiVoidFuncPtrT normal_func;
  mtiVoidFuncPtrT synch_func;
  mtiVoidFuncPtrT nba_func;
  mtiVoidFuncPtrT postponed_func;

  inst   = (instanceInfoT *)malloc( sizeof(instanceInfoT) );
  sigid  = mti_FindSignal( "/top/s1" );
  procid = mti_CreateProcessWithPriority( "TestProcess", testProcess,
                                         inst, MTI_PROC_IMMEDIATE );
  mti_Sensitize( procid, sigid, MTI_EVENT );

  inst->sig02 = mti_FindSignal( "/top/s2" );
  procid = mti_CreateProcessWithPriority( "sigImmedProc", sigImmedProc,
                                         inst, MTI_PROC_IMMEDIATE );
  mti_Sensitize( procid, inst->sig02, MTI_EVENT );

  for ( i = 0; i < 5; i++ ) {
    switch ( i ) {
      case 0:
        immed_func     = immedProcess1;
        normal_func    = normalProcess1;
        synch_func     = synchProcess1;
        nba_func       = nbaProcess1;
        postponed_func = postponedProcess1;
        immed_name     = "immedProcess1";
        normal_name    = "normalProcess1";
        synch_name     = "synchProcess1";
        nba_name       = "nbaProcess1";
        postponed_name = "postponedProcess1";
        break;
      case 1:
        immed_func     = immedProcess2;
        normal_func    = normalProcess2;
        synch_func     = synchProcess2;
        nba_func       = nbaProcess2;
        postponed_func = postponedProcess2;
        immed_name     = "immedProcess2";
        normal_name    = "normalProcess2";
        synch_name     = "synchProcess2";
        nba_name       = "nbaProcess2";
        postponed_name = "postponedProcess2";
        break;
      case 2:
        immed_func     = immedProcess3;
        normal_func    = normalProcess3;
        synch_func     = synchProcess3;
        nba_func       = nbaProcess3;
        postponed_func = postponedProcess3;
        immed_name     = "immedProcess3";
        normal_name    = "normalProcess3";
        synch_name     = "synchProcess3";
        nba_name       = "nbaProcess3";
        postponed_name = "postponedProcess3";
        break;
      case 3:
        immed_func     = immedProcess4;
        normal_func    = normalProcess4;
        synch_func     = synchProcess4;
        nba_func       = nbaProcess4;
        postponed_func = postponedProcess4;
        immed_name     = "immedProcess4";
        normal_name    = "normalProcess4";
        synch_name     = "synchProcess4";
        nba_name       = "nbaProcess4";
        postponed_name = "postponedProcess4";
        break;
      case 4:
        immed_func     = immedProcess5;
        normal_func    = normalProcess5;
        synch_func     = synchProcess5;
        nba_func       = nbaProcess5;
        postponed_func = postponedProcess5;
        immed_name     = "immedProcess5";
        normal_name    = "normalProcess5";
        synch_name     = "synchProcess5";
        nba_name       = "nbaProcess5";
        postponed_name = "postponedProcess5";
        break;
    }
    inst->immed_procid[i]  = mti_CreateProcessWithPriority( immed_name,
                                                      immed_func, inst,
                                                      MTI_PROC_IMMEDIATE );
    inst->normal_procid[i] = mti_CreateProcessWithPriority( normal_name,
                                                      normal_func, inst,
                                                      MTI_PROC_NORMAL );
    inst->synch_procid[i]  = mti_CreateProcessWithPriority( synch_name,
                                                      synch_func, inst,
                                                      MTI_PROC_SYNCH );
    inst->nba_procid[i]    = mti_CreateProcessWithPriority( nba_name,
                                                      nba_func, inst,
                                                      MTI_PROC_NBA );
    inst->postponed_procid[i] = mti_CreateProcessWithPriority
    ( postponed_name, postponed_func, inst, MTI_PROC_POSTPONED );
  }
  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 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.4

# vsim -c top 
# Loading .../modeltech/sunos5/../std.standard
# Loading work.top(a)
# Loading work.for_model(a)
# Loading ./for_model.sl
VSIM 1> run 8
# Time [0,0] delta 0: nbaProcess5()
# Time [0,0] delta 0: synchProcess5()
# Time [0,0] delta 0: normalProcess5()
# Time [0,0] delta 0: immedProcess5()
# Time [0,0] delta 0: nbaProcess4()
# Time [0,0] delta 0: synchProcess4()
# Time [0,0] delta 0: normalProcess4()
# Time [0,0] delta 0: immedProcess4()
# Time [0,0] delta 0: nbaProcess3()
# Time [0,0] delta 0: synchProcess3()
# Time [0,0] delta 0: normalProcess3()
# Time [0,0] delta 0: immedProcess3()
# Time [0,0] delta 0: nbaProcess2()
# Time [0,0] delta 0: synchProcess2()
# Time [0,0] delta 0: normalProcess2()
# Time [0,0] delta 0: immedProcess2()
# Time [0,0] delta 0: nbaProcess1():       Scheduling processes ending in 4
# Time [0,0] delta 0: synchProcess1():     Scheduling processes ending in 3
# Time [0,0] delta 0: normalProcess1():    Scheduling processes ending in 2
# Time [0,0] delta 0: immedProcess1()
# Time [0,0] delta 0: sigImmedProc()
# 
# Time [0,0] delta 0: testProcess()
# Time [0,0] delta 0: postponedProcess5()
# Time [0,0] delta 0: postponedProcess4()
# Time [0,0] delta 0: postponedProcess3()
# Time [0,0] delta 0: postponedProcess2()
# Time [0,0] delta 0: postponedProcess1(): Scheduling processes ending in 5
# Time [0,0] delta 1: sigImmedProc()
# Time [0,0] delta 1: immedProcess4()
# Time [0,0] delta 1: immedProcess3()
# Time [0,0] delta 1: immedProcess2()
# Time [0,0] delta 1: immedProcess1()
# Time [0,0] delta 1: normalProcess4()
# Time [0,0] delta 1: normalProcess3()
# Time [0,0] delta 1: normalProcess2()
# Time [0,0] delta 1: normalProcess1():    Scheduling processes ending in 2
# Time [0,0] delta 2: immedProcess2()
# Time [0,0] delta 2: normalProcess2()
# Time [0,0] delta 2: synchProcess4()
# Time [0,0] delta 2: synchProcess3()
# Time [0,0] delta 2: synchProcess2()
# Time [0,0] delta 2: synchProcess1():     Scheduling processes ending in 3
# Time [0,0] delta 3: immedProcess3()
# Time [0,0] delta 3: normalProcess3()
# Time [0,0] delta 3: synchProcess3()
# Time [0,0] delta 3: nbaProcess4()
# Time [0,0] delta 3: nbaProcess3()
# Time [0,0] delta 3: nbaProcess2()
# Time [0,0] delta 3: nbaProcess1():       Scheduling processes ending in 4
# Time [0,0] delta 4: immedProcess4()
# Time [0,0] delta 4: normalProcess4()
# Time [0,0] delta 4: synchProcess4()
# Time [0,0] delta 4: nbaProcess4()
# Time [0,0] delta 4: postponedProcess4()
# Time [0,0] delta 4: postponedProcess3()
# Time [0,0] delta 4: postponedProcess2()
# Time [0,0] delta 4: postponedProcess1(): Scheduling processes ending in 5
# Time [0,1] delta 0: immedProcess5()
# Time [0,1] delta 0: normalProcess5()
# Time [0,1] delta 0: synchProcess5()
# Time [0,1] delta 0: nbaProcess5()
# Time [0,1] delta 0: postponedProcess5()
# 
# Time [0,5] delta 0: testProcess()
# Time [0,5] delta 0: sigImmedProc()
# Time [0,5] delta 1: immedProcess1()
# Time [0,5] delta 1: normalProcess1():    Scheduling processes ending in 2
# Time [0,5] delta 2: immedProcess2()
# Time [0,5] delta 2: normalProcess2()
# Time [0,5] delta 2: synchProcess2()
# Time [0,5] delta 2: synchProcess1():     Scheduling processes ending in 3
# Time [0,5] delta 3: immedProcess3()
# Time [0,5] delta 3: normalProcess3()
# Time [0,5] delta 3: synchProcess3()
# Time [0,5] delta 3: nbaProcess3()
# Time [0,5] delta 3: nbaProcess2()
# Time [0,5] delta 3: nbaProcess1():       Scheduling processes ending in 4
# Time [0,5] delta 4: immedProcess4()
# Time [0,5] delta 4: normalProcess4()
# Time [0,5] delta 4: synchProcess4()
# Time [0,5] delta 4: nbaProcess4()
# Time [0,5] delta 4: postponedProcess4()
# Time [0,5] delta 4: postponedProcess3()
# Time [0,5] delta 4: postponedProcess2()
# Time [0,5] delta 4: postponedProcess1(): Scheduling processes ending in 5
# Time [0,6] delta 0: immedProcess5()
# Time [0,6] delta 0: normalProcess5()
# Time [0,6] delta 0: synchProcess5()
# Time [0,6] delta 0: nbaProcess5()
# Time [0,6] delta 0: postponedProcess5()
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