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_clock_divider.v] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 rozpruwacz
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// WISHBONE SD Card Controller IP Core                          ////
4
////                                                              ////
5
//// sd_clock_divider.v                                           ////
6
////                                                              ////
7
//// This file is part of the WISHBONE SD Card                    ////
8
//// Controller IP Core project                                   ////
9 8 rozpruwacz
//// http://opencores.org/project,sd_card_controller              ////
10 3 rozpruwacz
////                                                              ////
11
//// Description                                                  ////
12
//// Control of sd card clock rate                                ////
13
////                                                              ////
14
//// Author(s):                                                   ////
15
////     - Marek Czerski, ma.czerski@gmail.com                    ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2013 Authors                                   ////
20
////                                                              ////
21
//// Based on original work by                                    ////
22
////     Adam Edvardsson (adam.edvardsson@orsoc.se)               ////
23
////                                                              ////
24
////     Copyright (C) 2009 Authors                               ////
25
////                                                              ////
26
//// This source file may be used and distributed without         ////
27
//// restriction provided that this copyright statement is not    ////
28
//// removed from the file and that any derivative work contains  ////
29
//// the original copyright notice and the associated disclaimer. ////
30
////                                                              ////
31
//// This source file is free software; you can redistribute it   ////
32
//// and/or modify it under the terms of the GNU Lesser General   ////
33
//// Public License as published by the Free Software Foundation; ////
34
//// either version 2.1 of the License, or (at your option) any   ////
35
//// later version.                                               ////
36
////                                                              ////
37
//// This source is distributed in the hope that it will be       ////
38
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
39
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
40
//// PURPOSE. See the GNU Lesser General Public License for more  ////
41
//// details.                                                     ////
42
////                                                              ////
43
//// You should have received a copy of the GNU Lesser General    ////
44
//// Public License along with this source; if not, download it   ////
45
//// from http://www.opencores.org/lgpl.shtml                     ////
46
////                                                              ////
47
//////////////////////////////////////////////////////////////////////
48
 
49
module sd_clock_divider (
50
           input CLK,
51
           input [7:0] DIVIDER,
52
           input RST,
53
           output SD_CLK
54
       );
55
 
56
reg [7:0] ClockDiv;
57
reg SD_CLK_O;
58
 
59
//assign SD_CLK = DIVIDER[7] ? CLK : SD_CLK_O;
60
assign SD_CLK = SD_CLK_O;
61
 
62
always @(posedge CLK or posedge RST)
63
begin
64
    if (RST) begin
65
        ClockDiv <= 8'b0000_0000;
66
        SD_CLK_O <= 0;
67
    end
68
    else if (ClockDiv == DIVIDER) begin
69
        ClockDiv <= 0;
70
        SD_CLK_O <= ~SD_CLK_O;
71
    end else begin
72
        ClockDiv <= ClockDiv + 8'h1;
73
        SD_CLK_O <= SD_CLK_O;
74
    end
75
end
76
 
77
endmodule
78
 
79
 

powered by: WebSVN 2.1.0

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