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

Subversion Repositories sd_card_controller

[/] [sd_card_controller/] [trunk/] [rtl/] [verilog/] [sd_crc_7.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 rozpruwacz
// ==========================================================================
2
// CRC Generation Unit - Linear Feedback Shift Register implementation
3
// (c) Kay Gorontzi, GHSi.de, distributed under the terms of LGPL
4
// ==========================================================================
5
module sd_crc_7(BITVAL, ENABLE, BITSTRB, CLEAR, CRC);
6
   input        BITVAL;                            // Next input bit
7
   input        ENABLE;                            // Enable calculation
8
   input        BITSTRB;                           // Current bit valid (Clock)
9
   input        CLEAR;                             // Init CRC value
10
   output [6:0] CRC;                               // Current output CRC value
11
 
12
   reg    [6:0] CRC;                               // We need output registers
13
   wire         inv;
14
 
15
   assign inv = BITVAL ^ CRC[6];                   // XOR required?
16
 
17
   always @(posedge BITSTRB or posedge CLEAR) begin
18
      if (CLEAR) begin
19
         CRC <= 0;                                  // Init before calculation
20
         end
21
      else begin
22
         if (ENABLE == 1) begin
23
             CRC[6] <= CRC[5];
24
             CRC[5] <= CRC[4];
25
             CRC[4] <= CRC[3];
26
             CRC[3] <= CRC[2] ^ inv;
27
             CRC[2] <= CRC[1];
28
             CRC[1] <= CRC[0];
29
             CRC[0] <= inv;
30
             end
31
         end
32
      end
33
 
34
endmodule

powered by: WebSVN 2.1.0

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