Thread: Need clarification on Buffer concept for Pseudo_random binary sequence

  1. #1
    Registered User
    Join Date
    Mar 2017
    Posts
    52

    Need clarification on Buffer concept for Pseudo_random binary sequence

    I am trying this program for my project work. For hardware implementation, i am compiling PRBS through buffer concept. Whether the following codes are logically right? For me its showing compilation error.

    My goal in my project work is to get random bits 0`s and 1`s in a consecutive manner. Please help me.

    Code:
    int main(int bit, int *d)
    {
         unsigned lfsr  = 0xCD;
           int bit, i,j;
           int buff1[50], buff2[50];
             
    memycpy(buff1, d, 50*sizeof(int));
            for ( i = 0; i < 50; i++)
                  {
                  bit = ((lfsr >> 0) ^ (lfsr >> 2) ^ (lfsr >> 3) ^ (lfsr >> 4) ) & 1;
                  buff1[i] = bit; //storing bit value in buff1
               
                  lfsr = (lfsr >> 1) | (bit << 7);
                  }
            for (j = 0; j < 50; j++)
            {
            buff2[j] = buff1[50-j] ; // from buff1 storing bit value into buff2 for reading the bits in consecutive ways
            }
    
    memycpy(d, buff2, 50*sizeof(int));
    }

  2. #2
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Your code is getting more and more insane.

    What in the world is a "buffer concept" anyway?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > int main(int bit, int *d)
    You can't just make up declarations for main.

    > memycpy(d, buff2, 50*sizeof(int));
    It helps if you can spell 'memcpy'.

    TBH, you need to fess up to your employer that you're completely out of your depth and they should give you something else to do while they find some competent C programmer to do this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-08-2017, 06:48 AM
  2. Binary sequence in lexicographic order
    By confuser008 in forum C++ Programming
    Replies: 5
    Last Post: 10-16-2009, 01:10 PM
  3. Binary Sequence
    By royshh in forum C++ Programming
    Replies: 3
    Last Post: 03-31-2006, 02:56 PM

Tags for this Thread