Question: i need help with implementing the missing function outputing the rightmost bit of the state ... Your question has been answered Let us know if

i need help with implementing the missing function outputing the rightmost bit of the state ...

Your question has been answered

Let us know if you got a helpful answer. Rate this answer

Question: I need help with implementing the missing function outputing the rightmost bit of the state varia...

I need help with implementing the missing function outputing the rightmost bit of the state variable. The code is in C language.

#include

#include

#include

#include

/*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) */

int x = L -> state &1;

return x;

}

void next_state(LFSR* L)

{

/*Takes LFSR.

Returns nothing.

Side effect: advances L to next state.(shift to the right and replace leftmost bit with appropriate value)

*/

/* You implement this.

Hint: make use of the parity() function provided above*/

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!