Chapter 2 C Language Reference
© National Instruments Corporation 2-19 AutoCode Reference
As previously stated, the inputs and outputs of the UCB will have the same
data type as specified in the model diagram. Inputs are passed by value
while outputs are passed by reference. In addition, the “shape” of an
argument describes whether it is a scalar value or an array. For information
on how to specify the data type and shape of the inputs and outputs of the
UCB, refer to the SystemBuild User Guide.
Another complexity relates to vectorization with AutoCode code
generation. By design, the variable interface UCB is insulated from
the many possible combinations. The interface to the UCB will remain
constant relative to all of the AutoCode optimization. As a result,
AutoCode performs any needed copying—for example, staging—of inputs
and outputs to make sure the proper arguments are passed to the UCB.
Forexample, if the UCB expects an array of five inputs, yet scalar code is
generated, AutoCode creates a temporary array for those inputs and passes
that temporary array to the UCB.
Function Prototype
National Instruments recommends that you create a function prototype for
your variable interface UCB functions. This will provide some additional
checking that the compiler can do to ensure that the generated interface
matches what you expected without your implementation of the UCB
function.
The following is a sample prototype for a variable interface UCB function:
void ucb01(
RT_FLOAT change[2], /*** inputs ***/
RT_INTEGER xpos,
RT_INTEGER ypos,
RT_FLOAT *rate, /*** outputs ***/
RT_INTEGER posdata[3],
RT_FLOAT *RP, /*** RP ***/
RT_INTEGER NRP
);