4.0 Lab1-CRC Generation(1)

Although I haven't finished the whole lab yet, I'm going to write something I've done till this moment.

-------------------- Part of The Requirements of This Lab------------------------

1. Load a 16-bit register with FFFF hex (all ‘1’s). Call this the CRC register.

2. Exclusive OR the first 8-bit byte of the message with the low-order byte of the 16-bit CRC register, putting the result in the CRC register.

3. Shift the CRC register one bit to the right (toward the LSb), zero-filling the MSb. Extract and examine the LSb.

4. If the LSb is ‘0’, repeat Step 3 (another shift). Otherwise, if the LSB is ‘1’, Exclusive OR the CRC register with the polynomial value 0xA001 (1010 0000 0000 0001).

5. Repeat steps 3 and 4 until eight shifts have been performed. When this is done, a complete 8-bit byte will have been processed.

6. Repeat steps 2 through 5 for the next 8-bit byte of the message. Continue doing this until all bytes have been processed.

7. The final content of the CRC register is the CRC value.

8. When the CRC is placed into the message, its upper and lower bytes must be Swapped to let the High 8-bit first and followed by low 8-bit.

----------------------Part of My Codes----------------------

  

//read message from test.txt file

  

//read a byte of file once to message

  

//use an array of byte CRCRegister to store 0xFFFF

  

//shift 8 times once read a byte. EX or with 0xA001 if lsb is 1 while shifting

  

//one byte has 8 bits, however, if the MSB of the byte is 0, it won't be shown. So I use switch statements to show these 0s.

  

//combine 2 bytes of the CRCRegister together, and output the result

-----------------------END & TO BE CONTINUED-------------------------

 

posted on 2015-04-06 18:29  liyinglan 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lyli/p/4396328.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值