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

Subversion Repositories sdr_ctrl

[/] [sdr_ctrl/] [trunk/] [rtl/] [core/] [sdrc_bank_ctl.v] - Blame information for rev 52

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

Line No. Rev Author Line
1 3 dinesha
/*********************************************************************
2
 
3
  SDRAM Controller Bank Controller
4
 
5
  This file is part of the sdram controller project
6
  http://www.opencores.org/cores/sdr_ctrl/
7
 
8
  Description:
9
    This module takes requests from sdrc_req_gen, checks for page hit/miss and
10
    issues precharge/activate commands and then passes the request to sdrc_xfr_ctl.
11
 
12
  To Do:
13
    nothing
14
 
15
  Author(s):
16
      - Dinesh Annayya, dinesha@opencores.org
17
  Version  :  1.0  - 8th Jan 2012
18
 
19
 
20
 
21
 Copyright (C) 2000 Authors and OPENCORES.ORG
22
 
23
 This source file may be used and distributed without
24
 restriction provided that this copyright statement is not
25
 removed from the file and that any derivative work contains
26
 the original copyright notice and the associated disclaimer.
27
 
28
 This source file is free software; you can redistribute it
29
 and/or modify it under the terms of the GNU Lesser General
30
 Public License as published by the Free Software Foundation;
31
 either version 2.1 of the License, or (at your option) any
32
later version.
33
 
34
 This source is distributed in the hope that it will be
35
 useful, but WITHOUT ANY WARRANTY; without even the implied
36
 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
37
 PURPOSE.  See the GNU Lesser General Public License for more
38
 details.
39
 
40
 You should have received a copy of the GNU Lesser General
41
 Public License along with this source; if not, download it
42
 from http://www.opencores.org/lgpl.shtml
43
 
44
*******************************************************************/
45
 
46
 
47 37 dinesha
`include "sdrc_define.v"
48 3 dinesha
 
49
module sdrc_bank_ctl (clk,
50
                     reset_n,
51 4 dinesha
                     a2b_req_depth,  // Number of requests we can buffer
52 3 dinesha
 
53
                     /* Req from req_gen */
54
                     r2b_req,      // request
55
                     r2b_req_id,   // ID
56
                     r2b_start,    // First chunk of burst
57
                     r2b_last,     // Last chunk of burst
58
                     r2b_wrap,
59 4 dinesha
                     r2b_ba,       // bank address
60 3 dinesha
                     r2b_raddr,    // row address
61
                     r2b_caddr,    // col address
62
                     r2b_len,      // length
63
                     r2b_write,    // write request
64 4 dinesha
                     b2r_arb_ok,   // OK to arbitrate for next xfr
65 3 dinesha
                     b2r_ack,
66
 
67
                     /* Transfer request to xfr_ctl */
68 4 dinesha
                     b2x_idle,     // All banks are idle
69 3 dinesha
                     b2x_req,      // Request to xfr_ctl
70
                     b2x_start,    // first chunk of transfer
71
                     b2x_last,     // last chunk of transfer
72
                     b2x_wrap,
73
                     b2x_id,       // Transfer ID
74 4 dinesha
                     b2x_ba,       // bank address
75 3 dinesha
                     b2x_addr,     // row/col address
76
                     b2x_len,      // transfer length
77
                     b2x_cmd,      // transfer command
78
                     x2b_ack,      // command accepted
79
 
80
                     /* Status to/from xfr_ctl */
81 4 dinesha
                     b2x_tras_ok,  // TRAS OK for all banks
82 3 dinesha
                     x2b_refresh,  // We did a refresh
83
                     x2b_pre_ok,   // OK to do a precharge (per bank)
84
                     x2b_act_ok,   // OK to do an activate
85
                     x2b_rdok,     // OK to do a read
86
                     x2b_wrok,     // OK to do a write
87
 
88 4 dinesha
                     /* xfr msb address */
89
                     xfr_bank_sel,
90
                     sdr_req_norm_dma_last,
91 3 dinesha
 
92
                     /* SDRAM Timing */
93
                     tras_delay,   // Active to precharge delay
94
                     trp_delay,    // Precharge to active delay
95
                     trcd_delay);  // Active to R/W delay
96
 
97
parameter  APP_AW   = 30;  // Application Address Width
98
parameter  APP_DW   = 32;  // Application Data Width 
99
parameter  APP_BW   = 4;   // Application Byte Width
100
 
101
parameter  SDR_DW   = 16;  // SDR Data Width 
102
parameter  SDR_BW   = 2;   // SDR Byte Width
103 51 dinesha
// 12 bit subtractor is not feasibile for FPGA, so changed to 8 bits
104
parameter  REQ_BW   = (`TARGET_DESIGN == `FPGA) ? 8 : 12;   //  Request Width
105 3 dinesha
   input                        clk, reset_n;
106
 
107 4 dinesha
   input [1:0]                   a2b_req_depth;
108
 
109 3 dinesha
   /* Req from bank_ctl */
110
   input                        r2b_req, r2b_start, r2b_last,
111
                                r2b_write, r2b_wrap;
112
   input [`SDR_REQ_ID_W-1:0]     r2b_req_id;
113 4 dinesha
   input [1:0]                   r2b_ba;
114 3 dinesha
   input [11:0]          r2b_raddr;
115
   input [11:0]          r2b_caddr;
116 50 dinesha
   input [REQ_BW-1:0]            r2b_len;
117 4 dinesha
   output                       b2r_arb_ok, b2r_ack;
118
   input                        sdr_req_norm_dma_last;
119 3 dinesha
 
120
   /* Req to xfr_ctl */
121 4 dinesha
   output                       b2x_idle, b2x_req, b2x_start, b2x_last,
122
                                b2x_tras_ok, b2x_wrap;
123 3 dinesha
   output [`SDR_REQ_ID_W-1:0]    b2x_id;
124 4 dinesha
   output [1:0]          b2x_ba;
125 3 dinesha
   output [11:0]                 b2x_addr;
126 50 dinesha
   output [REQ_BW-1:0]   b2x_len;
127 3 dinesha
   output [1:0]          b2x_cmd;
128
   input                        x2b_ack;
129
 
130
   /* Status from xfr_ctl */
131 4 dinesha
   input [3:0]                   x2b_pre_ok;
132 3 dinesha
   input                        x2b_refresh, x2b_act_ok, x2b_rdok,
133 4 dinesha
                                x2b_wrok;
134 3 dinesha
 
135
   input [3:0]                   tras_delay, trp_delay, trcd_delay;
136
 
137 4 dinesha
   input [1:0] xfr_bank_sel;
138 3 dinesha
 
139
   /****************************************************************************/
140
   // Internal Nets
141
 
142 4 dinesha
   wire [3:0]                    r2i_req, i2r_ack, i2x_req,
143
                                i2x_start, i2x_last, i2x_wrap, tras_ok;
144
   wire [11:0]                   i2x_addr0, i2x_addr1, i2x_addr2, i2x_addr3;
145 50 dinesha
   wire [REQ_BW-1:0]     i2x_len0, i2x_len1, i2x_len2, i2x_len3;
146 4 dinesha
   wire [1:0]                    i2x_cmd0, i2x_cmd1, i2x_cmd2, i2x_cmd3;
147
   wire [`SDR_REQ_ID_W-1:0]      i2x_id0, i2x_id1, i2x_id2, i2x_id3;
148 3 dinesha
 
149 4 dinesha
   reg                          b2x_req;
150
   wire                         b2x_idle, b2x_start, b2x_last, b2x_wrap;
151 3 dinesha
   wire [`SDR_REQ_ID_W-1:0]      b2x_id;
152 4 dinesha
   wire [11:0]                   b2x_addr;
153 50 dinesha
   wire [REQ_BW-1:0]     b2x_len;
154 4 dinesha
   wire [1:0]                    b2x_cmd;
155
   wire [3:0]                    x2i_ack;
156
   reg [1:0]                     b2x_ba;
157 3 dinesha
 
158 4 dinesha
   reg [`SDR_REQ_ID_W-1:0]       curr_id;
159
 
160
   wire [1:0]                    xfr_ba;
161
   wire                         xfr_ba_last;
162
   wire [3:0]                    xfr_ok;
163
 
164
   // This 8 bit register stores the bank addresses for upto 4 requests.
165
   reg [7:0]                     rank_ba;
166
   reg [3:0]                     rank_ba_last;
167
   // This 3 bit counter counts the number of requests we have
168
   // buffered so far, legal values are 0, 1, 2, 3, or 4.
169
   reg [2:0]                     rank_cnt;
170
   wire [3:0]                    rank_req, rank_wr_sel;
171
   wire                         rank_fifo_wr, rank_fifo_rd;
172
   wire                         rank_fifo_full, rank_fifo_mt;
173 3 dinesha
 
174 4 dinesha
   wire [11:0] bank0_row, bank1_row, bank2_row, bank3_row;
175 3 dinesha
 
176 51 dinesha
   assign  b2x_tras_ok        = &tras_ok;
177 4 dinesha
 
178 51 dinesha
 
179 4 dinesha
   // Distribute the request from req_gen
180
 
181
   assign r2i_req[0] = (r2b_ba == 2'b00) ? r2b_req & ~rank_fifo_full : 1'b0;
182
   assign r2i_req[1] = (r2b_ba == 2'b01) ? r2b_req & ~rank_fifo_full : 1'b0;
183
   assign r2i_req[2] = (r2b_ba == 2'b10) ? r2b_req & ~rank_fifo_full : 1'b0;
184
   assign r2i_req[3] = (r2b_ba == 2'b11) ? r2b_req & ~rank_fifo_full : 1'b0;
185
 
186 51 dinesha
   /******************
187
   Modified the Better FPGA Timing Purpose
188 4 dinesha
   assign b2r_ack = (r2b_ba == 2'b00) ? i2r_ack[0] :
189
                    (r2b_ba == 2'b01) ? i2r_ack[1] :
190
                    (r2b_ba == 2'b10) ? i2r_ack[2] :
191
                    (r2b_ba == 2'b11) ? i2r_ack[3] : 1'b0;
192 51 dinesha
   ********************/
193
   // Assumption: Only one Ack Will be asserted at a time.
194
   assign b2r_ack  =|i2r_ack;
195 4 dinesha
 
196
   assign b2r_arb_ok = ~rank_fifo_full;
197
 
198
   // Put the requests from the 4 bank_fsms into a 4 deep shift
199
   // register file. The earliest request is prioritized over the
200
   // later requests. Also the number of requests we are allowed to
201
   // buffer is limited by a 2 bit external input
202
 
203
   // Mux the req/cmd to xfr_ctl. Allow RD/WR commands from the request in
204
   // rank0, allow only PR/ACT commands from the requests in other ranks
205
   // If the rank_fifo is empty, send the request from the bank addressed by
206
   // r2b_ba 
207
 
208 51 dinesha
   // In FPGA Mode, to improve the timing, also send the rank_ba
209
   assign xfr_ba = (`TARGET_DESIGN == `FPGA) ? rank_ba[1:0]:
210
                   ((rank_fifo_mt) ? r2b_ba : rank_ba[1:0]);
211
   assign xfr_ba_last = (`TARGET_DESIGN == `FPGA) ? rank_ba_last[0]:
212
                        ((rank_fifo_mt) ? sdr_req_norm_dma_last : rank_ba_last[0]);
213 4 dinesha
 
214
   assign rank_req[0] = i2x_req[xfr_ba];     // each rank generates requests
215
 
216
   assign rank_req[1] = (rank_cnt < 3'h2) ? 1'b0 :
217
                        (rank_ba[3:2] == 2'b00) ? i2x_req[0] & ~i2x_cmd0[1] :
218
                        (rank_ba[3:2] == 2'b01) ? i2x_req[1] & ~i2x_cmd1[1] :
219
                        (rank_ba[3:2] == 2'b10) ? i2x_req[2] & ~i2x_cmd2[1] :
220
                        i2x_req[3] & ~i2x_cmd3[1];
221
 
222
   assign rank_req[2] = (rank_cnt < 3'h3) ? 1'b0 :
223
                        (rank_ba[5:4] == 2'b00) ? i2x_req[0] & ~i2x_cmd0[1] :
224
                        (rank_ba[5:4] == 2'b01) ? i2x_req[1] & ~i2x_cmd1[1] :
225
                        (rank_ba[5:4] == 2'b10) ? i2x_req[2] & ~i2x_cmd2[1] :
226
                        i2x_req[3] & ~i2x_cmd3[1];
227
 
228
   assign rank_req[3] = (rank_cnt < 3'h4) ? 1'b0 :
229
                        (rank_ba[7:6] == 2'b00) ? i2x_req[0] & ~i2x_cmd0[1] :
230
                        (rank_ba[7:6] == 2'b01) ? i2x_req[1] & ~i2x_cmd1[1] :
231
                        (rank_ba[7:6] == 2'b10) ? i2x_req[2] & ~i2x_cmd2[1] :
232
                        i2x_req[3] & ~i2x_cmd3[1];
233
 
234
   always @ (rank_req or rank_ba or xfr_ba or xfr_ba_last) begin
235
 
236
      if (rank_req[0]) begin
237
         b2x_req = 1'b1;
238
         b2x_ba = xfr_ba;
239
      end // if (rank_req[0])
240
 
241
      else if (rank_req[1]) begin
242
         b2x_req = 1'b1;
243
         b2x_ba = rank_ba[3:2];
244
      end // if (rank_req[1])
245
 
246
      else if (rank_req[2]) begin
247
         b2x_req = 1'b1;
248
         b2x_ba = rank_ba[5:4];
249
      end // if (rank_req[2])
250
 
251
      else if (rank_req[3]) begin
252
         b2x_req = 1'b1;
253
         b2x_ba = rank_ba[7:6];
254
      end // if (rank_req[3])
255
 
256
      else begin
257
         b2x_req = 1'b0;
258
         b2x_ba = 2'b00;
259
      end // else: !if(rank_req[3])
260
 
261
   end // always @ (rank_req or rank_fifo_mt or r2b_ba or rank_ba)
262
 
263
   assign b2x_idle = rank_fifo_mt;
264
   assign b2x_start = i2x_start[b2x_ba];
265
   assign b2x_last = i2x_last[b2x_ba];
266
   assign b2x_wrap = i2x_wrap[b2x_ba];
267
 
268
   assign b2x_addr = (b2x_ba == 2'b11) ? i2x_addr3 :
269
                     (b2x_ba == 2'b10) ? i2x_addr2 :
270
                     (b2x_ba == 2'b01) ? i2x_addr1 : i2x_addr0;
271
 
272
   assign b2x_len = (b2x_ba == 2'b11) ? i2x_len3 :
273
                    (b2x_ba == 2'b10) ? i2x_len2 :
274
                    (b2x_ba == 2'b01) ? i2x_len1 : i2x_len0;
275
 
276
   assign b2x_cmd = (b2x_ba == 2'b11) ? i2x_cmd3 :
277
                    (b2x_ba == 2'b10) ? i2x_cmd2 :
278
                    (b2x_ba == 2'b01) ? i2x_cmd1 : i2x_cmd0;
279
 
280
   assign b2x_id = (b2x_ba == 2'b11) ? i2x_id3 :
281
                   (b2x_ba == 2'b10) ? i2x_id2 :
282
                   (b2x_ba == 2'b01) ? i2x_id1 : i2x_id0;
283
 
284
   assign x2i_ack[0] = (b2x_ba == 2'b00) ? x2b_ack : 1'b0;
285
   assign x2i_ack[1] = (b2x_ba == 2'b01) ? x2b_ack : 1'b0;
286
   assign x2i_ack[2] = (b2x_ba == 2'b10) ? x2b_ack : 1'b0;
287
   assign x2i_ack[3] = (b2x_ba == 2'b11) ? x2b_ack : 1'b0;
288
 
289
   // Rank Fifo
290
   // On a write write to selected rank and increment rank_cnt
291
   // On a read shift rank_ba right 2 bits and decrement rank_cnt
292
 
293
   assign rank_fifo_wr = b2r_ack;
294
 
295
   assign rank_fifo_rd = b2x_req & b2x_cmd[1] & x2b_ack;
296
 
297
   assign rank_wr_sel[0] = (rank_cnt == 3'h0) ? rank_fifo_wr :
298
                           (rank_cnt == 3'h1) ? rank_fifo_wr & rank_fifo_rd :
299
                           1'b0;
300
 
301
   assign rank_wr_sel[1] = (rank_cnt == 3'h1) ? rank_fifo_wr & ~rank_fifo_rd :
302
                           (rank_cnt == 3'h2) ? rank_fifo_wr & rank_fifo_rd :
303
                           1'b0;
304
 
305
   assign rank_wr_sel[2] = (rank_cnt == 3'h2) ? rank_fifo_wr & ~rank_fifo_rd :
306
                           (rank_cnt == 3'h3) ? rank_fifo_wr & rank_fifo_rd :
307
                           1'b0;
308
 
309
   assign rank_wr_sel[3] = (rank_cnt == 3'h3) ? rank_fifo_wr & ~rank_fifo_rd :
310
                           (rank_cnt == 3'h4) ? rank_fifo_wr & rank_fifo_rd :
311
                           1'b0;
312
 
313
   assign rank_fifo_mt = (rank_cnt == 3'b0) ? 1'b1 : 1'b0;
314
 
315
   assign rank_fifo_full = (rank_cnt[2]) ? 1'b1 :
316
                           (rank_cnt[1:0] == a2b_req_depth) ? 1'b1 : 1'b0;
317
 
318
   // FIFO Check
319
 
320
   // synopsys translate_off
321
 
322
   always @ (posedge clk) begin
323
 
324
      if (~rank_fifo_wr & rank_fifo_rd && rank_cnt == 3'h0) begin
325
         $display ("%t: %m: ERROR!!! Read from empty Fifo", $time);
326
         $stop;
327
      end // if (rank_fifo_rd && rank_cnt == 3'h0)
328
 
329
      if (rank_fifo_wr && ~rank_fifo_rd && rank_cnt == 3'h4) begin
330
         $display ("%t: %m: ERROR!!! Write to full Fifo", $time);
331
         $stop;
332
      end // if (rank_fifo_wr && ~rank_fifo_rd && rank_cnt == 3'h4)
333
 
334
   end // always @ (posedge clk)
335
 
336
   // synopsys translate_on
337
 
338 3 dinesha
   always @ (posedge clk)
339
      if (~reset_n) begin
340 4 dinesha
         rank_cnt <= 3'b0;
341
         rank_ba <= 8'b0;
342
         rank_ba_last <= 4'b0;
343
 
344 3 dinesha
      end // if (~reset_n)
345
      else begin
346
 
347 4 dinesha
         rank_cnt <= (rank_fifo_wr & ~rank_fifo_rd) ? rank_cnt + 3'b1 :
348
                     (~rank_fifo_wr & rank_fifo_rd) ? rank_cnt - 3'b1 :
349
                     rank_cnt;
350 3 dinesha
 
351 4 dinesha
         rank_ba[1:0] <= (rank_wr_sel[0]) ? r2b_ba :
352
                         (rank_fifo_rd) ? rank_ba[3:2] : rank_ba[1:0];
353 3 dinesha
 
354 4 dinesha
         rank_ba[3:2] <= (rank_wr_sel[1]) ? r2b_ba :
355
                         (rank_fifo_rd) ? rank_ba[5:4] : rank_ba[3:2];
356 3 dinesha
 
357 4 dinesha
         rank_ba[5:4] <= (rank_wr_sel[2]) ? r2b_ba :
358
                         (rank_fifo_rd) ? rank_ba[7:6] : rank_ba[5:4];
359
 
360
         rank_ba[7:6] <= (rank_wr_sel[3]) ? r2b_ba :
361
                         (rank_fifo_rd) ? 2'b00 : rank_ba[7:6];
362 3 dinesha
 
363 51 dinesha
         if(`TARGET_DESIGN == `ASIC) begin // This Logic is implemented for ASIC Only
364
            // Note: Currenly top-level does not generate the
365
            // sdr_req_norm_dma_last signal and can be tied zero at top-level
366
            rank_ba_last[0] <= (rank_wr_sel[0]) ? sdr_req_norm_dma_last :
367 4 dinesha
                            (rank_fifo_rd) ?  rank_ba_last[1] : rank_ba_last[0];
368 3 dinesha
 
369 51 dinesha
            rank_ba_last[1] <= (rank_wr_sel[1]) ? sdr_req_norm_dma_last :
370
                               (rank_fifo_rd) ?  rank_ba_last[2] : rank_ba_last[1];
371 3 dinesha
 
372 51 dinesha
            rank_ba_last[2] <= (rank_wr_sel[2]) ? sdr_req_norm_dma_last :
373
                               (rank_fifo_rd) ?  rank_ba_last[3] : rank_ba_last[2];
374 3 dinesha
 
375 51 dinesha
            rank_ba_last[3] <= (rank_wr_sel[3]) ? sdr_req_norm_dma_last :
376
                               (rank_fifo_rd) ?  1'b0 : rank_ba_last[3];
377
         end
378 3 dinesha
 
379 4 dinesha
      end // else: !if(~reset_n)
380 3 dinesha
 
381 4 dinesha
   assign xfr_ok[0] = (xfr_ba == 2'b00) ? 1'b1 : 1'b0;
382
   assign xfr_ok[1] = (xfr_ba == 2'b01) ? 1'b1 : 1'b0;
383
   assign xfr_ok[2] = (xfr_ba == 2'b10) ? 1'b1 : 1'b0;
384
   assign xfr_ok[3] = (xfr_ba == 2'b11) ? 1'b1 : 1'b0;
385
 
386
   /****************************************************************************/
387
   // Instantiate Bank Ctl FSM 0
388 3 dinesha
 
389 4 dinesha
   sdrc_bank_fsm bank0_fsm (.clk (clk),
390
                           .reset_n (reset_n),
391 3 dinesha
 
392 4 dinesha
                           /* Req from req_gen */
393
                           .r2b_req (r2i_req[0]),
394
                           .r2b_req_id (r2b_req_id),
395
                           .r2b_start (r2b_start),
396
                           .r2b_last (r2b_last),
397
                           .r2b_wrap (r2b_wrap),
398
                           .r2b_raddr (r2b_raddr),
399
                           .r2b_caddr (r2b_caddr),
400
                           .r2b_len (r2b_len),
401
                           .r2b_write (r2b_write),
402
                           .b2r_ack (i2r_ack[0]),
403
                           .sdr_dma_last(rank_ba_last[0]),
404 3 dinesha
 
405 4 dinesha
                           /* Transfer request to xfr_ctl */
406
                           .b2x_req (i2x_req[0]),
407
                           .b2x_start (i2x_start[0]),
408
                           .b2x_last (i2x_last[0]),
409
                           .b2x_wrap (i2x_wrap[0]),
410
                           .b2x_id (i2x_id0),
411
                           .b2x_addr (i2x_addr0),
412
                           .b2x_len (i2x_len0),
413
                           .b2x_cmd (i2x_cmd0),
414
                           .x2b_ack (x2i_ack[0]),
415
 
416
                           /* Status to/from xfr_ctl */
417
                           .tras_ok (tras_ok[0]),
418
                           .xfr_ok (xfr_ok[0]),
419
                           .x2b_refresh (x2b_refresh),
420
                           .x2b_pre_ok (x2b_pre_ok[0]),
421
                           .x2b_act_ok (x2b_act_ok),
422
                           .x2b_rdok (x2b_rdok),
423
                           .x2b_wrok (x2b_wrok),
424 3 dinesha
 
425 4 dinesha
                           .bank_row(bank0_row),
426 3 dinesha
 
427 4 dinesha
                           /* SDRAM Timing */
428
                           .tras_delay (tras_delay),
429
                           .trp_delay (trp_delay),
430
                           .trcd_delay (trcd_delay));
431 3 dinesha
 
432 4 dinesha
   /****************************************************************************/
433
   // Instantiate Bank Ctl FSM 1
434 3 dinesha
 
435 4 dinesha
   sdrc_bank_fsm bank1_fsm (.clk (clk),
436
                           .reset_n (reset_n),
437 3 dinesha
 
438 4 dinesha
                           /* Req from req_gen */
439
                           .r2b_req (r2i_req[1]),
440
                           .r2b_req_id (r2b_req_id),
441
                           .r2b_start (r2b_start),
442
                           .r2b_last (r2b_last),
443
                           .r2b_wrap (r2b_wrap),
444
                           .r2b_raddr (r2b_raddr),
445
                           .r2b_caddr (r2b_caddr),
446
                           .r2b_len (r2b_len),
447
                           .r2b_write (r2b_write),
448
                           .b2r_ack (i2r_ack[1]),
449
                           .sdr_dma_last(rank_ba_last[1]),
450 3 dinesha
 
451 4 dinesha
                           /* Transfer request to xfr_ctl */
452
                           .b2x_req (i2x_req[1]),
453
                           .b2x_start (i2x_start[1]),
454
                           .b2x_last (i2x_last[1]),
455
                           .b2x_wrap (i2x_wrap[1]),
456
                           .b2x_id (i2x_id1),
457
                           .b2x_addr (i2x_addr1),
458
                           .b2x_len (i2x_len1),
459
                           .b2x_cmd (i2x_cmd1),
460
                           .x2b_ack (x2i_ack[1]),
461
 
462
                           /* Status to/from xfr_ctl */
463
                           .tras_ok (tras_ok[1]),
464
                           .xfr_ok (xfr_ok[1]),
465
                           .x2b_refresh (x2b_refresh),
466
                           .x2b_pre_ok (x2b_pre_ok[1]),
467
                           .x2b_act_ok (x2b_act_ok),
468
                           .x2b_rdok (x2b_rdok),
469
                           .x2b_wrok (x2b_wrok),
470 3 dinesha
 
471 4 dinesha
                           .bank_row(bank1_row),
472 3 dinesha
 
473 4 dinesha
                           /* SDRAM Timing */
474
                           .tras_delay (tras_delay),
475
                           .trp_delay (trp_delay),
476
                           .trcd_delay (trcd_delay));
477
 
478
   /****************************************************************************/
479
   // Instantiate Bank Ctl FSM 2
480 3 dinesha
 
481 4 dinesha
   sdrc_bank_fsm bank2_fsm (.clk (clk),
482
                           .reset_n (reset_n),
483 3 dinesha
 
484 4 dinesha
                           /* Req from req_gen */
485
                           .r2b_req (r2i_req[2]),
486
                           .r2b_req_id (r2b_req_id),
487
                           .r2b_start (r2b_start),
488
                           .r2b_last (r2b_last),
489
                           .r2b_wrap (r2b_wrap),
490
                           .r2b_raddr (r2b_raddr),
491
                           .r2b_caddr (r2b_caddr),
492
                           .r2b_len (r2b_len),
493
                           .r2b_write (r2b_write),
494
                           .b2r_ack (i2r_ack[2]),
495
                           .sdr_dma_last(rank_ba_last[2]),
496 3 dinesha
 
497 4 dinesha
                           /* Transfer request to xfr_ctl */
498
                           .b2x_req (i2x_req[2]),
499
                           .b2x_start (i2x_start[2]),
500
                           .b2x_last (i2x_last[2]),
501
                           .b2x_wrap (i2x_wrap[2]),
502
                           .b2x_id (i2x_id2),
503
                           .b2x_addr (i2x_addr2),
504
                           .b2x_len (i2x_len2),
505
                           .b2x_cmd (i2x_cmd2),
506
                           .x2b_ack (x2i_ack[2]),
507
 
508
                           /* Status to/from xfr_ctl */
509
                           .tras_ok (tras_ok[2]),
510
                           .xfr_ok (xfr_ok[2]),
511
                           .x2b_refresh (x2b_refresh),
512
                           .x2b_pre_ok (x2b_pre_ok[2]),
513
                           .x2b_act_ok (x2b_act_ok),
514
                           .x2b_rdok (x2b_rdok),
515
                           .x2b_wrok (x2b_wrok),
516 3 dinesha
 
517 4 dinesha
                           .bank_row(bank2_row),
518 3 dinesha
 
519 4 dinesha
                           /* SDRAM Timing */
520
                           .tras_delay (tras_delay),
521
                           .trp_delay (trp_delay),
522
                           .trcd_delay (trcd_delay));
523
 
524
   /****************************************************************************/
525
   // Instantiate Bank Ctl FSM 3
526 3 dinesha
 
527 4 dinesha
   sdrc_bank_fsm bank3_fsm (.clk (clk),
528
                           .reset_n (reset_n),
529 3 dinesha
 
530 4 dinesha
                           /* Req from req_gen */
531
                           .r2b_req (r2i_req[3]),
532
                           .r2b_req_id (r2b_req_id),
533
                           .r2b_start (r2b_start),
534
                           .r2b_last (r2b_last),
535
                           .r2b_wrap (r2b_wrap),
536
                           .r2b_raddr (r2b_raddr),
537
                           .r2b_caddr (r2b_caddr),
538
                           .r2b_len (r2b_len),
539
                           .r2b_write (r2b_write),
540
                           .b2r_ack (i2r_ack[3]),
541
                           .sdr_dma_last(rank_ba_last[3]),
542 3 dinesha
 
543 4 dinesha
                           /* Transfer request to xfr_ctl */
544
                           .b2x_req (i2x_req[3]),
545
                           .b2x_start (i2x_start[3]),
546
                           .b2x_last (i2x_last[3]),
547
                           .b2x_wrap (i2x_wrap[3]),
548
                           .b2x_id (i2x_id3),
549
                           .b2x_addr (i2x_addr3),
550
                           .b2x_len (i2x_len3),
551
                           .b2x_cmd (i2x_cmd3),
552
                           .x2b_ack (x2i_ack[3]),
553
 
554
                           /* Status to/from xfr_ctl */
555
                           .tras_ok (tras_ok[3]),
556
                           .xfr_ok (xfr_ok[3]),
557
                           .x2b_refresh (x2b_refresh),
558
                           .x2b_pre_ok (x2b_pre_ok[3]),
559
                           .x2b_act_ok (x2b_act_ok),
560
                           .x2b_rdok (x2b_rdok),
561
                           .x2b_wrok (x2b_wrok),
562 3 dinesha
 
563 4 dinesha
                           .bank_row(bank3_row),
564
 
565
                           /* SDRAM Timing */
566
                           .tras_delay (tras_delay),
567
                           .trp_delay (trp_delay),
568
                           .trcd_delay (trcd_delay));
569 3 dinesha
 
570 4 dinesha
 
571
/* address for current xfr, debug only */
572
wire [11:0] cur_row = (xfr_bank_sel==3) ? bank3_row:
573
                        (xfr_bank_sel==2) ? bank2_row:
574
                        (xfr_bank_sel==1) ? bank1_row: bank0_row;
575
 
576
 
577
 
578
endmodule // sdr_bank_ctl

powered by: WebSVN 2.1.0

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