OpenCores
URL https://opencores.org/ocsvn/sdhc-sc-core/sdhc-sc-core/trunk

Subversion Repositories sdhc-sc-core

[/] [sdhc-sc-core/] [trunk/] [grpSd/] [unitSdClockMaster/] [src/] [SdClockMaster-Rtl-a.vhdl] - Blame information for rev 185

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 164 rkastl
-- SDHC-SC-Core
2
-- Secure Digital High Capacity Self Configuring Core
3 121 rkastl
-- 
4 170 rkastl
-- (C) Copyright 2010, Rainer Kastl
5
-- All rights reserved.
6 164 rkastl
-- 
7 170 rkastl
-- Redistribution and use in source and binary forms, with or without
8
-- modification, are permitted provided that the following conditions are met:
9
--     * Redistributions of source code must retain the above copyright
10
--       notice, this list of conditions and the following disclaimer.
11
--     * Redistributions in binary form must reproduce the above copyright
12
--       notice, this list of conditions and the following disclaimer in the
13
--       documentation and/or other materials provided with the distribution.
14
--     * Neither the name of the <organization> nor the
15
--       names of its contributors may be used to endorse or promote products
16
--       derived from this software without specific prior written permission.
17 164 rkastl
-- 
18 170 rkastl
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  "AS IS" AND
19
-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
-- DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
22
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 164 rkastl
-- 
29
-- File        : SdClockMaster-Rtl-a.vhdl
30
-- Owner       : Rainer Kastl
31
-- Description : Generation of SDClk and internal strobes
32
-- Links       : 
33
-- 
34 121 rkastl
 
35
architecture Rtl of SdClockMaster is
36
 
37 129 rkastl
        subtype aCounter is unsigned(1 downto 0); -- maximal division through 4
38 121 rkastl
 
39 129 rkastl
        type aRegSet is record
40
                Counter   : aCounter;
41
                Clk       : std_ulogic;
42
                Strobe    : std_ulogic;
43 150 rkastl
                InStrobe  : std_ulogic;
44 129 rkastl
                HighSpeed : std_ulogic;
45
        end record aRegSet;
46
 
47
        signal R,NxR : aRegSet;
48
 
49 121 rkastl
begin
50
 
51 129 rkastl
        -- connect outputs with registers
52
        oSdCardClk <= R.Clk;
53
        oSdStrobe  <= R.Strobe;
54 150 rkastl
        oSdInStrobe <= R.InStrobe;
55 121 rkastl
 
56 129 rkastl
        Regs : process (iClk, iRstSync)
57
        begin
58
                if (rising_edge(iClk)) then
59 121 rkastl
 
60 129 rkastl
                        -- synchronous reset
61
                        if (iRstSync = cActivated) then
62 121 rkastl
 
63 129 rkastl
                                R.Counter   <= to_unsigned(0, R.Counter'length);
64
                                R.Clk       <= cInactivated;
65
                                R.Strobe    <= cInactivated;
66 150 rkastl
                                R.InStrobe  <= cInactivated;
67 129 rkastl
                                R.HighSpeed <= cInactivated;
68 126 rkastl
 
69 129 rkastl
                        else
70
                                R <= NxR;
71 124 rkastl
 
72
                        end if;
73 129 rkastl
                end if;
74
        end process Regs;
75 121 rkastl
 
76 129 rkastl
        Comb : process (R, iHighSpeed, iDisable)
77
        begin
78 124 rkastl
 
79 129 rkastl
                -- defaults
80 124 rkastl
 
81 130 rkastl
                NxR <= R;
82 124 rkastl
 
83 130 rkastl
                case iDisable is
84
                        when cInactivated =>
85
                                NxR.Counter <= R.Counter + 1;
86 126 rkastl
 
87 130 rkastl
                                -- generate clock and strobe
88
                                case R.HighSpeed is
89
                                        when cInactivated => -- default mode
90
                                                NxR.Clk <= R.Counter(1);
91 124 rkastl
 
92 130 rkastl
                                                case R.Counter is
93 150 rkastl
                                                        when "00" | "11"  =>
94 130 rkastl
                                                                NxR.Strobe <= cInactivated;
95 150 rkastl
                                                                NxR.InStrobe <= cInactivated;
96 124 rkastl
 
97 130 rkastl
                                                        when "10" =>
98
                                                                NxR.Strobe <= cActivated;
99 150 rkastl
                                                                NxR.InStrobe <= cInactivated;
100 130 rkastl
 
101 150 rkastl
                                                        when "01" =>
102
                                                                NxR.InStrobe <= cActivated;
103
                                                                NxR.Strobe <= cInactivated;
104
 
105 130 rkastl
                                                        when others =>
106
                                                                NxR.Strobe <= 'X';
107 150 rkastl
                                                                NxR.InStrobe <= 'X';
108 130 rkastl
                                                end case;
109
 
110
                                        when cActivated => -- High-Speed mode
111
                                                NxR.Clk <= R.Counter(0);
112 146 rkastl
                                                NxR.Strobe  <= R.Counter(0);
113 152 rkastl
                                                NxR.InStrobe <= R.Counter(0);
114 130 rkastl
 
115 129 rkastl
                                        when others =>
116 130 rkastl
                                                NxR.Clk <= 'X';
117 129 rkastl
                                end case;
118
 
119 130 rkastl
                                -- switch speeds and increment counter
120
                                case R.HighSpeed is
121
                                        when cInactivated =>
122
                                                if (R.Counter = 3) then
123
                                                        NxR.HighSpeed <= iHighSpeed;
124
                                                end if;
125 129 rkastl
 
126 130 rkastl
                                        when cActivated =>
127
                                                if (R.Counter(0) = '1') then
128
                                                        NxR.HighSpeed <= iHighSpeed;
129
                                                        NxR.Counter <= "00";
130
                                                end if;
131 129 rkastl
 
132 130 rkastl
                                        when others =>
133
                                                NxR.HighSpeed <= 'X';
134
                                end case;
135 121 rkastl
 
136 129 rkastl
                        when cActivated =>
137 130 rkastl
                                -- disable strobes and do not increment the counter 
138
                                NxR.Strobe <= cInactivated;
139 150 rkastl
                                NxR.InStrobe <= cInactivated;
140 121 rkastl
 
141 129 rkastl
                        when others =>
142 130 rkastl
                                NxR.Clk    <= 'X';
143
                                NxR.Strobe <= 'X';
144 150 rkastl
                                NxR.InStrobe <= 'X';
145 130 rkastl
 
146 129 rkastl
                end case;
147 121 rkastl
 
148 129 rkastl
        end process Comb;
149 121 rkastl
 
150 129 rkastl
 
151 121 rkastl
end architecture Rtl;
152
 

powered by: WebSVN 2.1.0

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