?? commblkcrcgen2.m
字號:
function [genPolyDec, numBits, iniStatesDec, numChecksums] = ... commblkcrcgen2(genPoly, iniStates, numChecksums)%COMMBLKCRCGEN2 Mask function for CRC generator and CRC% syndrome detector blocks for parameter checking.% Copyright 1996-2001 The MathWorks, Inc.% $Revision: 1.3 $ $Date: 2001/11/15 22:26:04 $% Check the Generator Polynomial parameterif ~(isvector(genPoly) | isscalar(genPoly)) error('The generator polynomial parameter must be a binary vector.');endif any(genPoly~=1 & genPoly~=0) error('The generator polynomial parameter must be a binary vector.');endif ((genPoly(1) == 0) | (genPoly(end) == 0)) error('Invalid generator polynomial parameter values.');end% Check the Degree of polynomialnumBits = length(genPoly)-1;if numBits > 32 error('Only generator polynomials of degree 32 or less are allowed.');end% Convert to decimal valueif ( isscalar(genPoly) & (genPoly == 1) ) genPolyDec = 0; % numBits = 0else genPolyDec = bi2de(genPoly(2:end),'left-msb'); % without the leading implicit bitend% Check the Initial States parameterif ~(isvector(iniStates) | isscalar(iniStates)) error('The initial states parameter must be a scalar or a vector of size equal to the degree of the generator polynomial.');endif any(iniStates~=1 & iniStates~=0) error('The initial states parameter values must be binary.');endif length(iniStates) == 1 % scalar expansion iniStates = iniStates*ones(1,numBits);elseif length(iniStates) ~= numBits error('The initial states parameter must be a scalar or a vector of size equal to the degree of the generator polynomial.');end% Convert to decimal valueif isempty(iniStates) iniStatesDec = 0; % numBits = 0else iniStatesDec = bi2de(iniStates, 'left-msb');end% Check the number of Checksums parameterif ( isempty(numChecksums) | ~isreal(numChecksums) | isinf(numChecksums) | ... (numChecksums <= 0) | (floor(numChecksums) ~= numChecksums) | ... ~isscalar(numChecksums) ) error('The checksums per frame parameter must be an integer scalar greater than 0.');end% [EOF]
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -