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

Subversion Repositories mem_ctrl

[/] [mem_ctrl/] [trunk/] [rtl/] [verilog/] [mc_refresh.v] - Blame information for rev 22

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 rudi
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  WISHBONE Memory Controller                                 ////
4
////  Refresh Module                                             ////
5
////                                                             ////
6
////                                                             ////
7
////  Author: Rudolf Usselmann                                   ////
8
////          rudi@asics.ws                                      ////
9
////                                                             ////
10
////                                                             ////
11
////  Downloaded from: http://www.opencores.org/cores/mem_ctrl/  ////
12
////                                                             ////
13
/////////////////////////////////////////////////////////////////////
14
////                                                             ////
15 22 rudi
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
16
////                         www.asics.ws                        ////
17
////                         rudi@asics.ws                       ////
18 4 rudi
////                                                             ////
19
//// This source file may be used and distributed without        ////
20
//// restriction provided that this copyright statement is not   ////
21
//// removed from the file and that any derivative work contains ////
22
//// the original copyright notice and the associated disclaimer.////
23
////                                                             ////
24
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
25
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
26
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
27
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
28
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
29
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
30
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
31
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
32
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
33
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
34
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
35
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
36
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
37
////                                                             ////
38
/////////////////////////////////////////////////////////////////////
39
 
40
//  CVS Log
41
//
42 22 rudi
//  $Id: mc_refresh.v,v 1.4 2002-01-21 13:08:52 rudi Exp $
43 4 rudi
//
44 22 rudi
//  $Date: 2002-01-21 13:08:52 $
45
//  $Revision: 1.4 $
46 4 rudi
//  $Author: rudi $
47
//  $Locker:  $
48
//  $State: Exp $
49
//
50
// Change History:
51
//               $Log: not supported by cvs2svn $
52 22 rudi
//               Revision 1.3  2001/12/11 02:47:19  rudi
53
//
54
//               - Made some changes not to expect clock during reset ...
55
//
56 18 rudi
//               Revision 1.2  2001/09/24 00:38:21  rudi
57
//
58
//               Changed Reset to be active high and async.
59
//
60 12 rudi
//               Revision 1.1  2001/07/29 07:34:41  rudi
61
//
62
//
63
//               1) Changed Directory Structure
64
//               2) Fixed several minor bugs
65
//
66 4 rudi
//               Revision 1.3  2001/06/12 15:19:49  rudi
67
//
68
//
69
//               Minor changes after running lint, and a small bug fix reading csr and ba_mask registers.
70
//
71
//               Revision 1.2  2001/06/03 11:37:17  rudi
72
//
73
//
74
//               1) Fixed Chip Select Mask Register
75
//                      - Power On Value is now all ones
76
//                      - Comparison Logic is now correct
77
//
78
//               2) All resets are now asynchronous
79
//
80
//               3) Converted Power On Delay to an configurable item
81
//
82
//               4) Added reset to Chip Select Output Registers
83
//
84
//               5) Forcing all outputs to Hi-Z state during reset
85
//
86
//               Revision 1.1.1.1  2001/05/13 09:39:47  rudi
87
//               Created Directory Structure
88
//
89
//
90
//
91
//
92
 
93
`include "mc_defines.v"
94
 
95
module mc_refresh(clk, rst,
96
                cs_need_rfr, ref_int, rfr_req, rfr_ack,
97
                rfr_ps_val
98
                );
99
 
100
input           clk, rst;
101
input   [7:0]    cs_need_rfr;
102
input   [2:0]    ref_int;
103
output          rfr_req;
104
input           rfr_ack;
105
input   [7:0]    rfr_ps_val;
106
 
107
////////////////////////////////////////////////////////////////////
108
//
109
// Local Registers & Wires
110
//
111
 
112
reg             rfr_en;
113
reg     [7:0]    ps_cnt;
114
wire            ps_cnt_clr;
115
reg             rfr_ce;
116
reg     [7:0]    rfr_cnt;
117
reg             rfr_clr;
118
reg             rfr_req;
119
reg             rfr_early;
120
 
121
/*
122
Refresh generation
123
 
124
The prescaler generates a 0.48828 uS clock enable
125
 
126
The refresh counter generates the following refresh rates:
127
(Actual values are about 0.63% below the desired values).
128
This is for a 200 Mhz WISHBONE Bus.
129
0.970 uS,
130
1.940
131
3.880
132
7.760
133
15.520
134
32.040
135
62.080
136
124.160 uS
137
 
138
(desired values)
139
0.976 uS
140
1.953
141
3.906
142
7.812
143
15.625
144
31.250
145
62.500
146
125.000 uS
147
*/
148
 
149
////////////////////////////////////////////////////////////////////
150
//
151
// Prescaler
152
//
153
 
154 18 rudi
always @(posedge clk or posedge rst)
155
        if(rst)         rfr_en <= #1 1'b0;
156
        else            rfr_en <= #1 |cs_need_rfr;
157 4 rudi
 
158 12 rudi
always @(posedge clk or posedge rst)
159
        if(rst)                         ps_cnt <= #1 8'h0;
160 4 rudi
        else
161
        if(ps_cnt_clr)                  ps_cnt <= #1 8'h0;
162
        else
163
        if(rfr_en)                      ps_cnt <= #1 ps_cnt + 8'h1;
164
 
165
assign ps_cnt_clr = (ps_cnt == rfr_ps_val) & (rfr_ps_val != 8'h0);
166
 
167 18 rudi
always @(posedge clk or posedge rst)
168
        if(rst)         rfr_early <= #1 1'b0;
169
        else            rfr_early <= #1 (ps_cnt == rfr_ps_val);
170 4 rudi
 
171
////////////////////////////////////////////////////////////////////
172
//
173
// Refresh Counter
174
//
175
 
176 18 rudi
always @(posedge clk or posedge rst)
177
        if(rst)         rfr_ce <= #1 1'b0;
178
        else            rfr_ce <= #1 ps_cnt_clr;
179 4 rudi
 
180 12 rudi
always @(posedge clk or posedge rst)
181
        if(rst)                 rfr_cnt <= #1 8'h0;
182 4 rudi
        else
183
        if(rfr_ack)             rfr_cnt <= #1 8'h0;
184
        else
185
        if(rfr_ce)              rfr_cnt <= #1 rfr_cnt + 8'h1;
186
 
187
always @(posedge clk)
188
        case(ref_int)           // synopsys full_case parallel_case
189
           3'h0: rfr_clr <= #1  rfr_cnt[0]   & rfr_early;
190
           3'h1: rfr_clr <= #1 &rfr_cnt[1:0] & rfr_early;
191
           3'h2: rfr_clr <= #1 &rfr_cnt[2:0] & rfr_early;
192
           3'h3: rfr_clr <= #1 &rfr_cnt[3:0] & rfr_early;
193
           3'h4: rfr_clr <= #1 &rfr_cnt[4:0] & rfr_early;
194
           3'h5: rfr_clr <= #1 &rfr_cnt[5:0] & rfr_early;
195
           3'h6: rfr_clr <= #1 &rfr_cnt[6:0] & rfr_early;
196
           3'h7: rfr_clr <= #1 &rfr_cnt[7:0] & rfr_early;
197
        endcase
198
 
199 12 rudi
always @(posedge clk or posedge rst)
200
        if(rst)                 rfr_req <= #1 1'b0;
201 4 rudi
        else
202
        if(rfr_ack)             rfr_req <= #1 1'b0;
203
        else
204
        if(rfr_clr)             rfr_req <= #1 1'b1;
205
 
206
endmodule

powered by: WebSVN 2.1.0

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