Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MASK 12
- #define SEED 15
- unsigned LFSRshift(unsigned lfsr) {
- unsigned feedback = lfsr & 1;
- lfsr >>= 1;
- if (feedback == 1) {
- lfsr ^= MASK;
- }
- return lfsr;
- }
- int main() {
- unsigned lfsr = SEED;
- do {
- lfsr = LFSRshift(lfsr);
- printf("%u ", lfsr);
- } while (lfsr != SEED);
- putchar('\n');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement