root/ResearchApps/PHY/MIMO_OFDM/Alamouti/calcTxCRC.m

Revision 577, 0.8 kB (checked in by murphpo, 18 months ago)

Updated Alamouti model with PLB BRAM interface

Line 
1function crcOut = calcTxCRC(thePacketBytes)
2%Based on the C code example at:
3%http://www.packet.cc/files/CRC32-code.html
4CRCPolynomial = hex2dec('04c11db7');
5CRC_Table = CRC_table_gen(CRCPolynomial);
6
7init_crc = 0;
8myData = thePacketBytes;
9
10crc_accum = init_crc;
11for n=1:length(myData)
12        x = bitshift(crc_accum,-24,32);
13        x = bitxor(x,myData(n));
14        x = bitand(x,hex2dec('ff'));
15        crc_accum = bitxor(bitshift(crc_accum,8,32),CRC_Table(x+1));
16    crc_tracking(n) = crc_accum;
17end
18
19TxCRC32 = crc_accum;
20TxCRC32_b3 = bitand(bitshift(TxCRC32,-24,32),hex2dec('ff'));
21TxCRC32_b2 = bitand(bitshift(TxCRC32,-16,32),hex2dec('ff'));
22TxCRC32_b1 = bitand(bitshift(TxCRC32,-8,32),hex2dec('ff'));
23TxCRC32_b0 = bitand(TxCRC32,hex2dec('ff'));
24
25crcOut = [TxCRC32_b3 TxCRC32_b2 TxCRC32_b1 TxCRC32_b0];
26%crcOut = fliplr([TxCRC32_b3 TxCRC32_b2 TxCRC32_b1 TxCRC32_b0]);
Note: See TracBrowser for help on using the browser.