![]() |
![]() |
![]() |
![]() |
mti_SetDriverOwner()
Sets the owning process of a driver.
Syntax
mti_SetDriverOwner( driver_id, process_id )Returns
Arguments
Name Type Description driver_id mtiDriverIdT A handle to a VHDL driver process_id mtiProcessIdT A handle to a VHDL processDescription
mti_SetDriverOwner() makes the specified process the owner of the specified driver.
Normally, mti_CreateDriver() makes the <foreign_architecture> process the owner of a new driver. When using mti_CreateDriver() it is necessary to follow up with a call to mti_SetDriverOwner(); otherwise, the "drivers" command and the Dataflow window may give unexpected or incorrect information regarding FLI-created drivers.
Related functions
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 } mySigType; char *std_logic_lits[9] = { "'U'", "'X'", "'0'", "'1'", "'Z'", "'W'", "'L'", "'H'", "'-'" }; typedef struct { mtiSignalIdT sigid1; mtiSignalIdT sigid2; mtiDriverIdT drvid1; mtiDriverIdT drvid2; } instanceInfoT; /* This function inverts mySig1 every 5 ns. */ void driveSignal1( void * param ) { char * region_name; instanceInfoT * inst = (instanceInfoT*)param; mtiInt32T sigval; sigval = mti_GetSignalValue( inst->sigid1 ); switch ( sigval ) { case STD_LOGIC_U: mti_ScheduleDriver( inst->drvid1, STD_LOGIC_0, 0, MTI_INERTIAL ); break; case STD_LOGIC_0: mti_ScheduleDriver( inst->drvid1, STD_LOGIC_1, 5, MTI_INERTIAL ); break; case STD_LOGIC_1: mti_ScheduleDriver( inst->drvid1, STD_LOGIC_0, 5, MTI_INERTIAL ); break; case STD_LOGIC_X: region_name = mti_GetRegionFullName(mti_GetSignalRegion(inst->sigid1)); mti_PrintFormatted( "Time [%d,%d] delta %d: Signal %s/%s is UNKNOWN\n", mti_NowUpper(), mti_Now(), mti_Delta(), region_name, mti_GetSignalName( inst->sigid1 ) ); mti_VsimFree( region_name ); break; default: region_name = mti_GetRegionFullName(mti_GetSignalRegion(inst->sigid1)); mti_PrintFormatted( "Time [%d,%d] delta %d: " "Unexpected value %d on signal %s/%s\n", mti_NowUpper(), mti_Now(), mti_Delta(), sigval, region_name, mti_GetSignalName( inst->sigid1 ) ); mti_VsimFree( region_name ); break; } } /* This function inverts mySig2 every 10 ns. */ void driveSignal2( void * param ) { char * region_name; instanceInfoT * inst = (instanceInfoT*)param; mtiInt32T sigval; sigval = mti_GetSignalValue( inst->sigid2 ); switch ( sigval ) { case STD_LOGIC_U: mti_ScheduleDriver( inst->drvid2, STD_LOGIC_0, 0, MTI_INERTIAL ); break; case STD_LOGIC_0: mti_ScheduleDriver( inst->drvid2, STD_LOGIC_1, 10, MTI_INERTIAL ); break; case STD_LOGIC_1: mti_ScheduleDriver( inst->drvid2, STD_LOGIC_0, 10, MTI_INERTIAL ); break; case STD_LOGIC_X: region_name = mti_GetRegionFullName(mti_GetSignalRegion(inst->sigid2)); mti_PrintFormatted( "Time [%d,%d] delta %d: Signal %s/%s is UNKNOWN\n", mti_NowUpper(), mti_Now(), mti_Delta(), region_name, mti_GetSignalName( inst->sigid2 ) ); mti_VsimFree( region_name ); break; default: region_name = mti_GetRegionFullName(mti_GetSignalRegion(inst->sigid2)); mti_PrintFormatted( "Time [%d,%d] delta %d: " "Unexpected value %d on signal %s/%s\n", mti_NowUpper(), mti_Now(), mti_Delta(), sigval, region_name, mti_GetSignalName( inst->sigid2 ) ); mti_VsimFree( region_name ); break; } } 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; mtiTypeIdT enum_type; inst = (instanceInfoT *)malloc( sizeof(instanceInfoT) ); enum_type = mti_CreateEnumType( 1, 9, std_logic_lits ); inst->sigid1 = mti_CreateSignal( "mySig1", region, enum_type ); inst->drvid1 = mti_CreateDriver( inst->sigid1 ); procid = mti_CreateProcess( "mySig1Driver", driveSignal1, inst ); mti_Sensitize( procid, inst->sigid1, MTI_EVENT ); mti_SetDriverOwner( inst->drvid1, procid ); inst->sigid2 = mti_CreateSignal( "mySig2", region, enum_type ); inst->drvid2 = mti_CreateDriver( inst->sigid2 ); procid = mti_CreateProcess( "mySig2Driver", driveSignal2, inst ); mti_Sensitize( procid, inst->sigid2, MTI_EVENT ); /* Not setting driver owner for driver 2. */ 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'; component for_model end component; begin s1 <= not s1 after 5 ns; forinst : for_model; 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 5 VSIM 2> drivers /top/forinst/mySig1 # Drivers for /top/forinst/mysig1: # 1 : Signal /top/forinst/mysig1 # 1 : Driver /top/forinst/mySig1Driver # 0 at 10 ns # VSIM 3> drivers /top/forinst/mySig2 # Drivers for /top/forinst/mysig2: # 0 : Signal /top/forinst/mysig2 # 0 : Driver /top/forinst/<foreign_architecture> # 1 at 10 ns # VSIM 4> quit # Cleaning up...
![]() Model Technology Inc. Voice: (503) 641-1340 Fax: (503)526-5410 http://www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |