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 54

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
   input                        clk, reset_n;
104
 
105 4 dinesha
   input [1:0]                   a2b_req_depth;
106
 
107 3 dinesha
   /* Req from bank_ctl */
108
   input                        r2b_req, r2b_start, r2b_last,
109
                                r2b_write, r2b_wrap;
110
   input [`SDR_REQ_ID_W-1:0]     r2b_req_id;
111 4 dinesha
   input [1:0]                   r2b_ba;
112 3 dinesha
   input [11:0]          r2b_raddr;
113
   input [11:0]          r2b_caddr;
114 54 dinesha
   input [`REQ_BW-1:0]           r2b_len;
115 4 dinesha
   output                       b2r_arb_ok, b2r_ack;
116
   input                        sdr_req_norm_dma_last;
117 3 dinesha
 
118
   /* Req to xfr_ctl */
119 4 dinesha
   output                       b2x_idle, b2x_req, b2x_start, b2x_last,
120
                                b2x_tras_ok, b2x_wrap;
121 3 dinesha
   output [`SDR_REQ_ID_W-1:0]    b2x_id;
122 4 dinesha
   output [1:0]          b2x_ba;
123 3 dinesha
   output [11:0]                 b2x_addr;
124 54 dinesha
   output [`REQ_BW-1:0]  b2x_len;
125 3 dinesha
   output [1:0]          b2x_cmd;
126
   input                        x2b_ack;
127
 
128
   /* Status from xfr_ctl */
129 4 dinesha
   input [3:0]                   x2b_pre_ok;
130 3 dinesha
   input                        x2b_refresh, x2b_act_ok, x2b_rdok,
131 4 dinesha
                                x2b_wrok;
132 3 dinesha
 
133
   input [3:0]                   tras_delay, trp_delay, trcd_delay;
134
 
135 4 dinesha
   input [1:0] xfr_bank_sel;
136 3 dinesha
 
137
   /****************************************************************************/
138
   // Internal Nets
139
 
140 4 dinesha
   wire [3:0]                    r2i_req, i2r_ack, i2x_req,
141
                                i2x_start, i2x_last, i2x_wrap, tras_ok;
142
   wire [11:0]                   i2x_addr0, i2x_addr1, i2x_addr2, i2x_addr3;
143 54 dinesha
   wire [`REQ_BW-1:0]    i2x_len0, i2x_len1, i2x_len2, i2x_len3;
144 4 dinesha
   wire [1:0]                    i2x_cmd0, i2x_cmd1, i2x_cmd2, i2x_cmd3;
145
   wire [`SDR_REQ_ID_W-1:0]      i2x_id0, i2x_id1, i2x_id2, i2x_id3;
146 3 dinesha
 
147 4 dinesha
   reg                          b2x_req;
148
   wire                         b2x_idle, b2x_start, b2x_last, b2x_wrap;
149 3 dinesha
   wire [`SDR_REQ_ID_W-1:0]      b2x_id;
150 4 dinesha
   wire [11:0]                   b2x_addr;
151 54 dinesha
   wire [`REQ_BW-1:0]    b2x_len;
152 4 dinesha
   wire [1:0]                    b2x_cmd;
153
   wire [3:0]                    x2i_ack;
154
   reg [1:0]                     b2x_ba;
155 3 dinesha
 
156 4 dinesha
   reg [`SDR_REQ_ID_W-1:0]       curr_id;
157
 
158
   wire [1:0]                    xfr_ba;
159
   wire                         xfr_ba_last;
160
   wire [3:0]                    xfr_ok;
161
 
162
   // This 8 bit register stores the bank addresses for upto 4 requests.
163
   reg [7:0]                     rank_ba;
164
   reg [3:0]                     rank_ba_last;
165
   // This 3 bit counter counts the number of requests we have
166
   // buffered so far, legal values are 0, 1, 2, 3, or 4.
167
   reg [2:0]                     rank_cnt;
168
   wire [3:0]                    rank_req, rank_wr_sel;
169
   wire                         rank_fifo_wr, rank_fifo_rd;
170
   wire                         rank_fifo_full, rank_fifo_mt;
171 3 dinesha
 
172 4 dinesha
   wire [11:0] bank0_row, bank1_row, bank2_row, bank3_row;
173 3 dinesha
 
174 51 dinesha
   assign  b2x_tras_ok        = &tras_ok;
175 4 dinesha
 
176 51 dinesha
 
177 4 dinesha
   // Distribute the request from req_gen
178
 
179
   assign r2i_req[0] = (r2b_ba == 2'b00) ? r2b_req & ~rank_fifo_full : 1'b0;
180
   assign r2i_req[1] = (r2b_ba == 2'b01) ? r2b_req & ~rank_fifo_full : 1'b0;
181
   assign r2i_req[2] = (r2b_ba == 2'b10) ? r2b_req & ~rank_fifo_full : 1'b0;
182
   assign r2i_req[3] = (r2b_ba == 2'b11) ? r2b_req & ~rank_fifo_full : 1'b0;
183
 
184 51 dinesha
   /******************
185
   Modified the Better FPGA Timing Purpose
186 4 dinesha
   assign b2r_ack = (r2b_ba == 2'b00) ? i2r_ack[0] :
187
                    (r2b_ba == 2'b01) ? i2r_ack[1] :
188
                    (r2b_ba == 2'b10) ? i2r_ack[2] :
189
                    (r2b_ba == 2'b11) ? i2r_ack[3] : 1'b0;
190 51 dinesha
   ********************/
191
   // Assumption: Only one Ack Will be asserted at a time.
192
   assign b2r_ack  =|i2r_ack;
193 4 dinesha
 
194
   assign b2r_arb_ok = ~rank_fifo_full;
195
 
196
   // Put the requests from the 4 bank_fsms into a 4 deep shift
197
   // register file. The earliest request is prioritized over the
198
   // later requests. Also the number of requests we are allowed to
199
   // buffer is limited by a 2 bit external input
200
 
201
   // Mux the req/cmd to xfr_ctl. Allow RD/WR commands from the request in
202
   // rank0, allow only PR/ACT commands from the requests in other ranks
203
   // If the rank_fifo is empty, send the request from the bank addressed by
204
   // r2b_ba 
205
 
206 51 dinesha
   // In FPGA Mode, to improve the timing, also send the rank_ba
207
   assign xfr_ba = (`TARGET_DESIGN == `FPGA) ? rank_ba[1:0]:
208
                   ((rank_fifo_mt) ? r2b_ba : rank_ba[1:0]);
209
   assign xfr_ba_last = (`TARGET_DESIGN == `FPGA) ? rank_ba_last[0]:
210
                        ((rank_fifo_mt) ? sdr_req_norm_dma_last : rank_ba_last[0]);
211 4 dinesha
 
212
   assign rank_req[0] = i2x_req[xfr_ba];     // each rank generates requests
213
 
214
   assign rank_req[1] = (rank_cnt < 3'h2) ? 1'b0 :
215
                        (rank_ba[3:2] == 2'b00) ? i2x_req[0] & ~i2x_cmd0[1] :
216
                        (rank_ba[3:2] == 2'b01) ? i2x_req[1] & ~i2x_cmd1[1] :
217
                        (rank_ba[3:2] == 2'b10) ? i2x_req[2] & ~i2x_cmd2[1] :
218
                        i2x_req[3] & ~i2x_cmd3[1];
219
 
220
   assign rank_req[2] = (rank_cnt < 3'h3) ? 1'b0 :
221
                        (rank_ba[5:4] == 2'b00) ? i2x_req[0] & ~i2x_cmd0[1] :
222
                        (rank_ba[5:4] == 2'b01) ? i2x_req[1] & ~i2x_cmd1[1] :
223
                        (rank_ba[5:4] == 2'b10) ? i2x_req[2] & ~i2x_cmd2[1] :
224
                        i2x_req[3] & ~i2x_cmd3[1];
225
 
226
   assign rank_req[3] = (rank_cnt < 3'h4) ? 1'b0 :
227
                        (rank_ba[7:6] == 2'b00) ? i2x_req[0] & ~i2x_cmd0[1] :
228
                        (rank_ba[7:6] == 2'b01) ? i2x_req[1] & ~i2x_cmd1[1] :
229
                        (rank_ba[7:6] == 2'b10) ? i2x_req[2] & ~i2x_cmd2[1] :
230
                        i2x_req[3] & ~i2x_cmd3[1];
231
 
232 54 dinesha
   always @ (*) begin
233
      b2x_req = 1'b0;
234
      b2x_ba =   xfr_ba;
235 4 dinesha
 
236 54 dinesha
      if(`TARGET_DESIGN == `ASIC) begin // Support Multiple Rank request only on ASIC
237
         if (rank_req[0]) begin
238
            b2x_req = 1'b1;
239
            b2x_ba = xfr_ba;
240
         end // if (rank_req[0])
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
        else if (rank_req[2]) begin
246
          b2x_req = 1'b1;
247
          b2x_ba = rank_ba[5:4];
248
        end // if (rank_req[2])
249
        else if (rank_req[3]) begin
250
          b2x_req = 1'b1;
251
          b2x_ba = rank_ba[7:6];
252
        end // if (rank_req[3])
253
      end else begin // If FPGA
254
         if (rank_req[0]) begin
255
            b2x_req = 1'b1;
256
         end
257
      end
258
  end // always @ (rank_req or rank_fifo_mt or r2b_ba or rank_ba)
259 4 dinesha
 
260
   assign b2x_idle = rank_fifo_mt;
261
   assign b2x_start = i2x_start[b2x_ba];
262
   assign b2x_last = i2x_last[b2x_ba];
263
   assign b2x_wrap = i2x_wrap[b2x_ba];
264
 
265
   assign b2x_addr = (b2x_ba == 2'b11) ? i2x_addr3 :
266
                     (b2x_ba == 2'b10) ? i2x_addr2 :
267
                     (b2x_ba == 2'b01) ? i2x_addr1 : i2x_addr0;
268
 
269
   assign b2x_len = (b2x_ba == 2'b11) ? i2x_len3 :
270
                    (b2x_ba == 2'b10) ? i2x_len2 :
271
                    (b2x_ba == 2'b01) ? i2x_len1 : i2x_len0;
272
 
273
   assign b2x_cmd = (b2x_ba == 2'b11) ? i2x_cmd3 :
274
                    (b2x_ba == 2'b10) ? i2x_cmd2 :
275
                    (b2x_ba == 2'b01) ? i2x_cmd1 : i2x_cmd0;
276
 
277
   assign b2x_id = (b2x_ba == 2'b11) ? i2x_id3 :
278
                   (b2x_ba == 2'b10) ? i2x_id2 :
279
                   (b2x_ba == 2'b01) ? i2x_id1 : i2x_id0;
280
 
281
   assign x2i_ack[0] = (b2x_ba == 2'b00) ? x2b_ack : 1'b0;
282
   assign x2i_ack[1] = (b2x_ba == 2'b01) ? x2b_ack : 1'b0;
283
   assign x2i_ack[2] = (b2x_ba == 2'b10) ? x2b_ack : 1'b0;
284
   assign x2i_ack[3] = (b2x_ba == 2'b11) ? x2b_ack : 1'b0;
285
 
286
   // Rank Fifo
287
   // On a write write to selected rank and increment rank_cnt
288
   // On a read shift rank_ba right 2 bits and decrement rank_cnt
289
 
290
   assign rank_fifo_wr = b2r_ack;
291
 
292
   assign rank_fifo_rd = b2x_req & b2x_cmd[1] & x2b_ack;
293
 
294
   assign rank_wr_sel[0] = (rank_cnt == 3'h0) ? rank_fifo_wr :
295
                           (rank_cnt == 3'h1) ? rank_fifo_wr & rank_fifo_rd :
296
                           1'b0;
297
 
298
   assign rank_wr_sel[1] = (rank_cnt == 3'h1) ? rank_fifo_wr & ~rank_fifo_rd :
299
                           (rank_cnt == 3'h2) ? rank_fifo_wr & rank_fifo_rd :
300
                           1'b0;
301
 
302
   assign rank_wr_sel[2] = (rank_cnt == 3'h2) ? rank_fifo_wr & ~rank_fifo_rd :
303
                           (rank_cnt == 3'h3) ? rank_fifo_wr & rank_fifo_rd :
304
                           1'b0;
305
 
306
   assign rank_wr_sel[3] = (rank_cnt == 3'h3) ? rank_fifo_wr & ~rank_fifo_rd :
307
                           (rank_cnt == 3'h4) ? rank_fifo_wr & rank_fifo_rd :
308
                           1'b0;
309
 
310
   assign rank_fifo_mt = (rank_cnt == 3'b0) ? 1'b1 : 1'b0;
311
 
312
   assign rank_fifo_full = (rank_cnt[2]) ? 1'b1 :
313
                           (rank_cnt[1:0] == a2b_req_depth) ? 1'b1 : 1'b0;
314
 
315
   // FIFO Check
316
 
317
   // synopsys translate_off
318
 
319
   always @ (posedge clk) begin
320
 
321
      if (~rank_fifo_wr & rank_fifo_rd && rank_cnt == 3'h0) begin
322
         $display ("%t: %m: ERROR!!! Read from empty Fifo", $time);
323
         $stop;
324
      end // if (rank_fifo_rd && rank_cnt == 3'h0)
325
 
326
      if (rank_fifo_wr && ~rank_fifo_rd && rank_cnt == 3'h4) begin
327
         $display ("%t: %m: ERROR!!! Write to full Fifo", $time);
328
         $stop;
329
      end // if (rank_fifo_wr && ~rank_fifo_rd && rank_cnt == 3'h4)
330
 
331
   end // always @ (posedge clk)
332
 
333
   // synopsys translate_on
334
 
335 3 dinesha
   always @ (posedge clk)
336
      if (~reset_n) begin
337 4 dinesha
         rank_cnt <= 3'b0;
338
         rank_ba <= 8'b0;
339
         rank_ba_last <= 4'b0;
340
 
341 3 dinesha
      end // if (~reset_n)
342
      else begin
343
 
344 4 dinesha
         rank_cnt <= (rank_fifo_wr & ~rank_fifo_rd) ? rank_cnt + 3'b1 :
345
                     (~rank_fifo_wr & rank_fifo_rd) ? rank_cnt - 3'b1 :
346
                     rank_cnt;
347 3 dinesha
 
348 4 dinesha
         rank_ba[1:0] <= (rank_wr_sel[0]) ? r2b_ba :
349
                         (rank_fifo_rd) ? rank_ba[3:2] : rank_ba[1:0];
350 3 dinesha
 
351 4 dinesha
         rank_ba[3:2] <= (rank_wr_sel[1]) ? r2b_ba :
352
                         (rank_fifo_rd) ? rank_ba[5:4] : rank_ba[3:2];
353 3 dinesha
 
354 4 dinesha
         rank_ba[5:4] <= (rank_wr_sel[2]) ? r2b_ba :
355
                         (rank_fifo_rd) ? rank_ba[7:6] : rank_ba[5:4];
356
 
357
         rank_ba[7:6] <= (rank_wr_sel[3]) ? r2b_ba :
358
                         (rank_fifo_rd) ? 2'b00 : rank_ba[7:6];
359 3 dinesha
 
360 51 dinesha
         if(`TARGET_DESIGN == `ASIC) begin // This Logic is implemented for ASIC Only
361
            // Note: Currenly top-level does not generate the
362
            // sdr_req_norm_dma_last signal and can be tied zero at top-level
363
            rank_ba_last[0] <= (rank_wr_sel[0]) ? sdr_req_norm_dma_last :
364 4 dinesha
                            (rank_fifo_rd) ?  rank_ba_last[1] : rank_ba_last[0];
365 3 dinesha
 
366 51 dinesha
            rank_ba_last[1] <= (rank_wr_sel[1]) ? sdr_req_norm_dma_last :
367
                               (rank_fifo_rd) ?  rank_ba_last[2] : rank_ba_last[1];
368 3 dinesha
 
369 51 dinesha
            rank_ba_last[2] <= (rank_wr_sel[2]) ? sdr_req_norm_dma_last :
370
                               (rank_fifo_rd) ?  rank_ba_last[3] : rank_ba_last[2];
371 3 dinesha
 
372 51 dinesha
            rank_ba_last[3] <= (rank_wr_sel[3]) ? sdr_req_norm_dma_last :
373
                               (rank_fifo_rd) ?  1'b0 : rank_ba_last[3];
374
         end
375 3 dinesha
 
376 4 dinesha
      end // else: !if(~reset_n)
377 3 dinesha
 
378 4 dinesha
   assign xfr_ok[0] = (xfr_ba == 2'b00) ? 1'b1 : 1'b0;
379
   assign xfr_ok[1] = (xfr_ba == 2'b01) ? 1'b1 : 1'b0;
380
   assign xfr_ok[2] = (xfr_ba == 2'b10) ? 1'b1 : 1'b0;
381
   assign xfr_ok[3] = (xfr_ba == 2'b11) ? 1'b1 : 1'b0;
382
 
383
   /****************************************************************************/
384
   // Instantiate Bank Ctl FSM 0
385 3 dinesha
 
386 4 dinesha
   sdrc_bank_fsm bank0_fsm (.clk (clk),
387
                           .reset_n (reset_n),
388 3 dinesha
 
389 4 dinesha
                           /* Req from req_gen */
390
                           .r2b_req (r2i_req[0]),
391
                           .r2b_req_id (r2b_req_id),
392
                           .r2b_start (r2b_start),
393
                           .r2b_last (r2b_last),
394
                           .r2b_wrap (r2b_wrap),
395
                           .r2b_raddr (r2b_raddr),
396
                           .r2b_caddr (r2b_caddr),
397
                           .r2b_len (r2b_len),
398
                           .r2b_write (r2b_write),
399
                           .b2r_ack (i2r_ack[0]),
400
                           .sdr_dma_last(rank_ba_last[0]),
401 3 dinesha
 
402 4 dinesha
                           /* Transfer request to xfr_ctl */
403
                           .b2x_req (i2x_req[0]),
404
                           .b2x_start (i2x_start[0]),
405
                           .b2x_last (i2x_last[0]),
406
                           .b2x_wrap (i2x_wrap[0]),
407
                           .b2x_id (i2x_id0),
408
                           .b2x_addr (i2x_addr0),
409
                           .b2x_len (i2x_len0),
410
                           .b2x_cmd (i2x_cmd0),
411
                           .x2b_ack (x2i_ack[0]),
412
 
413
                           /* Status to/from xfr_ctl */
414
                           .tras_ok (tras_ok[0]),
415
                           .xfr_ok (xfr_ok[0]),
416
                           .x2b_refresh (x2b_refresh),
417
                           .x2b_pre_ok (x2b_pre_ok[0]),
418
                           .x2b_act_ok (x2b_act_ok),
419
                           .x2b_rdok (x2b_rdok),
420
                           .x2b_wrok (x2b_wrok),
421 3 dinesha
 
422 4 dinesha
                           .bank_row(bank0_row),
423 3 dinesha
 
424 4 dinesha
                           /* SDRAM Timing */
425
                           .tras_delay (tras_delay),
426
                           .trp_delay (trp_delay),
427
                           .trcd_delay (trcd_delay));
428 3 dinesha
 
429 4 dinesha
   /****************************************************************************/
430
   // Instantiate Bank Ctl FSM 1
431 3 dinesha
 
432 4 dinesha
   sdrc_bank_fsm bank1_fsm (.clk (clk),
433
                           .reset_n (reset_n),
434 3 dinesha
 
435 4 dinesha
                           /* Req from req_gen */
436
                           .r2b_req (r2i_req[1]),
437
                           .r2b_req_id (r2b_req_id),
438
                           .r2b_start (r2b_start),
439
                           .r2b_last (r2b_last),
440
                           .r2b_wrap (r2b_wrap),
441
                           .r2b_raddr (r2b_raddr),
442
                           .r2b_caddr (r2b_caddr),
443
                           .r2b_len (r2b_len),
444
                           .r2b_write (r2b_write),
445
                           .b2r_ack (i2r_ack[1]),
446
                           .sdr_dma_last(rank_ba_last[1]),
447 3 dinesha
 
448 4 dinesha
                           /* Transfer request to xfr_ctl */
449
                           .b2x_req (i2x_req[1]),
450
                           .b2x_start (i2x_start[1]),
451
                           .b2x_last (i2x_last[1]),
452
                           .b2x_wrap (i2x_wrap[1]),
453
                           .b2x_id (i2x_id1),
454
                           .b2x_addr (i2x_addr1),
455
                           .b2x_len (i2x_len1),
456
                           .b2x_cmd (i2x_cmd1),
457
                           .x2b_ack (x2i_ack[1]),
458
 
459
                           /* Status to/from xfr_ctl */
460
                           .tras_ok (tras_ok[1]),
461
                           .xfr_ok (xfr_ok[1]),
462
                           .x2b_refresh (x2b_refresh),
463
                           .x2b_pre_ok (x2b_pre_ok[1]),
464
                           .x2b_act_ok (x2b_act_ok),
465
                           .x2b_rdok (x2b_rdok),
466
                           .x2b_wrok (x2b_wrok),
467 3 dinesha
 
468 4 dinesha
                           .bank_row(bank1_row),
469 3 dinesha
 
470 4 dinesha
                           /* SDRAM Timing */
471
                           .tras_delay (tras_delay),
472
                           .trp_delay (trp_delay),
473
                           .trcd_delay (trcd_delay));
474
 
475
   /****************************************************************************/
476
   // Instantiate Bank Ctl FSM 2
477 3 dinesha
 
478 4 dinesha
   sdrc_bank_fsm bank2_fsm (.clk (clk),
479
                           .reset_n (reset_n),
480 3 dinesha
 
481 4 dinesha
                           /* Req from req_gen */
482
                           .r2b_req (r2i_req[2]),
483
                           .r2b_req_id (r2b_req_id),
484
                           .r2b_start (r2b_start),
485
                           .r2b_last (r2b_last),
486
                           .r2b_wrap (r2b_wrap),
487
                           .r2b_raddr (r2b_raddr),
488
                           .r2b_caddr (r2b_caddr),
489
                           .r2b_len (r2b_len),
490
                           .r2b_write (r2b_write),
491
                           .b2r_ack (i2r_ack[2]),
492
                           .sdr_dma_last(rank_ba_last[2]),
493 3 dinesha
 
494 4 dinesha
                           /* Transfer request to xfr_ctl */
495
                           .b2x_req (i2x_req[2]),
496
                           .b2x_start (i2x_start[2]),
497
                           .b2x_last (i2x_last[2]),
498
                           .b2x_wrap (i2x_wrap[2]),
499
                           .b2x_id (i2x_id2),
500
                           .b2x_addr (i2x_addr2),
501
                           .b2x_len (i2x_len2),
502
                           .b2x_cmd (i2x_cmd2),
503
                           .x2b_ack (x2i_ack[2]),
504
 
505
                           /* Status to/from xfr_ctl */
506
                           .tras_ok (tras_ok[2]),
507
                           .xfr_ok (xfr_ok[2]),
508
                           .x2b_refresh (x2b_refresh),
509
                           .x2b_pre_ok (x2b_pre_ok[2]),
510
                           .x2b_act_ok (x2b_act_ok),
511
                           .x2b_rdok (x2b_rdok),
512
                           .x2b_wrok (x2b_wrok),
513 3 dinesha
 
514 4 dinesha
                           .bank_row(bank2_row),
515 3 dinesha
 
516 4 dinesha
                           /* SDRAM Timing */
517
                           .tras_delay (tras_delay),
518
                           .trp_delay (trp_delay),
519
                           .trcd_delay (trcd_delay));
520
 
521
   /****************************************************************************/
522
   // Instantiate Bank Ctl FSM 3
523 3 dinesha
 
524 4 dinesha
   sdrc_bank_fsm bank3_fsm (.clk (clk),
525
                           .reset_n (reset_n),
526 3 dinesha
 
527 4 dinesha
                           /* Req from req_gen */
528
                           .r2b_req (r2i_req[3]),
529
                           .r2b_req_id (r2b_req_id),
530
                           .r2b_start (r2b_start),
531
                           .r2b_last (r2b_last),
532
                           .r2b_wrap (r2b_wrap),
533
                           .r2b_raddr (r2b_raddr),
534
                           .r2b_caddr (r2b_caddr),
535
                           .r2b_len (r2b_len),
536
                           .r2b_write (r2b_write),
537
                           .b2r_ack (i2r_ack[3]),
538
                           .sdr_dma_last(rank_ba_last[3]),
539 3 dinesha
 
540 4 dinesha
                           /* Transfer request to xfr_ctl */
541
                           .b2x_req (i2x_req[3]),
542
                           .b2x_start (i2x_start[3]),
543
                           .b2x_last (i2x_last[3]),
544
                           .b2x_wrap (i2x_wrap[3]),
545
                           .b2x_id (i2x_id3),
546
                           .b2x_addr (i2x_addr3),
547
                           .b2x_len (i2x_len3),
548
                           .b2x_cmd (i2x_cmd3),
549
                           .x2b_ack (x2i_ack[3]),
550
 
551
                           /* Status to/from xfr_ctl */
552
                           .tras_ok (tras_ok[3]),
553
                           .xfr_ok (xfr_ok[3]),
554
                           .x2b_refresh (x2b_refresh),
555
                           .x2b_pre_ok (x2b_pre_ok[3]),
556
                           .x2b_act_ok (x2b_act_ok),
557
                           .x2b_rdok (x2b_rdok),
558
                           .x2b_wrok (x2b_wrok),
559 3 dinesha
 
560 4 dinesha
                           .bank_row(bank3_row),
561
 
562
                           /* SDRAM Timing */
563
                           .tras_delay (tras_delay),
564
                           .trp_delay (trp_delay),
565
                           .trcd_delay (trcd_delay));
566 3 dinesha
 
567 4 dinesha
 
568
/* address for current xfr, debug only */
569
wire [11:0] cur_row = (xfr_bank_sel==3) ? bank3_row:
570
                        (xfr_bank_sel==2) ? bank2_row:
571
                        (xfr_bank_sel==1) ? bank1_row: bank0_row;
572
 
573
 
574
 
575
endmodule // sdr_bank_ctl

powered by: WebSVN 2.1.0

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