Last change
on this file was
1715,
checked in by murphpo, 13 years ago
|
cleaning up PHY directory; coded PHY is now primary OFDM_MIMO model
|
File size:
553 bytes
|
Line | |
---|
1 | function CRC_Table = CRC_table_gen(CRCPolynomial, bitLen) |
---|
2 | %Calculates table of polynomial remainders for CRC computation |
---|
3 | %Based on example code at http://www.netrino.com/Embedded-Systems/How-To/CRC-Calculation-C-Code |
---|
4 | |
---|
5 | if(bitLen > 32 | bitLen < 1) |
---|
6 | error('bitLen must be in [1,32]'); |
---|
7 | end |
---|
8 | |
---|
9 | crc_accum = 0; |
---|
10 | |
---|
11 | for n=0:255 |
---|
12 | crc_accum = bitshift(n,(bitLen-8),bitLen); |
---|
13 | |
---|
14 | for m=0:7 |
---|
15 | x = bitshift(crc_accum, 1, bitLen); |
---|
16 | if(crc_accum >= 2^(bitLen-1)) |
---|
17 | crc_accum = bitxor(x, CRCPolynomial); |
---|
18 | else |
---|
19 | crc_accum = x; |
---|
20 | end |
---|
21 | end |
---|
22 | |
---|
23 | CRC_Table(n+1) = crc_accum; |
---|
24 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.