source: ResearchApps/PHY/MIMO_OFDM/Deprecated/CRC_table_gen.m

Last change on this file was 1714, checked in by murphpo, 12 years ago

cleaning up PHY directory; coded PHY is now primary OFDM_MIMO model

File size: 553 bytes
RevLine 
[1531]1function CRC_Table = CRC_table_gen(CRCPolynomial, bitLen)
[610]2%Calculates table of polynomial remainders for CRC computation
[1531]3%Based on example code at http://www.netrino.com/Embedded-Systems/How-To/CRC-Calculation-C-Code
[608]4
[1531]5if(bitLen > 32 | bitLen < 1)
6    error('bitLen must be in [1,32]');
7end
8
[608]9crc_accum = 0;
[609]10
[608]11for n=0:255
[1531]12    crc_accum = bitshift(n,(bitLen-8),bitLen);
13
[608]14    for m=0:7
[1531]15        x = bitshift(crc_accum, 1, bitLen);
16        if(crc_accum >= 2^(bitLen-1))
17            crc_accum = bitxor(x, CRCPolynomial);
[608]18        else
19            crc_accum = x;
20        end
21    end
22
23    CRC_Table(n+1) = crc_accum;
24end
Note: See TracBrowser for help on using the repository browser.