-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffft.S
760 lines (682 loc) · 39 KB
/
ffft.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
;-----------------------------------------------------------------------------;
; Fixed-point FFT routines for megaAVRs (C)ChaN, 2005
;-----------------------------------------------------------------------------;
;
; void fft_input (const int16_t *array_src, complex_t *array_bfly);
; void fft_execute (complex_t *array_bfly);
; void fft_output (complex_t *array_bfly, uint16_t *array_dst);
;
; <array_src>: Wave form to be processed.
; <array_bfly>: Complex array for butterfly operations.
; <array_dst>: Spectrum output buffer.
;
; These functions must be called in sequence to do a DFT in FFT algorithm.
; fft_input() fills the complex array with a wave form to prepare butterfly
; operations. A hamming window is applied at the same time.
; fft_execute() executes the butterfly operations.
; fft_output() re-orders the results, converts the complex spectrum into
; scalar spectrum and output it in linear scale.
;
; The number of points FFT_N is defined in "ffft.h" and the value can be
; power of 2 in range of 64 - 1024.
;
;----------------------------------------------------------------------------;
; 16bit fixed-point FFT performance with MegaAVRs
; (Running at 16MHz/internal SRAM)
;
; Points: Input, Execute, Output, Total: Throughput
; 64pts: .17ms, 2.0ms, 1.2ms, 3.4ms: 19.0kpps
; 128pts: .33ms, 4.6ms, 2.4ms, 7.3ms: 17.5kpps
; 256pts: .66ms, 10.4ms, 4.9ms, 15.9ms: 16.1kpps
; 512pts: 1.3ms, 23.2ms, 9.7ms, 34.2ms: 14.9kpps
; 1024pts: 2.7ms, 51.7ms, 19.4ms, 73.7ms: 13.9kpps
;----------------------------------------------------------------------------;
.nolist
#define FFFT_ASM
#include "ffft.h"
#include "window.h"
#include "config.h"
.list
#if FFT_N == 1024
#define FFT_B 10
#elif FFT_N == 512
#define FFT_B 9
#elif FFT_N == 256
#define FFT_B 8
#elif FFT_N == 128
#define FFT_B 7
#elif FFT_N == 64
#define FFT_B 6
#else
#error Wrong setting of FFT_N.
#endif
; Recommend using routine 3 for speed -Bradley
#define SQRT32_ROUTINE 3
#if SQRT32_ROUTINE == 1
.macro SQRT32 ; 32bit square root (526..542clk)
clr T6L
clr T6H
clr T8L
clr T8H
ldi BL, 1
ldi BH, 0
clr CL
clr CH
ldi DH, 16
90: lsl T2L
rol T2H
rol T4L
rol T4H
rol T6L
rol T6H
rol T8L
rol T8H
lsl T2L
rol T2H
rol T4L
rol T4H
rol T6L
rol T6H
rol T8L
rol T8H
brpl 91f
add T6L, BL
adc T6H, BH
adc T8L, CL
adc T8H, CH
rjmp 92f
91: sub T6L, BL
sbc T6H, BH
sbc T8L, CL
sbc T8H, CH
92: lsl BL
rol BH
rol CL
andi BL, 0b11111000
ori BL, 0b00000101
sbrc T8H, 7
subi BL, 2
dec DH
brne 90b
lsr CL
ror BH
ror BL
lsr CL
ror BH
ror BL
.endm
#elif SQRT32_ROUTINE == 2
.macro SQRT32 ; 32bit square root (264-305clk) BH:BL = sqrt(T4:T2)
push r17
push r16
ldi r19,0xc0
clr r18 ; rotation mask in r19:r18
ldi r17,0x40
sub r16,r16 ; developing sqrt in r17:r16, C=0
_sq32_1:
brcs _sq32_2 ; C --> Bit is always 1
cp T4L,r16
cpc T4H,r17 ; Does test value fit?
brcs _sq32_3 ; C --> nope, bit is 0
_sq32_2:
sub T4L,r16
sbc T4H,r17 ; Adjust argument for next bit
or r16,r18
or r17,r19 ; Set bit to 1
_sq32_3:
lsr r19
ror r18 ; Shift right mask, C --> end loop
eor r17,r19
eor r16,r18 ; Shift right only test bit in result
rol T2L ; Bit 0 only set if end of loop
rol T2H
rol T4L
rol T4H ; Shift left remaining argument (C used at _sq32_1)
sbrs T2L,0 ; Skip if 15 bits developed
rjmp _sq32_1 ; Develop 15 bits of the sqrt
brcs _sq32_4 ; C--> Last bits always 1
lsl T2H ; Need bit 7 in C for cpc
cpc r16,T4L
cpc r17,T4H ; After this C is last bit
_sq32_4:
adc r16,r19 ; round up if C (r19=0)
mov BH,r17
mov BL,r16
pop r16
pop r17
.endm
#elif SQRT32_ROUTINE == 3
.macro SQRT32 ; 32bit square root (264-305clk) BH:BL = sqrt(T4:T2)
ldi CH,0xc0
clr CL ; rotation mask in CH:CL
ldi BH,0x40
sub BL,BL ; developing sqrt in BH:BL, C=0
_sq32_1:
brcs _sq32_2 ; C --> Bit is always 1
cp T4L,BL
cpc T4H,BH ; Does test value fit?
brcs _sq32_3 ; C --> nope, bit is 0
_sq32_2:
sub T4L,BL
sbc T4H,BH ; Adjust argument for next bit
or BL,CL
or BH,CH ; Set bit to 1
_sq32_3:
lsr CH
ror CL ; Shift right mask, C --> end loop
eor BH,CH
eor BL,CL ; Shift right only test bit in result
rol T2L ; Bit 0 only set if end of loop
rol T2H
rol T4L
rol T4H ; Shift left remaining argument (C used at _sq32_1)
sbrs T2L,0 ; Skip if 15 bits developed
rjmp _sq32_1 ; Develop 15 bits of the sqrt
brcs _sq32_4 ; C--> Last bits always 1
lsl T2H ; Need bit 7 in C for cpc
cpc BL,T4L
cpc BH,T4H ; After this C is last bit
_sq32_4:
adc BL,CH ; round up if C (CH=0)
.endm
#endif
;----------------------------------------------------------------------------;
; Constant Tables
tbl_cos_sin: ; Table of {cos(x),sin(x)}, (0 <= x < pi, in FFT_N/2 steps)
#if FFT_N == 1024
.dc.w 32767, 0, 32766, 201, 32764, 402, 32761, 603, 32757, 804, 32751, 1005, 32744, 1206, 32736, 1406
.dc.w 32727, 1607, 32717, 1808, 32705, 2009, 32692, 2209, 32678, 2410, 32662, 2610, 32646, 2811, 32628, 3011
.dc.w 32609, 3211, 32588, 3411, 32567, 3611, 32544, 3811, 32520, 4011, 32495, 4210, 32468, 4409, 32441, 4608
.dc.w 32412, 4807, 32382, 5006, 32350, 5205, 32318, 5403, 32284, 5601, 32249, 5799, 32213, 5997, 32176, 6195
.dc.w 32137, 6392, 32097, 6589, 32056, 6786, 32014, 6982, 31970, 7179, 31926, 7375, 31880, 7571, 31833, 7766
.dc.w 31785, 7961, 31735, 8156, 31684, 8351, 31633, 8545, 31580, 8739, 31525, 8932, 31470, 9126, 31413, 9319
.dc.w 31356, 9511, 31297, 9703, 31236, 9895, 31175, 10087, 31113, 10278, 31049, 10469, 30984, 10659, 30918, 10849
.dc.w 30851, 11038, 30783, 11227, 30713, 11416, 30643, 11604, 30571, 11792, 30498, 11980, 30424, 12166, 30349, 12353
.dc.w 30272, 12539, 30195, 12724, 30116, 12909, 30036, 13094, 29955, 13278, 29873, 13462, 29790, 13645, 29706, 13827
.dc.w 29621, 14009, 29534, 14191, 29446, 14372, 29358, 14552, 29268, 14732, 29177, 14911, 29085, 15090, 28992, 15268
.dc.w 28897, 15446, 28802, 15623, 28706, 15799, 28608, 15975, 28510, 16150, 28410, 16325, 28309, 16499, 28208, 16672
.dc.w 28105, 16845, 28001, 17017, 27896, 17189, 27790, 17360, 27683, 17530, 27575, 17699, 27466, 17868, 27355, 18036
.dc.w 27244, 18204, 27132, 18371, 27019, 18537, 26905, 18702, 26789, 18867, 26673, 19031, 26556, 19194, 26437, 19357
.dc.w 26318, 19519, 26198, 19680, 26077, 19840, 25954, 20000, 25831, 20159, 25707, 20317, 25582, 20474, 25456, 20631
.dc.w 25329, 20787, 25201, 20942, 25072, 21096, 24942, 21249, 24811, 21402, 24679, 21554, 24546, 21705, 24413, 21855
.dc.w 24278, 22004, 24143, 22153, 24006, 22301, 23869, 22448, 23731, 22594, 23592, 22739, 23452, 22883, 23311, 23027
.dc.w 23169, 23169, 23027, 23311, 22883, 23452, 22739, 23592, 22594, 23731, 22448, 23869, 22301, 24006, 22153, 24143
.dc.w 22004, 24278, 21855, 24413, 21705, 24546, 21554, 24679, 21402, 24811, 21249, 24942, 21096, 25072, 20942, 25201
.dc.w 20787, 25329, 20631, 25456, 20474, 25582, 20317, 25707, 20159, 25831, 20000, 25954, 19840, 26077, 19680, 26198
.dc.w 19519, 26318, 19357, 26437, 19194, 26556, 19031, 26673, 18867, 26789, 18702, 26905, 18537, 27019, 18371, 27132
.dc.w 18204, 27244, 18036, 27355, 17868, 27466, 17699, 27575, 17530, 27683, 17360, 27790, 17189, 27896, 17017, 28001
.dc.w 16845, 28105, 16672, 28208, 16499, 28309, 16325, 28410, 16150, 28510, 15975, 28608, 15799, 28706, 15623, 28802
.dc.w 15446, 28897, 15268, 28992, 15090, 29085, 14911, 29177, 14732, 29268, 14552, 29358, 14372, 29446, 14191, 29534
.dc.w 14009, 29621, 13827, 29706, 13645, 29790, 13462, 29873, 13278, 29955, 13094, 30036, 12909, 30116, 12724, 30195
.dc.w 12539, 30272, 12353, 30349, 12166, 30424, 11980, 30498, 11792, 30571, 11604, 30643, 11416, 30713, 11227, 30783
.dc.w 11038, 30851, 10849, 30918, 10659, 30984, 10469, 31049, 10278, 31113, 10087, 31175, 9895, 31236, 9704, 31297
.dc.w 9511, 31356, 9319, 31413, 9126, 31470, 8933, 31525, 8739, 31580, 8545, 31633, 8351, 31684, 8156, 31735
.dc.w 7961, 31785, 7766, 31833, 7571, 31880, 7375, 31926, 7179, 31970, 6983, 32014, 6786, 32056, 6589, 32097
.dc.w 6392, 32137, 6195, 32176, 5997, 32213, 5799, 32249, 5601, 32284, 5403, 32318, 5205, 32350, 5006, 32382
.dc.w 4807, 32412, 4608, 32441, 4409, 32468, 4210, 32495, 4011, 32520, 3811, 32544, 3611, 32567, 3411, 32588
.dc.w 3211, 32609, 3011, 32628, 2811, 32646, 2610, 32662, 2410, 32678, 2209, 32692, 2009, 32705, 1808, 32717
.dc.w 1607, 32727, 1407, 32736, 1206, 32744, 1005, 32751, 804, 32757, 603, 32761, 402, 32764, 201, 32766
.dc.w 0, 32766, -201, 32766, -402, 32764, -603, 32761, -804, 32757, -1005, 32751, -1206, 32744, -1406, 32736
.dc.w -1607, 32727, -1808, 32717, -2009, 32705, -2209, 32692, -2410, 32678, -2610, 32662, -2811, 32646, -3011, 32628
.dc.w -3211, 32609, -3411, 32588, -3611, 32567, -3811, 32544, -4010, 32520, -4210, 32495, -4409, 32468, -4608, 32441
.dc.w -4807, 32412, -5006, 32382, -5205, 32350, -5403, 32318, -5601, 32284, -5799, 32249, -5997, 32213, -6195, 32176
.dc.w -6392, 32137, -6589, 32097, -6786, 32056, -6982, 32014, -7179, 31970, -7375, 31926, -7571, 31880, -7766, 31833
.dc.w -7961, 31785, -8156, 31735, -8351, 31684, -8545, 31633, -8739, 31580, -8932, 31525, -9126, 31470, -9319, 31413
.dc.w -9511, 31356, -9703, 31297, -9895, 31236, -10087, 31175, -10278, 31113, -10469, 31049, -10659, 30984, -10849, 30918
.dc.w -11038, 30851, -11227, 30783, -11416, 30713, -11604, 30643, -11792, 30571, -11979, 30498, -12166, 30424, -12353, 30349
.dc.w -12539, 30272, -12724, 30195, -12909, 30116, -13094, 30036, -13278, 29955, -13462, 29873, -13645, 29790, -13827, 29706
.dc.w -14009, 29621, -14191, 29534, -14372, 29446, -14552, 29358, -14732, 29268, -14911, 29177, -15090, 29085, -15268, 28992
.dc.w -15446, 28897, -15623, 28802, -15799, 28706, -15975, 28608, -16150, 28510, -16325, 28410, -16499, 28309, -16672, 28208
.dc.w -16845, 28105, -17017, 28001, -17189, 27896, -17360, 27790, -17530, 27683, -17699, 27575, -17868, 27466, -18036, 27355
.dc.w -18204, 27244, -18371, 27132, -18537, 27019, -18702, 26905, -18867, 26789, -19031, 26673, -19194, 26556, -19357, 26438
.dc.w -19519, 26318, -19680, 26198, -19840, 26077, -20000, 25954, -20159, 25831, -20317, 25707, -20474, 25582, -20631, 25456
.dc.w -20787, 25329, -20942, 25201, -21096, 25072, -21249, 24942, -21402, 24811, -21554, 24679, -21705, 24546, -21855, 24413
.dc.w -22004, 24278, -22153, 24143, -22301, 24006, -22448, 23869, -22594, 23731, -22739, 23592, -22883, 23452, -23027, 23311
.dc.w -23169, 23169, -23311, 23027, -23452, 22883, -23592, 22739, -23731, 22594, -23869, 22448, -24006, 22301, -24143, 22153
.dc.w -24278, 22005, -24413, 21855, -24546, 21705, -24679, 21554, -24811, 21402, -24942, 21249, -25072, 21096, -25201, 20942
.dc.w -25329, 20787, -25456, 20631, -25582, 20474, -25707, 20317, -25831, 20159, -25954, 20000, -26077, 19840, -26198, 19680
.dc.w -26318, 19519, -26437, 19357, -26556, 19194, -26673, 19031, -26789, 18867, -26905, 18702, -27019, 18537, -27132, 18371
.dc.w -27244, 18204, -27355, 18036, -27466, 17868, -27575, 17699, -27683, 17530, -27790, 17360, -27896, 17189, -28001, 17017
.dc.w -28105, 16845, -28207, 16672, -28309, 16499, -28410, 16325, -28510, 16150, -28608, 15975, -28706, 15799, -28802, 15623
.dc.w -28897, 15446, -28992, 15268, -29085, 15090, -29177, 14911, -29268, 14732, -29358, 14552, -29446, 14372, -29534, 14191
.dc.w -29620, 14009, -29706, 13827, -29790, 13645, -29873, 13462, -29955, 13278, -30036, 13094, -30116, 12910, -30195, 12724
.dc.w -30272, 12539, -30349, 12353, -30424, 12167, -30498, 11980, -30571, 11792, -30643, 11604, -30713, 11416, -30783, 11228
.dc.w -30851, 11038, -30918, 10849, -30984, 10659, -31049, 10469, -31113, 10278, -31175, 10087, -31236, 9895, -31297, 9704
.dc.w -31356, 9511, -31413, 9319, -31470, 9126, -31525, 8933, -31580, 8739, -31633, 8545, -31684, 8351, -31735, 8156
.dc.w -31784, 7961, -31833, 7766, -31880, 7571, -31926, 7375, -31970, 7179, -32014, 6983, -32056, 6786, -32097, 6589
.dc.w -32137, 6392, -32175, 6195, -32213, 5997, -32249, 5799, -32284, 5601, -32318, 5403, -32350, 5205, -32382, 5006
.dc.w -32412, 4807, -32441, 4609, -32468, 4409, -32495, 4210, -32520, 4011, -32544, 3811, -32567, 3611, -32588, 3411
.dc.w -32609, 3211, -32628, 3011, -32646, 2811, -32662, 2611, -32678, 2410, -32692, 2210, -32705, 2009, -32717, 1808
.dc.w -32727, 1607, -32736, 1407, -32744, 1206, -32751, 1005, -32757, 804, -32761, 603, -32764, 402, -32766, 201
#elif FFT_N == 512
.dc.w 32767, 0, 32764, 402, 32757, 804, 32744, 1206, 32727, 1607, 32705, 2009, 32678, 2410, 32646, 2811
.dc.w 32609, 3211, 32567, 3611, 32520, 4011, 32468, 4409, 32412, 4807, 32350, 5205, 32284, 5601, 32213, 5997
.dc.w 32137, 6392, 32056, 6786, 31970, 7179, 31880, 7571, 31785, 7961, 31684, 8351, 31580, 8739, 31470, 9126
.dc.w 31356, 9511, 31236, 9895, 31113, 10278, 30984, 10659, 30851, 11038, 30713, 11416, 30571, 11792, 30424, 12166
.dc.w 30272, 12539, 30116, 12909, 29955, 13278, 29790, 13645, 29621, 14009, 29446, 14372, 29268, 14732, 29085, 15090
.dc.w 28897, 15446, 28706, 15799, 28510, 16150, 28309, 16499, 28105, 16845, 27896, 17189, 27683, 17530, 27466, 17868
.dc.w 27244, 18204, 27019, 18537, 26789, 18867, 26556, 19194, 26318, 19519, 26077, 19840, 25831, 20159, 25582, 20474
.dc.w 25329, 20787, 25072, 21096, 24811, 21402, 24546, 21705, 24278, 22004, 24006, 22301, 23731, 22594, 23452, 22883
.dc.w 23169, 23169, 22883, 23452, 22594, 23731, 22301, 24006, 22004, 24278, 21705, 24546, 21402, 24811, 21096, 25072
.dc.w 20787, 25329, 20474, 25582, 20159, 25831, 19840, 26077, 19519, 26318, 19194, 26556, 18867, 26789, 18537, 27019
.dc.w 18204, 27244, 17868, 27466, 17530, 27683, 17189, 27896, 16845, 28105, 16499, 28309, 16150, 28510, 15799, 28706
.dc.w 15446, 28897, 15090, 29085, 14732, 29268, 14372, 29446, 14009, 29621, 13645, 29790, 13278, 29955, 12909, 30116
.dc.w 12539, 30272, 12166, 30424, 11792, 30571, 11416, 30713, 11038, 30851, 10659, 30984, 10278, 31113, 9895, 31236
.dc.w 9511, 31356, 9126, 31470, 8739, 31580, 8351, 31684, 7961, 31785, 7571, 31880, 7179, 31970, 6786, 32056
.dc.w 6392, 32137, 5997, 32213, 5601, 32284, 5205, 32350, 4807, 32412, 4409, 32468, 4011, 32520, 3611, 32567
.dc.w 3211, 32609, 2811, 32646, 2410, 32678, 2009, 32705, 1607, 32727, 1206, 32744, 804, 32757, 402, 32764
.dc.w 0, 32766, -402, 32764, -804, 32757, -1206, 32744, -1607, 32727, -2009, 32705, -2410, 32678, -2811, 32646
.dc.w -3211, 32609, -3611, 32567, -4010, 32520, -4409, 32468, -4807, 32412, -5205, 32350, -5601, 32284, -5997, 32213
.dc.w -6392, 32137, -6786, 32056, -7179, 31970, -7571, 31880, -7961, 31785, -8351, 31684, -8739, 31580, -9126, 31470
.dc.w -9511, 31356, -9895, 31236, -10278, 31113, -10659, 30984, -11038, 30851, -11416, 30713, -11792, 30571, -12166, 30424
.dc.w -12539, 30272, -12909, 30116, -13278, 29955, -13645, 29790, -14009, 29621, -14372, 29446, -14732, 29268, -15090, 29085
.dc.w -15446, 28897, -15799, 28706, -16150, 28510, -16499, 28309, -16845, 28105, -17189, 27896, -17530, 27683, -17868, 27466
.dc.w -18204, 27244, -18537, 27019, -18867, 26789, -19194, 26556, -19519, 26318, -19840, 26077, -20159, 25831, -20474, 25582
.dc.w -20787, 25329, -21096, 25072, -21402, 24811, -21705, 24546, -22004, 24278, -22301, 24006, -22594, 23731, -22883, 23452
.dc.w -23169, 23169, -23452, 22883, -23731, 22594, -24006, 22301, -24278, 22005, -24546, 21705, -24811, 21402, -25072, 21096
.dc.w -25329, 20787, -25582, 20474, -25831, 20159, -26077, 19840, -26318, 19519, -26556, 19194, -26789, 18867, -27019, 18537
.dc.w -27244, 18204, -27466, 17868, -27683, 17530, -27896, 17189, -28105, 16845, -28309, 16499, -28510, 16150, -28706, 15799
.dc.w -28897, 15446, -29085, 15090, -29268, 14732, -29446, 14372, -29620, 14009, -29790, 13645, -29955, 13278, -30116, 12910
.dc.w -30272, 12539, -30424, 12167, -30571, 11792, -30713, 11416, -30851, 11038, -30984, 10659, -31113, 10278, -31236, 9895
.dc.w -31356, 9511, -31470, 9126, -31580, 8739, -31684, 8351, -31784, 7961, -31880, 7571, -31970, 7179, -32056, 6786
.dc.w -32137, 6392, -32213, 5997, -32284, 5601, -32350, 5205, -32412, 4807, -32468, 4409, -32520, 4011, -32567, 3611
.dc.w -32609, 3211, -32646, 2811, -32678, 2410, -32705, 2009, -32727, 1607, -32744, 1206, -32757, 804, -32764, 402
#elif FFT_N == 256
.dc.w 32767, 0, 32757, 804, 32727, 1607, 32678, 2410, 32609, 3211, 32520, 4011, 32412, 4807, 32284, 5601
.dc.w 32137, 6392, 31970, 7179, 31785, 7961, 31580, 8739, 31356, 9511, 31113, 10278, 30851, 11038, 30571, 11792
.dc.w 30272, 12539, 29955, 13278, 29621, 14009, 29268, 14732, 28897, 15446, 28510, 16150, 28105, 16845, 27683, 17530
.dc.w 27244, 18204, 26789, 18867, 26318, 19519, 25831, 20159, 25329, 20787, 24811, 21402, 24278, 22004, 23731, 22594
.dc.w 23169, 23169, 22594, 23731, 22004, 24278, 21402, 24811, 20787, 25329, 20159, 25831, 19519, 26318, 18867, 26789
.dc.w 18204, 27244, 17530, 27683, 16845, 28105, 16150, 28510, 15446, 28897, 14732, 29268, 14009, 29621, 13278, 29955
.dc.w 12539, 30272, 11792, 30571, 11038, 30851, 10278, 31113, 9511, 31356, 8739, 31580, 7961, 31785, 7179, 31970
.dc.w 6392, 32137, 5601, 32284, 4807, 32412, 4011, 32520, 3211, 32609, 2410, 32678, 1607, 32727, 804, 32757
.dc.w 0, 32766, -804, 32757, -1607, 32727, -2410, 32678, -3211, 32609, -4010, 32520, -4807, 32412, -5601, 32284
.dc.w -6392, 32137, -7179, 31970, -7961, 31785, -8739, 31580, -9511, 31356, -10278, 31113, -11038, 30851, -11792, 30571
.dc.w -12539, 30272, -13278, 29955, -14009, 29621, -14732, 29268, -15446, 28897, -16150, 28510, -16845, 28105, -17530, 27683
.dc.w -18204, 27244, -18867, 26789, -19519, 26318, -20159, 25831, -20787, 25329, -21402, 24811, -22004, 24278, -22594, 23731
.dc.w -23169, 23169, -23731, 22594, -24278, 22005, -24811, 21402, -25329, 20787, -25831, 20159, -26318, 19519, -26789, 18867
.dc.w -27244, 18204, -27683, 17530, -28105, 16845, -28510, 16150, -28897, 15446, -29268, 14732, -29620, 14009, -29955, 13278
.dc.w -30272, 12539, -30571, 11792, -30851, 11038, -31113, 10278, -31356, 9511, -31580, 8739, -31784, 7961, -31970, 7179
.dc.w -32137, 6392, -32284, 5601, -32412, 4807, -32520, 4011, -32609, 3211, -32678, 2410, -32727, 1607, -32757, 804
#elif FFT_N == 128
.dc.w 32767, 0, 32727, 1607, 32609, 3211, 32412, 4807, 32137, 6392, 31785, 7961, 31356, 9511, 30851, 11038
.dc.w 30272, 12539, 29621, 14009, 28897, 15446, 28105, 16845, 27244, 18204, 26318, 19519, 25329, 20787, 24278, 22004
.dc.w 23169, 23169, 22004, 24278, 20787, 25329, 19519, 26318, 18204, 27244, 16845, 28105, 15446, 28897, 14009, 29621
.dc.w 12539, 30272, 11038, 30851, 9511, 31356, 7961, 31785, 6392, 32137, 4807, 32412, 3211, 32609, 1607, 32727
.dc.w 0, 32766, -1607, 32727, -3211, 32609, -4807, 32412, -6392, 32137, -7961, 31785, -9511, 31356, -11038, 30851
.dc.w -12539, 30272, -14009, 29621, -15446, 28897, -16845, 28105, -18204, 27244, -19519, 26318, -20787, 25329, -22004, 24278
.dc.w -23169, 23169, -24278, 22005, -25329, 20787, -26318, 19519, -27244, 18204, -28105, 16845, -28897, 15446, -29620, 14009
.dc.w -30272, 12539, -30851, 11038, -31356, 9511, -31784, 7961, -32137, 6392, -32412, 4807, -32609, 3211, -32727, 1607
#elif FFT_N == 64
.dc.w 32767, 0, 32609, 3211, 32137, 6392, 31356, 9511, 30272, 12539, 28897, 15446, 27244, 18204, 25329, 20787
.dc.w 23169, 23169, 20787, 25329, 18204, 27244, 15446, 28897, 12539, 30272, 9511, 31356, 6392, 32137, 3211, 32609
.dc.w 0, 32766, -3211, 32609, -6392, 32137, -9511, 31356, -12539, 30272, -15446, 28897, -18204, 27244, -20787, 25329
.dc.w -23169, 23169, -25329, 20787, -27244, 18204, -28897, 15446, -30272, 12539, -31356, 9511, -32137, 6392, -32609, 3211
#endif
tbl_bitrev: ; tbl_bitrev[] = ...
#if FFT_N == 1024
#ifdef INPUT_IQ
.dc.w 1*4, 513*4, 257*4, 769*4, 129*4, 641*4, 385*4, 897*4, 65*4, 577*4, 321*4, 833*4, 193*4, 705*4, 449*4, 961*4
.dc.w 33*4, 545*4, 289*4, 801*4, 161*4, 673*4, 417*4, 929*4, 97*4, 609*4, 353*4, 865*4, 225*4, 737*4, 481*4, 993*4
.dc.w 17*4, 529*4, 273*4, 785*4, 145*4, 657*4, 401*4, 913*4, 81*4, 593*4, 337*4, 849*4, 209*4, 721*4, 465*4, 977*4
.dc.w 49*4, 561*4, 305*4, 817*4, 177*4, 689*4, 433*4, 945*4, 113*4, 625*4, 369*4, 881*4, 241*4, 753*4, 497*4, 1009*4
.dc.w 9*4, 521*4, 265*4, 777*4, 137*4, 649*4, 393*4, 905*4, 73*4, 585*4, 329*4, 841*4, 201*4, 713*4, 457*4, 969*4
.dc.w 41*4, 553*4, 297*4, 809*4, 169*4, 681*4, 425*4, 937*4, 105*4, 617*4, 361*4, 873*4, 233*4, 745*4, 489*4, 1001*4
.dc.w 25*4, 537*4, 281*4, 793*4, 153*4, 665*4, 409*4, 921*4, 89*4, 601*4, 345*4, 857*4, 217*4, 729*4, 473*4, 985*4
.dc.w 57*4, 569*4, 313*4, 825*4, 185*4, 697*4, 441*4, 953*4, 121*4, 633*4, 377*4, 889*4, 249*4, 761*4, 505*4, 1017*4
.dc.w 5*4, 517*4, 261*4, 773*4, 133*4, 645*4, 389*4, 901*4, 69*4, 581*4, 325*4, 837*4, 197*4, 709*4, 453*4, 965*4
.dc.w 37*4, 549*4, 293*4, 805*4, 165*4, 677*4, 421*4, 933*4, 101*4, 613*4, 357*4, 869*4, 229*4, 741*4, 485*4, 997*4
.dc.w 21*4, 533*4, 277*4, 789*4, 149*4, 661*4, 405*4, 917*4, 85*4, 597*4, 341*4, 853*4, 213*4, 725*4, 469*4, 981*4
.dc.w 53*4, 565*4, 309*4, 821*4, 181*4, 693*4, 437*4, 949*4, 117*4, 629*4, 373*4, 885*4, 245*4, 757*4, 501*4, 1013*4
.dc.w 13*4, 525*4, 269*4, 781*4, 141*4, 653*4, 397*4, 909*4, 77*4, 589*4, 333*4, 845*4, 205*4, 717*4, 461*4, 973*4
.dc.w 45*4, 557*4, 301*4, 813*4, 173*4, 685*4, 429*4, 941*4, 109*4, 621*4, 365*4, 877*4, 237*4, 749*4, 493*4, 1005*4
.dc.w 29*4, 541*4, 285*4, 797*4, 157*4, 669*4, 413*4, 925*4, 93*4, 605*4, 349*4, 861*4, 221*4, 733*4, 477*4, 989*4
.dc.w 61*4, 573*4, 317*4, 829*4, 189*4, 701*4, 445*4, 957*4, 125*4, 637*4, 381*4, 893*4, 253*4, 765*4, 509*4, 1021*4
.dc.w 3*4, 515*4, 259*4, 771*4, 131*4, 643*4, 387*4, 899*4, 67*4, 579*4, 323*4, 835*4, 195*4, 707*4, 451*4, 963*4
.dc.w 35*4, 547*4, 291*4, 803*4, 163*4, 675*4, 419*4, 931*4, 99*4, 611*4, 355*4, 867*4, 227*4, 739*4, 483*4, 995*4
.dc.w 19*4, 531*4, 275*4, 787*4, 147*4, 659*4, 403*4, 915*4, 83*4, 595*4, 339*4, 851*4, 211*4, 723*4, 467*4, 979*4
.dc.w 51*4, 563*4, 307*4, 819*4, 179*4, 691*4, 435*4, 947*4, 115*4, 627*4, 371*4, 883*4, 243*4, 755*4, 499*4, 1011*4
.dc.w 11*4, 523*4, 267*4, 779*4, 139*4, 651*4, 395*4, 907*4, 75*4, 587*4, 331*4, 843*4, 203*4, 715*4, 459*4, 971*4
.dc.w 43*4, 555*4, 299*4, 811*4, 171*4, 683*4, 427*4, 939*4, 107*4, 619*4, 363*4, 875*4, 235*4, 747*4, 491*4, 1003*4
.dc.w 27*4, 539*4, 283*4, 795*4, 155*4, 667*4, 411*4, 923*4, 91*4, 603*4, 347*4, 859*4, 219*4, 731*4, 475*4, 987*4
.dc.w 59*4, 571*4, 315*4, 827*4, 187*4, 699*4, 443*4, 955*4, 123*4, 635*4, 379*4, 891*4, 251*4, 763*4, 507*4, 1019*4
.dc.w 7*4, 519*4, 263*4, 775*4, 135*4, 647*4, 391*4, 903*4, 71*4, 583*4, 327*4, 839*4, 199*4, 711*4, 455*4, 967*4
.dc.w 39*4, 551*4, 295*4, 807*4, 167*4, 679*4, 423*4, 935*4, 103*4, 615*4, 359*4, 871*4, 231*4, 743*4, 487*4, 999*4
.dc.w 23*4, 535*4, 279*4, 791*4, 151*4, 663*4, 407*4, 919*4, 87*4, 599*4, 343*4, 855*4, 215*4, 727*4, 471*4, 983*4
.dc.w 55*4, 567*4, 311*4, 823*4, 183*4, 695*4, 439*4, 951*4, 119*4, 631*4, 375*4, 887*4, 247*4, 759*4, 503*4, 1015*4
.dc.w 15*4, 527*4, 271*4, 783*4, 143*4, 655*4, 399*4, 911*4, 79*4, 591*4, 335*4, 847*4, 207*4, 719*4, 463*4, 975*4
.dc.w 47*4, 559*4, 303*4, 815*4, 175*4, 687*4, 431*4, 943*4, 111*4, 623*4, 367*4, 879*4, 239*4, 751*4, 495*4, 1007*4
.dc.w 31*4, 543*4, 287*4, 799*4, 159*4, 671*4, 415*4, 927*4, 95*4, 607*4, 351*4, 863*4, 223*4, 735*4, 479*4, 991*4
.dc.w 63*4, 575*4, 319*4, 831*4, 191*4, 703*4, 447*4, 959*4, 127*4, 639*4, 383*4, 895*4, 255*4, 767*4, 511*4, 1023*4
#endif
.dc.w 0*4, 512*4, 256*4, 768*4, 128*4, 640*4, 384*4, 896*4, 64*4, 576*4, 320*4, 832*4, 192*4, 704*4, 448*4, 960*4
.dc.w 32*4, 544*4, 288*4, 800*4, 160*4, 672*4, 416*4, 928*4, 96*4, 608*4, 352*4, 864*4, 224*4, 736*4, 480*4, 992*4
.dc.w 16*4, 528*4, 272*4, 784*4, 144*4, 656*4, 400*4, 912*4, 80*4, 592*4, 336*4, 848*4, 208*4, 720*4, 464*4, 976*4
.dc.w 48*4, 560*4, 304*4, 816*4, 176*4, 688*4, 432*4, 944*4, 112*4, 624*4, 368*4, 880*4, 240*4, 752*4, 496*4, 1008*4
.dc.w 8*4, 520*4, 264*4, 776*4, 136*4, 648*4, 392*4, 904*4, 72*4, 584*4, 328*4, 840*4, 200*4, 712*4, 456*4, 968*4
.dc.w 40*4, 552*4, 296*4, 808*4, 168*4, 680*4, 424*4, 936*4, 104*4, 616*4, 360*4, 872*4, 232*4, 744*4, 488*4, 1000*4
.dc.w 24*4, 536*4, 280*4, 792*4, 152*4, 664*4, 408*4, 920*4, 88*4, 600*4, 344*4, 856*4, 216*4, 728*4, 472*4, 984*4
.dc.w 56*4, 568*4, 312*4, 824*4, 184*4, 696*4, 440*4, 952*4, 120*4, 632*4, 376*4, 888*4, 248*4, 760*4, 504*4, 1016*4
.dc.w 4*4, 516*4, 260*4, 772*4, 132*4, 644*4, 388*4, 900*4, 68*4, 580*4, 324*4, 836*4, 196*4, 708*4, 452*4, 964*4
.dc.w 36*4, 548*4, 292*4, 804*4, 164*4, 676*4, 420*4, 932*4, 100*4, 612*4, 356*4, 868*4, 228*4, 740*4, 484*4, 996*4
.dc.w 20*4, 532*4, 276*4, 788*4, 148*4, 660*4, 404*4, 916*4, 84*4, 596*4, 340*4, 852*4, 212*4, 724*4, 468*4, 980*4
.dc.w 52*4, 564*4, 308*4, 820*4, 180*4, 692*4, 436*4, 948*4, 116*4, 628*4, 372*4, 884*4, 244*4, 756*4, 500*4, 1012*4
.dc.w 12*4, 524*4, 268*4, 780*4, 140*4, 652*4, 396*4, 908*4, 76*4, 588*4, 332*4, 844*4, 204*4, 716*4, 460*4, 972*4
.dc.w 44*4, 556*4, 300*4, 812*4, 172*4, 684*4, 428*4, 940*4, 108*4, 620*4, 364*4, 876*4, 236*4, 748*4, 492*4, 1004*4
.dc.w 28*4, 540*4, 284*4, 796*4, 156*4, 668*4, 412*4, 924*4, 92*4, 604*4, 348*4, 860*4, 220*4, 732*4, 476*4, 988*4
.dc.w 60*4, 572*4, 316*4, 828*4, 188*4, 700*4, 444*4, 956*4, 124*4, 636*4, 380*4, 892*4, 252*4, 764*4, 508*4, 1020*4
.dc.w 2*4, 514*4, 258*4, 770*4, 130*4, 642*4, 386*4, 898*4, 66*4, 578*4, 322*4, 834*4, 194*4, 706*4, 450*4, 962*4
.dc.w 34*4, 546*4, 290*4, 802*4, 162*4, 674*4, 418*4, 930*4, 98*4, 610*4, 354*4, 866*4, 226*4, 738*4, 482*4, 994*4
.dc.w 18*4, 530*4, 274*4, 786*4, 146*4, 658*4, 402*4, 914*4, 82*4, 594*4, 338*4, 850*4, 210*4, 722*4, 466*4, 978*4
.dc.w 50*4, 562*4, 306*4, 818*4, 178*4, 690*4, 434*4, 946*4, 114*4, 626*4, 370*4, 882*4, 242*4, 754*4, 498*4, 1010*4
.dc.w 10*4, 522*4, 266*4, 778*4, 138*4, 650*4, 394*4, 906*4, 74*4, 586*4, 330*4, 842*4, 202*4, 714*4, 458*4, 970*4
.dc.w 42*4, 554*4, 298*4, 810*4, 170*4, 682*4, 426*4, 938*4, 106*4, 618*4, 362*4, 874*4, 234*4, 746*4, 490*4, 1002*4
.dc.w 26*4, 538*4, 282*4, 794*4, 154*4, 666*4, 410*4, 922*4, 90*4, 602*4, 346*4, 858*4, 218*4, 730*4, 474*4, 986*4
.dc.w 58*4, 570*4, 314*4, 826*4, 186*4, 698*4, 442*4, 954*4, 122*4, 634*4, 378*4, 890*4, 250*4, 762*4, 506*4, 1018*4
.dc.w 6*4, 518*4, 262*4, 774*4, 134*4, 646*4, 390*4, 902*4, 70*4, 582*4, 326*4, 838*4, 198*4, 710*4, 454*4, 966*4
.dc.w 38*4, 550*4, 294*4, 806*4, 166*4, 678*4, 422*4, 934*4, 102*4, 614*4, 358*4, 870*4, 230*4, 742*4, 486*4, 998*4
.dc.w 22*4, 534*4, 278*4, 790*4, 150*4, 662*4, 406*4, 918*4, 86*4, 598*4, 342*4, 854*4, 214*4, 726*4, 470*4, 982*4
.dc.w 54*4, 566*4, 310*4, 822*4, 182*4, 694*4, 438*4, 950*4, 118*4, 630*4, 374*4, 886*4, 246*4, 758*4, 502*4, 1014*4
.dc.w 14*4, 526*4, 270*4, 782*4, 142*4, 654*4, 398*4, 910*4, 78*4, 590*4, 334*4, 846*4, 206*4, 718*4, 462*4, 974*4
.dc.w 46*4, 558*4, 302*4, 814*4, 174*4, 686*4, 430*4, 942*4, 110*4, 622*4, 366*4, 878*4, 238*4, 750*4, 494*4, 1006*4
.dc.w 30*4, 542*4, 286*4, 798*4, 158*4, 670*4, 414*4, 926*4, 94*4, 606*4, 350*4, 862*4, 222*4, 734*4, 478*4, 990*4
.dc.w 62*4, 574*4, 318*4, 830*4, 190*4, 702*4, 446*4, 958*4, 126*4, 638*4, 382*4, 894*4, 254*4, 766*4, 510*4, 1022*4
#elif FFT_N == 512
#ifdef INPUT_IQ
.dc.w 1*4, 257*4, 129*4, 385*4, 65*4, 321*4, 193*4, 449*4, 33*4, 289*4, 161*4, 417*4, 97*4, 353*4, 225*4, 481*4
.dc.w 17*4, 273*4, 145*4, 401*4, 81*4, 337*4, 209*4, 465*4, 49*4, 305*4, 177*4, 433*4, 113*4, 369*4, 241*4, 497*4
.dc.w 9*4, 265*4, 137*4, 393*4, 73*4, 329*4, 201*4, 457*4, 41*4, 297*4, 169*4, 425*4, 105*4, 361*4, 233*4, 489*4
.dc.w 25*4, 281*4, 153*4, 409*4, 89*4, 345*4, 217*4, 473*4, 57*4, 313*4, 185*4, 441*4, 121*4, 377*4, 249*4, 505*4
.dc.w 5*4, 261*4, 133*4, 389*4, 69*4, 325*4, 197*4, 453*4, 37*4, 293*4, 165*4, 421*4, 101*4, 357*4, 229*4, 485*4
.dc.w 21*4, 277*4, 149*4, 405*4, 85*4, 341*4, 213*4, 469*4, 53*4, 309*4, 181*4, 437*4, 117*4, 373*4, 245*4, 501*4
.dc.w 13*4, 269*4, 141*4, 397*4, 77*4, 333*4, 205*4, 461*4, 45*4, 301*4, 173*4, 429*4, 109*4, 365*4, 237*4, 493*4
.dc.w 29*4, 285*4, 157*4, 413*4, 93*4, 349*4, 221*4, 477*4, 61*4, 317*4, 189*4, 445*4, 125*4, 381*4, 253*4, 509*4
.dc.w 3*4, 259*4, 131*4, 387*4, 67*4, 323*4, 195*4, 451*4, 35*4, 291*4, 163*4, 419*4, 99*4, 355*4, 227*4, 483*4
.dc.w 19*4, 275*4, 147*4, 403*4, 83*4, 339*4, 211*4, 467*4, 51*4, 307*4, 179*4, 435*4, 115*4, 371*4, 243*4, 499*4
.dc.w 11*4, 267*4, 139*4, 395*4, 75*4, 331*4, 203*4, 459*4, 43*4, 299*4, 171*4, 427*4, 107*4, 363*4, 235*4, 491*4
.dc.w 27*4, 283*4, 155*4, 411*4, 91*4, 347*4, 219*4, 475*4, 59*4, 315*4, 187*4, 443*4, 123*4, 379*4, 251*4, 507*4
.dc.w 7*4, 263*4, 135*4, 391*4, 71*4, 327*4, 199*4, 455*4, 39*4, 295*4, 167*4, 423*4, 103*4, 359*4, 231*4, 487*4
.dc.w 23*4, 279*4, 151*4, 407*4, 87*4, 343*4, 215*4, 471*4, 55*4, 311*4, 183*4, 439*4, 119*4, 375*4, 247*4, 503*4
.dc.w 15*4, 271*4, 143*4, 399*4, 79*4, 335*4, 207*4, 463*4, 47*4, 303*4, 175*4, 431*4, 111*4, 367*4, 239*4, 495*4
.dc.w 31*4, 287*4, 159*4, 415*4, 95*4, 351*4, 223*4, 479*4, 63*4, 319*4, 191*4, 447*4, 127*4, 383*4, 255*4, 511*4
#endif
.dc.w 0*4, 256*4, 128*4, 384*4, 64*4, 320*4, 192*4, 448*4, 32*4, 288*4, 160*4, 416*4, 96*4, 352*4, 224*4, 480*4
.dc.w 16*4, 272*4, 144*4, 400*4, 80*4, 336*4, 208*4, 464*4, 48*4, 304*4, 176*4, 432*4, 112*4, 368*4, 240*4, 496*4
.dc.w 8*4, 264*4, 136*4, 392*4, 72*4, 328*4, 200*4, 456*4, 40*4, 296*4, 168*4, 424*4, 104*4, 360*4, 232*4, 488*4
.dc.w 24*4, 280*4, 152*4, 408*4, 88*4, 344*4, 216*4, 472*4, 56*4, 312*4, 184*4, 440*4, 120*4, 376*4, 248*4, 504*4
.dc.w 4*4, 260*4, 132*4, 388*4, 68*4, 324*4, 196*4, 452*4, 36*4, 292*4, 164*4, 420*4, 100*4, 356*4, 228*4, 484*4
.dc.w 20*4, 276*4, 148*4, 404*4, 84*4, 340*4, 212*4, 468*4, 52*4, 308*4, 180*4, 436*4, 116*4, 372*4, 244*4, 500*4
.dc.w 12*4, 268*4, 140*4, 396*4, 76*4, 332*4, 204*4, 460*4, 44*4, 300*4, 172*4, 428*4, 108*4, 364*4, 236*4, 492*4
.dc.w 28*4, 284*4, 156*4, 412*4, 92*4, 348*4, 220*4, 476*4, 60*4, 316*4, 188*4, 444*4, 124*4, 380*4, 252*4, 508*4
.dc.w 2*4, 258*4, 130*4, 386*4, 66*4, 322*4, 194*4, 450*4, 34*4, 290*4, 162*4, 418*4, 98*4, 354*4, 226*4, 482*4
.dc.w 18*4, 274*4, 146*4, 402*4, 82*4, 338*4, 210*4, 466*4, 50*4, 306*4, 178*4, 434*4, 114*4, 370*4, 242*4, 498*4
.dc.w 10*4, 266*4, 138*4, 394*4, 74*4, 330*4, 202*4, 458*4, 42*4, 298*4, 170*4, 426*4, 106*4, 362*4, 234*4, 490*4
.dc.w 26*4, 282*4, 154*4, 410*4, 90*4, 346*4, 218*4, 474*4, 58*4, 314*4, 186*4, 442*4, 122*4, 378*4, 250*4, 506*4
.dc.w 6*4, 262*4, 134*4, 390*4, 70*4, 326*4, 198*4, 454*4, 38*4, 294*4, 166*4, 422*4, 102*4, 358*4, 230*4, 486*4
.dc.w 22*4, 278*4, 150*4, 406*4, 86*4, 342*4, 214*4, 470*4, 54*4, 310*4, 182*4, 438*4, 118*4, 374*4, 246*4, 502*4
.dc.w 14*4, 270*4, 142*4, 398*4, 78*4, 334*4, 206*4, 462*4, 46*4, 302*4, 174*4, 430*4, 110*4, 366*4, 238*4, 494*4
.dc.w 30*4, 286*4, 158*4, 414*4, 94*4, 350*4, 222*4, 478*4, 62*4, 318*4, 190*4, 446*4, 126*4, 382*4, 254*4, 510*4
#elif FFT_N == 256
#ifdef INPUT_IQ
.dc.w 1*4, 129*4, 65*4, 193*4, 33*4, 161*4, 97*4, 225*4, 17*4, 145*4, 81*4, 209*4, 49*4, 177*4, 113*4, 241*4
.dc.w 9*4, 137*4, 73*4, 201*4, 41*4, 169*4, 105*4, 233*4, 25*4, 153*4, 89*4, 217*4, 57*4, 185*4, 121*4, 249*4
.dc.w 5*4, 133*4, 69*4, 197*4, 37*4, 165*4, 101*4, 229*4, 21*4, 149*4, 85*4, 213*4, 53*4, 181*4, 117*4, 245*4
.dc.w 13*4, 141*4, 77*4, 205*4, 45*4, 173*4, 109*4, 237*4, 29*4, 157*4, 93*4, 221*4, 61*4, 189*4, 125*4, 253*4
.dc.w 3*4, 131*4, 67*4, 195*4, 35*4, 163*4, 99*4, 227*4, 19*4, 147*4, 83*4, 211*4, 51*4, 179*4, 115*4, 243*4
.dc.w 11*4, 139*4, 75*4, 203*4, 43*4, 171*4, 107*4, 235*4, 27*4, 155*4, 91*4, 219*4, 59*4, 187*4, 123*4, 251*4
.dc.w 7*4, 135*4, 71*4, 199*4, 39*4, 167*4, 103*4, 231*4, 23*4, 151*4, 87*4, 215*4, 55*4, 183*4, 119*4, 247*4
.dc.w 15*4, 143*4, 79*4, 207*4, 47*4, 175*4, 111*4, 239*4, 31*4, 159*4, 95*4, 223*4, 63*4, 191*4, 127*4, 255*4
#endif
.dc.w 0*4, 128*4, 64*4, 192*4, 32*4, 160*4, 96*4, 224*4, 16*4, 144*4, 80*4, 208*4, 48*4, 176*4, 112*4, 240*4
.dc.w 8*4, 136*4, 72*4, 200*4, 40*4, 168*4, 104*4, 232*4, 24*4, 152*4, 88*4, 216*4, 56*4, 184*4, 120*4, 248*4
.dc.w 4*4, 132*4, 68*4, 196*4, 36*4, 164*4, 100*4, 228*4, 20*4, 148*4, 84*4, 212*4, 52*4, 180*4, 116*4, 244*4
.dc.w 12*4, 140*4, 76*4, 204*4, 44*4, 172*4, 108*4, 236*4, 28*4, 156*4, 92*4, 220*4, 60*4, 188*4, 124*4, 252*4
.dc.w 2*4, 130*4, 66*4, 194*4, 34*4, 162*4, 98*4, 226*4, 18*4, 146*4, 82*4, 210*4, 50*4, 178*4, 114*4, 242*4
.dc.w 10*4, 138*4, 74*4, 202*4, 42*4, 170*4, 106*4, 234*4, 26*4, 154*4, 90*4, 218*4, 58*4, 186*4, 122*4, 250*4
.dc.w 6*4, 134*4, 70*4, 198*4, 38*4, 166*4, 102*4, 230*4, 22*4, 150*4, 86*4, 214*4, 54*4, 182*4, 118*4, 246*4
.dc.w 14*4, 142*4, 78*4, 206*4, 46*4, 174*4, 110*4, 238*4, 30*4, 158*4, 94*4, 222*4, 62*4, 190*4, 126*4, 254*4
#elif FFT_N == 128
#ifdef INPUT_IQ
.dc.w 1*4, 65*4, 33*4, 97*4, 17*4, 81*4, 49*4, 113*4, 9*4, 73*4, 41*4, 105*4, 25*4, 89*4, 57*4, 121*4
.dc.w 5*4, 69*4, 37*4, 101*4, 21*4, 85*4, 53*4, 117*4, 13*4, 77*4, 45*4, 109*4, 29*4, 93*4, 61*4, 125*4
.dc.w 3*4, 67*4, 35*4, 99*4, 19*4, 83*4, 51*4, 115*4, 11*4, 75*4, 43*4, 107*4, 27*4, 91*4, 59*4, 123*4
.dc.w 7*4, 71*4, 39*4, 103*4, 23*4, 87*4, 55*4, 119*4, 15*4, 79*4, 47*4, 111*4, 31*4, 95*4, 63*4, 127*4
#endif
.dc.w 0*4, 64*4, 32*4, 96*4, 16*4, 80*4, 48*4, 112*4, 8*4, 72*4, 40*4, 104*4, 24*4, 88*4, 56*4, 120*4
.dc.w 4*4, 68*4, 36*4, 100*4, 20*4, 84*4, 52*4, 116*4, 12*4, 76*4, 44*4, 108*4, 28*4, 92*4, 60*4, 124*4
.dc.w 2*4, 66*4, 34*4, 98*4, 18*4, 82*4, 50*4, 114*4, 10*4, 74*4, 42*4, 106*4, 26*4, 90*4, 58*4, 122*4
.dc.w 6*4, 70*4, 38*4, 102*4, 22*4, 86*4, 54*4, 118*4, 14*4, 78*4, 46*4, 110*4, 30*4, 94*4, 62*4, 126*4
#elif FFT_N == 64
#ifdef INPUT_IQ
.dc.w 1*4, 33*4, 17*4, 49*4, 9*4, 41*4, 25*4, 57*4, 5*4, 37*4, 21*4, 53*4, 13*4, 45*4, 29*4, 61*4
.dc.w 3*4, 35*4, 19*4, 51*4, 11*4, 43*4, 27*4, 59*4, 7*4, 39*4, 23*4, 55*4, 15*4, 47*4, 31*4, 63*4
#endif
.dc.w 0*4, 32*4, 16*4, 48*4, 8*4, 40*4, 24*4, 56*4, 4*4, 36*4, 20*4, 52*4, 12*4, 44*4, 28*4, 60*4
.dc.w 2*4, 34*4, 18*4, 50*4, 10*4, 42*4, 26*4, 58*4, 6*4, 38*4, 22*4, 54*4, 14*4, 46*4, 30*4, 62*4
#endif
;----------------------------------------------------------------------------;
#ifndef INPUT_NOUSE
.global fft_input
.func fft_input
fft_input:
pushw T2H,T2L
pushw AH,AL
pushw YH,YL
movw XL, EL ;X = array_src;
movw YL, DL ;Y = array_bfly;
clr EH ;Zero
ldiw ZH,ZL, tbl_window ;Z = &tbl_window[0];
ldiw AH,AL, FFT_N ;A = FFT_N;
1: lpmw BH,BL, Z+ ;B = *Z++; (window)
ldw CH,CL, X+ ;C = *X++; (I-axis)
FMULS16 DH,DL,T2H,T2L, BH,BL, CH,CL ;D = B * C;
stw Y+, DH,DL ;*Y++ = D;
#ifdef INPUT_IQ
ldw CH,CL, X+ ;C = *X++; (Q-axis)
FMULS16 DH,DL,T2H,T2L, BH,BL, CH,CL ;D = B * C;
#endif
stw Y+, DH,DL ;*Y++ = D;
subiw AH,AL, 1 ;while(--A)
brne 1b ;/
popw YH,YL
popw AH,AL
popw T2H,T2L
clr r1
ret
.endfunc
; Copies not raw data, but pre-windowed data from the capture array and copies it to the real and imaginary members of the complex_t array members
.global fft_input2
.func fft_input2
fft_input2:
pushw AH,AL
pushw YH,YL
movw XL, EL ;X = array_src;
movw YL, DL ;Y = array_bfly;
ldiw AH,AL, FFT_N ;A = FFT_N;
1:
ldw CH,CL, X+ ;C = *X++; (I-axis)
stw Y+, CH,CL ;*Y++ = D; ; copy to real real
stw Y+, CH,CL ;*Y++ = D; ; also copy to imaginary
subiw AH,AL, 1 ;while(--A)
brne 1b ;/
popw YH,YL
popw AH,AL
ret
.endfunc
#endif /* INPUT_NOUSE */
;----------------------------------------------------------------------------;
.global fft_execute
.func fft_execute
fft_execute:
pushw T2H,T2L
pushw T4H,T4L
pushw T6H,T6L
pushw T8H,T8L
pushw T10H,T10L
pushw T12H,T12L
pushw T14H,T14L
pushw AH,AL
pushw YH,YL
movw ZL, EL ;Z = array_bfly;
ldiw EH,EL, 1 ;E = 1;
ldiw XH,XL, FFT_N/2 ;X = FFT_N/2;
1:
ldi AL, 4 ;T12 = E; (angular speed)
mul EL, AL ;
movw T12L, T0L ;
mul EH, AL ;
add T12H, T0L ;/
movw T14L, EL ;T14 = E;
pushw EH,EL
movw YL, ZL ;Z = &array_bfly[0];
mul XL, AL ;Y = &array_bfly[X];
addw YH,YL, T0H,T0L ;
mul XH, AL ;
add YH, T0L ;/
pushw ZH,ZL
2:
clrw T10H,T10L ;T10 = 0 (angle)
clr EH ;Zero reg.
3:
lddw AH,AL, Z+0 ;A = *Z - *Y; *Z++ += *Y;
asrw AH,AL ;
lddw DH,DL, Y+0 ;
asrw DH,DL ;
movw CL, AL ;
subw AH,AL, DH,DL ;
addw CH,CL, DH,DL ;
stw Z+, CH,CL ;/
lddw BH,BL, Z+0 ;B = *Z - *Y; *Z++ += *Y;
asrw BH,BL ;
lddw DH,DL, Y+2 ;
asrw DH,DL ;
movw CL, BL ;
subw BH,BL, DH,DL ;
addw CH,CL, DH,DL ;
stw Z+, CH,CL ;/
movw T0L, ZL
ldiw ZH,ZL, tbl_cos_sin ;C = cos(T10); D = sin(T10);
addw ZH,ZL, T10H,T10L ;
lpmw CH,CL, Z+ ;
lpmw DH,DL, Z+ ;/
movw ZL, T0L
FMULS16 T4H,T4L,T2H,T2L, AH,AL, CH,CL ;*Y++ = A * C + B * D;
FMULS16 T8H,T8L,T6H,T6L, BH,BL, DH,DL ;
addd T4H,T4L,T2H,T2L, T8H,T8L,T6H,T6L;
stw Y+, T4H,T4L ;/
FMULS16 T4H,T4L,T2H,T2L, BH,BL, CH,CL ;*Y++ = B * C - A * D;
FMULS16 T8H,T8L,T6H,T6L, AH,AL, DH,DL ;
subd T4H,T4L,T2H,T2L, T8H,T8L,T6H,T6L;
stw Y+, T4H,T4L ;/
addw T10H,T10L, T12H,T12L ;T10 += T12; (next angle)
#if FFT_N >= 128
sbrs T10H, FFT_B - 7 ;while(T10 < pi)
#else
sbrs T10L, FFT_B + 1
#endif
rjmp 3b ;/
ldi AL, 4 ;Y += X; Z += X; (skip split segment)
mul XL, AL
addw YH,YL, T0H,T0L ;
addw ZH,ZL, T0H,T0L ;
mul XH, AL ;
add YH, T0L ;
add ZH, T0L ;/
ldi EL, 1 ;while(--T14)
subw T14H,T14L, EH,EL ;
rjne 2b ;/
popw ZH,ZL
popw EH,EL
lslw EH,EL ;E *= 2;
lsrw XH,XL ;while(X /= 2)
adiw XL, 0 ;
rjne 1b ;/
popw YH,YL
popw AH,AL
popw T14H,T14L
popw T12H,T12L
popw T10H,T10L
popw T8H,T8L
popw T6H,T6L
popw T4H,T4L
popw T2H,T2L
; clr r1
ret
.endfunc
.macro FFT_OUTPUT_CLEANUP_AND_RETURN
st Y+,BL ; Store the final value into the output buffer
subiw AH,AL, 1 ;while(--A)
rjne 1b ;/
popw YH,YL
popw AH,AL
popw T10H,T10L
popw T8H,T8L
popw T6H,T6L
popw T4H,T4L
popw T2H,T2L
ret
.endm
;----------------------------------------------------------------------------;
.global fft_output
.func fft_output
fft_output:
pushw T2H,T2L
pushw T4H,T4L
pushw T6H,T6L
pushw T8H,T8L
pushw T10H,T10L
pushw AH,AL
pushw YH,YL
; DL:DH is the pointer to spektrum
movw T10L, EL ;T10 = array_bfly;
; Using Y as output data pointer
movw YL, DL ;Y = array_output;
ldiw ZH,ZL, tbl_bitrev ;Z = tbl_bitrev;
clr EH ;Zero
#ifdef INPUT_IQ
ldiw AH,AL, FFT_N ;A = FFT_N; (plus/minus)
#else
ldiw AH,AL, FFT_N / 2 ;A = FFT_N / 2; (plus only)
#endif
1: lpmw XH,XL, Z+ ;X = *Z++;
addw XH,XL, T10H,T10L ;X += array_bfly;
ldw BH,BL, X+ ;B = *X++;
ldw CH,CL, X+ ;C = *X++;
FMULS16 T4H,T4L,T2H,T2L, BH,BL, BH,BL ;T4:T2 = B * B;
FMULS16 T8H,T8L,T6H,T6L, CH,CL, CH,CL ;T8:T6 = C * C;
addd T4H,T4L,T2H,T2L, T8H,T8L,T6H,T6L;T4:T2 += T8:T6;
SQRT32 ;B = sqrt(T4:T2);
;;;;;;;;;;;;;;;;; XXX
;; Edited!!! -Bradley
;stw Y+, BH,BL ;*Y++ = B;
; Only store the low 8 bits cuz that's all we need
;;
; divide steps loop
lds XL,(divide_steps) ; test for non-zero
cpi XL,0
breq 5f ; continue if zero
4:
; Divide by 2
lsr BH
ror BL
dec XL ; Decrement the divide_steps counter
brne 4b ; Branch out when divide steps reaches 0
5:
; Check if the high byte still has a value
cpi BH,0
brne 6f ; if non-zero, set BL to 0xff
FFT_OUTPUT_CLEANUP_AND_RETURN
6:
ldi BL,0xff
FFT_OUTPUT_CLEANUP_AND_RETURN
.endfunc
;----------------------------------------------------------------------------;
.global fmuls_f
.func fmuls_f
fmuls_f:
movw CL, EL ;C = E;
clr EH ;Zero
FMULS16 ZH,ZL,XH,XL, CH,CL, DH,DL ;Z:X = C * D;
movw EL, ZL
ret
.endfunc