-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmktestvectors.m
36 lines (27 loc) · 991 Bytes
/
mktestvectors.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
N=31;K=21; PPoly = [1 0 1 0 0 1]; PPolyDec=PPoly*(2.^[0:5]'); T=2;
GPoly = bchpoly(N,K);
ntv = K;
W=zeros(ntv,N);
W(1,:) = bchenco( [1 zeros(1,K-1) ] , N , K,GPoly,'end');
for i=2:size(W,1)
%W(i,:) = bchenco( circshift( [1 zeros(1,K-1) ]',i-1)' , N , K,GPoly,'end'); % slide a single set bit along the message
W(i,:) = W(i-1,[N 1:(N-1)]); % create circular shifts of the valid codeword (which are also valid codewords by properties of BCH)
end
M = W(:,1:K);
E = W(:,(K+1):N);
fprintf('unsigned int prim_poly=%d;\n' , PPolyDec);
fprintf('const int N=%d;\n' , N );
fprintf('const int K=%d;\n' , K );
fprintf('const int ntrials=%d;\n' , ntv );
fprintf('int m=%d;\n' , log2(N+1) );
fprintf('int t=%d;\n' , T );
fprintf('char msgbits[ntrials][K+1] = {');
for i=1:ntv
fprintf('"'); fprintf('%d',M(i,:));fprintf('", ');
end
fprintf('};\n ');
fprintf('char eccbits[ntrials][N-K+1] = {');
for i=1:ntv
fprintf('"'); fprintf('%d',E(i,:));fprintf('", ');
end
fprintf('};\n ');