|
4 | 4 |
|
5 | 5 | // Include files
|
6 | 6 | #include <stdio.h>
|
7 |
| -#include <siglib.h> // SigLib DSP library |
| 7 | +#include <siglib.h> // SigLib DSP library |
8 | 8 | #if ENABLE_BENCHMARK
|
9 | 9 | #include "xbenchmark.h"
|
10 | 10 | #endif
|
11 | 11 |
|
12 | 12 | // Define constants
|
13 | 13 | #define FFT_LENGTH 16
|
14 |
| -#define LOG2_FFT_LENGTH SAI_FftLengthLog2(FFT_LENGTH) // Log2 FFT length, |
| 14 | +#define LOG2_FFT_LENGTH SAI_FftLengthLog2(FFT_LENGTH) // Log2 FFT length, |
15 | 15 |
|
16 | 16 | // Declare global variables and arrays
|
17 |
| -static SLData_t *pRealData, *pImagData, *pFFTCoeffs; |
18 |
| -static SLData_t SinePhase; |
| 17 | +static SLData_t *pRealData, *pImagData, *pFFTCoeffs; |
| 18 | +static SLData_t SinePhase; |
19 | 19 |
|
20 | 20 |
|
21 |
| -int main(void) |
22 |
| - |
| 21 | +int main ( |
| 22 | + void) |
23 | 23 | {
|
24 | 24 | #if ENABLE_BENCHMARK
|
25 |
| - int start_time, end_time, overhead_time; |
26 |
| - overhead_time = xbench_init(); |
| 25 | + int start_time, end_time, overhead_time; |
| 26 | + overhead_time = xbench_init (); |
27 | 27 | #endif
|
28 | 28 |
|
29 |
| - // Allocate memory |
30 |
| - pRealData = SUF_VectorArrayAllocate (FFT_LENGTH); |
31 |
| - pImagData = SUF_VectorArrayAllocate (FFT_LENGTH); |
32 |
| - pFFTCoeffs = SUF_FftCoefficientAllocate (FFT_LENGTH); |
| 29 | +// Allocate memory |
| 30 | + pRealData = SUF_VectorArrayAllocate (FFT_LENGTH); |
| 31 | + pImagData = SUF_VectorArrayAllocate (FFT_LENGTH); |
| 32 | + pFFTCoeffs = SUF_FftCoefficientAllocate (FFT_LENGTH); |
33 | 33 |
|
34 |
| - if ((NULL == pRealData) || (NULL == pImagData) || (NULL == pFFTCoeffs)) { |
35 |
| - printf ("\n\nMemory allocation failed\n\n"); |
36 |
| - exit(0); |
37 |
| - } |
| 34 | + if ((NULL == pRealData) || (NULL == pImagData) || (NULL == pFFTCoeffs)) { |
| 35 | + printf ("\n\nMemory allocation failed\n\n"); |
| 36 | + exit (0); |
| 37 | + } |
38 | 38 |
|
39 |
| - // Initialise FFT |
40 |
| - SIF_Fft (pFFTCoeffs, // Pointer to FFT coefficients |
41 |
| - SIGLIB_BIT_REV_STANDARD, // Bit reverse mode flag / Pointer to bit reverse address table |
42 |
| - FFT_LENGTH); // FFT length |
| 39 | +// Initialise FFT |
| 40 | + SIF_Fft (pFFTCoeffs, // Pointer to FFT coefficients |
| 41 | + SIGLIB_BIT_REV_STANDARD, // Bit reverse mode flag / Pointer to bit reverse address table |
| 42 | + FFT_LENGTH); // FFT length |
43 | 43 |
|
44 | 44 |
|
45 |
| - SinePhase = SIGLIB_ZERO; |
46 |
| - SDA_SignalGenerate (pRealData, // Pointer to destination array |
47 |
| - SIGLIB_SINE_WAVE, // Signal type - Sine wave |
48 |
| - 0.9, // Signal peak level |
49 |
| - SIGLIB_FILL, // Fill (overwrite) or add to existing array contents |
50 |
| - SIGLIB_TWO / (SLData_t)FFT_LENGTH, // Signal frequency |
51 |
| - SIGLIB_ZERO, // D.C. Offset |
52 |
| - SIGLIB_ZERO, // Unused |
53 |
| - SIGLIB_ZERO, // Signal end value - Unused |
54 |
| - &SinePhase, // Signal phase - maintained across array boundaries |
55 |
| - SIGLIB_NULL_DATA_PTR , // Unused |
56 |
| - FFT_LENGTH); // Output dataset length |
| 45 | + SinePhase = SIGLIB_ZERO; |
| 46 | + SDA_SignalGenerate (pRealData, // Pointer to destination array |
| 47 | + SIGLIB_SINE_WAVE, // Signal type - Sine wave |
| 48 | + 0.9, // Signal peak level |
| 49 | + SIGLIB_FILL, // Fill (overwrite) or add to existing array contents |
| 50 | + SIGLIB_TWO / (SLData_t) FFT_LENGTH, // Signal frequency |
| 51 | + SIGLIB_ZERO, // D.C. Offset |
| 52 | + SIGLIB_ZERO, // Unused |
| 53 | + SIGLIB_ZERO, // Signal end value - Unused |
| 54 | + &SinePhase, // Signal phase - maintained across array boundaries |
| 55 | + SIGLIB_NULL_DATA_PTR, // Unused |
| 56 | + FFT_LENGTH); // Output dataset length |
57 | 57 |
|
58 |
| - printf ("\nSource sine wave\n"); |
59 |
| - SUF_PrintArray (pRealData, FFT_LENGTH); |
| 58 | + printf ("\nSource sine wave\n"); |
| 59 | + SUF_PrintArray (pRealData, FFT_LENGTH); |
60 | 60 |
|
61 | 61 |
|
62 | 62 | #if ENABLE_BENCHMARK
|
63 |
| - start_time = xbench_get_time(); |
| 63 | + start_time = xbench_get_time (); |
64 | 64 | #endif
|
65 |
| - SDA_Rfft (pRealData, // Pointer to real array |
66 |
| - pImagData, // Pointer to imaginary array |
67 |
| - pFFTCoeffs, // Pointer to FFT coefficients |
68 |
| - SIGLIB_BIT_REV_STANDARD, // Bit reverse mode flag / Pointer to bit reverse address table |
69 |
| - FFT_LENGTH, // FFT length |
70 |
| - LOG2_FFT_LENGTH); // log2 FFT length |
| 65 | + SDA_Rfft (pRealData, // Pointer to real array |
| 66 | + pImagData, // Pointer to imaginary array |
| 67 | + pFFTCoeffs, // Pointer to FFT coefficients |
| 68 | + SIGLIB_BIT_REV_STANDARD, // Bit reverse mode flag / Pointer to bit reverse address table |
| 69 | + FFT_LENGTH, // FFT length |
| 70 | + LOG2_FFT_LENGTH); // log2 FFT length |
71 | 71 | #if ENABLE_BENCHMARK
|
72 |
| - end_time = xbench_get_time(); |
73 |
| - printf ("FFT Elapsed time = %d cycles\n", end_time - start_time - overhead_time); |
| 72 | + end_time = xbench_get_time (); |
| 73 | + printf ("FFT Elapsed time = %d cycles\n", end_time - start_time - overhead_time); |
74 | 74 | #endif
|
75 | 75 |
|
76 | 76 |
|
77 |
| - printf ("\nReal FFT of pure sine wave\n"); |
78 |
| - SUF_PrintArray (pRealData, FFT_LENGTH); |
| 77 | + printf ("\nReal FFT of pure sine wave\n"); |
| 78 | + SUF_PrintArray (pRealData, FFT_LENGTH); |
79 | 79 |
|
80 | 80 |
|
81 |
| - SUF_MemoryFree (pRealData); // Free memory |
82 |
| - SUF_MemoryFree (pImagData); |
83 |
| - SUF_MemoryFree (pFFTCoeffs); |
| 81 | + SUF_MemoryFree (pRealData); // Free memory |
| 82 | + SUF_MemoryFree (pImagData); |
| 83 | + SUF_MemoryFree (pFFTCoeffs); |
84 | 84 |
|
85 |
| - exit(0); |
| 85 | + exit (0); |
86 | 86 | }
|
87 |
| - |
88 |
| - |
0 commit comments