/**************************************************************************//**
* [url=home.php?mod=space&uid=288409]@file[/url] fft_lut.h
* [url=home.php?mod=space&uid=895143]@version[/url] V1.00
* [url=home.php?mod=space&uid=247401]@brief[/url] Fast Fourier Transform Parameter Look-up Table
*
* [url=home.php?mod=space&uid=17282]@CopyRight[/url] (C) 2019 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
#ifndef __FFT_LUT_H__
#define __FFT_LUT_H__
/* This example provides 3 types of selectable data length */
#define FFT_128_POINT (0)
#define FFT_256_POINT (1)
#define FFT_512_POINT (2)
/* User can select one of the length setting here. */
#define FFT_N_POINT_SEL (FFT_512_POINT)
/* Assign the corresponding look-up table according to the length setting.
Do not modify the contents here. */
#if (FFT_N_POINT_SEL == FFT_128_POINT)
#define SEQUENCE_LEN (128)
#define RESCALE(x) (x>>7)
#define COS_LUT COS_SCALED_LUT_128
#define SIN_LUT SIN_SCALED_LUT_128
#define REV_LUT REV_LUT_128
#elif (FFT_N_POINT_SEL == FFT_256_POINT)
#define SEQUENCE_LEN (256)
#define RESCALE(x) (x>>8)
#define COS_LUT COS_SCALED_LUT_256
#define SIN_LUT SIN_SCALED_LUT_256
#define REV_LUT REV_LUT_256
#elif (FFT_N_POINT_SEL == FFT_512_POINT)
#define SEQUENCE_LEN (512)
#define RESCALE(x) (x>>9)
#define COS_LUT COS_SCALED_LUT_512
#define SIN_LUT SIN_SCALED_LUT_512
#define REV_LUT REV_LUT_512
#else
#define "configuration error"
#endif
#if (FFT_SEQUENCE_LEN == FFT_SEQUENCE_LEN_128)
#define COS_SCALED_LUT_128 \
{ \
127, 127, 126, 126, 125, 123, 122, 120, 117, 115, 112, 109, 106, 102, 98, 94, \
90, 85, 81, 76, 71, 65, 60, 54, 49, 43, 37, 31, 25, 19, 12, 6, \
0, -6, -12, -19, -25, -31, -37, -43, -49, -54, -60, -65, -71, -76, -81, -85, \
-90, -94, -98, -102, -106, -109, -112, -115, -117, -120, -122, -123, -125, -126, -126, -127, \
-127, -127, -126, -126, -125, -123, -122, -120, -117, -115, -112, -109, -106, -102, -98, -94, \
-90, -85, -81, -76, -71, -65, -60, -54, -49, -43, -37, -31, -25, -19, -12, -6, \
0, 6, 12, 19, 25, 31, 37, 43, 49, 54, 60, 65, 71, 76, 81, 85, \
90, 94, 98, 102, 106, 109, 112, 115, 117, 120, 122, 123, 125, 126, 126, 127, \
}
#define SIN_SCALED_LUT_128 \
{ \
0, 6, 12, 19, 25, 31, 37, 43, 49, 54, 60, 65, 71, 76, 81, 85, \
90, 94, 98, 102, 106, 109, 112, 115, 117, 120, 122, 123, 125, 126, 126, 127, \
127, 127, 126, 126, 125, 123, 122, 120, 117, 115, 112, 109, 106, 102, 98, 94, \
90, 85, 81, 76, 71, 65, 60, 54, 49, 43, 37, 31, 25, 19, 12, 6, \
0, -6, -12, -19, -25, -31, -37, -43, -49, -54, -60, -65, -71, -76, -81, -85, \
-90, -94, -98, -102, -106, -109, -112, -115, -117, -120, -122, -123, -125, -126, -126, -127, \
-127, -127, -126, -126, -125, -123, -122, -120, -117, -115, -112, -109, -106, -102, -98, -94, \
-90, -85, -81, -76, -71, -65, -60, -54, -49, -43, -37, -31, -25, -19, -12, -6, \
}
#define REV_LUT_128 \
{ \
0, 64, 32, 96, 16, 80, 48, 112, 8, 72, 40, 104, 24, 88, 56, 120, \
4, 68, 36, 100, 20, 84, 52, 116, 12, 76, 44, 108, 28, 92, 60, 124, \
2, 66, 34, 98, 18, 82, 50, 114, 10, 74, 42, 106, 26, 90, 58, 122, \
6, 70, 38, 102, 22, 86, 54, 118, 14, 78, 46, 110, 30, 94, 62, 126, \
1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57, 121, \
5, 69, 37, 101, 21, 85, 53, 117, 13, 77, 45, 109, 29, 93, 61, 125, \
3, 67, 35, 99, 19, 83, 51, 115, 11, 75, 43, 107, 27, 91, 59, 123, \
7, 71, 39, 103, 23, 87, 55, 119, 15, 79, 47, 111, 31, 95, 63, 127, \
}
#endif
#if (FFT_SEQUENCE_LEN == FFT_SEQUENCE_LEN_256)
#define COS_SCALED_LUT_256 \
{ \
255, 255, 255, 254, 254, 253, 252, 251, 250, 249, 247, 246, 244, 242, 240, 238, \
236, 233, 231, 228, 225, 222, 219, 215, 212, 208, 205, 201, 197, 193, 189, 185, \
180, 176, 171, 167, 162, 157, 152, 147, 142, 136, 131, 126, 120, 115, 109, 103, \
98, 92, 86, 80, 74, 68, 62, 56, 50, 44, 37, 31, 25, 19, 13, 6, \
0, -6, -13, -19, -25, -31, -37, -44, -50, -56, -62, -68, -74, -80, -86, -92, \
-98, -103, -109, -115, -120, -126, -131, -136, -142, -147, -152, -157, -162, -167, -171, -176, \
-180, -185, -189, -193, -197, -201, -205, -208, -212, -215, -219, -222, -225, -228, -231, -233, \
-236, -238, -240, -242, -244, -246, -247, -249, -250, -251, -252, -253, -254, -254, -255, -255, \
-255, -255, -255, -254, -254, -253, -252, -251, -250, -249, -247, -246, -244, -242, -240, -238, \
-236, -233, -231, -228, -225, -222, -219, -215, -212, -208, -205, -201, -197, -193, -189, -185, \
-180, -176, -171, -167, -162, -157, -152, -147, -142, -136, -131, -126, -120, -115, -109, -103, \
-98, -92, -86, -80, -74, -68, -62, -56, -50, -44, -37, -31, -25, -19, -13, -6, \
0, 6, 13, 19, 25, 31, 37, 44, 50, 56, 62, 68, 74, 80, 86, 92, \
98, 103, 109, 115, 120, 126, 131, 136, 142, 147, 152, 157, 162, 167, 171, 176, \
180, 185, 189, 193, 197, 201, 205, 208, 212, 215, 219, 222, 225, 228, 231, 233, \
236, 238, 240, 242, 244, 246, 247, 249, 250, 251, 252, 253, 254, 254, 255, 255, \
}
#define SIN_SCALED_LUT_256 \
{ \
0, 6, 13, 19, 25, 31, 37, 44, 50, 56, 62, 68, 74, 80, 86, 92, \
98, 103, 109, 115, 120, 126, 131, 136, 142, 147, 152, 157, 162, 167, 171, 176, \
180, 185, 189, 193, 197, 201, 205, 208, 212, 215, 219, 222, 225, 228, 231, 233, \
236, 238, 240, 242, 244, 246, 247, 249, 250, 251, 252, 253, 254, 254, 255, 255, \
255, 255, 255, 254, 254, 253, 252, 251, 250, 249, 247, 246, 244, 242, 240, 238, \
236, 233, 231, 228, 225, 222, 219, 215, 212, 208, 205, 201, 197, 193, 189, 185, \
180, 176, 171, 167, 162, 157, 152, 147, 142, 136, 131, 126, 120, 115, 109, 103, \
98, 92, 86, 80, 74, 68, 62, 56, 50, 44, 37, 31, 25, 19, 13, 6, \
0, -6, -13, -19, -25, -31, -37, -44, -50, -56, -62, -68, -74, -80, -86, -92, \
-98, -103, -109, -115, -120, -126, -131, -136, -142, -147, -152, -157, -162, -167, -171, -176, \
-180, -185, -189, -193, -197, -201, -205, -208, -212, -215, -219, -222, -225, -228, -231, -233, \
-236, -238, -240, -242, -244, -246, -247, -249, -250, -251, -252, -253, -254, -254, -255, -255, \
-255, -255, -255, -254, -254, -253, -252, -251, -250, -249, -247, -246, -244, -242, -240, -238, \
-236, -233, -231, -228, -225, -222, -219, -215, -212, -208, -205, -201, -197, -193, -189, -185, \
-180, -176, -171, -167, -162, -157, -152, -147, -142, -136, -131, -126, -120, -115, -109, -103, \
-98, -92, -86, -80, -74, -68, -62, -56, -50, -44, -37, -31, -25, -19, -13, -6, \
}
#define REV_LUT_256 \
{ \
0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, \
8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, \
4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, \
12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, \
2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, \
10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, \
6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, \
14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, \
1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, \
9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, \
5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, \
13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, \
3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, \
11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, \
7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, \
15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255, \
}
#endif
#if (FFT_SEQUENCE_LEN == FFT_SEQUENCE_LEN_512)
#define COS_SCALED_LUT_512 \
{ \
511, 511, 511, 511, 510, 510, 510, 509, 509, 508, 507, 506, 505, 505, 503, 502, \
501, 500, 499, 497, 496, 494, 492, 491, 489, 487, 485, 483, 481, 479, 477, 474, \
472, 470, 467, 465, 462, 459, 456, 454, 451, 448, 445, 441, 438, 435, 432, 428, \
425, 421, 418, 414, 410, 407, 403, 399, 395, 391, 387, 383, 379, 374, 370, 366, \
361, 357, 352, 348, 343, 338, 334, 329, 324, 319, 314, 309, 304, 299, 294, 289, \
284, 279, 273, 268, 263, 257, 252, 246, 241, 235, 230, 224, 218, 213, 207, 201, \
196, 190, 184, 178, 172, 166, 160, 154, 148, 142, 136, 130, 124, 118, 112, 106, \
100, 94, 87, 81, 75, 69, 63, 56, 50, 44, 38, 31, 25, 19, 13, 6, \
0, -6, -13, -19, -25, -31, -38, -44, -50, -56, -63, -69, -75, -81, -87, -94, \
-100, -106, -112, -118, -124, -130, -136, -142, -148, -154, -160, -166, -172, -178, -184, -190, \
-196, -201, -207, -213, -218, -224, -230, -235, -241, -246, -252, -257, -263, -268, -273, -279, \
-284, -289, -294, -299, -304, -309, -314, -319, -324, -329, -334, -338, -343, -348, -352, -357, \
-361, -366, -370, -374, -379, -383, -387, -391, -395, -399, -403, -407, -410, -414, -418, -421, \
-425, -428, -432, -435, -438, -441, -445, -448, -451, -454, -456, -459, -462, -465, -467, -470, \
-472, -474, -477, -479, -481, -483, -485, -487, -489, -491, -492, -494, -496, -497, -499, -500, \
-501, -502, -503, -505, -505, -506, -507, -508, -509, -509, -510, -510, -510, -511, -511, -511, \
-511, -511, -511, -511, -510, -510, -510, -509, -509, -508, -507, -506, -505, -505, -503, -502, \
-501, -500, -499, -497, -496, -494, -492, -491, -489, -487, -485, -483, -481, -479, -477, -474, \
-472, -470, -467, -465, -462, -459, -456, -454, -451, -448, -445, -441, -438, -435, -432, -428, \
-425, -421, -418, -414, -410, -407, -403, -399, -395, -391, -387, -383, -379, -374, -370, -366, \
-361, -357, -352, -348, -343, -338, -334, -329, -324, -319, -314, -309, -304, -299, -294, -289, \
-284, -279, -273, -268, -263, -257, -252, -246, -241, -235, -230, -224, -218, -213, -207, -201, \
-196, -190, -184, -178, -172, -166, -160, -154, -148, -142, -136, -130, -124, -118, -112, -106, \
-100, -94, -87, -81, -75, -69, -63, -56, -50, -44, -38, -31, -25, -19, -13, -6, \
0, 6, 13, 19, 25, 31, 38, 44, 50, 56, 63, 69, 75, 81, 87, 94, \
100, 106, 112, 118, 124, 130, 136, 142, 148, 154, 160, 166, 172, 178, 184, 190, \
196, 201, 207, 213, 218, 224, 230, 235, 241, 246, 252, 257, 263, 268, 273, 279, \
284, 289, 294, 299, 304, 309, 314, 319, 324, 329, 334, 338, 343, 348, 352, 357, \
361, 366, 370, 374, 379, 383, 387, 391, 395, 399, 403, 407, 410, 414, 418, 421, \
425, 428, 432, 435, 438, 441, 445, 448, 451, 454, 456, 459, 462, 465, 467, 470, \
472, 474, 477, 479, 481, 483, 485, 487, 489, 491, 492, 494, 496, 497, 499, 500, \
501, 502, 503, 505, 505, 506, 507, 508, 509, 509, 510, 510, 510, 511, 511, 511, \
}
#define SIN_SCALED_LUT_512 \
{ \
0, 6, 13, 19, 25, 31, 38, 44, 50, 56, 63, 69, 75, 81, 87, 94, \
100, 106, 112, 118, 124, 130, 136, 142, 148, 154, 160, 166, 172, 178, 184, 190, \
196, 201, 207, 213, 218, 224, 230, 235, 241, 246, 252, 257, 263, 268, 273, 279, \
284, 289, 294, 299, 304, 309, 314, 319, 324, 329, 334, 338, 343, 348, 352, 357, \
361, 366, 370, 374, 379, 383, 387, 391, 395, 399, 403, 407, 410, 414, 418, 421, \
425, 428, 432, 435, 438, 441, 445, 448, 451, 454, 456, 459, 462, 465, 467, 470, \
472, 474, 477, 479, 481, 483, 485, 487, 489, 491, 492, 494, 496, 497, 499, 500, \
501, 502, 503, 505, 505, 506, 507, 508, 509, 509, 510, 510, 510, 511, 511, 511, \
511, 511, 511, 511, 510, 510, 510, 509, 509, 508, 507, 506, 505, 505, 503, 502, \
501, 500, 499, 497, 496, 494, 492, 491, 489, 487, 485, 483, 481, 479, 477, 474, \
472, 470, 467, 465, 462, 459, 456, 454, 451, 448, 445, 441, 438, 435, 432, 428, \
425, 421, 418, 414, 410, 407, 403, 399, 395, 391, 387, 383, 379, 374, 370, 366, \
361, 357, 352, 348, 343, 338, 334, 329, 324, 319, 314, 309, 304, 299, 294, 289, \
284, 279, 273, 268, 263, 257, 252, 246, 241, 235, 230, 224, 218, 213, 207, 201, \
196, 190, 184, 178, 172, 166, 160, 154, 148, 142, 136, 130, 124, 118, 112, 106, \
100, 94, 87, 81, 75, 69, 63, 56, 50, 44, 38, 31, 25, 19, 13, 6, \
0, -6, -13, -19, -25, -31, -38, -44, -50, -56, -63, -69, -75, -81, -87, -94, \
-100, -106, -112, -118, -124, -130, -136, -142, -148, -154, -160, -166, -172, -178, -184, -190, \
-196, -201, -207, -213, -218, -224, -230, -235, -241, -246, -252, -257, -263, -268, -273, -279, \
-284, -289, -294, -299, -304, -309, -314, -319, -324, -329, -334, -338, -343, -348, -352, -357, \
-361, -366, -370, -374, -379, -383, -387, -391, -395, -399, -403, -407, -410, -414, -418, -421, \
-425, -428, -432, -435, -438, -441, -445, -448, -451, -454, -456, -459, -462, -465, -467, -470, \
-472, -474, -477, -479, -481, -483, -485, -487, -489, -491, -492, -494, -496, -497, -499, -500, \
-501, -502, -503, -505, -505, -506, -507, -508, -509, -509, -510, -510, -510, -511, -511, -511, \
-511, -511, -511, -511, -510, -510, -510, -509, -509, -508, -507, -506, -505, -505, -503, -502, \
-501, -500, -499, -497, -496, -494, -492, -491, -489, -487, -485, -483, -481, -479, -477, -474, \
-472, -470, -467, -465, -462, -459, -456, -454, -451, -448, -445, -441, -438, -435, -432, -428, \
-425, -421, -418, -414, -410, -407, -403, -399, -395, -391, -387, -383, -379, -374, -370, -366, \
-361, -357, -352, -348, -343, -338, -334, -329, -324, -319, -314, -309, -304, -299, -294, -289, \
-284, -279, -273, -268, -263, -257, -252, -246, -241, -235, -230, -224, -218, -213, -207, -201, \
-196, -190, -184, -178, -172, -166, -160, -154, -148, -142, -136, -130, -124, -118, -112, -106, \
-100, -94, -87, -81, -75, -69, -63, -56, -50, -44, -38, -31, -25, -19, -13, -6, \
}
#define REV_LUT_512 \
{ \
0, 256, 128, 384, 64, 320, 192, 448, 32, 288, 160, 416, 96, 352, 224, 480, \
16, 272, 144, 400, 80, 336, 208, 464, 48, 304, 176, 432, 112, 368, 240, 496, \
8, 264, 136, 392, 72, 328, 200, 456, 40, 296, 168, 424, 104, 360, 232, 488, \
24, 280, 152, 408, 88, 344, 216, 472, 56, 312, 184, 440, 120, 376, 248, 504, \
4, 260, 132, 388, 68, 324, 196, 452, 36, 292, 164, 420, 100, 356, 228, 484, \
20, 276, 148, 404, 84, 340, 212, 468, 52, 308, 180, 436, 116, 372, 244, 500, \
12, 268, 140, 396, 76, 332, 204, 460, 44, 300, 172, 428, 108, 364, 236, 492, \
28, 284, 156, 412, 92, 348, 220, 476, 60, 316, 188, 444, 124, 380, 252, 508, \
2, 258, 130, 386, 66, 322, 194, 450, 34, 290, 162, 418, 98, 354, 226, 482, \
18, 274, 146, 402, 82, 338, 210, 466, 50, 306, 178, 434, 114, 370, 242, 498, \
10, 266, 138, 394, 74, 330, 202, 458, 42, 298, 170, 426, 106, 362, 234, 490, \
26, 282, 154, 410, 90, 346, 218, 474, 58, 314, 186, 442, 122, 378, 250, 506, \
6, 262, 134, 390, 70, 326, 198, 454, 38, 294, 166, 422, 102, 358, 230, 486, \
22, 278, 150, 406, 86, 342, 214, 470, 54, 310, 182, 438, 118, 374, 246, 502, \
14, 270, 142, 398, 78, 334, 206, 462, 46, 302, 174, 430, 110, 366, 238, 494, \
30, 286, 158, 414, 94, 350, 222, 478, 62, 318, 190, 446, 126, 382, 254, 510, \
1, 257, 129, 385, 65, 321, 193, 449, 33, 289, 161, 417, 97, 353, 225, 481, \
17, 273, 145, 401, 81, 337, 209, 465, 49, 305, 177, 433, 113, 369, 241, 497, \
9, 265, 137, 393, 73, 329, 201, 457, 41, 297, 169, 425, 105, 361, 233, 489, \
25, 281, 153, 409, 89, 345, 217, 473, 57, 313, 185, 441, 121, 377, 249, 505, \
5, 261, 133, 389, 69, 325, 197, 453, 37, 293, 165, 421, 101, 357, 229, 485, \
21, 277, 149, 405, 85, 341, 213, 469, 53, 309, 181, 437, 117, 373, 245, 501, \
13, 269, 141, 397, 77, 333, 205, 461, 45, 301, 173, 429, 109, 365, 237, 493, \
29, 285, 157, 413, 93, 349, 221, 477, 61, 317, 189, 445, 125, 381, 253, 509, \
3, 259, 131, 387, 67, 323, 195, 451, 35, 291, 163, 419, 99, 355, 227, 483, \
19, 275, 147, 403, 83, 339, 211, 467, 51, 307, 179, 435, 115, 371, 243, 499, \
11, 267, 139, 395, 75, 331, 203, 459, 43, 299, 171, 427, 107, 363, 235, 491, \
27, 283, 155, 411, 91, 347, 219, 475, 59, 315, 187, 443, 123, 379, 251, 507, \
7, 263, 135, 391, 71, 327, 199, 455, 39, 295, 167, 423, 103, 359, 231, 487, \
23, 279, 151, 407, 87, 343, 215, 471, 55, 311, 183, 439, 119, 375, 247, 503, \
15, 271, 143, 399, 79, 335, 207, 463, 47, 303, 175, 431, 111, 367, 239, 495, \
31, 287, 159, 415, 95, 351, 223, 479, 63, 319, 191, 447, 127, 383, 255, 511, \
}
#endif
#endif