home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume5 / dsp-fft < prev    next >
Encoding:
Internet Message Format  |  1989-02-03  |  19.1 KB

  1. Path: xanth!nic.MR.NET!hal!ncoast!allbery
  2. From: dan@srs.UUCP (Dan Kegel)
  3. Newsgroups: comp.sources.misc
  4. Subject: v05i015: fft generating routines
  5. Message-ID: <8810261809.AA21153@rem.srs.com>
  6. Date: 28 Oct 88 02:48:45 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: dan@srs.UUCP (Dan Kegel)
  9. Organization: S.R.Systems
  10. Lines: 563
  11. Approved: allbery@ncoast.UUCP
  12.  
  13. Posting-number: Volume 5, Issue 15
  14. Submitted-by: "Dan Kegel" <dan@srs.UUCP>
  15. Archive-name: dsp-fft
  16.  
  17. Here are some routines I slapped together to generate inline code
  18. to perform FFT's of any power-of-2 size; this was done for a TMS32020
  19. project, but it may be useful for any DSP chip.
  20. It hasn't been tested, but it looks correct, and should be helpful
  21. to anybody who was about to do the same thing :-)
  22.  
  23. #!/bin/sh
  24. #
  25. # shar archiver, delete everything above the #!/bin/sh line
  26. # and run through sh (not csh)
  27. #
  28. echo 'shar: extracting "README" (735 characters)'
  29. # 'README' has a checksum of 18124 on BSD and 468 on System V.
  30. sed 's/^X//' > README << 'XXX_EOF_XXX'
  31. XHere's a little package I wrote out of frustration with the example
  32. XFFT routines given by TI in their online application notes.
  33. XAlthough they gave examples for a couple sizes, they didn't show how to 
  34. Xgenerate FFT routines for other sizes.
  35. XWell... a little lurking around in Oppenheim & Schafer and in Blahut,
  36. Xand voila, two programs to generate inline decimation-in-time fft routines.
  37. X
  38. XTo try it out, unpack the archive, then type "make demo_fft.asm demo_bit.asm",
  39. Xwhich will generate fft and bit reversal routines for a 256-point fft
  40. Xthat are very similar to those in the TI application note mentioned in
  41. Xgen_fft.doc.
  42. X
  43. XI hope others find them helpful.
  44. X
  45. X- Dan Kegel
  46. X  S.R.Systems, Rochester, NY
  47. X  rochester!srs!dan
  48. X  GEnie: d.r.kegel
  49. XXX_EOF_XXX
  50. if test 735 -ne "`wc -c < README`"
  51. then
  52.     echo 'shar: transmission error on "README"'
  53. fi
  54. chk=`sum README | awk '{print $1}'`
  55. if test 18124 -ne $chk -a 468 -ne $chk
  56. then
  57.     echo 'shar: checksum error on "README"'
  58. fi
  59. echo 'shar: extracting "gen_fft.doc" (3115 characters)'
  60. # 'gen_fft.doc' has a checksum of 22225 on BSD and 63097 on System V.
  61. sed 's/^X//' > gen_fft.doc << 'XXX_EOF_XXX'
  62. Xgen_fft - generate inline code to perform a given size FFT
  63. X
  64. XUSAGE
  65. X    gen_fft log_fft_size < instruction_formats
  66. X
  67. XDESCRIPTION
  68. X    Reads the log base two of the fft size from the command line,
  69. X    then reads seven template lines from stdin;
  70. X    builds a section of inline code from the given templates
  71. X    that implements a decimation-in-time FFT of the given size.
  72. X    Can generate FFT's of length 8, 16, 32... up to some arbitrary limit.
  73. X
  74. X    See Oppenheim & Schafer, "Digital Signal Processing", 1975, p. 318; 
  75. X    the particular dataflow graph implemented is that of figure 6.10, 
  76. X    which uses bit-reversed input, and accesses coefficients in normal order.
  77. X
  78. X    See the application note "Implementation of the Fast Fourier Transform 
  79. X    Algorithms with the TMS32020," in
  80. X    "Digital Signal Processing Applications with the TMS320 Family",
  81. X    Texas Instruments Inc., for macros to use with this program.
  82. X    The routines in that note are available online from the Texas Instruments
  83. X    DSP Bulletin Board, 300-2400 baud, telephone 713-274-2323,
  84. X    in the archive FFT32020.ARC.
  85. X
  86. X    This program was tested by generating a 256-point FFT and comparing
  87. X    with the routine FFT256, "A 256-POINT RADIX-2 DIT COMPLEX FFT FOR THE 
  88. X    TMS32020", given in that application note.
  89. X
  90. X    The twiddle factors are represented as fixed-point numbers with
  91. X    12 bits of fraction, where unity is 4096, to accomodate the TMS320's
  92. X    MPYK instruction.  Of course, 4096 can't be represented in a 13-bit
  93. X    field, but that's okay, because only the special-case butterflies
  94. X    need to use unity, and they don't use MPYK to do it.
  95. X
  96. X    Although this was written to generate code for the TMS320x0,
  97. X    the fact that it is template based should make it very easy to
  98. X    modify to generate code for other architectures.
  99. X
  100. X    The resulting code expects the input array to be in bit-reversed
  101. X    order; see the file 'gen_brev.doc' for info on generating bit-reversal
  102. X    routines.
  103. X
  104. XINPUT
  105. X    Reads seven lines from stdin giving the format of six macros:
  106. X    1. radix-2 butterfly for any twiddle factor
  107. X    2. radix-2 butterfly for twiddle factor of 1              (k / N = 0)
  108. X    3. radix-2 butterfly for twiddle factor of (i+1)/sqrt(2)  (k / N = 1/8)
  109. X    4. radix-2 butterfly for twiddle factor of i              (k / N = 1/4)
  110. X    5. radix-2 butterfly for twiddle factor of (i-1)/sqrt(2)  (k / N = 3/8)
  111. X    6. radix-4 butterfly for stages 1 and 2; twiddle factors are all trivial
  112. X    7. comment macro used to explain the purpose of the following code
  113. X
  114. X    In all butterfly templates, the first 'radix' %d's are expanded to the 
  115. X    index of the locations the butterfly is to operate upon.
  116. X
  117. X    In the radix-2 butterflies, the third and fourth %d's are expanded to
  118. X    the real and imaginary componants of the twiddle factor, expressed
  119. X    as 12-bit fixed-point fractions for use with the TMS320's MPYK instruction.
  120. X
  121. X    In the comment template, %s is expanded to the text of a comment.
  122. X
  123. X    The expansion of %d's is done by the C function printf(), so you can
  124. X    use fancier formatting (for example, %03d) if you like.
  125. X
  126. XOUTPUT
  127. X
  128. XXX_EOF_XXX
  129. if test 3115 -ne "`wc -c < gen_fft.doc`"
  130. then
  131.     echo 'shar: transmission error on "gen_fft.doc"'
  132. fi
  133. chk=`sum gen_fft.doc | awk '{print $1}'`
  134. if test 22225 -ne $chk -a 63097 -ne $chk
  135. then
  136.     echo 'shar: checksum error on "gen_fft.doc"'
  137. fi
  138. echo 'shar: extracting "gen_brev.doc" (1021 characters)'
  139. # 'gen_brev.doc' has a checksum of 30043 on BSD and 22604 on System V.
  140. sed 's/^X//' > gen_brev.doc << 'XXX_EOF_XXX'
  141. Xgen_brev - generate inline in-place bit-reversal code for use with FFT
  142. X
  143. XUSAGE
  144. X    gen_brev log_fft_size < instruction_template_file
  145. X
  146. XDESCRIPTION
  147. X    Reads log base two of the fft size from the commandline, then
  148. X    outputs inline code to implement bit reversal for 2^log_fft_size-point fft.
  149. X
  150. XINPUT
  151. X    Input is two swap instruction templates, for example:
  152. X    SWAP    X%03d,X%03d
  153. X    * (swap %d and %d, so do nothing)
  154. X    Second line used when operands are identical; it is there in case
  155. X    you wish to use autoincrement indexing for the swap macro,
  156. X    and need to increment a pointer regardless of performing a swap.
  157. X
  158. X    The first %d in each template is expanded to the bit-reversed index,
  159. X    the second %d (if any) is expanded to the normal index.
  160. X
  161. X    Each %d is expanded via the C function printf(), so you can use fancier
  162. X    formats if you like.
  163. X    
  164. XOUTPUT
  165. X    Output is fft_size/2 lines which scan over all fft_size elements of
  166. X    the input array in order, swapping any location that hasn't already
  167. X    been swapped.
  168. XXX_EOF_XXX
  169. if test 1021 -ne "`wc -c < gen_brev.doc`"
  170. then
  171.     echo 'shar: transmission error on "gen_brev.doc"'
  172. fi
  173. chk=`sum gen_brev.doc | awk '{print $1}'`
  174. if test 30043 -ne $chk -a 22604 -ne $chk
  175. then
  176.     echo 'shar: checksum error on "gen_brev.doc"'
  177. fi
  178. echo 'shar: extracting "Makefile" (745 characters)'
  179. # 'Makefile' has a checksum of 32750 on BSD and 64324 on System V.
  180. sed 's/^X//' > Makefile << 'XXX_EOF_XXX'
  181. X# Makefile for fft code generating routines
  182. X# Could be used for any processor, but will need to change FRAC_BITS in
  183. X# gen_fft.c to use with anything but the TMS320 family.
  184. X# Tested on a Sun workstation; Makefile will need changes for MS-DOS machines.
  185. X
  186. Xgen_fft: gen_fft.c
  187. X    cc gen_fft.c -lm -o gen_fft
  188. Xgen_brev: gen_brev.c
  189. X    cc gen_brev.c -o gen_brev
  190. X
  191. X# Perform example run to generate code for a 256-point FFT.
  192. Xdemo_fft.asm: gen_fft demo_fft.dat
  193. X    gen_fft 8 < demo_fft.dat > demo_fft.asm
  194. Xdemo_bit.asm: gen_brev demo_bit.dat
  195. X    gen_brev 8 < demo_bit.dat > demo_bit.asm
  196. X
  197. X# Build distribution archive.
  198. XARCFILES = README gen_fft.doc gen_brev.doc Makefile \
  199. X    gen_fft.c gen_brev.c demo_fft.dat demo_bit.dat
  200. Xgen.shar: $(ARCFILES)
  201. X    shar gen.shar $(ARCFILES)
  202. XXX_EOF_XXX
  203. if test 745 -ne "`wc -c < Makefile`"
  204. then
  205.     echo 'shar: transmission error on "Makefile"'
  206. fi
  207. chk=`sum Makefile | awk '{print $1}'`
  208. if test 32750 -ne $chk -a 64324 -ne $chk
  209. then
  210.     echo 'shar: checksum error on "Makefile"'
  211. fi
  212. echo 'shar: extracting "gen_fft.c" (6510 characters)'
  213. # 'gen_fft.c' has a checksum of 20944 on BSD and 28831 on System V.
  214. sed 's/^X//' > gen_fft.c << 'XXX_EOF_XXX'
  215. X/*--------------------------------------------------------------------------
  216. X Generate inline fft code for a N-point radix-2 DIT FFT.
  217. X Reads six lines from stdin giving the format of six macros:
  218. X 1. radix-2 butterfly for any twiddle factor
  219. X 2. radix-2 butterfly for twiddle factor of 1              (k / N = 0)
  220. X 3. radix-2 butterfly for twiddle factor of (i+1)/sqrt(2)  (k / N = 1/8)
  221. X 4. radix-2 butterfly for twiddle factor of i              (k / N = 1/4)
  222. X 5. radix-2 butterfly for twiddle factor of (i-1)/sqrt(2)  (k / N = 3/8)
  223. X 6. radix-4 butterfly for stages 1 and 2; twiddle factors are all trivial
  224. X
  225. X In all cases, the first 'radix' %d's are expanded to the index
  226. X of the locations the butterfly is to operate upon.
  227. X
  228. X In the radix-2 butterflies, the third and fourth %d's are expanded to
  229. X the real and imaginary componants of the twiddle factor, expressed
  230. X as 13-bit fixed-point fractions.
  231. X
  232. X See Oppenheim & Schafer, "Digital Signal Processing", 1975, p. 318; 
  233. X the particular dataflow graph implemented is that of figure 6.10, 
  234. X which uses bit-reversed input, and accesses coefficients in normal order.
  235. X
  236. X Dan Kegel, rochester!srs!dan, S.R. Systems, Oct '88
  237. X This code is hereby placed in the public domain without any promise
  238. X that it functions as intended, or at all.
  239. X--------------------------------------------------------------------------*/
  240. X#include <stdio.h>
  241. X#include <math.h>
  242. X
  243. X#ifndef PI
  244. X#define PI 3.1415926
  245. X#endif
  246. X
  247. X/* Symbolic constants for the indices of the format array, read in from stdin.
  248. X * Each entry handles a different special case, except BTRFLY2_ANY,
  249. X * which is general.
  250. X */
  251. X#define BTRFLY2_ANY      0
  252. X#define BTRFLY2_0_4TH_PI 1
  253. X#define BTRFLY2_1_4TH_PI 2
  254. X#define BTRFLY2_2_4TH_PI 3
  255. X#define BTRFLY2_3_4TH_PI 4
  256. X#define BTRFLY4_STAGE0   5
  257. X#define COMMENT 6
  258. X#define N_FORMATS 7
  259. X
  260. X#define FRAC_BITS 12        /* for TMS320 inline multiply */
  261. X
  262. X/* The following global should be set to (1 << FRAC_BITS) if
  263. X * multiplies by unity are optimized away, and to
  264. X * (1 << FRAC_BITS) - 1 if multiplies by unity are done in the same
  265. X * manner as other multiplies.
  266. X * I think.
  267. X */
  268. Xstatic float i_unity = (float) (1 << FRAC_BITS);
  269. X
  270. X/*--------------------------------------------------------------------------
  271. X Routine to convert floating point number to integer format.
  272. X Result is a fixed-point number with FRAC_BITS of fraction.
  273. X
  274. X Constructed so that ftoi(x) = -ftoi(-x), for whatever that's worth.
  275. X--------------------------------------------------------------------------*/
  276. Xint
  277. Xftoi(f)
  278. X    float f;
  279. X{
  280. X    int i;
  281. X    if (f < 0.0)
  282. X    i = - (int) (0.5 - f * i_unity);
  283. X    else
  284. X    i = (int) (0.5 + f * i_unity);
  285. X    return i;
  286. X}
  287. X
  288. X/*--------------------------------------------------------------------------
  289. X Routine to calculate real part of j'th twiddle factor for an n-point DIT fft.
  290. X--------------------------------------------------------------------------*/
  291. Xint
  292. Xicos(j, n)
  293. X    int j, n;
  294. X{
  295. X    return ftoi(cos((2 * PI * j) / (float) n));
  296. X}
  297. X
  298. X/*--------------------------------------------------------------------------
  299. X Routine to calculate imaginary part of j'th twiddle factor for an 
  300. X n-point DIT fft.
  301. X--------------------------------------------------------------------------*/
  302. Xint
  303. Xisin(j, n)
  304. X    int j, n;
  305. X{
  306. X    return ftoi(sin((2 * PI * j) / (float) n));
  307. X}
  308. X
  309. Xmain(argc, argv)
  310. X    int argc;
  311. X    char **argv;
  312. X{
  313. X    int log_n;
  314. X    int i, j, k, n;
  315. X    int stage;
  316. X    char format[N_FORMATS][256];
  317. X    char comment[256];
  318. X
  319. X    if (argc < 2) {
  320. X    (void) fprintf(stderr, "usage: %s log_fft_size < instruction_formats\n\
  321. XOutputs inline code to implement given size DIT fft.\n\
  322. XInput is six butterfly template lines, in which %%d is expanded to array \n\
  323. Xindices and real and imaginary parts of the twiddle factors; for instance,\n\
  324. X    BFLY2    X%%03d,X%%03d,%%d,%%d\n\
  325. X    BFLY2_0PI4    X%%03d,X%%03d\n\
  326. X    BFLY2_1PI4    X%%03d,X%%03d\n\
  327. X    BFLY2_2PI4    X%%03d,X%%03d\n\
  328. X    BFLY2_3PI4    X%%03d,X%%03d\n\
  329. X    BFLY4_SPECIAL    X%%03d,X%%03d,X%%03d,X%%03d\n\
  330. Xfollowed by a comment template line, in which %%s is expanded to a remark\n\
  331. Xabout the following code, for example\n\
  332. X    * %%s\n\
  333. X", argv[0]);
  334. X    exit(1);
  335. X    }
  336. X
  337. X    /* Get arguments. */
  338. X    log_n = atoi(argv[1]);
  339. X    if (log_n < 2 || log_n > 13) {
  340. X    (void) fprintf(stderr, 
  341. X        "log_fft_size %s out of range, must be 2 to 13\n", argv[1]);
  342. X    exit(1);
  343. X    }
  344. X    n = 1 << log_n;
  345. X
  346. X    /* Read templates. */
  347. X    for (i=0; i<N_FORMATS; i++) {
  348. X    if (gets(format[i]) == NULL) {
  349. X        (void) fprintf(stderr, 
  350. X        "%s: couldn't read all %d formats from stdin\n",
  351. X        argv[0], N_FORMATS);
  352. X        exit(1);
  353. X    }
  354. X    }
  355. X
  356. X    (void) sprintf(comment, "Inline code for %d-point FFT.", n);
  357. X    (void) printf(format[COMMENT], comment);
  358. X    (void) putchar('\n');
  359. X
  360. X    (void) printf(format[COMMENT], "Radix-4 butterflies for stages 1 and 2.");
  361. X    (void) putchar('\n');
  362. X    /* For each 4-point DFT making up the combined first two stages: */
  363. X    for (j=0; j < n/4; j++) {
  364. X    (void) printf(format[BTRFLY4_STAGE0], 4*j, 4*j+1, 4*j+2, 4*j+3);
  365. X    (void) putchar('\n');
  366. X    }
  367. X
  368. X    /* For each following stage of the Cooley-Tukey FFT */
  369. X    for (stage=3; stage<=log_n; stage++) {
  370. X    int n_dft;
  371. X    int n_butterfly;
  372. X    int dft_size;
  373. X
  374. X    (void) sprintf(comment, "Stage %d.", stage);
  375. X    (void) printf(format[COMMENT], comment);
  376. X    (void) putchar('\n');
  377. X
  378. X    n_dft = 1 << (log_n - stage);        /* # of dft's */
  379. X    n_butterfly = 1 << (stage-1);        /* # of butterflies per dft */
  380. X    dft_size = 1 << stage;            /* size of each dft */
  381. X
  382. X    /* For each (dft_size)-point dft making up this stage: */
  383. X    for (j=0; j < n_dft; j++) {
  384. X
  385. X        (void) sprintf(comment, 
  386. X        "Radix-2 butterflies for %d-point dft %d of stage %d.", 
  387. X            dft_size, j, stage);
  388. X        (void) printf(format[COMMENT], comment);
  389. X        (void) putchar('\n');
  390. X
  391. X        /* For each butterfly making up this dft: */
  392. X        for (k=0; k<n_butterfly; k++) {
  393. X        int f;
  394. X        int index1, index2;
  395. X
  396. X        /* Calculate the indices of the two locations this butterfly
  397. X         * operates upon.
  398. X         */
  399. X        index1 = j * 2 * n_butterfly + k;
  400. X        index2 = index1 + n_butterfly;
  401. X
  402. X        /* Decide which butterfly to use.
  403. X         * Special cases that can be optimized are those where
  404. X         *    ln (twiddle factor)
  405. X         * is a multiple of sqrt(-1) * pi/4.
  406. X         */
  407. X        if ( ((8 * k) % dft_size) != 0) {
  408. X            /* Must use general case. */
  409. X            f = BTRFLY2_ANY;
  410. X        } else {
  411. X            /* Use one of four optimized cases. */
  412. X            int pi_quarter = (8 * k) / dft_size;
  413. X            f = pi_quarter + BTRFLY2_0_4TH_PI;
  414. X        }
  415. X
  416. X        /* Output the butterfly. */
  417. X        (void) printf(format[f],
  418. X            index1, index2, icos(k, dft_size), isin(k, dft_size));
  419. X        (void) putchar('\n');
  420. X        }
  421. X    }
  422. X    }
  423. X
  424. X
  425. X    exit(0);
  426. X}
  427. XXX_EOF_XXX
  428. if test 6510 -ne "`wc -c < gen_fft.c`"
  429. then
  430.     echo 'shar: transmission error on "gen_fft.c"'
  431. fi
  432. chk=`sum gen_fft.c | awk '{print $1}'`
  433. if test 20944 -ne $chk -a 28831 -ne $chk
  434. then
  435.     echo 'shar: checksum error on "gen_fft.c"'
  436. fi
  437. echo 'shar: extracting "gen_brev.c" (2617 characters)'
  438. # 'gen_brev.c' has a checksum of 17463 on BSD and 52233 on System V.
  439. sed 's/^X//' > gen_brev.c << 'XXX_EOF_XXX'
  440. X/*--------------------------------------------------------------------------
  441. X Generate bit-reversing code for a N-point radix-2 FFT.
  442. X Reads two lines from stdin giving the format of the macro
  443. X that swaps two complex numbers, for instance
  444. X    SWAP_COMPLEX FFT_BUF+%d FFT_BUF+%d
  445. X    *SWAP_COMPLEX FFT_BUF+%d FFT_BUF+%d
  446. X
  447. X The first %d is expanded to the bit-reversed number; the second %d is
  448. X expanded to the non-bit-reversed number.
  449. X If desired, the second %d may be omitted.
  450. X The second line is used when the two arguments would be identical.
  451. X
  452. X Dan Kegel, rochester!srs!dan, S.R. Systems, Oct '88
  453. X This code is hereby placed in the public domain without any promise
  454. X that it functions as intended, or at all.
  455. X--------------------------------------------------------------------------*/
  456. X#include <stdio.h>
  457. X
  458. X/*--------------------------------------------------------------------------
  459. X Stupid bitreversal routine.  Works for n <= 8192.
  460. X--------------------------------------------------------------------------*/
  461. Xint
  462. Xbitrev(i, n)
  463. X    register int i;
  464. X    register int n;
  465. X{
  466. X    n >>= 1;
  467. X    return
  468. X    ((i & 1<<0) ? (n>>0) : 0) +
  469. X    ((i & 1<<1) ? (n>>1) : 0) +
  470. X    ((i & 1<<2) ? (n>>2) : 0) +
  471. X    ((i & 1<<3) ? (n>>3) : 0) +
  472. X    ((i & 1<<4) ? (n>>4) : 0) +
  473. X    ((i & 1<<5) ? (n>>5) : 0) +
  474. X    ((i & 1<<6) ? (n>>6) : 0) +
  475. X    ((i & 1<<7) ? (n>>7) : 0) +
  476. X    ((i & 1<<8) ? (n>>8) : 0) +
  477. X    ((i & 1<<9) ? (n>>9) : 0) +
  478. X    ((i & 1<<10) ? (n>>10) : 0) +
  479. X    ((i & 1<<11) ? (n>>11) : 0) +
  480. X    ((i & 1<<12) ? (n>>12) : 0) +
  481. X    ((i & 1<<13) ? (n>>13) : 0);
  482. X}
  483. X
  484. Xmain(argc, argv)
  485. X    int argc;
  486. X    char **argv;
  487. X{
  488. X    int log_n;
  489. X    int n;
  490. X    int i;
  491. X    char format[2][256];    /* [0] is normal swap, [1] is no-op swap */
  492. X
  493. X    if (argc < 2) {
  494. X    (void) fprintf(stderr, "usage: %s log_fft_size < instruction_format\n\
  495. XOutputs inline code to implement bit reversal for 2^log_fft_size-point fft.\n\
  496. XInput is two swap instruction templates, for example:\n\
  497. X    SWAP    X%%03d,X%%03d\n\
  498. X    * (swap %%d and %%d, so do nothing)\n\
  499. XSecond line used when operands are identical.\n\
  500. X", argv[0]);
  501. X    exit(1);
  502. X    }
  503. X
  504. X    /* Get arguments */
  505. X    log_n = atoi(argv[1]);
  506. X    if (log_n < 2 || log_n > 13) {
  507. X    (void) fprintf(stderr, "log_fft_size %s out of range 2..13\n", 
  508. X        argv[1]);
  509. X    exit(1);
  510. X    }
  511. X    n = 1 << log_n;
  512. X
  513. X    /* Get formats for normal and no-op swaps. */
  514. X    for (i=0; i<2; i++)
  515. X    (void) gets(format[i]);
  516. X
  517. X    /* Output bitreversal code. */
  518. X    for (i=0; i<n; i++) {
  519. X    int b = bitrev(i,n);
  520. X    if (b > i) {
  521. X        (void) printf(format[0], b, i);
  522. X        (void) putchar('\n');
  523. X    } else if (b == i) {
  524. X        (void) printf(format[1], b, i);
  525. X        (void) putchar('\n');
  526. X    }
  527. X    }
  528. X
  529. X    exit(0);
  530. X}
  531. XXX_EOF_XXX
  532. if test 2617 -ne "`wc -c < gen_brev.c`"
  533. then
  534.     echo 'shar: transmission error on "gen_brev.c"'
  535. fi
  536. chk=`sum gen_brev.c | awk '{print $1}'`
  537. if test 17463 -ne $chk -a 52233 -ne $chk
  538. then
  539.     echo 'shar: checksum error on "gen_brev.c"'
  540. fi
  541. echo 'shar: extracting "demo_fft.dat" (159 characters)'
  542. # 'demo_fft.dat' has a checksum of 55690 on BSD and 8952 on System V.
  543. sed 's/^X//' > demo_fft.dat << 'XXX_EOF_XXX'
  544. X    BTRFLI    X%03d,X%03d,%d,%d,512
  545. X    ZEROI    X%03d,X%03d,512
  546. X    PBY4I    X%03d,X%03d,512
  547. X    PBY2I    X%03d,X%03d,512
  548. X    P3BY4I    X%03d,X%03d,512
  549. X    COMBO    X%03d,X%03d,X%03d,X%03d
  550. X*    %s
  551. XXX_EOF_XXX
  552. if test 159 -ne "`wc -c < demo_fft.dat`"
  553. then
  554.     echo 'shar: transmission error on "demo_fft.dat"'
  555. fi
  556. chk=`sum demo_fft.dat | awk '{print $1}'`
  557. if test 55690 -ne $chk -a 8952 -ne $chk
  558. then
  559.     echo 'shar: checksum error on "demo_fft.dat"'
  560. fi
  561. echo 'shar: extracting "demo_bit.dat" (58 characters)'
  562. # 'demo_bit.dat' has a checksum of 04304 on BSD and 3136 on System V.
  563. sed 's/^X//' > demo_bit.dat << 'XXX_EOF_XXX'
  564. X      BITRVI    X%03d,X%03d,512
  565. X      * BITRVI  X%03d,X%03d,512
  566. XXX_EOF_XXX
  567. if test 58 -ne "`wc -c < demo_bit.dat`"
  568. then
  569.     echo 'shar: transmission error on "demo_bit.dat"'
  570. fi
  571. chk=`sum demo_bit.dat | awk '{print $1}'`
  572. if test 04304 -ne $chk -a 3136 -ne $chk
  573. then
  574.     echo 'shar: checksum error on "demo_bit.dat"'
  575. fi
  576.