Crc16 verify source code

Source: Internet
Author: User

 

Crc16 ValidationCodeWhich can be used to write to the SD card.

 

 

1 Module Crc_unit_16 (CLK, ready, indata, reset, CRC );
2
3 Input CLK;
4 Input Ready;
5 Input Indata;
6 Input Reset;
7 Output [ 15 : 0 ] CRC; // CRC checksum
8
9 // Registers for CRC
10 Reg D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, d15, D16;
11
12 Wire Xor1, xor2, xor3;
13
14 Assign Xor1 = Indata ^ D16;
15 Assign Xor2 = D5 ^ Xor1;
16 Assign Xor3 = D12 ^ Xor1;
17
18 Assign CRC [ 0 ] = D1;
19 Assign CRC [ 1 ] = D2;
20 Assign CRC [ 2 ] = D3;
21 Assign CRC [ 3 ] = D4;
22 Assign CRC [ 4 ] = D5;
23 Assign CRC [ 5 ] = D6;
24 Assign CRC [ 6 ] = D7;
25 Assign CRC [ 7 ] = D8;
26 Assign CRC [ 8 ] = D9;
27 Assign CRC [ 9 ] = D10;
28 Assign CRC [ 10 ] = D11;
29 Assign CRC [ 11 ] = D12;
30 Assign CRC [ 12 ] = D13;
31 Assign CRC [ 13 ] = D14;
32 Assign CRC [ 14 ] = D15;
33 Assign CRC [ 15 ] = D16;
34
35
36 Always @( Posedge CLK Or   Posedge Reset) Begin
37 If (Reset) Begin
38 D1 <=   0 ;
39 D2 <=   0 ;
40 D3 <=   0 ;
41 D4 <=   0 ;
42 D5 <=   0 ;
43 D6 <=   0 ;
44 D7 <=   0 ;
45 D8 <=   0 ;
46 D9 <=   0 ;
47 D10 <=   0 ;
48 D11 <=   0 ;
49 D12 <=   0 ;
50 D13 <=   0 ;
51 D14 <=   0 ;
52 D15 <=   0 ;
53 D16 <=   0 ;
54 End
55 Else   If (Ready) Begin
56 D1 <= Xor1;
57 D2 <= D1;
58 D3 <= D2;
59 D4 <= D3;
60 D5 <= D4;
61 D6 <= Xor2;
62 D7 <= D6;
63 D8 <= D7;
64 D9 <= D8;
65 D10 <= D9;
66 D11 <= D10;
67 D12 <= D11;
68 D13 <= Xor3;
69 D14 <= D13;
70 D15 <= D14;
71 D16 <= D15;
72 End
73 End
74
75 Endmodule
76

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.