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

Subversion Repositories wdsp

[/] [wdsp/] [trunk/] [rtl/] [verilog/] [minsoc/] [mc/] [mc_top.v] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 parrado
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  WISHBONE Memory Controller Top Level                       ////
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-2002 Rudolf Usselmann                    ////
15
////                         www.asics.ws                        ////
16
////                         rudi@asics.ws                       ////
17
////                                                             ////
18
//// This source file may be used and distributed without        ////
19
//// restriction provided that this copyright statement is not   ////
20
//// removed from the file and that any derivative work contains ////
21
//// the original copyright notice and the associated disclaimer.////
22
////                                                             ////
23
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
24
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
25
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
26
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
27
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
28
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
29
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
30
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
31
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
32
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
33
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
34
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
35
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
36
////                                                             ////
37
/////////////////////////////////////////////////////////////////////
38
 
39
//  CVS Log
40
//
41
//  $Id: mc_top.v,v 1.7 2002/01/21 13:08:52 rudi Exp $
42
//
43
//  $Date: 2002/01/21 13:08:52 $
44
//  $Revision: 1.7 $
45
//  $Author: rudi $
46
//  $Locker:  $
47
//  $State: Exp $
48
//
49
// Change History:
50
//               $Log: mc_top.v,v $
51
//               Revision 1.7  2002/01/21 13:08:52  rudi
52
//
53
//               Fixed several minor bugs, cleaned up the code further ...
54
//
55
//               Revision 1.6  2001/12/21 05:09:30  rudi
56
//
57
//               - Fixed combinatorial loops in synthesis
58
//               - Fixed byte select bug
59
//
60
//               Revision 1.5  2001/11/29 02:16:28  rudi
61
//
62
//
63
//               - More Synthesis cleanup, mostly for speed
64
//               - Several bug fixes
65
//               - Changed code to avoid auto-precharge and
66
//                 burst-terminate combinations (apparently illegal ?)
67
//                 Now we will do a manual precharge ...
68
//
69
//               Revision 1.4  2001/09/10 13:44:17  rudi
70
//               *** empty log message ***
71
//
72
//               Revision 1.3  2001/09/02 02:28:28  rudi
73
//
74
//               Many fixes for minor bugs that showed up in gate level simulations.
75
//
76
//               Revision 1.2  2001/08/10 08:16:21  rudi
77
//
78
//               - Changed IO names to be more clear.
79
//               - Uniquifyed define names to be core specific.
80
//               - Removed "Refresh Early" configuration
81
//
82
//               Revision 1.1  2001/07/29 07:34:41  rudi
83
//
84
//
85
//               1) Changed Directory Structure
86
//               2) Fixed several minor bugs
87
//
88
//               Revision 1.3  2001/06/12 15:19:49  rudi
89
//
90
//
91
//               Minor changes after running lint, and a small bug fix reading csr and ba_mask registers.
92
//
93
//               Revision 1.2  2001/06/03 11:37:17  rudi
94
//
95
//
96
//               1) Fixed Chip Select Mask Register
97
//                      - Power On Value is now all ones
98
//                      - Comparison Logic is now correct
99
//
100
//               2) All resets are now asynchronous
101
//
102
//               3) Converted Power On Delay to an configurable item
103
//
104
//               4) Added reset to Chip Select Output Registers
105
//
106
//               5) Forcing all outputs to Hi-Z state during reset
107
//
108
//               Revision 1.1.1.1  2001/05/13 09:39:39  rudi
109
//               Created Directory Structure
110
//
111
//
112
//
113
//
114
 
115
`include "mc_defines.v"
116
 
117
module mc_top(clk_i, rst_i,
118
 
119
        wb_data_i, wb_data_o, wb_addr_i, wb_sel_i, wb_we_i, wb_cyc_i,
120
        wb_stb_i, wb_ack_o, wb_err_o,
121
 
122
        susp_req_i, resume_req_i, suspended_o, poc_o,
123
 
124
        mc_clk_i, mc_br_pad_i, mc_bg_pad_o, mc_ack_pad_i,
125
        mc_addr_pad_o, mc_data_pad_i, mc_data_pad_o, mc_dp_pad_i,
126
        mc_dp_pad_o, mc_doe_pad_doe_o, mc_dqm_pad_o, mc_oe_pad_o_,
127
        mc_we_pad_o_, mc_cas_pad_o_, mc_ras_pad_o_, mc_cke_pad_o_,
128
        mc_cs_pad_o_, mc_sts_pad_i, mc_rp_pad_o_, mc_vpen_pad_o,
129
        mc_adsc_pad_o_, mc_adv_pad_o_, mc_zz_pad_o, mc_coe_pad_coe_o
130
        );
131
 
132
input           clk_i, rst_i;
133
 
134
// --------------------------------------
135
// WISHBONE SLAVE INTERFACE 
136
input   [31:0]   wb_data_i;
137
output  [31:0]   wb_data_o;
138
input   [31:0]   wb_addr_i;
139
input   [3:0]    wb_sel_i;
140
input           wb_we_i;
141
input           wb_cyc_i;
142
input           wb_stb_i;
143
output          wb_ack_o;
144
output          wb_err_o;
145
 
146
// --------------------------------------
147
// Suspend Resume Interface
148
input           susp_req_i;
149
input           resume_req_i;
150
output          suspended_o;
151
 
152
// POC
153
output  [31:0]   poc_o;
154
 
155
// --------------------------------------
156
// Memory Bus Signals
157
input           mc_clk_i;
158
input           mc_br_pad_i;
159
output          mc_bg_pad_o;
160
input           mc_ack_pad_i;
161
output  [23:0]   mc_addr_pad_o;
162
input   [31:0]   mc_data_pad_i;
163
output  [31:0]   mc_data_pad_o;
164
input   [3:0]    mc_dp_pad_i;
165
output  [3:0]    mc_dp_pad_o;
166
output          mc_doe_pad_doe_o;
167
output  [3:0]    mc_dqm_pad_o;
168
output          mc_oe_pad_o_;
169
output          mc_we_pad_o_;
170
output          mc_cas_pad_o_;
171
output          mc_ras_pad_o_;
172
output          mc_cke_pad_o_;
173
output  [7:0]    mc_cs_pad_o_;
174
input           mc_sts_pad_i;
175
output          mc_rp_pad_o_;
176
output          mc_vpen_pad_o;
177
output          mc_adsc_pad_o_;
178
output          mc_adv_pad_o_;
179
output          mc_zz_pad_o;
180
output          mc_coe_pad_coe_o;
181
 
182
////////////////////////////////////////////////////////////////////
183
//
184
// Local Wires
185
//
186
 
187
// WISHBONE Interface Interconnects
188
wire            wb_read_go;
189
wire            wb_write_go;
190
wire            wb_first;
191
wire            wb_wait;
192
wire            mem_ack;
193
 
194
// Suspend Resume Interface
195
wire            susp_sel;
196
 
197
// Register File Interconnects
198
wire    [31:0]   rf_dout;
199
wire    [31:0]   csc;
200
wire    [31:0]   tms;
201
wire    [31:0]   sp_csc;
202
wire    [31:0]   sp_tms;
203
wire    [7:0]    cs;
204
wire            fs;
205
wire            cs_le;
206
wire    [7:0]    cs_need_rfr;
207
wire    [2:0]    ref_int;
208
wire    [31:0]   mem_dout;
209
wire            wp_err;
210
 
211
// Address Select Signals
212
wire    [12:0]   row_adr;
213
wire    [1:0]    bank_adr;
214
wire            cmd_a10;
215
wire            row_sel;
216
wire            next_adr;
217
wire    [10:0]   page_size;
218
wire            lmr_sel;
219
wire            wr_hold;
220
 
221
// OBCT Signals
222
wire            bank_set;
223
wire            bank_clr;
224
wire            bank_clr_all;
225
wire            bank_open;
226
wire            row_same;
227
wire    [7:0]    obct_cs;
228
wire            any_bank_open;
229
 
230
// Data path Controller Signals
231
wire            dv;
232
wire            pack_le0, pack_le1, pack_le2;   // Pack Latch Enable
233
wire            par_err;
234
wire    [31:0]   mc_data_od;
235
wire    [3:0]    mc_dp_od;
236
wire    [23:0]   mc_addr_d;
237
wire    [35:0]   mc_data_ir;
238
 
239
// Refresh Counter Signals
240
wire            rfr_req;
241
wire            rfr_ack;
242
wire    [7:0]    rfr_ps_val;
243
 
244
// Memory Timing Block Signals
245
wire            data_oe;
246
wire            oe_;
247
wire            we_;
248
wire            cas_;
249
wire            ras_;
250
wire            cke_;
251
wire            lmr_req;
252
wire            lmr_ack;
253
wire            init_req;
254
wire            init_ack;
255
wire    [7:0]    spec_req_cs;
256
wire            cs_en;
257
wire            wb_cycle, wr_cycle;
258
wire    [31:0]   tms_s;
259
wire    [31:0]   csc_s;
260
wire            mc_c_oe_d;
261
wire            mc_br_r;
262
wire            mc_bg_d;
263
wire            mc_adsc_d;
264
wire            mc_adv_d;
265
wire            mc_ack_r;
266
wire            err;
267
wire            mc_sts_i;
268
 
269
////////////////////////////////////////////////////////////////////
270
//
271
// Misc Logic
272
//
273
 
274
assign obct_cs =        (rfr_ack | susp_sel) ? cs_need_rfr :
275
                        (lmr_ack | init_ack) ? spec_req_cs : cs;
276
 
277
assign lmr_sel = lmr_ack | init_ack;
278
 
279
assign tms_s = lmr_sel ? sp_tms : tms;
280
assign csc_s = lmr_sel ? sp_csc : csc;
281
 
282
 
283
wire            not_mem_cyc;
284
 
285
assign  not_mem_cyc = wb_cyc_i & wb_stb_i & !( `MC_MEM_SEL );
286
 
287
reg             mem_ack_r;
288
 
289
always @(posedge clk_i)
290
        mem_ack_r <= #1 mem_ack;
291
 
292
////////////////////////////////////////////////////////////////////
293
//
294
// Modules
295
//
296
 
297
mc_rf           u0(
298
                .clk(           clk_i           ),
299
                .rst(           rst_i           ),
300
                .wb_data_i(     wb_data_i       ),
301
                .rf_dout(       rf_dout         ),
302
                .wb_addr_i(     wb_addr_i       ),
303
                .wb_we_i(       wb_we_i         ),
304
                .wb_cyc_i(      wb_cyc_i        ),
305
                .wb_stb_i(      wb_stb_i        ),
306
                .wb_ack_o(                      ),
307
                .wp_err(        wp_err          ),
308
                .csc(           csc             ),
309
                .tms(           tms             ),
310
                .poc(           poc_o           ),
311
                .sp_csc(        sp_csc          ),
312
                .sp_tms(        sp_tms          ),
313
                .cs(            cs              ),
314
                .mc_data_i(     mc_data_ir[31:0]),
315
                .mc_sts(        mc_sts_ir       ),
316
                .mc_vpen(       mc_vpen_pad_o   ),
317
                .fs(            fs              ),
318
                .cs_le(         cs_le           ),
319
                .cs_le_d(       cs_le_d         ),
320
                .cs_need_rfr(   cs_need_rfr     ),
321
                .ref_int(       ref_int         ),
322
                .rfr_ps_val(    rfr_ps_val      ),
323
                .spec_req_cs(   spec_req_cs     ),
324
                .init_req(      init_req        ),
325
                .init_ack(      init_ack        ),
326
                .lmr_req(       lmr_req         ),
327
                .lmr_ack(       lmr_ack         )
328
                );
329
 
330
mc_adr_sel      u1(
331
                .clk(           clk_i           ),
332
                .csc(           csc_s           ),
333
                .tms(           tms_s           ),
334
                .wb_stb_i(      wb_stb_i        ),
335
                //.wb_ack_o(    wb_ack_o        ),
336
                .wb_ack_o(      mem_ack_r       ),
337
                .wb_addr_i(     wb_addr_i       ),
338
                .wb_we_i(       wb_we_i         ),
339
                .wb_write_go(   wb_write_go     ),
340
                .wr_hold(       wr_hold         ),
341
                .cas_(          cas_            ),
342
                .mc_addr(       mc_addr_d       ),
343
                .row_adr(       row_adr         ),
344
                .bank_adr(      bank_adr        ),
345
                .rfr_ack(       rfr_ack         ),
346
                .cs_le(         cs_le           ),
347
                .cmd_a10(       cmd_a10         ),
348
                .row_sel(       row_sel         ),
349
                .lmr_sel(       lmr_sel         ),
350
                .next_adr(      next_adr        ),
351
                .wr_cycle(      wr_cycle        ),
352
                .page_size(     page_size       )
353
                );
354
 
355
mc_obct_top     u2(
356
                .clk(           clk_i           ),
357
                .rst(           rst_i           ),
358
                .cs(            obct_cs         ),
359
                .row_adr(       row_adr         ),
360
                .bank_adr(      bank_adr        ),
361
                .bank_set(      bank_set        ),
362
                .bank_clr(      bank_clr        ),
363
                .bank_clr_all(  bank_clr_all    ),
364
                .bank_open(     bank_open       ),
365
                .any_bank_open( any_bank_open   ),
366
                .row_same(      row_same        ),
367
                .rfr_ack(       rfr_ack         )
368
                );
369
 
370
mc_dp           u3(
371
                .clk(           clk_i           ),
372
                .rst(           rst_i           ),
373
                .csc(           csc             ),
374
                .wb_cyc_i(      wb_cyc_i        ),
375
                .wb_stb_i(      wb_stb_i        ),
376
                .mem_ack(       mem_ack         ),
377
                //.wb_ack_o(    wb_ack_o        ),
378
                .wb_ack_o(      mem_ack_r       ),
379
                .wb_we_i(       wb_we_i         ),
380
                .wb_data_i(     wb_data_i       ),
381
                .wb_data_o(     mem_dout        ),
382
                .wb_read_go(    wb_read_go      ),
383
                .mc_clk(        mc_clk_i        ),
384
                .mc_data_del(   mc_data_ir      ),
385
                .mc_dp_i(       mc_dp_pad_i     ),
386
                .mc_data_o(     mc_data_od      ),
387
                .mc_dp_o(       mc_dp_od        ),
388
                .dv(            dv              ),
389
                .pack_le0(      pack_le0        ),
390
                .pack_le1(      pack_le1        ),
391
                .pack_le2(      pack_le2        ),
392
                .byte_en(       wb_sel_i        ),
393
                .par_err(       par_err         )
394
                );
395
 
396
mc_refresh      u4(
397
                .clk(           clk_i           ),
398
                .rst(           rst_i           ),
399
                .cs_need_rfr(   cs_need_rfr     ),
400
                .ref_int(       ref_int         ),
401
                .rfr_req(       rfr_req         ),
402
                .rfr_ack(       rfr_ack         ),
403
                .rfr_ps_val(    rfr_ps_val      )
404
                );
405
 
406
mc_timing       u5(
407
                .clk(           clk_i           ),
408
                .mc_clk(        mc_clk_i        ),
409
                .rst(           rst_i           ),
410
                .wb_cyc_i(      wb_cyc_i        ),
411
                .wb_stb_i(      wb_stb_i        ),
412
                .wb_we_i(       wb_we_i         ),
413
                .wb_read_go(    wb_read_go      ),
414
                .wb_write_go(   wb_write_go     ),
415
                .wb_first(      wb_first        ),
416
                .wb_wait(       wb_wait         ),
417
                .mem_ack(       mem_ack         ),
418
                .err(           err             ),
419
                .susp_req(      susp_req_i      ),
420
                .resume_req(    resume_req_i    ),
421
                .suspended(     suspended_o     ),
422
                .susp_sel(      susp_sel        ),
423
                .mc_br(         mc_br_r         ),
424
                .mc_bg(         mc_bg_d         ),
425
                .mc_ack(        mc_ack_r        ),
426
                .not_mem_cyc(   not_mem_cyc     ),
427
                .data_oe(       data_oe         ),
428
                .oe_(           oe_             ),
429
                .we_(           we_             ),
430
                .cas_(          cas_            ),
431
                .ras_(          ras_            ),
432
                .cke_(          cke_            ),
433
                .cs_en(         cs_en           ),
434
                .mc_adsc(       mc_adsc_d       ),
435
                .mc_adv(        mc_adv_d        ),
436
                .mc_c_oe(       mc_c_oe_d       ),
437
                .wb_cycle(      wb_cycle        ),
438
                .wr_cycle(      wr_cycle        ),
439
                .csc(           csc_s           ),
440
                .tms(           tms_s           ),
441
                .cs(            obct_cs         ),
442
                .lmr_req(       lmr_req         ),
443
                .lmr_ack(       lmr_ack         ),
444
                .cs_le(         cs_le           ),
445
                .cs_le_d(       cs_le_d         ),
446
                .cmd_a10(       cmd_a10         ),
447
                .row_sel(       row_sel         ),
448
                .next_adr(      next_adr        ),
449
                .page_size(     page_size       ),
450
                .bank_set(      bank_set        ),
451
                .bank_clr(      bank_clr        ),
452
                .bank_clr_all(  bank_clr_all    ),
453
                .bank_open(     bank_open       ),
454
                .any_bank_open( any_bank_open   ),
455
                .row_same(      row_same        ),
456
                .dv(            dv              ),
457
                .pack_le0(      pack_le0        ),
458
                .pack_le1(      pack_le1        ),
459
                .pack_le2(      pack_le2        ),
460
                .par_err(       par_err         ),
461
                .rfr_req(       rfr_req         ),
462
                .rfr_ack(       rfr_ack         ),
463
                .init_req(      init_req        ),
464
                .init_ack(      init_ack        )
465
                );
466
 
467
mc_wb_if        u6(
468
                .clk(           clk_i           ),
469
                .rst(           rst_i           ),
470
                .wb_addr_i(     wb_addr_i       ),
471
                .wb_cyc_i(      wb_cyc_i        ),
472
                .wb_stb_i(      wb_stb_i        ),
473
                .wb_we_i(       wb_we_i         ),
474
                .wb_ack_o(      wb_ack_o        ),
475
                .wb_err(        wb_err_o        ),
476
                .wb_read_go(    wb_read_go      ),
477
                .wb_write_go(   wb_write_go     ),
478
                .wb_first(      wb_first        ),
479
                .wb_wait(       wb_wait         ),
480
                .mem_ack(       mem_ack         ),
481
                .wr_hold(       wr_hold         ),
482
                .err(           err             ),
483
                .par_err(       par_err         ),
484
                .wp_err(        wp_err          ),
485
                .wb_data_o(     wb_data_o       ),
486
                .mem_dout(      mem_dout        ),
487
                .rf_dout(       rf_dout         )
488
                );
489
 
490
mc_mem_if       u7(
491
                .clk(           clk_i           ),
492
                .rst(           rst_i           ),
493
                .mc_rp(         mc_rp_pad_o_    ),
494
                .mc_clk(        mc_clk_i        ),
495
                .mc_br(         mc_br_pad_i     ),
496
                .mc_bg(         mc_bg_pad_o     ),
497
                .mc_addr(       mc_addr_pad_o   ),
498
                .mc_data_o(     mc_data_pad_o   ),
499
                .mc_dp_o(       mc_dp_pad_o     ),
500
                .mc_data_oe(    mc_doe_pad_doe_o),
501
                .mc_dqm(        mc_dqm_pad_o    ),
502
                .mc_oe_(        mc_oe_pad_o_    ),
503
                .mc_we_(        mc_we_pad_o_    ),
504
                .mc_cas_(       mc_cas_pad_o_   ),
505
                .mc_ras_(       mc_ras_pad_o_   ),
506
                .mc_cke_(       mc_cke_pad_o_   ),
507
                .mc_cs_(        mc_cs_pad_o_    ),
508
                .mc_adsc_(      mc_adsc_pad_o_  ),
509
                .mc_adv_(       mc_adv_pad_o_   ),
510
                .mc_br_r(       mc_br_r         ),
511
                .mc_bg_d(       mc_bg_d         ),
512
                .mc_data_od(    mc_data_od      ),
513
                .mc_dp_od(      mc_dp_od        ),
514
                .mc_addr_d(     mc_addr_d       ),
515
                .mc_ack(        mc_ack_pad_i    ),
516
                .mc_zz_o(       mc_zz_pad_o     ),
517
                .we_(           we_             ),
518
                .ras_(          ras_            ),
519
                .cas_(          cas_            ),
520
                .cke_(          cke_            ),
521
                .mc_adsc_d(     mc_adsc_d       ),
522
                .mc_adv_d(      mc_adv_d        ),
523
                .cs_en(         cs_en           ),
524
                .rfr_ack(       rfr_ack         ),
525
                .cs_need_rfr(   cs_need_rfr     ),
526
                .lmr_sel(       lmr_sel         ),
527
                .spec_req_cs(   spec_req_cs     ),
528
                .cs(            cs              ),
529
                .fs(            fs              ),
530
                .data_oe(       data_oe         ),
531
                .susp_sel(      susp_sel        ),
532
                .suspended_o(   suspended_o     ),
533
                .mc_c_oe(       mc_coe_pad_coe_o),
534
                .mc_c_oe_d(     mc_c_oe_d       ),
535
                .mc_ack_r(      mc_ack_r        ),
536
                .oe_(           oe_             ),
537
                .wb_cyc_i(      wb_cyc_i        ),
538
                .wb_stb_i(      wb_stb_i        ),
539
                .wb_sel_i(      wb_sel_i        ),
540
                .wb_cycle(      wb_cycle        ),
541
                .wr_cycle(      wr_cycle        ),
542
                .mc_data_i(     mc_data_pad_i   ),
543
                .mc_dp_i(       mc_dp_pad_i     ),
544
                .mc_data_ir(    mc_data_ir      ),
545
                .mc_sts_i(      mc_sts_pad_i    ),
546
                .mc_sts_ir(     mc_sts_ir       )
547
                );
548
 
549
endmodule

powered by: WebSVN 2.1.0

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