0
I need help with implementing the missing function outputing the rightmost bit of the state variable. The code is in C language.
#include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> /*The following struct will represent an LFSR with a 64 bit state. The taps are represented by a 64 bit number, where the ith bit (from the right) corresponds to p_i. The uint64_t is a 64 bit unsigned integer. typedef struct { uint64_t state; uint64_t taps; } LFSR; int parity(uint64_t N) { /* Return the parity of N*/ int p = __builtin_parity(N); // parity of first 32 bits N = __builtin_bswap64(N); //move back 32 to the front return (p+__builtin_parity(N))%2; //overall parity } int read_lfsr(LFSR* L) { /*Return the current output bit (the rightmost bit of the state variable) */ /* You implement this*/ return 0; }
1 Answer
+ 3
You can read the rightmost bit of a number x with `x & 1`.