📄 fire_sys_encode.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
% input:cc, the information bit-sequence whose length is 184 输入信息序列,长度184bits
% output:uu, the fire code, bit-sequence whose length is 224 输出法尔码序列,长度224bits
function uu=fire_sys_encode(cc)
% if the length of cc <184 then add 0 如果输入序列长度小于184bits则补零
% if the length of cc >184 then remove the addition 如果输入序列长度大于184bits则去掉多余部分
% 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); % 输出编码序列序列长度224bits
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 第40个移位寄存器的值与输入异或后反馈
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); % 移位寄存器中的值从第40位起逐个与1进行异或后输出
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -