1 |
4 |
rudi |
/////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// WISHBONE Memory Controller Definitions ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// ////
|
6 |
|
|
//// Author: Rudolf Usselmann ////
|
7 |
|
|
//// rudi@asics.ws ////
|
8 |
|
|
//// ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// Downloaded from: http://www.opencores.org/cores/mem_ctrl/ ////
|
11 |
|
|
//// ////
|
12 |
|
|
/////////////////////////////////////////////////////////////////////
|
13 |
|
|
//// ////
|
14 |
|
|
//// Copyright (C) 2000 Rudolf Usselmann ////
|
15 |
|
|
//// rudi@asics.ws ////
|
16 |
|
|
//// ////
|
17 |
|
|
//// This source file may be used and distributed without ////
|
18 |
|
|
//// restriction provided that this copyright statement is not ////
|
19 |
|
|
//// removed from the file and that any derivative work contains ////
|
20 |
|
|
//// the original copyright notice and the associated disclaimer.////
|
21 |
|
|
//// ////
|
22 |
|
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
23 |
|
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
24 |
|
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
25 |
|
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
26 |
|
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
27 |
|
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
28 |
|
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
29 |
|
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
30 |
|
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
31 |
|
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
32 |
|
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
33 |
|
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
34 |
|
|
//// POSSIBILITY OF SUCH DAMAGE. ////
|
35 |
|
|
//// ////
|
36 |
|
|
/////////////////////////////////////////////////////////////////////
|
37 |
|
|
|
38 |
|
|
// CVS Log
|
39 |
|
|
//
|
40 |
11 |
rudi |
// $Id: mc_defines.v,v 1.3 2001-09-10 13:44:17 rudi Exp $
|
41 |
4 |
rudi |
//
|
42 |
11 |
rudi |
// $Date: 2001-09-10 13:44:17 $
|
43 |
|
|
// $Revision: 1.3 $
|
44 |
4 |
rudi |
// $Author: rudi $
|
45 |
|
|
// $Locker: $
|
46 |
|
|
// $State: Exp $
|
47 |
|
|
//
|
48 |
|
|
// Change History:
|
49 |
|
|
// $Log: not supported by cvs2svn $
|
50 |
11 |
rudi |
// Revision 1.2 2001/08/10 08:16:21 rudi
|
51 |
|
|
//
|
52 |
|
|
// - Changed IO names to be more clear.
|
53 |
|
|
// - Uniquifyed define names to be core specific.
|
54 |
|
|
// - Removed "Refresh Early" configuration
|
55 |
|
|
//
|
56 |
8 |
rudi |
// Revision 1.1 2001/07/29 07:34:41 rudi
|
57 |
|
|
//
|
58 |
|
|
//
|
59 |
|
|
// 1) Changed Directory Structure
|
60 |
|
|
// 2) Fixed several minor bugs
|
61 |
|
|
//
|
62 |
4 |
rudi |
// Revision 1.3 2001/06/12 15:19:49 rudi
|
63 |
|
|
//
|
64 |
|
|
//
|
65 |
|
|
// Minor changes after running lint, and a small bug fix reading csr and ba_mask registers.
|
66 |
|
|
//
|
67 |
|
|
// Revision 1.2 2001/06/03 11:37:17 rudi
|
68 |
|
|
//
|
69 |
|
|
//
|
70 |
|
|
// 1) Fixed Chip Select Mask Register
|
71 |
|
|
// - Power On Value is now all ones
|
72 |
|
|
// - Comparison Logic is now correct
|
73 |
|
|
//
|
74 |
|
|
// 2) All resets are now asynchronous
|
75 |
|
|
//
|
76 |
|
|
// 3) Converted Power On Delay to an configurable item
|
77 |
|
|
//
|
78 |
|
|
// 4) Added reset to Chip Select Output Registers
|
79 |
|
|
//
|
80 |
|
|
// 5) Forcing all outputs to Hi-Z state during reset
|
81 |
|
|
//
|
82 |
|
|
// Revision 1.1.1.1 2001/05/13 09:39:38 rudi
|
83 |
|
|
// Created Directory Structure
|
84 |
|
|
//
|
85 |
|
|
//
|
86 |
|
|
//
|
87 |
|
|
//
|
88 |
|
|
|
89 |
|
|
`timescale 1ns / 10ps
|
90 |
|
|
|
91 |
|
|
/////////////////////////////////////////////////////////////////////
|
92 |
|
|
//
|
93 |
|
|
// This define selects how the WISHBONE interface determines if
|
94 |
|
|
// the internal register file is selected.
|
95 |
|
|
// This should be a simple address decoder. "wb_addr_i" is the
|
96 |
|
|
// WISHBONE address bus (32 bits wide).
|
97 |
11 |
rudi |
//`define MC_REG_SEL (wb_addr_i[31:29] == 3'h6)
|
98 |
|
|
`define MC_REG_SEL (wb_addr_i[31:29] == 3'b011)
|
99 |
4 |
rudi |
|
100 |
|
|
// This define selects how the WISHBONE interface determines if
|
101 |
|
|
// the memory is selected.
|
102 |
|
|
// This should be a simple address decoder. "wb_addr_i" is the
|
103 |
|
|
// WISHBONE address bus (32 bits wide).
|
104 |
8 |
rudi |
`define MC_MEM_SEL (wb_addr_i[31:29] == 3'h0)
|
105 |
4 |
rudi |
|
106 |
|
|
/////////////////////////////////////////////////////////////////////
|
107 |
|
|
//
|
108 |
|
|
// This are the default Power-On Reset values for Chip Select
|
109 |
|
|
//
|
110 |
|
|
|
111 |
|
|
// Defines which chip select is used for Power On booting
|
112 |
11 |
rudi |
`define MC_DEF_SEL 3'h1
|
113 |
4 |
rudi |
|
114 |
|
|
// Defines the default (reset) TMS value for the DEF_SEL chip select
|
115 |
8 |
rudi |
`define MC_DEF_POR_TMS 32'hffff_ffff
|
116 |
4 |
rudi |
|
117 |
|
|
|
118 |
|
|
/////////////////////////////////////////////////////////////////////
|
119 |
|
|
//
|
120 |
|
|
// Define how many Chip Selects to Implement
|
121 |
|
|
//
|
122 |
8 |
rudi |
`define MC_HAVE_CS1 1
|
123 |
11 |
rudi |
//`define MC_HAVE_CS2 1
|
124 |
|
|
//`define MC_HAVE_CS3 1
|
125 |
|
|
//`define MC_HAVE_CS4 1
|
126 |
|
|
//`define MC_HAVE_CS5 1
|
127 |
|
|
//`define MC_HAVE_CS6 1
|
128 |
|
|
//`define MC_HAVE_CS7 1
|
129 |
4 |
rudi |
|
130 |
|
|
|
131 |
|
|
/////////////////////////////////////////////////////////////////////
|
132 |
|
|
//
|
133 |
|
|
// Init Refresh
|
134 |
|
|
//
|
135 |
|
|
// Number of Refresh Cycles to perform during SDRAM initialization.
|
136 |
|
|
// This varies between SDRAM manufacturer. Typically this value is
|
137 |
|
|
// between 2 and 8. This number must be smaller than 16.
|
138 |
8 |
rudi |
`define MC_INIT_RFRC_CNT 2
|
139 |
4 |
rudi |
|
140 |
|
|
/////////////////////////////////////////////////////////////////////
|
141 |
|
|
//
|
142 |
|
|
// Power On Delay
|
143 |
|
|
//
|
144 |
|
|
// Most if SDRAMs require some time to initialize before they can be used
|
145 |
|
|
// after power on. If the Memory Controller shall stall after power on to
|
146 |
|
|
// allow SDRAMs to finish the initialization process uncomment the below
|
147 |
|
|
// define statement
|
148 |
8 |
rudi |
`define MC_POR_DELAY 1
|
149 |
4 |
rudi |
|
150 |
|
|
// This value defines how many MEM_CLK cycles the Memory Controller should
|
151 |
|
|
// stall. Default is 2.5uS. At a 10nS MEM_CLK cycle time, this would 250
|
152 |
|
|
// cycles.
|
153 |
8 |
rudi |
`define MC_POR_DELAY_VAL 8'd250
|
154 |
4 |
rudi |
|
155 |
|
|
|
156 |
|
|
// ===============================================================
|
157 |
|
|
// ===============================================================
|
158 |
|
|
// Various internal defines (DO NOT MODIFY !)
|
159 |
|
|
// ===============================================================
|
160 |
|
|
// ===============================================================
|
161 |
|
|
|
162 |
|
|
// Register settings encodings
|
163 |
8 |
rudi |
`define MC_BW_8 2'h0
|
164 |
|
|
`define MC_BW_16 2'h1
|
165 |
|
|
`define MC_BW_32 2'h2
|
166 |
4 |
rudi |
|
167 |
8 |
rudi |
`define MC_MEM_TYPE_SDRAM 3'h0
|
168 |
|
|
`define MC_MEM_TYPE_SRAM 3'h1
|
169 |
|
|
`define MC_MEM_TYPE_ACS 3'h2
|
170 |
|
|
`define MC_MEM_TYPE_SCS 3'h3
|
171 |
4 |
rudi |
|
172 |
8 |
rudi |
`define MC_MEM_SIZE_64 2'h0
|
173 |
|
|
`define MC_MEM_SIZE_128 2'h1
|
174 |
|
|
`define MC_MEM_SIZE_256 2'h2
|
175 |
|
|
|
176 |
|
|
// Command Valid, Ras_, Cas_, We_
|
177 |
|
|
`define MC_CMD_NOP 4'b0111
|
178 |
|
|
`define MC_CMD_PC 4'b1010
|
179 |
|
|
`define MC_CMD_ACT 4'b1011
|
180 |
|
|
`define MC_CMD_WR 4'b1100
|
181 |
|
|
`define MC_CMD_RD 4'b1101
|
182 |
|
|
`define MC_CMD_BT 4'b1110
|
183 |
|
|
`define MC_CMD_ARFR 4'b1001
|
184 |
|
|
`define MC_CMD_LMR 4'b1000
|
185 |
|
|
`define MC_CMD_XRD 4'b1111
|
186 |
|
|
`define MC_CMD_XWR 4'b1110
|
187 |
|
|
|
188 |
|
|
`define MC_SINGLE_BANK 1'b0
|
189 |
|
|
`define MC_ALL_BANKS 1'b1
|
190 |
|
|
|