Technical data
Support for Verilog instances
ModelSim EE/PLUS Reference Manual VHDL Foreign Language Interface and Verilog PLI
-
465
} else if (mti_IsFirstInit()) {
ip = (inst_rec *)mti_Malloc(sizeof(inst_rec));
/* malloc changed to mti_Malloc */
ip->in1 = mti_FindPort(ports, "in1");
ip->in2 = mti_FindPort(ports, "in2");
outp = mti_FindPort(ports, "out1");
ip->out1 = mti_CreateDriver(outp);
proc = mti_CreateProcess("p1", do_and, ip);
mti_Sensitize(proc, ip->in1, MTI_EVENT);
mti_Sensitize(proc, ip->in2, MTI_EVENT);
} else {
/* do whatever you might want to do for restart */
/*...*/
}
mti_AddSaveCB(mti_SaveLong, ip); /* new */
mti_AddSaveCB(mti_SaveLong, proc); /* new */
mti_AddRestartCB(mti_Free, ip);
/* free changed to mti_Free */
}
/* ------------------------------------------- */
The above example displays the following features:
• Malloc and free calls have been replaced by mti_Malloc and mti_Free.
• Call-backs are added using mti_AddSaveCB to save the ip and proc pointers.
• The mti_IsRestore() flag is checked for restore.
• When a restore is being done, mti_RestoreLong() is used to restore the ip and
proc pointers.
• mti_RestoreProcess() is used to update mti_CreateProcess with the possibly
new address of the do_and() function. (This is in case the foreign code gets
loaded into a different memory location.)
• All call-backs are added on first init and on restore. The restore does not restore
call-backs, because the routines might be located at different places after the
restore operation.
Support for Verilog instances
VSIM FLI functions are designed to work with VHDL designs and VHDL
objects. However, these routines can also be used on the Verilog instances in a
mixed VHDL/Verilog design. In addition, the routines for traversing the design
hierarchy also recognize Verilog instances.
The following functions operate on Verilog instances as follows: