使用 C Function 模块旧式查找表函数
此示例显示如何使用 C Function 模块调用实现 n 维表查找的旧式 C 函数。
在此示例中,遗留的 C 函数在 lookupTable.h 中定义,并在 directLookupTableND.c 中实现。本示例中使用的类型定义可以在 your_types.h 中找到。
在模型中,头文件和源文件在模型配置参数 >仿真目标中指定。现在可以在 C Function 模块中调用 C 函数。本示例中被调用的函数的原型是:
FLT directLookupTableND(const FLT *tableND, const UINT32 nbDims, const UINT32 *tableDims, const UINT32 *tableIdx)
其中 FLT
是浮点类型的类型定义,而 UINT32
是无符号 32 位整数的类型定义。
此示例定义了两个使用函数 directLookupTableND
的宏函数,它们使用 C Function 模块进行调用。它们是:
DirectLookupTable3D
- 三维查找表DirectLookupTable4D
- 四维查找表
这两个函数都采用以下输入参量:
const FLT *tableND
- 表const UINT32 *tableDims
- 表的大小const UINT32 *tableIdx
- 表索引
其中 tableND
和 tableDims
映射到 C Function 模块参数,而 tableIdx
是该模块的输入。传统 C 函数返回的值是该模块的输出。
model = 'slexCFunctionLookupTable';
open_system(model);
sim(model);