fire_sys_encode.m

来自「GSM信道编码设计」· M 代码 · 共 52 行

M
52
字号
%fire_code
%g(x)=x^40+x^26+x^23+x^17+x^3+1=(x^23+1)(x^17+x^3+1)
%remark: not system code

%input:cc, the information bit-sequence whose length is 184
%output:uu, the fire code, bit-sequence whose length is 224

function uu=fire_sys_encode(cc)
% if the length of cc <184 then add 0
% if the length of cc >184 then remove the addition
% cc(x)=cc(1)*x^183+cc(2)*x^182+...+cc(183)*x+cc(184)
% uu(x)=cc(x)*g(x)=uu(1)*x^223+uu(2)*x^222+...+uu(223)*x+uu(224)

uu=zeros(1,228);


if(length(cc)<224)
   cc=[cc,zeros(1,224-length(cc))];
end

% information
for i=1:184,
   uu(i)=cc(i);
end

% check
cc(185:224)=1;

%generator vetrix
reg=zeros(1,40);
gg=zeros(1,41);
gg(41)=1;
gg(27)=1;
gg(24)=1;
gg(18)=1;
gg(4)=1;
gg(1)=1;

%division circuit
for i=1:184,
   tmp=rem((reg(40)+cc(i))*gg(41),2);%feedback
   for j=40:-1:2,
      reg(j)=rem(reg(j-1)+tmp*gg(j),2);
   end
   reg(1)=tmp;
end

for i=1:40,
   uu(184+i)=rem(reg(41-i)+1,2);
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?