📄 simrsdbv.m
字号:
function [sys, x0, str, ts] = simbchdc(t, x, u, flag, n, k, tp, dim);
%SIMBCHDC SIMULINK S-function for BCH decode.
% The m-dile is designed to be used in a SIMULINK S-Function block.
% This function will decode the cyclic code using BCH decod method.
% Parameters: n -- length of code word.
% k -- length of message.
% t -- error-correction capability.
% tp-- list of all GF(2^M) elements. n=2^M-1.
%
% The output has length n+1, the last digit is the error signal err.
% A non-negative err indicates number of errors have been corrected.
% A nagative err indicates that more than t error have been found in
% in the code, the routine cannot correct such error.
% Wes Wang
% Copyright (c) 1995-96 by The MathWorks, Inc.
if (flag == 3)
% refresh the state only when there is a trigger signal
len_u = length(u);
if u(len_u)
% output the decode result.
% main calculation
code_word = bi2de(vec2mat(u(1:len_u-1), dim)) - 1;
[sys, err] = rscore(code_word, k, tp, dim, n);
% output is the combination of message and error information.
sys = sys +1;
indx = find(~(sys>=0));
sys(indx) = indx-indx;
sys = de2bi(sys, dim)';
sys = [sys(:); err];
% disp(['should output ', num2str(k * dim + 1), 'it is now ', num2str(length(sys))])
else
% if there is no trigger, no calculation.
if t <= 0
sys = zeros(m*k+1, 1);
end;
end;
elseif flag == 0
if 2^dim-1 ~= n
error('Reed-Solomon decode has illegal code word length')
end;
sys(1) = 0; % no continuous state
sys(2) = 0;
sys(3) = k * dim + 1; % number of output, code word length plus one.
sys(4) = n * dim + 1; % number of input, message length.
sys(5) = 0;
sys(6) = 1; % direct through flag.
sys(7) = 1; % one sample rate
x0 = [];
ts = [-1, 0];
else
sys = [];
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -