Main Content

Call Legacy Lookup Table Function Using C Caller Block

This example shows how to use the C Caller block to call legacy C functions that implement N-dimensional table lookups.

In this example the legacy C functions are defined in lookupTable.h, and implemented in directLookupTableND.c. The type definitions used in this example can be found in your_types.h.

To enable calling the C functions from the C Function block, in the model, specify the header file and the source file in the Configuration Parameters > Simulation Target pane. The prototype of the legacy function being called in this example is:

FLT directLookupTableND(const FLT *tableND, const UINT32 nbDims, const UINT32 *tableDims, const UINT32 *tableIdx)

where FLT is a type definition to a floating-point type, and UINT32 is a type definition to an unsigned 32-bit integer.

  • const FLT *tableND - Table

  • const UINT32 nbDims - Dimensionality of the table

  • const UINT32 *tableDims - Size of the table

  • const UINT32 *tableIdx - Table index

In the C Caller block, tableND and tableDims are mapped to C Caller block parameters, nbDims is a block constant, and tableIdx is the input to the block. The value returned by the legacy C function is the output of the block.

mdl = 'slexCCallerLookupTable';
open_system(mdl);
sim(mdl);

See Also

Blocks

Related Topics