| Contents | Index |
h= crc.detector(polynomial)
h= crc.detector(generatorObj)
h= crc.detector(‘Polynomial', polynomial, ‘param1', val1, etc.)
h= crc.detector
h= crc.detector(polynomial) constructs a CRC detector object H defined by the generator polynomial POLYNOMIAL
h= crc.detector(generatorObj) constructs a CRC detector object H defined by the parameters found in the CRC generator object GENERATOROBJ
h= crc.detector(‘property1', val1, ...) constructs a CRC detector object H with properties as specified by PROPERTY/VALUE pairs.
h= crc.detector constructs a CRC detector object H with default properties. It constructs a CRC-CCITT detector, and is equivalent to:
h= crc.detector('Polynomial', '0x1021', 'InitialState', '0xFFFF', 'ReflectInput', ...
false, 'ReflectRemainder', false, 'FinalXOR', '0x0000')
The following table describes the properties of a CRC detector object. All properties are writable, except Type.
| Property | Description |
|---|---|
| Type | Specifies the object as a 'CRC Detector'. |
| Polynomial | The generator polynomial that defines connections for a linear feedback shift register. This property can be specified as a binary vector representing descending powers of the polynomial. In this case, the leading '1' of the polynomial must be included. It can also be specified as a string, prefaced by '0x', that is a hexadecimal representation of the descending powers of the polynomial. In this case, the leading '1' of the polynomial is omitted. |
| InitialState | The initial contents of the shift register. This property can be specified as a binary scalar, a binary vector, or as a string, prefaced by '0x', that is a hexadecimal representation of the binary vector. As a binary vector, its length must be one less than the length of the binary vector representation of the Polynomial. |
| ReflectInput | A Boolean quantity that specifies whether the input data should be flipped on a bytewise basis prior to entering the shift register. |
| ReflectRemainder | A Boolean quantity that specifies whether the binary output CRC checksum should be flipped around its center after the input data is completely through the shift register. |
| FinalXOR | The value with which the CRC checksum is to be XORed just prior to being appended to the input data. This property can be specified as a binary scalar, a binary vector or as a string, prefaced by '0x', that is a hexadecimal representation of the binary vector. As a binary vector, its length must be one less than the length of the binary vector representation of the Polynomial. |
A detect method is used with the object to detect errors in digital transmission.
For information pertaining to the CRC generation algorithm, see CRC Algorithm in the Communications System Toolbox User's Guide.
[OUTDATA ERROR] = DETECT(H, INDATA) detects transmission errors in the encoded input message INDATA by regenerating a CRC checksum using the CRC detector object H. The detector then compares the regenerated checksum with the checksum appended to INDATA. The binary-valued INDATA can be either a column vector or a matrix. If it is a matrix, each column is considered to be a separate channel. OUTDATA is identical to the input message INDATA, except that it has the CRC checksum stripped off. ERROR is a 1xC logical vector indicating if the encoded message INDATA has errors, where C is the number of channels in INDATA. An ERROR value of 0 indicates no errors, and a value of 1 indicates errors.
The following three examples demonstrate the use of constructing an object. The fourth example demonstrates use of the detect method.
% Construct a CRC detector with a polynomial % defined by x^4+x^3+x^2+x+1: h = crc.detector([1 1 1 1 1])
This example generates the following output:
h =
Type: CRC Detector
Polynomial: 0xF
InitialState: 0x0
ReflectInput: false
ReflectRemainder: false
FinalXOR: 0x0% Construct a CRC detector with a polynomial % defined by x^3+x+1, with % zero initial states, and with an all-ones % final XOR value: h = crc.detector('Polynomial', [1 0 1 1], ... 'InitialState', [0 0 0], 'FinalXOR', [1 1 1])
This example generates the following output:
h =
Type: CRC Detector
Polynomial: [1 0 1 1]
InitialState: [0 0 0]
ReflectInput: false
ReflectRemainder: false
FinalXOR: [1 1 1]% Construct a CRC detector with a polynomial % defined by x^4+x^3+x^2+x+1, % all-ones initial states, reflected input, and all-zeros % final XOR value: h = crc.detector('Polynomial', '0xF', 'InitialState', ... '0xF', 'ReflectInput', true, 'FinalXOR', '0x0')
This example generates the following output:
h =
Type: CRC Detector
Polynomial: 0xF
InitialState: 0xF
ReflectInput: true
ReflectRemainder: false
FinalXOR: 0x0% Create a CRC-16 CRC generator, then use it to generate % a checksum for the % binary vector represented by the % ASCII sequence '123456789'. % Introduce an error, then detect it % using a CRC-16 CRC detector. gen = crc.generator('Polynomial', '0x8005', 'ReflectInput', ... true, 'ReflectRemainder', true); det = crc.detector('Polynomial', '0x8005', 'ReflectInput', ... true, 'ReflectRemainder', true); % The message below is an ASCII representation % of the digits 1-9 msg = reshape(de2bi(49:57, 8, 'left-msb')', 72, 1); encoded = generate(gen, msg); encoded(1) = ~encoded(1); % Introduce an error [outdata error] = detect(det, encoded); % Detect the error noErrors = isequal(msg, outdata) % Should be 0 error % Should be 1
This example generates the following output:
noErrors =
0
error =
1

Learn how to apply early verification to your development process through these technical resources.
How much time do you spend on testing to ensure implementation meets system-level requirements?
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |