OpenCores
URL https://opencores.org/ocsvn/sdcard_mass_storage_controller/sdcard_mass_storage_controller/trunk

Subversion Repositories sdcard_mass_storage_controller

[/] [sdcard_mass_storage_controller/] [trunk/] [rtl/] [sdc_dma/] [verilog/] [sd_crc_16.v] - Blame information for rev 134

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 134 tac2
// ==========================================================================
2
// CRC Generation Unit - Linear Feedback Shift Register implementation
3
// (c) Kay Gorontzi, GHSi.de, distributed under the terms of LGPL
4
// https://www.ghsi.de/CRC/index.php?
5
 
6
// https://www.ghsi.de/CRC/index.php?
7
// =========================================================================
8
module sd_crc_16(BITVAL, Enable, CLK, RST, CRC);
9
 input        BITVAL;// Next input bit
10
   input Enable;
11
   input        CLK;                           // Current bit valid (Clock)
12
   input        RST;                             // Init CRC value
13
   output reg [15:0] CRC;                               // Current output CRC value
14
 
15
 
16
                     // We need output registers
17
   wire         inv;
18
 
19
   assign inv = BITVAL ^ CRC[15];                   // XOR required?
20
 
21
  always @(posedge CLK or posedge RST) begin
22
                if (RST) begin
23
                        CRC = 0;
24
 
25
        end
26
      else begin
27
        if (Enable==1) begin
28
         CRC[15] = CRC[14];
29
         CRC[14] = CRC[13];
30
         CRC[13] = CRC[12];
31
         CRC[12] = CRC[11] ^ inv;
32
         CRC[11] = CRC[10];
33
         CRC[10] = CRC[9];
34
         CRC[9] = CRC[8];
35
         CRC[8] = CRC[7];
36
         CRC[7] = CRC[6];
37
         CRC[6] = CRC[5];
38
         CRC[5] = CRC[4] ^ inv;
39
         CRC[4] = CRC[3];
40
         CRC[3] = CRC[2];
41
         CRC[2] = CRC[1];
42
         CRC[1] = CRC[0];
43
         CRC[0] = inv;
44
        end
45
         end
46
      end
47
 
48
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.