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

Subversion Repositories sdr_ctrl

[/] [sdr_ctrl/] [trunk/] [rtl/] [top/] [sdrc_top.v] - Blame information for rev 33

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

Line No. Rev Author Line
1 31 dinesha
/*********************************************************************
2
 
3
  SDRAM Controller top File
4
 
5
  This file is part of the sdram controller project
6
  http://www.opencores.org/cores/sdr_ctrl/
7
 
8 33 dinesha
  Description: SDRAM Controller Top Module.
9
    Support 81/6/32 Bit SDRAM.
10
    Column Address is Programmable
11
    Bank Bit are 2 Bit
12
    Row Bits are 12 Bits
13
 
14 31 dinesha
    This block integrate following sub modules
15
 
16
    sdrc_core
17
        SDRAM Controller file
18
    wb2sdrc
19
        This module transalate the bus protocl from wishbone to custome
20
        sdram controller
21
 
22
  To Do:
23
    nothing
24
 
25
  Author(s): Dinesh Annayya, dinesha@opencores.org
26
  Version  : 1.0 - 8th Jan 2012
27
                Initial version with 16/32 Bit SDRAM Support
28
           : 1.1 - 24th Jan 2012
29
                 8 Bit SDRAM Support is added
30
 
31
 
32
 Copyright (C) 2000 Authors and OPENCORES.ORG
33
 
34
 This source file may be used and distributed without
35
 restriction provided that this copyright statement is not
36
 removed from the file and that any derivative work contains
37
 the original copyright notice and the associated disclaimer.
38
 
39
 This source file is free software; you can redistribute it
40
 and/or modify it under the terms of the GNU Lesser General
41
 Public License as published by the Free Software Foundation;
42
 either version 2.1 of the License, or (at your option) any
43
later version.
44
 
45
 This source is distributed in the hope that it will be
46
 useful, but WITHOUT ANY WARRANTY; without even the implied
47
 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
48
 PURPOSE.  See the GNU Lesser General Public License for more
49
 details.
50
 
51
 You should have received a copy of the GNU Lesser General
52
 Public License along with this source; if not, download it
53
 from http://www.opencores.org/lgpl.shtml
54
 
55
*******************************************************************/
56
 
57
 
58
`include "sdrc.def"
59
module sdrc_top
60
           (
61 33 dinesha
                    sdr_width           ,
62
                    cfg_colbits         ,
63
 
64 31 dinesha
                // WB bus
65 33 dinesha
                    wb_rst_i            ,
66
                    wb_clk_i            ,
67
 
68
                    wb_stb_i            ,
69
                    wb_ack_o            ,
70
                    wb_addr_i           ,
71
                    wb_we_i             ,
72
                    wb_dat_i            ,
73
                    wb_sel_i            ,
74
                    wb_dat_o            ,
75
                    wb_cyc_i            ,
76
                    wb_cti_i            ,
77 31 dinesha
 
78
 
79
                /* Interface to SDRAMs */
80 33 dinesha
                    sdram_clk           ,
81
                    sdram_pad_clk       ,
82
                    sdram_resetn        ,
83
                    sdr_cs_n            ,
84
                    sdr_cke             ,
85
                    sdr_ras_n           ,
86
                    sdr_cas_n           ,
87
                    sdr_we_n            ,
88
                    sdr_dqm             ,
89
                    sdr_ba              ,
90
                    sdr_addr            ,
91
                    pad_sdr_din         ,
92
                    sdr_dout            ,
93
                    sdr_den_n           ,
94
 
95 31 dinesha
                /* Parameters */
96 33 dinesha
                    sdr_init_done       ,
97
                    cfg_req_depth       ,               //how many req. buffer should hold
98
                    cfg_sdr_en          ,
99
                    cfg_sdr_mode_reg    ,
100
                    cfg_sdr_tras_d      ,
101
                    cfg_sdr_trp_d       ,
102
                    cfg_sdr_trcd_d      ,
103
                    cfg_sdr_cas         ,
104
                    cfg_sdr_trcar_d     ,
105
                    cfg_sdr_twr_d       ,
106
                    cfg_sdr_rfsh        ,
107
                    cfg_sdr_rfmax
108
            );
109 31 dinesha
 
110 33 dinesha
parameter      APP_AW   = 30;  // Application Address Width
111
parameter      APP_DW   = 32;  // Application Data Width 
112
parameter      APP_BW   = 4;   // Application Byte Width
113
parameter      APP_RW   = 9;   // Application Request Width
114 31 dinesha
 
115 33 dinesha
parameter      SDR_DW   = 16;  // SDR Data Width 
116
parameter      SDR_BW   = 2;   // SDR Byte Width
117 31 dinesha
 
118 33 dinesha
parameter      dw       = 32;  // data width
119
parameter      tw       = 8;   // tag id width
120
parameter      bl       = 9;   // burst_lenght_width 
121 31 dinesha
 
122
//-----------------------------------------------
123
// Global Variable
124
// ----------------------------------------------
125 33 dinesha
input                   sdram_clk          ; // SDRAM Clock 
126
input                   sdram_pad_clk      ; // SDRAM Clock from Pad, used for registering Read Data
127
input                   sdram_resetn       ; // Reset Signal
128
input [1:0]             sdr_width          ; // 2'b00 - 32 Bit SDR, 2'b01 - 16 Bit SDR, 2'b1x - 8 Bit
129
input [1:0]             cfg_colbits        ; // 2'b00 - 8 Bit column address, 
130
                                             // 2'b01 - 9 Bit, 10 - 10 bit, 11 - 11Bits
131 31 dinesha
 
132
//--------------------------------------
133
// Wish Bone Interface
134
// -------------------------------------      
135 33 dinesha
input                   wb_rst_i           ;
136
input                   wb_clk_i           ;
137 31 dinesha
 
138 33 dinesha
input                   wb_stb_i           ;
139
output                  wb_ack_o           ;
140
input [29:0]            wb_addr_i          ;
141
input                   wb_we_i            ; // 1 - Write, 0 - Read
142
input [dw-1:0]          wb_dat_i           ;
143
input [dw/8-1:0]        wb_sel_i           ; // Byte enable
144
output [dw-1:0]         wb_dat_o           ;
145
input                   wb_cyc_i           ;
146
input  [2:0]            wb_cti_i           ;
147 31 dinesha
 
148
//------------------------------------------------
149
// Interface to SDRAMs
150
//------------------------------------------------
151
output                  sdr_cke             ; // SDRAM CKE
152
output                  sdr_cs_n            ; // SDRAM Chip Select
153
output                  sdr_ras_n           ; // SDRAM ras
154
output                  sdr_cas_n           ; // SDRAM cas
155
output                  sdr_we_n            ; // SDRAM write enable
156
output [SDR_BW-1:0]      sdr_dqm             ; // SDRAM Data Mask
157
output [1:0]             sdr_ba              ; // SDRAM Bank Enable
158
output [11:0]            sdr_addr            ; // SDRAM Address
159
input [SDR_DW-1:0]       pad_sdr_din         ; // SDRA Data Input
160
output [SDR_DW-1:0]      sdr_dout            ; // SDRAM Data Output
161
output [SDR_BW-1:0]      sdr_den_n           ; // SDRAM Data Output enable
162
 
163
//------------------------------------------------
164
// Configuration Parameter
165
//------------------------------------------------
166
output                  sdr_init_done       ; // Indicate SDRAM Initialisation Done
167
input [3:0]              cfg_sdr_tras_d      ; // Active to precharge delay
168
input [3:0]             cfg_sdr_trp_d       ; // Precharge to active delay
169
input [3:0]             cfg_sdr_trcd_d      ; // Active to R/W delay
170
input                   cfg_sdr_en          ; // Enable SDRAM controller
171
input [1:0]              cfg_req_depth       ; // Maximum Request accepted by SDRAM controller
172
input [11:0]             cfg_sdr_mode_reg    ;
173
input [2:0]              cfg_sdr_cas         ; // SDRAM CAS Latency
174
input [3:0]              cfg_sdr_trcar_d     ; // Auto-refresh period
175
input [3:0]             cfg_sdr_twr_d       ; // Write recovery delay
176
input [`SDR_RFSH_TIMER_W-1 : 0] cfg_sdr_rfsh;
177
input [`SDR_RFSH_ROW_CNT_W -1 : 0] cfg_sdr_rfmax;
178
 
179
//--------------------------------------------
180
// SDRAM controller Interface 
181
//--------------------------------------------
182
wire                  app_req            ; // SDRAM request
183
wire [29:0]           app_req_addr       ; // SDRAM Request Address
184
wire [bl-1:0]         app_req_len        ;
185
wire                  app_req_wr_n       ; // 0 - Write, 1 -> Read
186
wire                  app_req_ack        ; // SDRAM request Accepted
187
wire                  app_busy_n         ; // 0 -> sdr busy
188
wire [dw/8-1:0]       app_wr_en_n        ; // Active low sdr byte-wise write data valid
189
wire                  app_wr_next_req    ; // Ready to accept the next write
190
wire                  app_rd_valid       ; // sdr read valid
191
wire                  app_last_rd        ; // Indicate last Read of Burst Transfer
192
wire [dw-1:0]         app_wr_data        ; // sdr write data
193
wire  [dw-1:0]        app_rd_data        ; // sdr read data
194
 
195
wb2sdrc u_wb2sdrc (
196
      // WB bus
197
          .wb_rst_i           (wb_rst_i           ) ,
198
          .wb_clk_i           (wb_clk_i           ) ,
199
 
200
          .wb_stb_i           (wb_stb_i           ) ,
201
          .wb_ack_o           (wb_ack_o           ) ,
202
          .wb_addr_i          (wb_addr_i          ) ,
203
          .wb_we_i            (wb_we_i            ) ,
204
          .wb_dat_i           (wb_dat_i           ) ,
205
          .wb_sel_i           (wb_sel_i           ) ,
206
          .wb_dat_o           (wb_dat_o           ) ,
207
          .wb_cyc_i           (wb_cyc_i           ) ,
208
          .wb_cti_i           (wb_cti_i           ) ,
209
 
210
 
211
      //SDRAM Controller Hand-Shake Signal 
212
          .sdram_clk          (sdram_clk          ) ,
213
          .sdram_resetn       (sdram_resetn       ) ,
214
          .sdr_req            (app_req            ) ,
215
          .sdr_req_addr       (app_req_addr       ) ,
216
          .sdr_req_len        (app_req_len        ) ,
217
          .sdr_req_wr_n       (app_req_wr_n       ) ,
218
          .sdr_req_ack        (app_req_ack        ) ,
219
          .sdr_busy_n         (app_busy_n         ) ,
220
          .sdr_wr_en_n        (app_wr_en_n        ) ,
221
          .sdr_wr_next        (app_wr_next_req    ) ,
222
          .sdr_rd_valid       (app_rd_valid       ) ,
223
          .sdr_last_rd        (app_last_rd        ) ,
224
          .sdr_wr_data        (app_wr_data        ) ,
225
          .sdr_rd_data        (app_rd_data        )
226
 
227
      );
228
 
229
 
230
sdrc_core #(.SDR_DW(SDR_DW) , .SDR_BW(SDR_BW)) u_sdrc_core (
231
          .clk                (sdram_clk          ) ,
232
          .pad_clk            (sdram_pad_clk      ) ,
233
          .reset_n            (sdram_resetn       ) ,
234
          .sdr_width          (sdr_width          ) ,
235
          .cfg_colbits        (cfg_colbits        ) ,
236
 
237
                /* Request from app */
238
          .app_req            (app_req            ) ,// Transfer Request
239
          .app_req_addr       (app_req_addr       ) ,// SDRAM Address
240
          .app_req_addr_mask  (29'h0              ) ,// Address mask for queue wrap
241
          .app_req_len        (app_req_len        ) ,// Burst Length (in 16 bit words)
242
          .app_req_wrap       (1'b0               ) ,// Wrap mode request 
243
          .app_req_wr_n       (app_req_wr_n       ) ,// 0 => Write request, 1 => read req
244
          .app_req_ack        (app_req_ack        ) ,// Request has been accepted
245
          .sdr_core_busy_n    (app_core_busy_n    ) ,// OK to arbitrate next request
246
          .cfg_req_depth      (cfg_req_depth      ) ,//how many req. buffer should hold
247
 
248
          .app_wr_data        (app_wr_data        ) ,
249
          .app_wr_en_n        (app_wr_en_n        ) ,
250
          .app_rd_data        (app_rd_data        ) ,
251
          .app_rd_valid       (app_rd_valid       ) ,
252
          .app_last_rd        (app_last_rd        ) ,
253
          .app_wr_next_req    (app_wr_next_req    ) ,
254
          .sdr_init_done      (sdr_init_done      ) ,
255
          .app_req_dma_last   (app_req            ) ,
256
 
257
                /* Interface to SDRAMs */
258
          .sdr_cs_n           (sdr_cs_n           ) ,
259
          .sdr_cke            (sdr_cke            ) ,
260
          .sdr_ras_n          (sdr_ras_n          ) ,
261
          .sdr_cas_n          (sdr_cas_n          ) ,
262
          .sdr_we_n           (sdr_we_n           ) ,
263
          .sdr_dqm            (sdr_dqm            ) ,
264
          .sdr_ba             (sdr_ba             ) ,
265
          .sdr_addr           (sdr_addr           ) ,
266
          .pad_sdr_din        (pad_sdr_din        ) ,
267
          .sdr_dout           (sdr_dout           ) ,
268
          .sdr_den_n          (sdr_den_n          ) ,
269
 
270
                /* Parameters */
271
          .cfg_sdr_en         (cfg_sdr_en         ) ,
272
          .cfg_sdr_mode_reg   (cfg_sdr_mode_reg   ) ,
273
          .cfg_sdr_tras_d     (cfg_sdr_tras_d     ) ,
274
          .cfg_sdr_trp_d      (cfg_sdr_trp_d      ) ,
275
          .cfg_sdr_trcd_d     (cfg_sdr_trcd_d     ) ,
276
          .cfg_sdr_cas        (cfg_sdr_cas        ) ,
277
          .cfg_sdr_trcar_d    (cfg_sdr_trcar_d    ) ,
278
          .cfg_sdr_twr_d      (cfg_sdr_twr_d      ) ,
279
          .cfg_sdr_rfsh       (cfg_sdr_rfsh       ) ,
280
          .cfg_sdr_rfmax      (cfg_sdr_rfmax      )
281
               );
282
 
283
endmodule // sdrc_core

powered by: WebSVN 2.1.0

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