Generating Fixed-Point C Code (Digital Filter Design Toolkit)
You usually program target digital signal processing (DSP) hardware using C code. To generate C code from the fixed-point filter model, use the C Code instance of the DFD FXP Code Generator VI. You can compile the generated code to run on a fixed-point DSP.
Note C code can yield a less compact and less efficient implementation than a hand-written, assembly-coded implementation. If you need to improve the performance of a filter, you can translate the C code to assembly code manually. |
The DFD FXP Code Generator VI produces three files, where filtername is the string you wire to the filter name input:
- nidfdtyp.h contains the definitions of the data types in the C source files that the DFD FXP Code Generator VI generates.
- filtername.h contains type definitions, global variable declarations, and function prototypes.
- filtername.c contains the code that implements the filter, including the filter coefficients, information about the implementation structure and quantizer settings in the fixed-point model, and the following functions:
- filtername_State filtername_CreateState() creates the memory space needed to store the internal states of the filter.
- void filtername_DisposeState(filtername_State state) disposes of the memory space used to store the internal states of the filter.
- void filtername_InitState(filtername_State state) initializes the internal states to zeroes. Call this function for the first block when processing a large data sequence that consists of multiple data blocks.
- I16 filtername_Filtering(I16 sampleIn, filtername_State state) implements the fixed-point filter.
- static I16 filtername_Coef[] contains the quantized coefficients of the fixed-point filter.
Refer to the LabVIEW C Code Generation VI in the labview\examples\Digital Filter Design\Fixed-Point Filters\Single-Rate directory for an example that demonstrates how to generate LabVIEW C code from a fixed-point filter.