Question: There are two question in this code. where you have You do this please what is the functions or code that is supposed to
There are two question in this code. where you have "You do this " please what is the functions or code that is supposed to be there. Thanks. #include
using namespace std;
void printstate(bool *s) { /* This function prints out the 25 bit register*/ cout << "state: "; for(int i =0; i < 25;i++) cout << s[i]; cout << endl; }
void leftshift(bool *s) { /*This function shifts the 25 bit register one place to the left*/ //You do this! }
void timestep(bool *s) { /* This function executes one time step of the NLFSR. * The state variable s (which is an array of bool types of length 25) * should be updated according to the NLFSR update rule as discussed * in the project description.*/ //You do this! }
void runnlfsr(bool *s, int numsteps, bool print) { /*This function runs the LFSR from the state s for numsteps steps*/ for(int i =0 ; i < numsteps; i++) { if(print) { cout << s[0]; } timestep(s); } cout << endl; }
#define INITIALSTATE {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} const bool t[25] = INITIALSTATE;
void setstate(bool *s) {/*This function makes the state equal to the initial state (defined above)*/ for(int i=0; i < 25; i++) s[i]=t[i]; }
bool period_over(bool *s) {/*This function returns true iff the current state is equal to the initial state*/ for(int i = 0; i < 25;i++) { if(t[i] != s[i]) return false; } return true; }
int main() { bool state[25]; setstate(state); runnlfsr(state,50,true); setstate(state); runnlfsr(state,(1 << 25)-1,false); // 2**25 -1 runnlfsr(state,50,true); return 1; }
int main2() { bool state[25]; setstate(state); timestep(state); int i = 1; while(!period_over(state)) { timestep(state);
i++; } cout << "done in " << i << " steps" << endl; printstate(state); return 1; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
