lfsr_test.c revision f4ce616539dd81322fa4db9676f42ef2e0a19031
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <stdio.h>
#include <isc/assertions.h>
int
{
int i, j;
/*
* Verify that returned values are reproducable.
*/
for (i = 0 ; i < 32 ; i++) {
}
for (i = 0 ; i < 32 ; i++) {
printf("lfsr1: state[%2d] = %08x, but new state is %08x\n",
}
/*
* Now do the same with skipping.
*/
for (i = 0 ; i < 32 ; i++) {
}
for (i = 0 ; i < 32 ; i++) {
printf("lfsr1: state[%2d] = %08x, but new state is %08x\n",
}
/*
* Try to find the period of the LFSR.
*/
printf("Searching for repeating patterns in a %d-bit LFSR\n",
for (i = 0 ; i < (1024 * 64) ; i++)
for (i = 0 ; i < (1024 * 64) ; i++) {
for (j = i + 1 ; j < (1024 * 64) ; j++) {
printf("%08x: state %d and %d are the same, distance %d.\n",
state[i], i, j, j - i);
goto next_i;
}
}
}
return (0);
}