⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fire_sys_encode.m

📁 实现GSM通信的快速接入控制信道(FACCH)的信道编码的MATLAB仿真
💻 M
字号:
%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
%输入码元长度为184,输出码元长度为224
%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,224);  %定义长度为224的空间以存放编码

%定义信息位空间,如果信息位长度小于184则补全184位
if(length(cc)<184)
   cc=[cc,zeros(1,184-length(cc))];
end

% information 系统码的信息位
for i=1:184,
   uu(i)=cc(i);
end

% check
cc(185:224)=1;

%generator vetrix
reg=zeros(1,40); %定义40个寄存器,初始状态为全0
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -