/* lfsr.c
** Scott Harrington
** Program to print out the sequence produced by the 15-bit
** linear feedback shift register used as a fifo counter.
*/
#include <stdio.h>
#include <stdlib.h>
#define BIT(n,x) ( ( (x) >> (n) ) & 1 )
void main()
{
unsigned reg;
int feedback;
reg = 0;
do {
printf("%u\n", reg);
feedback = (BIT(14,reg) == BIT(13,reg)); /* reg[14] XNOR reg[13] */
reg = (reg<<1) + feedback;
reg &= 0x7FFF;
}
while (reg != 0);
}