1 Attachment(s)
C codes takes more timing cycles_Better OPTIMIZATION for Codes
Hi,
It takes more timing cycles.
Starts at 46 clock cycles but execution continues for 678 clock cycles. Trying to reduce execution time. Please modify codes.
Code:
#include <stdio.h>
int main()
{
int n,r,c,no_e,S;
int y[6] = {0};
int i,j,pos,I;
int Imax = 20;
int E[4][6] = {0};
int H[4][6] = {1,1,0,1,0,0,0,1,1,0,1,0,1,0,0,0,1,1,0,0,1,1,0,1};
int M[6] = {0,0,1,-1,-1,-1};
n = 6;
r = 4;
c = 6;
//Decoding using Message passing in Erasure channel
no_e = 0;
S = 0;
pos = 0;
I = 0;
for(j=0;j<r && I<Imax;j++)
{
for(i=0;i<n;i++)
{
if(H[j][i] == 1)
{
if(M[i] < 0)
{
no_e = no_e + 1;
pos = i; //The position of erasure bit
}
if(M[i] == 0 || M[i] == 1)
S = S + M[i];
}
}
if(no_e > 1)
for(i=0;i<n;i++)
E[I][i] = -1; //Make the entire jth row -1
else
for(i=0;i<n;i++)
E[I][i] = M[i];
if(no_e == 1)
{
E[I][pos] = S%2; // Set the bit with the correct value
M[pos] = S%2; //Replace the bit with the corrected
}
no_e = 0;
S = 0;
for(i=0;i<n;i++)
if(M[i]<0)
no_e = no_e+1;
if(no_e == 0)
break;
I = I + 1;
no_e = 0;
if(j==r-1)
j=0;
}
printf("\n\n\nThe corrected Code Word is(%d): \n\n",I);
for(i=0;i<n;i++)
printf("%d\t",M[i]);
}
Attachment 15171