77 lines
2.6 KiB
Mathematica
77 lines
2.6 KiB
Mathematica
![]() |
function res = ChangeZn2MReg(Zc,path,filename)
|
||
|
%ChangeZn2MReg: 将算法给的Zn顺序值更改为MREG中的存储顺序
|
||
|
% Zc: LDPC提升值
|
||
|
% path: 文件路径
|
||
|
% filename: 文件名
|
||
|
ACodeBlockIndex = [1 2 3 5 6 7 12 13 15 18 20 24 26];
|
||
|
BCodeBlockIndex = [4 8 9 10 11 14 16 17 19 21 22 23 25];
|
||
|
res = 0;
|
||
|
|
||
|
|
||
|
Data = u32DataFromFile(path,filename);
|
||
|
Data = Int32ToInt8(Data);
|
||
|
DotIndex = find(filename == '.');
|
||
|
Afilename_mreg = [filename(1:DotIndex-1) '_Amreg' filename(DotIndex:end)];
|
||
|
Bfilename_mreg = [filename(1:DotIndex-1) '_Bmreg' filename(DotIndex:end)];
|
||
|
if Zc<=64
|
||
|
Data = reshape(Data,Zc,[]);
|
||
|
Afid = fopen([path Afilename_mreg],'w');
|
||
|
if -1 == Afid
|
||
|
fprintf('write %s filled.\n',Afilename_mreg);
|
||
|
res = -1;
|
||
|
return;
|
||
|
end
|
||
|
Bfid = fopen([path Bfilename_mreg],'w');
|
||
|
if -1 == Afid
|
||
|
fprintf('write %s filled.\n',Afilename_mreg);
|
||
|
res = -1;
|
||
|
return;
|
||
|
end
|
||
|
AData = Data(:,ACodeBlockIndex);
|
||
|
BData = Data(:,BCodeBlockIndex);
|
||
|
fprintf(Afid,'0x%08x\n',Int8ToInt32(AData));
|
||
|
fprintf(Bfid,'0x%08x\n',Int8ToInt32(BData));
|
||
|
fclose(Afid);fclose(Bfid);
|
||
|
elseif Zc == 256
|
||
|
Data = reshape(Data,Zc,[]);
|
||
|
Afid = fopen([path Afilename_mreg],'w');
|
||
|
if -1 == Afid
|
||
|
fprintf('write %s filled.\n',Afilename_mreg);
|
||
|
res = -1;
|
||
|
return;
|
||
|
end
|
||
|
Bfid = fopen([path Bfilename_mreg],'w');
|
||
|
if -1 == Afid
|
||
|
fprintf('write %s filled.\n',Afilename_mreg);
|
||
|
res = -1;
|
||
|
return;
|
||
|
end
|
||
|
AData = Data(:,ACodeBlockIndex);
|
||
|
BData = Data(:,BCodeBlockIndex);
|
||
|
fprintf(Afid,'0x%08x\n',Int8ToInt32(AData));
|
||
|
fprintf(Bfid,'0x%08x\n',Int8ToInt32(BData));
|
||
|
fclose(Afid);fclose(Bfid);
|
||
|
else
|
||
|
Data = reshape(Data,Zc,[]); %zc>64, mod(zc,8)===0
|
||
|
Afid = fopen([path Afilename_mreg],'w');
|
||
|
if -1 == Afid
|
||
|
fprintf('write %s filled.\n',Afilename_mreg);
|
||
|
res = -1;
|
||
|
return;
|
||
|
end
|
||
|
Bfid = fopen([path Bfilename_mreg],'w');
|
||
|
if -1 == Afid
|
||
|
fprintf('write %s filled.\n',Afilename_mreg);
|
||
|
res = -1;
|
||
|
return;
|
||
|
end
|
||
|
AData = Data(:,ACodeBlockIndex);
|
||
|
BData = Data(:,BCodeBlockIndex);
|
||
|
fprintf(Afid,'0x%08x\n',Int8ToInt32(AData));
|
||
|
fprintf(Bfid,'0x%08x\n',Int8ToInt32(BData));
|
||
|
fclose(Afid);fclose(Bfid);
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|