• 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-------------------------

  • 相关阅读:
    ThinkPHP模版引擎之变量输出具体解释
    Heat-AutoScaling
    開始搭建第一个zookeeper
    OpenCV学习笔记(六十二)——《OpenCV Computer Version with Python》阅读摘要
    Oracle可插拔数据库的jdbc连接串写法
    MVVM设计模式基础知识--ICommand接口
    CodeForces
    一见钟情Sublime
    # 从零開始搭建Hadoop2.7.1的分布式集群
    C语言遍历文件和文件夹——————【Badboy】
  • 原文地址:https://www.cnblogs.com/lyli/p/4396328.html
Copyright © 2020-2023  润新知