| Customize Help

Developing a user-defined MIL function to run the primitive function



Although creating a primitive function that calls the appropriate functions of the MIL FPGA module is a critical step to issuing commands to your processing FPGA, sometimes additional steps are required. If your Matrox imaging board has an on-board processor, you must call your primitive function from the slave function of a user-defined MIL function; for more information on how to define a user-defined MIL function, see Chapter 53: The MIL function development module.

If your Matrox imaging board does not have an on-board processor (for example, Matrox Solios), you can also call your primitive function from the slave function of a user-defined function to obtain basic error reporting or other built-in MIL features. Doing so might incur some small overhead but provides great benefits and can save considerable development time.

To develop a user-defined MIL function to call the primitive function, perform the following:

  1. Create a master function to register and check the parameters passed to the master function before sending the information to the slave function.

  2. Create a slave function to recuperate the values of the parameters registered in the master function and call the primitive function. To log any of your user-defined error messages with the MIL error handling mechanism, use MfuncErrorReport().

    Note that when your Matrox imaging board has an on-board processor, the slave and primitive functions must be precompiled and preloaded into the shell of the on-board processor.

Master function and slave function and execution of operation specified by command context

When you allocate a MIL function context in the master function of your user-defined MIL function using MfuncAlloc(), you must specify the identifier to associate with the MIL function. This identifier need not match the PU's function identifier that is specified when allocating the command context using MfpgaCommandAlloc().

Operation synchronization

When you allocate your MIL function context using MfuncAlloc(), you must specify whether your master function should wait for the slave function to finish executing before executing the next statement in the master function. This should not be confused with the synchronization specified by MfpgaCommandAlloc(), which specifies whether the current thread should issue the Processing FPGA command synchronously or asynchronously.

The following illustrates the primitive function call from the slave function of a user-defined function.

Choosing whether to set the user-defined function as synchronous or asynchronous depends on the application. A synchronous function can be easier to code, but using an asynchronous function allows you to perform Host and Processing FPGA operations simultaneously. Note that for Matrox imaging boards with on-board processors, the thread of the on-board processor always waits until each Processing FPGA command has completed its synchronous operation.