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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [actel/] [ordb1a3pe1500/] [rtl/] [verilog/] [versatile_mem_ctrl/] [versatile_mem_ctrl.v] - Blame information for rev 411

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 408 julius
`line 1 "sdr_16_defines.v" 1
2
//
3
// Specify either type of memory
4
// or
5
// BA_SIZE, ROW_SIZE, COL_SIZE and SDRAM_DATA_WIDTH
6
//
7
// either in this file or as command line option; +define+MT48LC16M16
8
//
9
 
10
// Most of these defines have an effect on things in fsm_sdr_16.v
11
 
12
//`define MT48LC32M16   // 64MB part
13
 // 32MB part
14
//`define MT48LC4M16    //  8MB part
15
 
16
// Define this to allow indication that a burst read is still going
17
// to the wishbone state machine, so it doesn't start emptying the
18
// ingress fifo after a aborted burst before the burst read is
19
// actually finished.
20
 
21
 
22
// If intending to burst write, and the wishbone clock is about 1/4 the speed
23
// of the SDRAM clock, then the data may come late, and this triggers a bug
24
// during write. To avoid this we can just wait a little longer for data when
25
// burst reading (there's no almost_empty signal from the FIFO)
26
 
27
 
28
 
29
 
30
 
31
 
32
 
33
 
34
 
35
 
36
 
37
 
38
 
39
`line 37 "sdr_16_defines.v" 0
40
 //  `ifdef MT48LC16M16
41
 
42
 
43
// using 1 of MT48LC16M16
44
// SDRAM data width is 16
45
 
46
 
47
 
48
 
49
 
50
 
51
 //  `ifdef MT48LC16M16
52
 
53
 
54
 
55
 
56
 
57
 
58
 
59
 
60
 
61
 
62
 
63
`line 59 "sdr_16_defines.v" 0
64
 //  `ifdef MT48LC4M16
65
 
66
// LMR
67
// [12:10] reserved
68
// [9]     WB, write burst; 0 - programmed burst length, 1 - single location
69
// [8:7]   OP Mode, 2'b00
70
// [6:4]   CAS Latency; 3'b010 - 2, 3'b011 - 3
71
// [3]     BT, Burst Type; 1'b0 - sequential, 1'b1 - interleaved
72
// [2:0]   Burst length; 3'b000 - 1, 3'b001 - 2, 3'b010 - 4, 3'b011 - 8, 3'b111 - full page
73
 
74
 
75
 
76
 
77
`line 72 "sdr_16_defines.v" 2
78
`line 1 "fsm_wb.v" 1
79
module fsm_wb (
80
               stall_i, stall_o,
81
               we_i, cti_i, bte_i, stb_i, cyc_i, ack_o,
82
               egress_fifo_we, egress_fifo_full,
83
               ingress_fifo_re, ingress_fifo_empty,
84
               state_idle,
85
               sdram_burst_reading,
86
               debug_state,
87
               wb_clk, wb_rst
88
               );
89
 
90
   input stall_i;
91
   output stall_o;
92
 
93
   input [2:0] cti_i;
94
   input [1:0] bte_i;
95
   input       we_i, stb_i, cyc_i;
96
   output      ack_o;
97
   output      egress_fifo_we, ingress_fifo_re;
98
   input       egress_fifo_full, ingress_fifo_empty;
99
   input       sdram_burst_reading;
100
   output      state_idle;
101
   input       wb_clk, wb_rst;
102
   output [1:0] debug_state;
103
 
104
 
105
 
106
   reg         ingress_fifo_read_reg;
107
 
108
   // bte
109
   parameter linear       = 2'b00;
110
   parameter wrap4        = 2'b01;
111
   parameter wrap8        = 2'b10;
112
   parameter wrap16       = 2'b11;
113
   // cti
114
   parameter classic      = 3'b000;
115
   parameter endofburst   = 3'b111;
116
 
117
   parameter idle = 2'b00;
118
   parameter rd   = 2'b01;
119
   parameter wr   = 2'b10;
120
   parameter fe   = 2'b11;
121
   reg [1:0]   state;
122
 
123
   assign debug_state = state;
124
 
125
 
126
   reg         sdram_burst_reading_1, sdram_burst_reading_2;
127
   wire        sdram_burst_reading_wb_clk;
128
 
129
 
130
   always @ (posedge wb_clk or posedge wb_rst)
131
     if (wb_rst)
132
       state <= idle;
133
     else
134
       case (state)
135
         idle:
136
           if (we_i & stb_i & cyc_i & !egress_fifo_full & !stall_i)
137
             state <= wr;
138
           else if (!we_i & stb_i & cyc_i & !egress_fifo_full & !stall_i)
139
             state <= rd;
140
         wr:
141
           if ((cti_i==classic | cti_i==endofburst | bte_i==linear) &
142
               stb_i & cyc_i & !egress_fifo_full & !stall_i)
143
             state <= idle;
144
         rd:
145
           if ((cti_i==classic | cti_i==endofburst | bte_i==linear) &
146
               stb_i & cyc_i & ack_o)
147
             state <= fe;
148
         fe:
149
           if (ingress_fifo_empty & !sdram_burst_reading_wb_clk)
150
             state <= idle;
151
         default: ;
152
       endcase
153
 
154
   assign state_idle = (state==idle);
155
 
156
   assign stall_o = (stall_i) ? 1'b1 :
157
                    (state==idle & stb_i & cyc_i & !egress_fifo_full) ? 1'b1 :
158
                    (state==wr   & stb_i & cyc_i & !egress_fifo_full) ? 1'b1 :
159
                    (state==rd   & stb_i & cyc_i & !ingress_fifo_empty) ? 1'b1 :
160
                    (state==fe   & !ingress_fifo_empty) ? 1'b1 :
161
                    1'b0;
162
 
163
   assign egress_fifo_we = (state==idle & stb_i & cyc_i & !egress_fifo_full & !stall_i) ? 1'b1 :
164
                           (state==wr   & stb_i & cyc_i & !egress_fifo_full & !stall_i) ? 1'b1 :
165
                           1'b0;
166
 
167
   assign ingress_fifo_re = (state==rd & stb_i & cyc_i & !ingress_fifo_empty & !stall_i) ? 1'b1 :
168
                            (state==fe & !ingress_fifo_empty & !stall_i) ? 1'b1:
169
                            1'b0;
170
 
171
   always @ (posedge wb_clk or posedge wb_rst)
172
     if (wb_rst)
173
       ingress_fifo_read_reg <= 1'b0;
174
     else
175
       ingress_fifo_read_reg <= ingress_fifo_re;
176
 
177
   /*assign ack_o = (ingress_fifo_read_reg & stb_i) ? 1'b1 :
178
                  (state==fe) ? 1'b0 :
179
                  (state==wr & stb_i & cyc_i & !egress_fifo_full & !stall_i) ? 1'b1 :
180
                  1'b0;*/
181
 
182
   assign ack_o = !(state==fe) & ((ingress_fifo_read_reg & stb_i) | (state==wr & stb_i & cyc_i & !egress_fifo_full & !stall_i));
183
 
184
 
185
   // Sample the SDRAM burst reading signal in WB domain
186
   always @(posedge wb_clk)
187
     sdram_burst_reading_1 <= sdram_burst_reading;
188
 
189
   always @(posedge wb_clk)
190
     sdram_burst_reading_2 <= sdram_burst_reading_1;
191
 
192
   assign sdram_burst_reading_wb_clk = sdram_burst_reading_2;
193
 
194
endmodule
195
`line 116 "fsm_wb.v" 2
196
`line 1 "versatile_fifo_async_cmp.v" 1
197
//////////////////////////////////////////////////////////////////////
198
////                                                              ////
199
////  Versatile counter                                           ////
200
////                                                              ////
201
////  Description                                                 ////
202
////  Versatile counter, a reconfigurable binary, gray or LFSR    ////
203
////  counter                                                     ////
204
////                                                              ////
205
////  To Do:                                                      ////
206
////   - add LFSR with more taps                                  ////
207
////                                                              ////
208
////  Author(s):                                                  ////
209
////      - Michael Unneback, unneback@opencores.org              ////
210
////        ORSoC AB                                              ////
211
////                                                              ////
212
//////////////////////////////////////////////////////////////////////
213
////                                                              ////
214
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 ////
215
////                                                              ////
216
//// This source file may be used and distributed without         ////
217
//// restriction provided that this copyright statement is not    ////
218
//// removed from the file and that any derivative work contains  ////
219
//// the original copyright notice and the associated disclaimer. ////
220
////                                                              ////
221
//// This source file is free software; you can redistribute it   ////
222
//// and/or modify it under the terms of the GNU Lesser General   ////
223
//// Public License as published by the Free Software Foundation; ////
224
//// either version 2.1 of the License, or (at your option) any   ////
225
//// later version.                                               ////
226
////                                                              ////
227
//// This source is distributed in the hope that it will be       ////
228
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
229
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
230
//// PURPOSE.  See the GNU Lesser General Public License for more ////
231
//// details.                                                     ////
232
////                                                              ////
233
//// You should have received a copy of the GNU Lesser General    ////
234
//// Public License along with this source; if not, download it   ////
235
//// from http://www.opencores.org/lgpl.shtml                     ////
236
////                                                              ////
237
//////////////////////////////////////////////////////////////////////
238
 
239
module versatile_fifo_async_cmp ( wptr, rptr, fifo_empty, fifo_full, wclk, rclk, rst );
240
 
241
   parameter ADDR_WIDTH = 4;
242
   parameter N = ADDR_WIDTH-1;
243
 
244
   parameter Q1 = 2'b00;
245
   parameter Q2 = 2'b01;
246
   parameter Q3 = 2'b11;
247
   parameter Q4 = 2'b10;
248
 
249
   parameter going_empty = 1'b0;
250
   parameter going_full  = 1'b1;
251
 
252
   input [N:0]  wptr, rptr;
253
   output reg   fifo_empty;
254
   output       fifo_full;
255
   input        wclk, rclk, rst;
256
 
257
 
258
   wire direction;
259
 
260
 
261
 
262
 
263
`line 66 "versatile_fifo_async_cmp.v" 0
264
 
265
   reg  direction_set, direction_clr;
266
 
267
   wire async_empty, async_full;
268
   wire fifo_full2;
269
   reg  fifo_empty2;
270
 
271
   // direction_set
272
   always @ (wptr[N:N-1] or rptr[N:N-1])
273
     case ({wptr[N:N-1],rptr[N:N-1]})
274
       {Q1,Q2} : direction_set <= 1'b1;
275
       {Q2,Q3} : direction_set <= 1'b1;
276
       {Q3,Q4} : direction_set <= 1'b1;
277
       {Q4,Q1} : direction_set <= 1'b1;
278
       default : direction_set <= 1'b0;
279
     endcase
280
 
281
   // direction_clear
282
   always @ (wptr[N:N-1] or rptr[N:N-1] or rst)
283
     if (rst)
284
       direction_clr <= 1'b1;
285
     else
286
       case ({wptr[N:N-1],rptr[N:N-1]})
287
         {Q2,Q1} : direction_clr <= 1'b1;
288
         {Q3,Q2} : direction_clr <= 1'b1;
289
         {Q4,Q3} : direction_clr <= 1'b1;
290
         {Q1,Q4} : direction_clr <= 1'b1;
291
         default : direction_clr <= 1'b0;
292
       endcase
293
 
294
 
295
    dff_sr dff_sr_dir( .aclr(direction_clr), .aset(direction_set), .clock(1'b1), .data(1'b1), .q(direction));
296
 
297
 
298
 
299
 
300
 
301
 
302
 
303
 
304
 
305
`line 106 "versatile_fifo_async_cmp.v" 0
306
 
307
 
308
   assign async_empty = (wptr == rptr) && (direction==going_empty);
309
   assign async_full  = (wptr == rptr) && (direction==going_full);
310
 
311
    dff_sr dff_sr_empty0( .aclr(rst), .aset(async_full), .clock(wclk), .data(async_full), .q(fifo_full2));
312
    dff_sr dff_sr_empty1( .aclr(rst), .aset(async_full), .clock(wclk), .data(fifo_full2), .q(fifo_full));
313
 
314
/*
315
   always @ (posedge wclk or posedge rst or posedge async_full)
316
     if (rst)
317
       {fifo_full, fifo_full2} <= 2'b00;
318
     else if (async_full)
319
       {fifo_full, fifo_full2} <= 2'b11;
320
     else
321
       {fifo_full, fifo_full2} <= {fifo_full2, async_full};
322
*/
323
   always @ (posedge rclk or posedge async_empty)
324
     if (async_empty)
325
       {fifo_empty, fifo_empty2} <= 2'b11;
326
     else
327
       {fifo_empty,fifo_empty2} <= {fifo_empty2,async_empty};
328
 
329
endmodule // async_comp
330
`line 130 "versatile_fifo_async_cmp.v" 2
331
`line 1 "async_fifo_mq.v" 1
332
// async FIFO with multiple queues
333
 
334
module async_fifo_mq (
335
    d, fifo_full, write, write_enable, clk1, rst1,
336
    q, fifo_empty, read, read_enable, clk2, rst2
337
);
338
 
339
parameter a_hi_size = 4;
340
parameter a_lo_size = 4;
341
parameter nr_of_queues = 16;
342
parameter data_width = 36;
343
 
344
input [data_width-1:0] d;
345
output [0:nr_of_queues-1] fifo_full;
346
input                     write;
347
input  [0:nr_of_queues-1] write_enable;
348
input clk1;
349
input rst1;
350
 
351
output [data_width-1:0] q;
352
output [0:nr_of_queues-1] fifo_empty;
353
input                     read;
354
input  [0:nr_of_queues-1] read_enable;
355
input clk2;
356
input rst2;
357
 
358
wire [a_lo_size-1:0]  fifo_wadr_bin[0:nr_of_queues-1];
359
wire [a_lo_size-1:0]  fifo_wadr_gray[0:nr_of_queues-1];
360
wire [a_lo_size-1:0]  fifo_radr_bin[0:nr_of_queues-1];
361
wire [a_lo_size-1:0]  fifo_radr_gray[0:nr_of_queues-1];
362
reg [a_lo_size-1:0] wadr;
363
reg [a_lo_size-1:0] radr;
364
reg [data_width-1:0] wdata;
365
wire [data_width-1:0] wdataa[0:nr_of_queues-1];
366
 
367
genvar i;
368
integer j,k,l;
369
 
370
function [a_lo_size-1:0] onehot2bin;
371
input [0:nr_of_queues-1] a;
372
integer i;
373
begin
374
    onehot2bin = {a_lo_size{1'b0}};
375
    for (i=1;i<nr_of_queues;i=i+1) begin
376
        if (a[i])
377
            onehot2bin = i;
378
    end
379
end
380
endfunction
381
 
382
generate
383
    for (i=0;i<nr_of_queues;i=i+1) begin : fifo_adr
384
 
385
        gray_counter wadrcnt (
386
            .cke(write & write_enable[i]),
387
            .q(fifo_wadr_gray[i]),
388
            .q_bin(fifo_wadr_bin[i]),
389
            .rst(rst1),
390
            .clk(clk1));
391
 
392
        gray_counter radrcnt (
393
            .cke(read & read_enable[i]),
394
            .q(fifo_radr_gray[i]),
395
            .q_bin(fifo_radr_bin[i]),
396
            .rst(rst2),
397
            .clk(clk2));
398
 
399
        versatile_fifo_async_cmp
400
            #(.ADDR_WIDTH(a_lo_size))
401
            egresscmp (
402
                .wptr(fifo_wadr_gray[i]),
403
                .rptr(fifo_radr_gray[i]),
404
                .fifo_empty(fifo_empty[i]),
405
                .fifo_full(fifo_full[i]),
406
                .wclk(clk1),
407
                .rclk(clk2),
408
                .rst(rst1));
409
 
410
    end
411
endgenerate
412
 
413
// and-or mux write address
414
always @*
415
begin
416
    wadr = {a_lo_size{1'b0}};
417
    for (j=0;j<nr_of_queues;j=j+1) begin
418
        wadr = (fifo_wadr_bin[j] & {a_lo_size{write_enable[j]}}) | wadr;
419
    end
420
end
421
 
422
// and-or mux read address
423
always @*
424
begin
425
    radr = {a_lo_size{1'b0}};
426
    for (k=0;k<nr_of_queues;k=k+1) begin
427
        radr = (fifo_radr_bin[k] & {a_lo_size{read_enable[k]}}) | radr;
428
    end
429
end
430
 
431
vfifo_dual_port_ram_dc_sw # ( .DATA_WIDTH(data_width), .ADDR_WIDTH(a_hi_size+a_lo_size))
432
    dpram (
433
    .d_a(d),
434
    .adr_a({onehot2bin(write_enable),wadr}),
435
    .we_a(write),
436
    .clk_a(clk1),
437
    .q_b(q),
438
    .adr_b({onehot2bin(read_enable),radr}),
439
    .clk_b(clk2) );
440
 
441
endmodule
442
`line 111 "async_fifo_mq.v" 2
443
`line 1 "delay.v" 1
444
`timescale 1ns/1ns
445
module delay (d, q, clk, rst);
446
 
447
   parameter width = 4;
448
   parameter depth = 3;
449
 
450
   input  [width-1:0] d;
451
   output [width-1:0] q;
452
   input              clk;
453
   input              rst;
454
 
455
   reg [width-1:0] dffs [1:depth];
456
 
457
   integer i;
458
 
459
   always @ (posedge clk or posedge rst)
460
     if (rst)
461
       for ( i=1; i <= depth; i=i+1)
462
         dffs[i] <= {width{1'b0}};
463
     else
464
       begin
465
          dffs[1] <= d;
466
          for ( i=2; i <= depth; i=i+1 )
467
            dffs[i] <= dffs[i-1];
468
       end
469
 
470
   assign q = dffs[depth];
471
 
472
endmodule //delay
473
 
474
 
475
`line 32 "delay.v" 2
476
`line 1 "codec.v" 1
477
`timescale 1ns/1ns
478
module encode (
479
    fifo_empty_0, fifo_empty_1, fifo_empty_2, fifo_empty_3,
480
    fifo_sel, fifo_sel_domain
481
);
482
 
483
input  [0:15] fifo_empty_0, fifo_empty_1, fifo_empty_2, fifo_empty_3;
484
output [0:15] fifo_sel;
485
output [1:0]  fifo_sel_domain;
486
 
487
function [0:15] encode;
488
input [0:15] a;
489
input [0:15] b;
490
input [0:15] c;
491
input [0:15] d;
492
integer i;
493
begin
494
    if (!(&d))
495
        casex (d)
496
        16'b0xxxxxxxxxxxxxxx: encode = 16'b1000000000000000;
497
        16'b10xxxxxxxxxxxxxx: encode = 16'b0100000000000000;
498
        16'b110xxxxxxxxxxxxx: encode = 16'b0010000000000000;
499
        16'b1110xxxxxxxxxxxx: encode = 16'b0001000000000000;
500
        16'b11110xxxxxxxxxxx: encode = 16'b0000100000000000;
501
        16'b111110xxxxxxxxxx: encode = 16'b0000010000000000;
502
        16'b1111110xxxxxxxxx: encode = 16'b0000001000000000;
503
        16'b11111110xxxxxxxx: encode = 16'b0000000100000000;
504
        16'b111111110xxxxxxx: encode = 16'b0000000010000000;
505
        16'b1111111110xxxxxx: encode = 16'b0000000001000000;
506
        16'b11111111110xxxxx: encode = 16'b0000000000100000;
507
        16'b111111111110xxxx: encode = 16'b0000000000010000;
508
        16'b1111111111110xxx: encode = 16'b0000000000001000;
509
        16'b11111111111110xx: encode = 16'b0000000000000100;
510
        16'b111111111111110x: encode = 16'b0000000000000010;
511
        16'b1111111111111110: encode = 16'b0000000000000001;
512
        default:              encode = 16'b0000000000000000;
513
        endcase
514
    else if (!(&c))
515
        casex (c)
516
        16'b0xxxxxxxxxxxxxxx: encode = 16'b1000000000000000;
517
        16'b10xxxxxxxxxxxxxx: encode = 16'b0100000000000000;
518
        16'b110xxxxxxxxxxxxx: encode = 16'b0010000000000000;
519
        16'b1110xxxxxxxxxxxx: encode = 16'b0001000000000000;
520
        16'b11110xxxxxxxxxxx: encode = 16'b0000100000000000;
521
        16'b111110xxxxxxxxxx: encode = 16'b0000010000000000;
522
        16'b1111110xxxxxxxxx: encode = 16'b0000001000000000;
523
        16'b11111110xxxxxxxx: encode = 16'b0000000100000000;
524
        16'b111111110xxxxxxx: encode = 16'b0000000010000000;
525
        16'b1111111110xxxxxx: encode = 16'b0000000001000000;
526
        16'b11111111110xxxxx: encode = 16'b0000000000100000;
527
        16'b111111111110xxxx: encode = 16'b0000000000010000;
528
        16'b1111111111110xxx: encode = 16'b0000000000001000;
529
        16'b11111111111110xx: encode = 16'b0000000000000100;
530
        16'b111111111111110x: encode = 16'b0000000000000010;
531
        16'b1111111111111110: encode = 16'b0000000000000001;
532
        default:              encode = 16'b0000000000000000;
533
        endcase
534
    else if (!(&b))
535
        casex (b)
536
        16'b0xxxxxxxxxxxxxxx: encode = 16'b1000000000000000;
537
        16'b10xxxxxxxxxxxxxx: encode = 16'b0100000000000000;
538
        16'b110xxxxxxxxxxxxx: encode = 16'b0010000000000000;
539
        16'b1110xxxxxxxxxxxx: encode = 16'b0001000000000000;
540
        16'b11110xxxxxxxxxxx: encode = 16'b0000100000000000;
541
        16'b111110xxxxxxxxxx: encode = 16'b0000010000000000;
542
        16'b1111110xxxxxxxxx: encode = 16'b0000001000000000;
543
        16'b11111110xxxxxxxx: encode = 16'b0000000100000000;
544
        16'b111111110xxxxxxx: encode = 16'b0000000010000000;
545
        16'b1111111110xxxxxx: encode = 16'b0000000001000000;
546
        16'b11111111110xxxxx: encode = 16'b0000000000100000;
547
        16'b111111111110xxxx: encode = 16'b0000000000010000;
548
        16'b1111111111110xxx: encode = 16'b0000000000001000;
549
        16'b11111111111110xx: encode = 16'b0000000000000100;
550
        16'b111111111111110x: encode = 16'b0000000000000010;
551
        16'b1111111111111110: encode = 16'b0000000000000001;
552
        default:              encode = 16'b0000000000000000;
553
        endcase
554
    else
555
        casex (a)
556
        16'b0xxxxxxxxxxxxxxx: encode = 16'b1000000000000000;
557
        16'b10xxxxxxxxxxxxxx: encode = 16'b0100000000000000;
558
        16'b110xxxxxxxxxxxxx: encode = 16'b0010000000000000;
559
        16'b1110xxxxxxxxxxxx: encode = 16'b0001000000000000;
560
        16'b11110xxxxxxxxxxx: encode = 16'b0000100000000000;
561
        16'b111110xxxxxxxxxx: encode = 16'b0000010000000000;
562
        16'b1111110xxxxxxxxx: encode = 16'b0000001000000000;
563
        16'b11111110xxxxxxxx: encode = 16'b0000000100000000;
564
        16'b111111110xxxxxxx: encode = 16'b0000000010000000;
565
        16'b1111111110xxxxxx: encode = 16'b0000000001000000;
566
        16'b11111111110xxxxx: encode = 16'b0000000000100000;
567
        16'b111111111110xxxx: encode = 16'b0000000000010000;
568
        16'b1111111111110xxx: encode = 16'b0000000000001000;
569
        16'b11111111111110xx: encode = 16'b0000000000000100;
570
        16'b111111111111110x: encode = 16'b0000000000000010;
571
        16'b1111111111111110: encode = 16'b0000000000000001;
572
        default:              encode = 16'b0000000000000000;
573
        endcase
574
end
575
endfunction
576
 
577
assign fifo_sel = encode( fifo_empty_0, fifo_empty_1, fifo_empty_2, fifo_empty_3);
578
assign fifo_sel_domain = (!(&fifo_empty_3)) ? 2'b11 :
579
                         (!(&fifo_empty_2)) ? 2'b10 :
580
                         (!(&fifo_empty_1)) ? 2'b01 :
581
                         2'b00;
582
 
583
endmodule
584
 
585
`timescale 1ns/1ns
586
module decode (
587
    fifo_sel, fifo_sel_domain,
588
    fifo_we_0, fifo_we_1, fifo_we_2, fifo_we_3
589
);
590
 
591
input  [0:15] fifo_sel;
592
input  [1:0]  fifo_sel_domain;
593
output [0:15] fifo_we_0, fifo_we_1, fifo_we_2, fifo_we_3;
594
 
595
assign fifo_we_0 = (fifo_sel_domain == 2'b00) ? fifo_sel : {16{1'b0}};
596
assign fifo_we_1 = (fifo_sel_domain == 2'b01) ? fifo_sel : {16{1'b0}};
597
assign fifo_we_2 = (fifo_sel_domain == 2'b10) ? fifo_sel : {16{1'b0}};
598
assign fifo_we_3 = (fifo_sel_domain == 2'b11) ? fifo_sel : {16{1'b0}};
599
 
600
endmodule
601
`line 125 "codec.v" 2
602
`line 1 "gray_counter.v" 1
603
//////////////////////////////////////////////////////////////////////
604
////                                                              ////
605
////  Versatile counter                                           ////
606
////                                                              ////
607
////  Description                                                 ////
608
////  Versatile counter, a reconfigurable binary, gray or LFSR    ////
609
////  counter                                                     ////
610
////                                                              ////
611
////  To Do:                                                      ////
612
////   - add LFSR with more taps                                  ////
613
////                                                              ////
614
////  Author(s):                                                  ////
615
////      - Michael Unneback, unneback@opencores.org              ////
616
////        ORSoC AB                                              ////
617
////                                                              ////
618
//////////////////////////////////////////////////////////////////////
619
////                                                              ////
620
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 ////
621
////                                                              ////
622
//// This source file may be used and distributed without         ////
623
//// restriction provided that this copyright statement is not    ////
624
//// removed from the file and that any derivative work contains  ////
625
//// the original copyright notice and the associated disclaimer. ////
626
////                                                              ////
627
//// This source file is free software; you can redistribute it   ////
628
//// and/or modify it under the terms of the GNU Lesser General   ////
629
//// Public License as published by the Free Software Foundation; ////
630
//// either version 2.1 of the License, or (at your option) any   ////
631
//// later version.                                               ////
632
////                                                              ////
633
//// This source is distributed in the hope that it will be       ////
634
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
635
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
636
//// PURPOSE.  See the GNU Lesser General Public License for more ////
637
//// details.                                                     ////
638
////                                                              ////
639
//// You should have received a copy of the GNU Lesser General    ////
640
//// Public License along with this source; if not, download it   ////
641
//// from http://www.opencores.org/lgpl.shtml                     ////
642
////                                                              ////
643
//////////////////////////////////////////////////////////////////////
644
 
645
// GRAY counter
646
module gray_counter ( cke, q, q_bin, rst, clk);
647
 
648
   parameter length = 4;
649
   input cke;
650
   output reg [length:1] q;
651
   output [length:1] q_bin;
652
   input rst;
653
   input clk;
654
 
655
   parameter clear_value = 0;
656
 
657
   reg  [length:1] qi;
658
   wire [length:1] q_next;
659
   assign q_next = qi + {{length-1{1'b0}},1'b1};
660
 
661
   always @ (posedge clk or posedge rst)
662
     if (rst)
663
       qi <= {length{1'b0}};
664
     else
665
     if (cke)
666
       qi <= q_next;
667
 
668
   always @ (posedge clk or posedge rst)
669
     if (rst)
670
       q <= {length{1'b0}};
671
     else
672
       if (cke)
673
         q <= (q_next>>1) ^ q_next;
674
 
675
   assign q_bin = qi;
676
 
677
endmodule
678
`line 76 "gray_counter.v" 2
679
`line 1 "egress_fifo.v" 1
680
// async FIFO with multiple queues, multiple data
681
 
682
 
683
module egress_fifo (
684
    d, fifo_full, write, write_enable, clk1, rst1,
685
    q, fifo_empty, read_adr, read_data, read_enable, clk2, rst2
686
);
687
 
688
parameter a_hi_size = 4;
689
parameter a_lo_size = 4;
690
parameter nr_of_queues = 16;
691
parameter data_width = 36;
692
 
693
input [data_width*nr_of_queues-1:0] d;
694
output [0:nr_of_queues-1] fifo_full;
695
input                     write;
696
input  [0:nr_of_queues-1] write_enable;
697
input clk1;
698
input rst1;
699
 
700
output reg [data_width-1:0] q;
701
output [0:nr_of_queues-1] fifo_empty;
702
input                     read_adr, read_data;
703
input  [0:nr_of_queues-1] read_enable;
704
input clk2;
705
input rst2;
706
 
707
wire [data_width-1:0] fifo_q;
708
 
709
wire [a_lo_size-1:0]  fifo_wadr_bin[0:nr_of_queues-1];
710
wire [a_lo_size-1:0]  fifo_wadr_gray[0:nr_of_queues-1];
711
wire [a_lo_size-1:0]  fifo_radr_bin[0:nr_of_queues-1];
712
wire [a_lo_size-1:0]  fifo_radr_gray[0:nr_of_queues-1];
713
reg [a_lo_size-1:0] wadr;
714
reg [a_lo_size-1:0] radr;
715
reg [data_width-1:0] wdata;
716
wire [data_width-1:0] wdataa[0:nr_of_queues-1];
717
 
718
reg read_adr_reg;
719
reg [0:nr_of_queues-1] read_enable_reg;
720
 
721
genvar i;
722
integer j,k,l;
723
 
724
function [a_lo_size-1:0] onehot2bin;
725
input [0:nr_of_queues-1] a;
726
integer i;
727
begin
728
    onehot2bin = {a_lo_size{1'b0}};
729
    for (i=1;i<nr_of_queues;i=i+1) begin
730
        if (a[i])
731
            onehot2bin = i;
732
    end
733
end
734
endfunction
735
 
736
// a pipeline stage for address read gives higher clock frequency but adds one 
737
// clock latency for adr read
738
always @ (posedge clk2 or posedge rst2)
739
if (rst2)
740
    read_adr_reg <= 1'b0;
741
else
742
    read_adr_reg <= read_adr;
743
 
744
always @ (posedge clk2 or posedge rst2)
745
if (rst2)
746
    read_enable_reg <= {nr_of_queues{1'b0}};
747
else
748
    if (read_adr)
749
        read_enable_reg <= read_enable;
750
 
751
 
752
generate
753
    for (i=0;i<nr_of_queues;i=i+1) begin : fifo_adr
754
 
755
        gray_counter wadrcnt (
756
            .cke(write & write_enable[i]),
757
            .q(fifo_wadr_gray[i]),
758
            .q_bin(fifo_wadr_bin[i]),
759
            .rst(rst1),
760
            .clk(clk1));
761
 
762
        gray_counter radrcnt (
763
            .cke((read_adr_reg | read_data) & read_enable_reg[i]),
764
            .q(fifo_radr_gray[i]),
765
            .q_bin(fifo_radr_bin[i]),
766
            .rst(rst2),
767
            .clk(clk2));
768
 
769
        versatile_fifo_async_cmp
770
            #(.ADDR_WIDTH(a_lo_size))
771
            egresscmp (
772
                .wptr(fifo_wadr_gray[i]),
773
                .rptr(fifo_radr_gray[i]),
774
                .fifo_empty(fifo_empty[i]),
775
                .fifo_full(fifo_full[i]),
776
                .wclk(clk1),
777
                .rclk(clk2),
778
                .rst(rst1));
779
 
780
    end
781
endgenerate
782
 
783
// and-or mux write address
784
always @*
785
begin
786
    wadr = {a_lo_size{1'b0}};
787
    for (j=0;j<nr_of_queues;j=j+1) begin
788
        wadr = (fifo_wadr_bin[j] & {a_lo_size{write_enable[j]}}) | wadr;
789
    end
790
end
791
 
792
// and-or mux read address
793
always @*
794
begin
795
    radr = {a_lo_size{1'b0}};
796
    for (k=0;k<nr_of_queues;k=k+1) begin
797
        radr = (fifo_radr_bin[k] & {a_lo_size{read_enable_reg[k]}}) | radr;
798
    end
799
end
800
 
801
// and-or mux write data
802
generate
803
    for (i=0;i<nr_of_queues;i=i+1) begin : vector2array
804
        assign wdataa[i] = d[(nr_of_queues-i)*data_width-1:(nr_of_queues-1-i)*data_width];
805
    end
806
endgenerate
807
 
808
always @*
809
begin
810
    wdata = {data_width{1'b0}};
811
    for (l=0;l<nr_of_queues;l=l+1) begin
812
        wdata = (wdataa[l] & {data_width{write_enable[l]}}) | wdata;
813
    end
814
end
815
 
816
 
817
 
818
vfifo_dual_port_ram_dc_sw
819
  # (
820
      .DATA_WIDTH(data_width),
821
      .ADDR_WIDTH(a_hi_size+a_lo_size)
822
      )
823
    dpram (
824
    .d_a(wdata),
825
    .adr_a({onehot2bin(write_enable),wadr}),
826
    .we_a(write),
827
    .clk_a(clk1),
828
    .q_b(fifo_q),
829
    .adr_b({onehot2bin(read_enable_reg),radr}),
830
    .clk_b(clk2) );
831
 
832
   // Added registering of FIFO output to break a timing path
833
   always@(posedge clk2)
834
     q <= fifo_q;
835
 
836
 
837
endmodule
838
 
839
 
840
 
841
 
842
 
843
 
844
 
845
 
846
 
847
 
848
 
849
 
850
 
851
 
852
 
853
 
854
 
855
 
856
 
857
 
858
 
859
 
860
 
861
 
862
 
863
 
864
 
865
 
866
 
867
 
868
 
869
 
870
 
871
 
872
 
873
 
874
 
875
 
876
 
877
 
878
 
879
 
880
 
881
 
882
 
883
 
884
 
885
 
886
 
887
 
888
 
889
 
890
 
891
 
892
 
893
 
894
 
895
 
896
 
897
 
898
 
899
 
900
 
901
 
902
 
903
 
904
 
905
 
906
 
907
 
908
 
909
 
910
 
911
 
912
 
913
 
914
 
915
 
916
 
917
 
918
 
919
 
920
 
921
 
922
 
923
 
924
 
925
 
926
 
927
 
928
 
929
 
930
 
931
 
932
 
933
 
934
 
935
 
936
 
937
 
938
 
939
 
940
 
941
 
942
 
943
 
944
 
945
 
946
 
947
 
948
 
949
 
950
 
951
 
952
 
953
 
954
 
955
 
956
 
957
 
958
 
959
 
960
 
961
 
962
 
963
 
964
 
965
 
966
 
967
 
968
 
969
 
970
 
971
 
972
 
973
 
974
 
975
 
976
 
977
 
978
 
979
 
980
 
981
 
982
 
983
 
984
 
985
 
986
 
987
 
988
 
989
 
990
 
991
 
992
 
993
 
994
 
995
 
996
 
997
 
998
 
999
 
1000
 
1001
 
1002
 
1003
 
1004
 
1005
 
1006
 
1007
 
1008
 
1009
 
1010
 
1011
 
1012
 
1013
 
1014
 
1015
 
1016
 
1017
 
1018
 
1019
 
1020
 
1021
 
1022
 
1023
 
1024
 
1025
 
1026
 
1027
 
1028
 
1029
 
1030
 
1031
 
1032
 
1033
 
1034
 
1035
 
1036
 
1037
 
1038
 
1039
 
1040
 
1041
 
1042
 
1043
 
1044
 
1045
`line 365 "egress_fifo.v" 0
1046
 // !`ifdef ORIGINAL_EGRESS_FIFO
1047
`line 366 "egress_fifo.v" 2
1048
`line 1 "versatile_fifo_dual_port_ram_dc_sw.v" 1
1049
// true dual port RAM, sync
1050
 
1051
 
1052
 
1053
 
1054
`line 5 "versatile_fifo_dual_port_ram_dc_sw.v" 0
1055
 
1056
module vfifo_dual_port_ram_dc_sw
1057
  (
1058
   d_a,
1059
   adr_a,
1060
   we_a,
1061
   clk_a,
1062
   q_b,
1063
   adr_b,
1064
   clk_b
1065
   );
1066
   parameter DATA_WIDTH = 32;
1067
   parameter ADDR_WIDTH = 8;
1068
   input [(DATA_WIDTH-1):0]      d_a;
1069
   input [(ADDR_WIDTH-1):0]       adr_a;
1070
   input [(ADDR_WIDTH-1):0]       adr_b;
1071
   input                         we_a;
1072
   output [(DATA_WIDTH-1):0]      q_b;
1073
   input                         clk_a, clk_b;
1074
   reg [(ADDR_WIDTH-1):0]         adr_b_reg;
1075 411 julius
   reg [DATA_WIDTH-1:0] ram [(1<<ADDR_WIDTH)-1:0] /*synthesis syn_ramstyle = "no_rw_check"*/;
1076 408 julius
   always @ (posedge clk_a)
1077
   if (we_a)
1078
     ram[adr_a] <= d_a;
1079
   always @ (posedge clk_b)
1080
   adr_b_reg <= adr_b;
1081
   assign q_b = ram[adr_b_reg];
1082
endmodule
1083
`line 33 "versatile_fifo_dual_port_ram_dc_sw.v" 2
1084
`line 1 "dff_sr.v" 1
1085
//////////////////////////////////////////////////////////////////////
1086
////                                                              ////
1087
////  Versatile counter                                           ////
1088
////                                                              ////
1089
////  Description                                                 ////
1090
////  Versatile counter, a reconfigurable binary, gray or LFSR    ////
1091
////  counter                                                     ////
1092
////                                                              ////
1093
////  To Do:                                                      ////
1094
////   - add LFSR with more taps                                  ////
1095
////                                                              ////
1096
////  Author(s):                                                  ////
1097
////      - Michael Unneback, unneback@opencores.org              ////
1098
////        ORSoC AB                                              ////
1099
////                                                              ////
1100
//////////////////////////////////////////////////////////////////////
1101
////                                                              ////
1102
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 ////
1103
////                                                              ////
1104
//// This source file may be used and distributed without         ////
1105
//// restriction provided that this copyright statement is not    ////
1106
//// removed from the file and that any derivative work contains  ////
1107
//// the original copyright notice and the associated disclaimer. ////
1108
////                                                              ////
1109
//// This source file is free software; you can redistribute it   ////
1110
//// and/or modify it under the terms of the GNU Lesser General   ////
1111
//// Public License as published by the Free Software Foundation; ////
1112
//// either version 2.1 of the License, or (at your option) any   ////
1113
//// later version.                                               ////
1114
////                                                              ////
1115
//// This source is distributed in the hope that it will be       ////
1116
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
1117
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
1118
//// PURPOSE.  See the GNU Lesser General Public License for more ////
1119
//// details.                                                     ////
1120
////                                                              ////
1121
//// You should have received a copy of the GNU Lesser General    ////
1122
//// Public License along with this source; if not, download it   ////
1123
//// from http://www.opencores.org/lgpl.shtml                     ////
1124
////                                                              ////
1125
//////////////////////////////////////////////////////////////////////
1126
 
1127
module dff_sr ( aclr, aset, clock, data, q);
1128
 
1129
    input         aclr;
1130
    input         aset;
1131
    input         clock;
1132
    input         data;
1133
    output reg    q;
1134
 
1135
   always @ (posedge clock or posedge aclr or posedge aset)
1136
     if (aclr)
1137
       q <= 1'b0;
1138
     else if (aset)
1139
       q <= 1'b1;
1140
     else
1141
       q <= data;
1142
 
1143
endmodule
1144
`line 60 "dff_sr.v" 2
1145
`line 1 "ref_counter.v" 1
1146
//////////////////////////////////////////////////////////////////////
1147
////                                                              ////
1148
////  Versatile counter                                           ////
1149
////                                                              ////
1150
////  Description                                                 ////
1151
////  Versatile counter, a reconfigurable binary, gray or LFSR    ////
1152
////  counter                                                     ////
1153
////                                                              ////
1154
////  To Do:                                                      ////
1155
////   - add LFSR with more taps                                  ////
1156
////                                                              ////
1157
////  Author(s):                                                  ////
1158
////      - Michael Unneback, unneback@opencores.org              ////
1159
////        ORSoC AB                                              ////
1160
////                                                              ////
1161
//////////////////////////////////////////////////////////////////////
1162
////                                                              ////
1163
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 ////
1164
////                                                              ////
1165
//// This source file may be used and distributed without         ////
1166
//// restriction provided that this copyright statement is not    ////
1167
//// removed from the file and that any derivative work contains  ////
1168
//// the original copyright notice and the associated disclaimer. ////
1169
////                                                              ////
1170
//// This source file is free software; you can redistribute it   ////
1171
//// and/or modify it under the terms of the GNU Lesser General   ////
1172
//// Public License as published by the Free Software Foundation; ////
1173
//// either version 2.1 of the License, or (at your option) any   ////
1174
//// later version.                                               ////
1175
////                                                              ////
1176
//// This source is distributed in the hope that it will be       ////
1177
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
1178
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
1179
//// PURPOSE.  See the GNU Lesser General Public License for more ////
1180
//// details.                                                     ////
1181
////                                                              ////
1182
//// You should have received a copy of the GNU Lesser General    ////
1183
//// Public License along with this source; if not, download it   ////
1184
//// from http://www.opencores.org/lgpl.shtml                     ////
1185
////                                                              ////
1186
//////////////////////////////////////////////////////////////////////
1187
 
1188
// LFSR counter
1189
module ref_counter ( zq, rst, clk);
1190
 
1191
   parameter length = 10;
1192
   output reg zq;
1193
   input rst;
1194
   input clk;
1195
 
1196
   parameter clear_value = 0;
1197
   parameter set_value = 0;
1198
   parameter wrap_value = 417;
1199
 
1200
   reg  [length:1] qi;
1201
   reg lfsr_fb;
1202
   wire [length:1] q_next;
1203
   reg [32:1] polynom;
1204
   integer i;
1205
 
1206
   always @ (qi)
1207
   begin
1208
        case (length)
1209
         2: polynom = 32'b11;                               // 0x3
1210
         3: polynom = 32'b110;                              // 0x6
1211
         4: polynom = 32'b1100;                             // 0xC
1212
         5: polynom = 32'b10100;                            // 0x14
1213
         6: polynom = 32'b110000;                           // 0x30
1214
         7: polynom = 32'b1100000;                          // 0x60
1215
         8: polynom = 32'b10111000;                         // 0xb8
1216
         9: polynom = 32'b100010000;                        // 0x110
1217
        10: polynom = 32'b1001000000;                       // 0x240
1218
        11: polynom = 32'b10100000000;                      // 0x500
1219
        12: polynom = 32'b100000101001;                     // 0x829
1220
        13: polynom = 32'b1000000001100;                    // 0x100C
1221
        14: polynom = 32'b10000000010101;                   // 0x2015
1222
        15: polynom = 32'b110000000000000;                  // 0x6000
1223
        16: polynom = 32'b1101000000001000;                 // 0xD008
1224
        17: polynom = 32'b10010000000000000;                // 0x12000
1225
        18: polynom = 32'b100000010000000000;               // 0x20400
1226
        19: polynom = 32'b1000000000000100011;              // 0x40023
1227
        20: polynom = 32'b10000010000000000000;             // 0x82000
1228
        21: polynom = 32'b101000000000000000000;            // 0x140000
1229
        22: polynom = 32'b1100000000000000000000;           // 0x300000
1230
        23: polynom = 32'b10000100000000000000000;          // 0x420000
1231
        24: polynom = 32'b111000010000000000000000;         // 0xE10000
1232
        25: polynom = 32'b1001000000000000000000000;        // 0x1200000
1233
        26: polynom = 32'b10000000000000000000100011;       // 0x2000023
1234
        27: polynom = 32'b100000000000000000000010011;      // 0x4000013
1235
        28: polynom = 32'b1100100000000000000000000000;     // 0xC800000
1236
        29: polynom = 32'b10100000000000000000000000000;    // 0x14000000
1237
        30: polynom = 32'b100000000000000000000000101001;   // 0x20000029
1238
        31: polynom = 32'b1001000000000000000000000000000;  // 0x48000000
1239
        32: polynom = 32'b10000000001000000000000000000011; // 0x80200003
1240
        default: polynom = 32'b0;
1241
        endcase
1242
        lfsr_fb = qi[length];
1243
        for (i=length-1; i>=1; i=i-1) begin
1244
            if (polynom[i])
1245
                lfsr_fb = lfsr_fb  ~^ qi[i];
1246
        end
1247
    end
1248
   assign q_next = (qi == wrap_value) ? {length{1'b0}} :{qi[length-1:1],lfsr_fb};
1249
 
1250
   always @ (posedge clk or posedge rst)
1251
     if (rst)
1252
       qi <= {length{1'b0}};
1253
     else
1254
       qi <= q_next;
1255
 
1256
 
1257
 
1258
   always @ (posedge clk or posedge rst)
1259
     if (rst)
1260
       zq <= 1'b1;
1261
     else
1262
       zq <= q_next == {length{1'b0}};
1263
endmodule
1264
`line 119 "ref_counter.v" 2
1265
`line 1 "fsm_sdr_16.v" 1
1266
`timescale 1ns/1ns
1267
 
1268
`line 2 "fsm_sdr_16.v" 0
1269
`line 1 "sdr_16_defines.v" 1
1270
//
1271
// Specify either type of memory
1272
// or
1273
// BA_SIZE, ROW_SIZE, COL_SIZE and SDRAM_DATA_WIDTH
1274
//
1275
// either in this file or as command line option; +define+MT48LC16M16
1276
//
1277
 
1278
// Most of these defines have an effect on things in fsm_sdr_16.v
1279
 
1280
//`define MT48LC32M16   // 64MB part
1281
 // 32MB part
1282
//`define MT48LC4M16    //  8MB part
1283
 
1284
// Define this to allow indication that a burst read is still going
1285
// to the wishbone state machine, so it doesn't start emptying the
1286
// ingress fifo after a aborted burst before the burst read is
1287
// actually finished.
1288
 
1289
 
1290
// If intending to burst write, and the wishbone clock is about 1/4 the speed
1291
// of the SDRAM clock, then the data may come late, and this triggers a bug
1292
// during write. To avoid this we can just wait a little longer for data when
1293
// burst reading (there's no almost_empty signal from the FIFO)
1294
 
1295
 
1296
 
1297
 
1298
 
1299
 
1300
 
1301
 
1302
 
1303
 
1304
 
1305
 
1306
 
1307
`line 37 "sdr_16_defines.v" 0
1308
 //  `ifdef MT48LC16M16
1309
 
1310
 
1311
// using 1 of MT48LC16M16
1312
// SDRAM data width is 16
1313
 
1314
 
1315
 
1316
 
1317
 
1318
 
1319
 //  `ifdef MT48LC16M16
1320
 
1321
 
1322
 
1323
 
1324
 
1325
 
1326
 
1327
 
1328
 
1329
 
1330
 
1331
`line 59 "sdr_16_defines.v" 0
1332
 //  `ifdef MT48LC4M16
1333
 
1334
// LMR
1335
// [12:10] reserved
1336
// [9]     WB, write burst; 0 - programmed burst length, 1 - single location
1337
// [8:7]   OP Mode, 2'b00
1338
// [6:4]   CAS Latency; 3'b010 - 2, 3'b011 - 3
1339
// [3]     BT, Burst Type; 1'b0 - sequential, 1'b1 - interleaved
1340
// [2:0]   Burst length; 3'b000 - 1, 3'b001 - 2, 3'b010 - 4, 3'b011 - 8, 3'b111 - full page
1341
 
1342
 
1343
 
1344
 
1345
`line 72 "sdr_16_defines.v" 2
1346
`line 2 "fsm_sdr_16.v" 0
1347
 
1348
module fsm_sdr_16 (
1349
                   adr_i, we_i, bte_i, cti_i, sel_i,
1350
                   fifo_empty, fifo_rd_adr, fifo_rd_data, count0,
1351
                   refresh_req, cmd_aref, cmd_read, state_idle,
1352
                   ba, a, cmd, dqm, dq_oe,
1353
                   sdram_burst_reading,
1354
                   debug_state, debug_fifo_we_record,
1355
                   sdram_clk, sdram_fifo_wr, sdram_rst
1356
                   );
1357
 
1358
   /* Now these are defined
1359
    parameter ba_size = 2;
1360
    parameter row_size = 13;
1361
    parameter col_size = 9;
1362
    */
1363
 
1364
   input [2+13+9-1:0] adr_i;
1365
   input                                 we_i;
1366
   input [1:0]                            bte_i;
1367
   input [2:0]                            cti_i;
1368
   input [3:0]                            sel_i;
1369
 
1370
   input                                 fifo_empty;
1371
   output                                fifo_rd_adr, fifo_rd_data;
1372
   output reg                            count0;
1373
 
1374
   input                                 refresh_req;
1375
   output reg                            cmd_aref; // used for rerfresh ack
1376
   output reg                            cmd_read; // used for ingress fifo control
1377
   output                                state_idle; // state=idle
1378
 
1379
   output reg [1:0]                       ba /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
1380
   output reg [12:0]                      a /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
1381
   output reg [2:0]                       cmd /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
1382
   output reg [1:0]                       dqm /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
1383
   output reg                            dq_oe;
1384
 
1385
   output                                sdram_burst_reading;
1386
   input                                 sdram_clk, sdram_fifo_wr, sdram_rst;
1387
 
1388
   output [2:0]                   debug_state;
1389
   output [3:0]                   debug_fifo_we_record;
1390
 
1391
   wire [2-1:0]                   bank;
1392
   wire [13-1:0]                          row;
1393
   wire [9-1:0]                   col;
1394
   wire [12:0]                            col_reg_a10_fix;
1395
   reg [0:31]                             shreg;
1396
   wire                                  stall; // active if write burst need data
1397
 
1398
   reg [0:15]                             fifo_sel_reg_int;
1399
   reg [1:0]                              fifo_sel_domain_reg_int;
1400
 
1401
   // adr_reg {ba,row,col,we}
1402
   reg [1:0]                              ba_reg;
1403
   reg [13-1:0]                   row_reg;
1404
   reg [9-1:0]                    col_reg;
1405
   reg                                   we_reg;
1406
   reg [1:0]                              bte_reg;
1407
   reg [2:0]                              cti_reg;
1408
 
1409
   // to keep track of open rows per bank
1410
   reg [13-1:0]                   open_row[0:3];
1411
   reg [0:3]                              open_ba;
1412
   wire                                  current_bank_closed, current_row_open;
1413
   reg                                   current_bank_closed_reg, current_row_open_reg;
1414
 
1415
   parameter [2:0] classic=3'b000,
1416
                constant=3'b001,
1417
                increment=3'b010,
1418
                endburst=3'b111;
1419
 
1420
   parameter [1:0] linear = 2'b00,
1421
                beat4  = 2'b01,
1422
                beat8  = 2'b10,
1423
                beat16 = 2'b11;
1424
 
1425
   parameter [2:0] cmd_nop = 3'b111,
1426
                cmd_act = 3'b011,
1427
                cmd_rd  = 3'b101,
1428
                cmd_wr  = 3'b100,
1429
                cmd_pch = 3'b010,
1430
                cmd_rfr = 3'b001,
1431
                cmd_lmr = 3'b000;
1432
 
1433
   // ctrl FSM
1434
 
1435
/*    define instead of param, as synplify is doing weird things
1436
 parameter [2:0] init = 3'b000,
1437
                idle = 3'b001,
1438
                rfr  = 3'b010,
1439
                adr  = 3'b011,
1440
                pch  = 3'b100,
1441
                act  = 3'b101,
1442
                w4d  = 3'b110,
1443
                rw   = 3'b111;
1444
 */
1445
 
1446
 
1447
 
1448
 
1449
 
1450
 
1451
 
1452
 
1453
 
1454
   reg [2:0]                              state, next;
1455
 
1456
   assign debug_state = state;
1457
 
1458
   function [12:0] a10_fix;
1459
      input [9-1:0]               a;
1460
      integer                            i;
1461
      begin
1462
         for (i=0;i<13;i=i+1) begin
1463
            if (i<10)
1464
              if (i<9)
1465
                a10_fix[i] = a[i];
1466
              else
1467
                a10_fix[i] = 1'b0;
1468
            else if (i==10)
1469
              a10_fix[i] = 1'b0;
1470
            else
1471
              if (i<9)
1472
                a10_fix[i] = a[i-1];
1473
              else
1474
                a10_fix[i] = 1'b0;
1475
         end
1476
      end
1477
   endfunction
1478
 
1479
 
1480
   assign {bank,row,col} = adr_i;
1481
 
1482
   always @ (posedge sdram_clk or posedge sdram_rst)
1483
     if (sdram_rst)
1484
       state <= 3'b000;
1485
     else
1486
       state <= next;
1487
 
1488
   always @*
1489
     begin
1490
        next = 3'bx;
1491
        case (state)
1492
          3'b000:
1493
            if (shreg[31])
1494
              next = 3'b001;
1495
            else
1496
              next = 3'b000;
1497
          3'b001:
1498
            if (refresh_req)
1499
              next = 3'b010;
1500
            else if (!shreg[0] & !fifo_empty)
1501
              next = 3'b011;
1502
            else
1503
              next = 3'b001;
1504
          3'b010:
1505
            if (shreg[5])
1506
              next = 3'b001;
1507
            else
1508
              next = 3'b010;
1509
          3'b011:
1510
            if (shreg[5])
1511
              begin
1512
                 if (current_bank_closed_reg)
1513
                   next = 3'b101;
1514
                 else if (current_row_open_reg)
1515
                   next = (we_reg) ?  3'b110 : 3'b111;
1516
                 else
1517
                   next = 3'b100;
1518
              end
1519
            else
1520
              next = 3'b011;
1521
          3'b100:
1522
            if (shreg[1])
1523
              next = 3'b101;
1524
            else
1525
              next = 3'b100;
1526
          3'b101:
1527
            if (shreg[2])
1528
              begin
1529
 
1530
                 // Automatiacally go to wait for data if burst writing
1531
                 if ((|bte_reg) & we_reg & cti_reg==increment)
1532
                   next = 3'b110;
1533
                 else if ((!fifo_empty | !we_reg))
1534
                   next = 3'b111;
1535
 
1536
 
1537
 
1538
 
1539
`line 193 "fsm_sdr_16.v" 0
1540
 
1541
                 else if (fifo_empty)
1542
                   next = 3'b110;
1543
              end
1544
            else
1545
              next = 3'b101;
1546
 
1547
          // Add some wait here if bursting and the wishbone clock is slow
1548
          3'b110:
1549
            if (!fifo_empty & ((cti_reg!=increment)|(cti_reg==increment /*& bte_reg==beat4*/  & shreg[14])))
1550
              next = 3'b111;
1551
 
1552
 
1553
 
1554
 
1555
 
1556
`line 208 "fsm_sdr_16.v" 0
1557
 
1558
            else
1559
              next = 3'b110;
1560
          3'b111:
1561
            if ((bte_reg==linear | !(cti_reg==increment)) & shreg[1])
1562
              next = 3'b001;
1563
            else if (bte_reg==beat4 & shreg[7])
1564
              next = 3'b001;
1565
 
1566
 
1567
 
1568
 
1569
`line 219 "fsm_sdr_16.v" 0
1570
 
1571
 
1572
 
1573
 
1574
 
1575
`line 223 "fsm_sdr_16.v" 0
1576
 
1577
            else
1578
              next = 3'b111;
1579
        endcase
1580
     end // always @ *
1581
 
1582
 
1583
   // active if write burst need data
1584
   assign stall = state==3'b111 & next==3'b111 & fifo_empty & count0 & we_reg;
1585
 
1586
   // counter
1587
   always @ (posedge sdram_clk or posedge sdram_rst)
1588
     begin
1589
        if (sdram_rst) begin
1590
           shreg   <= {1'b1,{31{1'b0}}};
1591
           count0  <= 1'b0;
1592
        end else
1593
          if (state!=next) begin
1594
             shreg   <= {1'b1,{31{1'b0}}};
1595
             count0  <= 1'b0;
1596
          end else
1597
            if (~stall) begin
1598
               shreg   <= shreg >> 1;
1599
               count0  <= ~count0;
1600
            end
1601
     end
1602
 
1603
   // ba, a, cmd
1604
   // col_reg_a10 has bit [10] set to zero to disable auto precharge
1605
   assign col_reg_a10_fix = a10_fix(col_reg);
1606
 
1607
   // outputs dependent on state vector
1608
   always @ (posedge sdram_clk or posedge sdram_rst)
1609
     begin
1610
        if (sdram_rst) begin
1611
           {ba,a,cmd} <= {2'b00,13'd0,cmd_nop};
1612
           dqm <= 2'b11;
1613
           cmd_aref <= 1'b0;
1614
           cmd_read <= 1'b0;
1615
           dq_oe <= 1'b0;
1616
           {open_ba,open_row[0],open_row[1],open_row[2],open_row[3]} <=
1617
                                                  {4'b0000,{13*4{1'b0}}};
1618
           {ba_reg,row_reg,col_reg,we_reg,cti_reg,bte_reg} <=
1619
                     {2'b00, {13{1'b0}}, {9{1'b0}}, 1'b0,3'b000, 2'b00 };
1620
        end else begin
1621
           {ba,a,cmd} <= {2'b00,13'd0,cmd_nop};
1622
           dqm <= 2'b11;
1623
           cmd_aref <= 1'b0;
1624
           cmd_read <= 1'b0;
1625
           dq_oe <= 1'b0;
1626
           case (state)
1627
             3'b000:
1628
               if (shreg[3]) begin
1629
                  {ba,a,cmd} <= {2'b00, 13'b0010000000000, cmd_pch};
1630
                  open_ba[ba_reg] <= 1'b0;
1631
               end else if (shreg[7] | shreg[19])
1632
                 {ba,a,cmd,cmd_aref} <= {2'b00, 13'd0, cmd_rfr,1'b1};
1633
               else if (shreg[31])
1634
                 {ba,a,cmd} <=
1635
                  {2'b00,3'b000,1'b0,2'b00,3'b010,1'b0,3'b001, cmd_lmr};
1636
             3'b010:
1637
               if (shreg[0]) begin
1638
                  {ba,a,cmd} <= {2'b00, 13'b0010000000000, cmd_pch};
1639
                  open_ba <= 4'b0000;
1640
               end else if (shreg[2])
1641
                 {ba,a,cmd,cmd_aref} <= {2'b00, 13'd0, cmd_rfr,1'b1};
1642
             3'b011:
1643
               if (shreg[4])
1644
                 {ba_reg,row_reg,col_reg,we_reg,cti_reg,bte_reg} <=
1645
                                                {bank,row,col,we_i,cti_i,bte_i};
1646
             3'b100:
1647
               if (shreg[0]) begin
1648
                  {ba,a,cmd} <= {ba_reg,13'd0,cmd_pch};
1649
                  //open_ba <= 4'b0000;
1650
                  open_ba[ba_reg] <= 1'b0;
1651
               end
1652
             3'b101:
1653
               if (shreg[0]) begin
1654
                  {ba,a,cmd} <= {ba_reg,(13'd0 | row_reg),cmd_act};
1655
                  {open_ba[ba_reg],open_row[ba_reg]} <= {1'b1,row_reg};
1656
               end
1657
             3'b111:
1658
               begin
1659
                  if (we_reg & !count0)
1660
                    cmd <= cmd_wr;
1661
                  else if (!count0)
1662
                    {cmd,cmd_read} <= {cmd_rd,1'b1};
1663
                  else
1664
                    cmd <= cmd_nop;
1665
                  if (we_reg)
1666
                    begin
1667
                       dqm <= count0 ? ~sel_i[1:0] : ~sel_i[3:2];
1668
                    end
1669
                  else
1670
                    dqm <= 2'b00;
1671
                  //if (we_reg)
1672
                  dq_oe <= we_reg;//1'b1;
1673
                  if (!stall)
1674
                    begin
1675
                       if (cti_reg==increment)
1676
                         case (bte_reg)
1677
                           linear: {ba,a} <= {ba_reg,col_reg_a10_fix};
1678
                           beat4:  {ba,a,col_reg[2:0]} <=
1679
                                  {ba_reg,col_reg_a10_fix, col_reg[2:0] + 3'd1};
1680
 
1681
 
1682
 
1683
 
1684
`line 330 "fsm_sdr_16.v" 0
1685
 
1686
 
1687
 
1688
 
1689
 
1690
`line 334 "fsm_sdr_16.v" 0
1691
 
1692
                         endcase // case (bte_reg)
1693
                       else
1694
                         {ba,a} <= {ba_reg,col_reg_a10_fix};
1695
 
1696
                    end // if (!stall)
1697
               end
1698
                           endcase
1699
        end
1700
     end
1701
 
1702
   reg fifo_read_data_en;
1703
   always @(posedge sdram_clk)
1704
     if (sdram_rst)
1705
       fifo_read_data_en <= 1;
1706
     else if (next==3'b111)
1707
       fifo_read_data_en <= ~fifo_read_data_en;
1708
     else
1709
       fifo_read_data_en <= 1;
1710
 
1711
   reg [3:0] beat4_data_read_limiter; // Use this to record how many times we've pulsed fifo_rd_data
1712
   // Only 3 bits, becuase we're looking at when fifo_read_data_en goes low - should only happen 3
1713
   // times for a 4-beat burst
1714
   always @(posedge sdram_clk)
1715
     if (sdram_rst)
1716
       beat4_data_read_limiter <= 0;
1717
     else if(state==3'b011)
1718
       beat4_data_read_limiter <= 0;
1719
     else if (!fifo_read_data_en)
1720
       beat4_data_read_limiter <= {beat4_data_read_limiter[2:0],1'b1};
1721
 
1722
 
1723
 
1724
   // rd_adr goes high when next adr is fetched from sync RAM and during write burst
1725
   assign fifo_rd_adr  = state==3'b011 & shreg[1];
1726
 
1727
   assign fifo_rd_data = (((state!=3'b111 & next==3'b111)|(state==3'b111 & (cti_reg==increment && bte_reg==beat4 & fifo_read_data_en & !(&beat4_data_read_limiter)))) & we_reg & !fifo_empty);
1728
 
1729
   /*
1730
   assign fifo_rd_data = ((state==`FSM_RW & next==`FSM_RW) &
1731
                          we_reg & !count0 & !fifo_empty);
1732
*/
1733
   assign state_idle = (state==3'b001);
1734
 
1735
   // bank and row open ?
1736
   assign current_bank_closed = !(open_ba[bank]);
1737
   assign current_row_open = open_row[bank]==row;
1738
 
1739
   always @ (posedge sdram_clk or posedge sdram_rst)
1740
     if (sdram_rst)
1741
       {current_bank_closed_reg, current_row_open_reg} <= {1'b1, 1'b0};
1742
     else
1743
       //if (state==adr & counter[1:0]==2'b10)
1744
       {current_bank_closed_reg, current_row_open_reg} <=
1745
                                        {current_bank_closed, current_row_open};
1746
 
1747
   // Record the number of write enables going to INGRESS fifo (ie. that we 
1748
   // generate when we're reading) - this makes sure we keep track of when a
1749
   // burst read is in progress, and we can signal the wishbone bus to wait
1750
   // for this data to be put into the FIFO before it'll empty it when it's
1751
   // had a terminated burst transfer.
1752
   reg [3:0] fifo_we_record;
1753
   assign debug_fifo_we_record = fifo_we_record;
1754
   always @(posedge sdram_clk)
1755
     if (sdram_rst)
1756
       fifo_we_record <= 0;
1757
     else if (next==3'b111 & ((state==3'b011)|(state==3'b101)) &
1758
              cti_reg==increment & (bte_reg==beat4) & !we_reg)
1759
       fifo_we_record <= 4'b0001;
1760
     else if (sdram_fifo_wr)
1761
       fifo_we_record <= {fifo_we_record[2:0],1'b0};
1762
 
1763
   assign sdram_burst_reading = |fifo_we_record;
1764
 
1765
 
1766
 
1767
`line 409 "fsm_sdr_16.v" 0
1768
 
1769
 
1770
 
1771
endmodule
1772
`line 413 "fsm_sdr_16.v" 2
1773
`line 1 "versatile_mem_ctrl_wb.v" 1
1774
`timescale 1ns/1ns
1775
module versatile_mem_ctrl_wb
1776
  (
1777
   // wishbone side
1778
   wb_adr_i_v, wb_dat_i_v, wb_dat_o_v,
1779
   wb_stb_i, wb_cyc_i, wb_ack_o,
1780
   wb_clk, wb_rst,
1781
    // SDRAM controller interface
1782
   sdram_dat_o, sdram_fifo_empty, sdram_fifo_rd_adr, sdram_fifo_rd_data, sdram_fifo_re,
1783
   sdram_dat_i, sdram_fifo_wr, sdram_fifo_we, sdram_burst_reading,
1784
   debug_wb_fsm_state, debug_ingress_fifo_empty, debug_egress_fifo_empty,
1785
   sdram_clk, sdram_rst
1786
 
1787
);
1788
 
1789
parameter nr_of_wb_ports = 3;
1790
 
1791
input  [36*nr_of_wb_ports-1:0]  wb_adr_i_v;
1792
input  [36*nr_of_wb_ports-1:0]  wb_dat_i_v;
1793
input  [0:nr_of_wb_ports-1]     wb_stb_i;
1794
input  [0:nr_of_wb_ports-1]     wb_cyc_i;
1795
output [32*nr_of_wb_ports-1:0]  wb_dat_o_v;
1796
output [0:nr_of_wb_ports-1]     wb_ack_o;
1797
input                           wb_clk;
1798
input                           wb_rst;
1799
 
1800
output [35:0]               sdram_dat_o;
1801
output [0:nr_of_wb_ports-1] sdram_fifo_empty;
1802
input                       sdram_fifo_rd_adr, sdram_fifo_rd_data;
1803
input  [0:nr_of_wb_ports-1] sdram_fifo_re;
1804
input  [31:0]               sdram_dat_i;
1805
input                       sdram_fifo_wr;
1806
input  [0:nr_of_wb_ports-1] sdram_fifo_we;
1807
input                       sdram_burst_reading;
1808
input                       sdram_clk;
1809
input                       sdram_rst;
1810
 
1811
   output [(2*nr_of_wb_ports)-1:0] debug_wb_fsm_state;
1812
   output [nr_of_wb_ports-1:0]   debug_ingress_fifo_empty;
1813
   output [nr_of_wb_ports-1:0]   debug_egress_fifo_empty;
1814
 
1815
 
1816
 
1817
parameter linear       = 2'b00;
1818
parameter wrap4        = 2'b01;
1819
parameter wrap8        = 2'b10;
1820
parameter wrap16       = 2'b11;
1821
parameter classic      = 3'b000;
1822
parameter endofburst   = 3'b111;
1823
 
1824
 
1825
 
1826
 
1827
 
1828
parameter idle = 2'b00;
1829
parameter rd   = 2'b01;
1830
parameter wr   = 2'b10;
1831
parameter fe   = 2'b11;
1832
 
1833
reg [1:0] wb_state[0:nr_of_wb_ports-1];
1834
 
1835
wire [35:0] wb_adr_i[0:nr_of_wb_ports-1];
1836
wire [35:0] wb_dat_i[0:nr_of_wb_ports-1];
1837
wire [36*nr_of_wb_ports-1:0] egress_fifo_di;
1838
wire [31:0] wb_dat_o;
1839
 
1840
wire [0:nr_of_wb_ports] stall;
1841
wire [0:nr_of_wb_ports-1] state_idle;
1842
wire [0:nr_of_wb_ports-1] egress_fifo_we,  egress_fifo_full;
1843
wire [0:nr_of_wb_ports-1] ingress_fifo_re, ingress_fifo_empty;
1844
 
1845
   wire [1:0]              debug_each_wb_fsm_state [0:nr_of_wb_ports-1];
1846
 
1847
 
1848
genvar i;
1849
 
1850
assign stall[0] = 1'b0;
1851
 
1852
 
1853
generate
1854
    for (i=0;i<nr_of_wb_ports;i=i+1) begin : vector2array
1855
        assign wb_adr_i[i] = wb_adr_i_v[(nr_of_wb_ports-i)*36-1:(nr_of_wb_ports-1-i)*36];
1856
        assign wb_dat_i[i] = wb_dat_i_v[(nr_of_wb_ports-i)*36-1:(nr_of_wb_ports-1-i)*36];
1857
        assign egress_fifo_di[(nr_of_wb_ports-i)*36-1:(nr_of_wb_ports-1-i)*36] = (state_idle[i]) ?
1858
                                        wb_adr_i[i] : wb_dat_i[i];
1859
 
1860
    end
1861
endgenerate
1862
 
1863
   // Debug output assignments
1864
   generate
1865
      for (i=0;i<nr_of_wb_ports;i=i+1) begin : vector2debugarray
1866
         assign debug_wb_fsm_state[(nr_of_wb_ports-i)*2-1:(nr_of_wb_ports-1-i)*2] = debug_each_wb_fsm_state[i];
1867
      end
1868
   endgenerate
1869
   assign debug_ingress_fifo_empty = ingress_fifo_empty;
1870
   assign debug_egress_fifo_empty = egress_fifo_we;
1871
 
1872
 
1873
generate
1874
    for (i=0;i<nr_of_wb_ports;i=i+1) begin : fsm
1875
        fsm_wb fsm_wb_i
1876
          (
1877
           .stall_i(stall[i]),
1878
           .stall_o(stall[i+1]),
1879
           .we_i (wb_adr_i[i][5]),
1880
           .cti_i(wb_adr_i[i][2:0]),
1881
           .bte_i(wb_adr_i[i][4:3]),
1882
           .stb_i(wb_stb_i[i]),
1883
           .cyc_i(wb_cyc_i[i]),
1884
           .ack_o(wb_ack_o[i]),
1885
           .egress_fifo_we(egress_fifo_we[i]),
1886
           .egress_fifo_full(egress_fifo_full[i]),
1887
            .ingress_fifo_re(ingress_fifo_re[i]),
1888
           .ingress_fifo_empty(ingress_fifo_empty[i]),
1889
           .state_idle(state_idle[i]),
1890
           .sdram_burst_reading(sdram_burst_reading),
1891
           .debug_state(debug_each_wb_fsm_state[i]),
1892
           .wb_clk(wb_clk),
1893
           .wb_rst(wb_rst)
1894
           );
1895
    end
1896
endgenerate
1897
 
1898
egress_fifo # (
1899
               .a_hi_size(4),.a_lo_size(4),.nr_of_queues(nr_of_wb_ports),
1900
               .data_width(36))
1901
   egress_FIFO(
1902
               .d(egress_fifo_di),
1903
               .fifo_full(egress_fifo_full),
1904
               .write(|(egress_fifo_we)),
1905
               .write_enable(egress_fifo_we),
1906
               .q(sdram_dat_o),
1907
               .fifo_empty(sdram_fifo_empty),
1908
               .read_adr(sdram_fifo_rd_adr),
1909
               .read_data(sdram_fifo_rd_data),
1910
               .read_enable(sdram_fifo_re),
1911
               .clk1(wb_clk),
1912
               .rst1(wb_rst),
1913
               .clk2(sdram_clk),
1914
               .rst2(sdram_rst)
1915
               );
1916
 
1917
   async_fifo_mq # (
1918
                    .a_hi_size(4),.a_lo_size(4),.nr_of_queues(nr_of_wb_ports),
1919
                    .data_width(32))
1920
   ingress_FIFO(
1921
                .d(sdram_dat_i), .fifo_full(), .write(sdram_fifo_wr),
1922
                .write_enable(sdram_fifo_we), .q(wb_dat_o),
1923
                .fifo_empty(ingress_fifo_empty), .read(|(ingress_fifo_re)),
1924
                .read_enable(ingress_fifo_re), .clk1(sdram_clk),
1925
                .rst1(sdram_rst), .clk2(wb_clk), .rst2(wb_rst)
1926
                );
1927
 
1928
assign wb_dat_o_v = {nr_of_wb_ports{wb_dat_o}};
1929
 
1930
endmodule
1931
`line 157 "versatile_mem_ctrl_wb.v" 2
1932
`line 1 "versatile_mem_ctrl_top.v" 1
1933
`timescale 1ns/1ns
1934
 
1935
 
1936
 
1937
`line 4 "versatile_mem_ctrl_top.v" 0
1938
 
1939
 
1940
 
1941
`line 6 "versatile_mem_ctrl_top.v" 0
1942
`line 1 "sdr_16_defines.v" 1
1943
//
1944
// Specify either type of memory
1945
// or
1946
// BA_SIZE, ROW_SIZE, COL_SIZE and SDRAM_DATA_WIDTH
1947
//
1948
// either in this file or as command line option; +define+MT48LC16M16
1949
//
1950
 
1951
// Most of these defines have an effect on things in fsm_sdr_16.v
1952
 
1953
//`define MT48LC32M16   // 64MB part
1954
 // 32MB part
1955
//`define MT48LC4M16    //  8MB part
1956
 
1957
// Define this to allow indication that a burst read is still going
1958
// to the wishbone state machine, so it doesn't start emptying the
1959
// ingress fifo after a aborted burst before the burst read is
1960
// actually finished.
1961
 
1962
 
1963
// If intending to burst write, and the wishbone clock is about 1/4 the speed
1964
// of the SDRAM clock, then the data may come late, and this triggers a bug
1965
// during write. To avoid this we can just wait a little longer for data when
1966
// burst reading (there's no almost_empty signal from the FIFO)
1967
 
1968
 
1969
 
1970
 
1971
 
1972
 
1973
 
1974
 
1975
 
1976
 
1977
 
1978
 
1979
 
1980
`line 37 "sdr_16_defines.v" 0
1981
 //  `ifdef MT48LC16M16
1982
 
1983
 
1984
// using 1 of MT48LC16M16
1985
// SDRAM data width is 16
1986
 
1987
 
1988
 
1989
 
1990
 
1991
 
1992
 //  `ifdef MT48LC16M16
1993
 
1994
 
1995
 
1996
 
1997
 
1998
 
1999
 
2000
 
2001
 
2002
 
2003
 
2004
`line 59 "sdr_16_defines.v" 0
2005
 //  `ifdef MT48LC4M16
2006
 
2007
// LMR
2008
// [12:10] reserved
2009
// [9]     WB, write burst; 0 - programmed burst length, 1 - single location
2010
// [8:7]   OP Mode, 2'b00
2011
// [6:4]   CAS Latency; 3'b010 - 2, 3'b011 - 3
2012
// [3]     BT, Burst Type; 1'b0 - sequential, 1'b1 - interleaved
2013
// [2:0]   Burst length; 3'b000 - 1, 3'b001 - 2, 3'b010 - 4, 3'b011 - 8, 3'b111 - full page
2014
 
2015
 
2016
 
2017
 
2018
`line 72 "sdr_16_defines.v" 2
2019
`line 6 "versatile_mem_ctrl_top.v" 0
2020
 
2021
 
2022
module versatile_mem_ctrl
2023
  (
2024
   // wishbone side
2025
   wb_adr_i_0, wb_dat_i_0, wb_dat_o_0,
2026
   wb_stb_i_0, wb_cyc_i_0, wb_ack_o_0,
2027
   wb_adr_i_1, wb_dat_i_1, wb_dat_o_1,
2028
   wb_stb_i_1, wb_cyc_i_1, wb_ack_o_1,
2029
   wb_adr_i_2, wb_dat_i_2, wb_dat_o_2,
2030
   wb_stb_i_2, wb_cyc_i_2, wb_ack_o_2,
2031
   wb_adr_i_3, wb_dat_i_3, wb_dat_o_3,
2032
   wb_stb_i_3, wb_cyc_i_3, wb_ack_o_3,
2033
   wb_clk, wb_rst,
2034
 
2035
 
2036
   ba_pad_o, a_pad_o, cs_n_pad_o, ras_pad_o, cas_pad_o, we_pad_o, dq_o, dqm_pad_o, dq_i, dq_oe, cke_pad_o,
2037
 
2038
 
2039
 
2040
 
2041
 
2042
 
2043
 
2044
`line 29 "versatile_mem_ctrl_top.v" 0
2045
 
2046
   // SDRAM signals
2047
   sdram_clk, sdram_rst
2048
   );
2049
 
2050
   // number of wb clock domains
2051
   parameter nr_of_wb_clk_domains = 1;
2052
   // number of wb ports in each wb clock domain
2053
   parameter nr_of_wb_ports_clk0  = 3;
2054
   parameter nr_of_wb_ports_clk1  = 0;
2055
   parameter nr_of_wb_ports_clk2  = 0;
2056
   parameter nr_of_wb_ports_clk3  = 0;
2057
 
2058
   input  [36*nr_of_wb_ports_clk0-1:0] wb_adr_i_0;
2059
   input [36*nr_of_wb_ports_clk0-1:0]  wb_dat_i_0;
2060
   output [32*nr_of_wb_ports_clk0-1:0] wb_dat_o_0;
2061
   input [0:nr_of_wb_ports_clk0-1]     wb_stb_i_0, wb_cyc_i_0;
2062
   output [0:nr_of_wb_ports_clk0-1]    wb_ack_o_0;
2063
 
2064
 
2065
   input [36*nr_of_wb_ports_clk1-1:0]  wb_adr_i_1;
2066
   input [36*nr_of_wb_ports_clk1-1:0]  wb_dat_i_1;
2067
   output [32*nr_of_wb_ports_clk1-1:0] wb_dat_o_1;
2068
   input [0:nr_of_wb_ports_clk1-1]     wb_stb_i_1, wb_cyc_i_1;
2069
   output [0:nr_of_wb_ports_clk1-1]    wb_ack_o_1;
2070
 
2071
   input [36*nr_of_wb_ports_clk2-1:0]  wb_adr_i_2;
2072
   input [36*nr_of_wb_ports_clk2-1:0]  wb_dat_i_2;
2073
   output [32*nr_of_wb_ports_clk2-1:0] wb_dat_o_2;
2074
   input [0:nr_of_wb_ports_clk2-1]     wb_stb_i_2, wb_cyc_i_2;
2075
   output [0:nr_of_wb_ports_clk2-1]    wb_ack_o_2;
2076
 
2077
   input [36*nr_of_wb_ports_clk3-1:0]  wb_adr_i_3;
2078
   input [36*nr_of_wb_ports_clk3-1:0]  wb_dat_i_3;
2079
   output [32*nr_of_wb_ports_clk3-1:0] wb_dat_o_3;
2080
   input [0:nr_of_wb_ports_clk3-1]     wb_stb_i_3, wb_cyc_i_3;
2081
   output [0:nr_of_wb_ports_clk3-1]    wb_ack_o_3;
2082
 
2083
   input [0:nr_of_wb_clk_domains-1]    wb_clk;
2084
   input [0:nr_of_wb_clk_domains-1]    wb_rst;
2085
 
2086
 
2087
   output [1:0]                 ba_pad_o;
2088
   output [12:0]                        a_pad_o;
2089
   output                              cs_n_pad_o;
2090
   output                              ras_pad_o;
2091
   output                              cas_pad_o;
2092
   output                              we_pad_o;
2093
   output reg [(16)-1:0] dq_o /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
2094
   output [1:0]                 dqm_pad_o;
2095
   input [(16)-1:0]     dq_i ;
2096
   output                              dq_oe;
2097
   output                              cke_pad_o;
2098
 
2099
 
2100
 
2101
 
2102
 
2103
 
2104
 
2105
 
2106
 
2107
 
2108
 
2109
 
2110
 
2111
 
2112
 
2113
 
2114
 
2115
 
2116
 
2117
 
2118
 
2119
`line 102 "versatile_mem_ctrl_top.v" 0
2120
 
2121
   input                               sdram_clk, sdram_rst;
2122
 
2123
   wire [0:15]                          fifo_empty[0:3];
2124
   wire                                current_fifo_empty;
2125
   wire [0:15]                          fifo_re[0:3];
2126
   wire [35:0]                          fifo_dat_o[0:3];
2127
   wire [31:0]                          fifo_dat_i;
2128
   wire [0:15]                          fifo_we[0:3];
2129
   wire                                fifo_rd_adr, fifo_rd_data, fifo_wr, idle, count0;
2130
 
2131
   wire [0:15]                          fifo_sel_i, fifo_sel_dly;
2132
   reg [0:15]                           fifo_sel_reg;
2133
   wire [1:0]                           fifo_sel_domain_i, fifo_sel_domain_dly;
2134
   reg [1:0]                            fifo_sel_domain_reg;
2135
 
2136
   reg                                 refresh_req;
2137
 
2138
   wire [35:0]                          tx_fifo_dat_o;
2139
 
2140
   wire                                burst_reading;
2141
   reg                                 sdram_fifo_wr_r;
2142
 
2143
 
2144
   generate
2145
      if (nr_of_wb_clk_domains > 0) begin
2146
         versatile_mem_ctrl_wb
2147
           # (.nr_of_wb_ports(nr_of_wb_ports_clk0))
2148
         wb0
2149
           (
2150
            // wishbone side
2151
            .wb_adr_i_v(wb_adr_i_0),
2152
            .wb_dat_i_v(wb_dat_i_0),
2153
            .wb_dat_o_v(wb_dat_o_0),
2154
            .wb_stb_i(wb_stb_i_0),
2155
            .wb_cyc_i(wb_cyc_i_0),
2156
            .wb_ack_o(wb_ack_o_0),
2157
            .wb_clk(wb_clk[0]),
2158
            .wb_rst(wb_rst[0]),
2159
            // SDRAM controller interface
2160
            .sdram_dat_o(fifo_dat_o[0]),
2161
            .sdram_fifo_empty(fifo_empty[0][0:nr_of_wb_ports_clk0-1]),
2162
            .sdram_fifo_rd_adr(fifo_rd_adr),
2163
            .sdram_fifo_rd_data(fifo_rd_data),
2164
            .sdram_fifo_re(fifo_re[0][0:nr_of_wb_ports_clk0-1]),
2165
            .sdram_dat_i(fifo_dat_i),
2166
            .sdram_fifo_wr(fifo_wr),
2167
            .sdram_fifo_we(fifo_we[0][0:nr_of_wb_ports_clk0-1]),
2168
            .sdram_burst_reading(burst_reading),
2169
            .debug_wb_fsm_state(),
2170
            .debug_ingress_fifo_empty(),
2171
            .debug_egress_fifo_empty(),
2172
            .sdram_clk(sdram_clk),
2173
            .sdram_rst(sdram_rst) );
2174
      end
2175
      if (nr_of_wb_ports_clk0 < 16) begin
2176
         assign fifo_empty[0][nr_of_wb_ports_clk0:15] = {(16-nr_of_wb_ports_clk0){1'b1}};
2177
      end
2178
   endgenerate
2179
 
2180
   generate
2181
      if (nr_of_wb_clk_domains > 1) begin
2182
         versatile_mem_ctrl_wb
2183
           # (.nr_of_wb_ports(nr_of_wb_ports_clk1))
2184
         wb1
2185
           (
2186
            // wishbone side
2187
            .wb_adr_i_v(wb_adr_i_1),
2188
            .wb_dat_i_v(wb_dat_i_1),
2189
            .wb_dat_o_v(wb_dat_o_1),
2190
            .wb_stb_i(wb_stb_i_1),
2191
            .wb_cyc_i(wb_cyc_i_1),
2192
            .wb_ack_o(wb_ack_o_1),
2193
            .wb_clk(wb_clk[1]),
2194
            .wb_rst(wb_rst[1]),
2195
            // SDRAM controller interface
2196
            .sdram_dat_o(fifo_dat_o[1]),
2197
            .sdram_fifo_empty(fifo_empty[1][0:nr_of_wb_ports_clk1-1]),
2198
            .sdram_fifo_rd_adr(fifo_rd_adr),
2199
            .sdram_fifo_rd_data(fifo_rd_data),
2200
            .sdram_fifo_re(fifo_re[1][0:nr_of_wb_ports_clk1-1]),
2201
            .sdram_dat_i(fifo_dat_i),
2202
            .sdram_fifo_wr(fifo_wr),
2203
            .sdram_fifo_we(fifo_we[1][0:nr_of_wb_ports_clk1-1]),
2204
            .sdram_burst_reading(burst_reading),
2205
            .sdram_clk(sdram_clk),
2206
            .sdram_rst(sdram_rst) );
2207
         if (nr_of_wb_ports_clk1 < 16) begin
2208
            assign fifo_empty[1][nr_of_wb_ports_clk1:15] = {(16-nr_of_wb_ports_clk1){1'b1}};
2209
         end
2210
      end else begin
2211
         assign fifo_empty[1] = {16{1'b1}};
2212
         assign fifo_dat_o[1] = {36{1'b0}};
2213
      end
2214
   endgenerate
2215
 
2216
   generate
2217
      if (nr_of_wb_clk_domains > 2) begin
2218
         versatile_mem_ctrl_wb
2219
           # (.nr_of_wb_ports(nr_of_wb_ports_clk1))
2220
         wb2
2221
           (
2222
            // wishbone side
2223
            .wb_adr_i_v(wb_adr_i_2),
2224
            .wb_dat_i_v(wb_dat_i_2),
2225
            .wb_dat_o_v(wb_dat_o_2),
2226
            .wb_stb_i(wb_stb_i_2),
2227
            .wb_cyc_i(wb_cyc_i_2),
2228
            .wb_ack_o(wb_ack_o_2),
2229
            .wb_clk(wb_clk[2]),
2230
            .wb_rst(wb_rst[2]),
2231
            // SDRAM controller interface
2232
            .sdram_dat_o(fifo_dat_o[2]),
2233
            .sdram_fifo_empty(fifo_empty[2][0:nr_of_wb_ports_clk2-1]),
2234
            .sdram_fifo_rd_adr(fifo_rd_adr),
2235
            .sdram_fifo_rd_data(fifo_rd_data),
2236
            .sdram_fifo_re(fifo_re[2][0:nr_of_wb_ports_clk2-1]),
2237
            .sdram_dat_i(fifo_dat_i),
2238
            .sdram_fifo_wr(fifo_wr),
2239
            .sdram_fifo_we(fifo_we[2][0:nr_of_wb_ports_clk2-1]),
2240
            .sdram_burst_reading(burst_reading),
2241
            .sdram_clk(sdram_clk),
2242
            .sdram_rst(sdram_rst) );
2243
         if (nr_of_wb_ports_clk2 < 16) begin
2244
            assign fifo_empty[2][nr_of_wb_ports_clk2:15] = {(16-nr_of_wb_ports_clk2){1'b1}};
2245
         end
2246
      end else begin
2247
         assign fifo_empty[2] = {16{1'b1}};
2248
         assign fifo_dat_o[2] = {36{1'b0}};
2249
      end
2250
   endgenerate
2251
 
2252
   generate
2253
      if (nr_of_wb_clk_domains > 3) begin
2254
         versatile_mem_ctrl_wb
2255
           # (.nr_of_wb_ports(nr_of_wb_ports_clk3))
2256
         wb3
2257
           (
2258
            // wishbone side
2259
            .wb_adr_i_v(wb_adr_i_3),
2260
            .wb_dat_i_v(wb_dat_i_3),
2261
            .wb_dat_o_v(wb_dat_o_3),
2262
            .wb_stb_i(wb_stb_i_3),
2263
            .wb_cyc_i(wb_cyc_i_3),
2264
            .wb_ack_o(wb_ack_o_3),
2265
            .wb_clk(wb_clk[3]),
2266
            .wb_rst(wb_rst[3]),
2267
            // SDRAM controller interface
2268
            .sdram_dat_o(fifo_dat_o[3]),
2269
            .sdram_fifo_empty(fifo_empty[3][0:nr_of_wb_ports_clk3-1]),
2270
            .sdram_fifo_rd_adr(fifo_rd_adr),
2271
            .sdram_fifo_rd_data(fifo_rd_data),
2272
            .sdram_fifo_re(fifo_re[3][0:nr_of_wb_ports_clk3-1]),
2273
            .sdram_dat_i(fifo_dat_i),
2274
            .sdram_fifo_wr(fifo_wr),
2275
            .sdram_fifo_we(fifo_we[3][0:nr_of_wb_ports_clk3-1]),
2276
            .sdram_burst_reading(burst_reading),
2277
            .sdram_clk(sdram_clk),
2278
            .sdram_rst(sdram_rst) );
2279
         if (nr_of_wb_ports_clk3 < 16) begin
2280
            assign fifo_empty[3][nr_of_wb_ports_clk3:15] = {(16-nr_of_wb_ports_clk3){1'b1}};
2281
         end
2282
      end else begin
2283
         assign fifo_empty[3] = {16{1'b1}};
2284
         assign fifo_dat_o[3] = {36{1'b0}};
2285
      end
2286
   endgenerate
2287
 
2288
   encode encode0
2289
     (
2290
      .fifo_empty_0(fifo_empty[0]), .fifo_empty_1(fifo_empty[1]),
2291
      .fifo_empty_2(fifo_empty[2]), .fifo_empty_3(fifo_empty[3]),
2292
      .fifo_sel(fifo_sel_i), .fifo_sel_domain(fifo_sel_domain_i)
2293
      );
2294
 
2295
   always @ (posedge sdram_clk or posedge sdram_rst)
2296
     begin
2297
        if (sdram_rst)
2298
          {fifo_sel_reg,fifo_sel_domain_reg} <= {16'h0,2'b00};
2299
        else
2300
          if (idle)
2301
            {fifo_sel_reg,fifo_sel_domain_reg}<={fifo_sel_i,fifo_sel_domain_i};
2302
     end
2303
 
2304
   decode decode0
2305
     (
2306
      .fifo_sel(fifo_sel_reg), .fifo_sel_domain(fifo_sel_domain_reg),
2307
      .fifo_we_0(fifo_re[0]), .fifo_we_1(fifo_re[1]), .fifo_we_2(fifo_re[2]),
2308
      .fifo_we_3(fifo_re[3])
2309
      );
2310
 
2311
   // fifo_re[0-3] is a one-hot read enable structure
2312
   // fifo_empty should go active when chosen fifo queue is empty
2313
   assign current_fifo_empty = (idle) ?
2314
                               (!(|fifo_sel_i)) :
2315
                               (|(fifo_empty[0] & fifo_re[0])) |
2316
                               (|(fifo_empty[1] & fifo_re[1])) |
2317
                               (|(fifo_empty[2] & fifo_re[2])) |
2318
                               (|(fifo_empty[3] & fifo_re[3]));
2319
 
2320
   decode decode1
2321
     (
2322
      .fifo_sel(fifo_sel_dly), .fifo_sel_domain(fifo_sel_domain_dly),
2323
      .fifo_we_0(fifo_we[0]), .fifo_we_1(fifo_we[1]), .fifo_we_2(fifo_we[2]),
2324
      .fifo_we_3(fifo_we[3])
2325
      );
2326
 
2327
 
2328
 
2329
   wire ref_cnt_zero;
2330
   reg [(16)-1:0] dq_i_reg /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
2331
   reg [(16)-1:0] dq_i_tmp_reg;
2332
   reg [17:0] dq_o_tmp_reg;
2333
   wire       cmd_aref, cmd_read;
2334
 
2335
   // refresch counter
2336
   //ref_counter ref_counter0( .zq(ref_cnt_zero), .rst(sdram_rst), .clk(sdram_clk));
2337
   ref_counter
2338
 
2339
 
2340
 
2341
`line 322 "versatile_mem_ctrl_top.v" 0
2342
 
2343
   ref_counter0( .zq(ref_cnt_zero), .rst(sdram_rst), .clk(sdram_clk));
2344
 
2345
   always @ (posedge sdram_clk or posedge sdram_rst)
2346
     if (sdram_rst)
2347
       refresh_req <= 1'b0;
2348
     else
2349
       if (ref_cnt_zero)
2350
         refresh_req <= 1'b1;
2351
       else if (cmd_aref)
2352
         refresh_req <= 1'b0;
2353
 
2354
   reg        current_fifo_empty_r;
2355
   always @(posedge sdram_clk)
2356
     current_fifo_empty_r <= current_fifo_empty;
2357
 
2358
   always @(posedge sdram_clk)
2359
     sdram_fifo_wr_r <= fifo_wr;
2360
 
2361
 
2362
 
2363
   // SDR SDRAM 16 FSM
2364
   fsm_sdr_16 fsm_sdr_16_0
2365
     (
2366
      .adr_i({fifo_dat_o[0][2+13+9+6-2:6],1'b0}),
2367
      .we_i(fifo_dat_o[0][5]),
2368
      .bte_i(fifo_dat_o[0][4:3]),
2369
      .cti_i(fifo_dat_o[0][2:0]),
2370
      .sel_i({fifo_dat_o[0][3:2],dq_o_tmp_reg[1:0]}),
2371
      .fifo_empty(current_fifo_empty_r),
2372
      .fifo_rd_adr(fifo_rd_adr),
2373
      .fifo_rd_data(fifo_rd_data),
2374
      .state_idle(idle),
2375
      .count0(count0),
2376
      .refresh_req(refresh_req),
2377
      .cmd_aref(cmd_aref),
2378
      .cmd_read(cmd_read),
2379
      .ba(ba_pad_o), .a(a_pad_o),
2380
      .cmd({ras_pad_o, cas_pad_o, we_pad_o}),
2381
      .dq_oe(dq_oe),
2382
      .dqm(dqm_pad_o),
2383
      .sdram_fifo_wr(sdram_fifo_wr_r),
2384
      .sdram_burst_reading(burst_reading),
2385
      .debug_state(),
2386
      .debug_fifo_we_record(),
2387
      .sdram_clk(sdram_clk),
2388
      .sdram_rst(sdram_rst)
2389
      );
2390
 
2391
   assign cs_pad_o = 1'b0;
2392
   assign cke_pad_o = 1'b1;
2393
 
2394
   genvar     i;
2395
   generate
2396
      for (i=0; i < 16; i=i+1) begin : dly
2397
 
2398
         defparam delay0.depth=3'b010+2;
2399
         defparam delay0.width=1;
2400
         delay delay0 (
2401
                       .d(fifo_sel_reg[i]),
2402
                       .q(fifo_sel_dly[i]),
2403
                       .clk(sdram_clk),
2404
                       .rst(sdram_rst)
2405
                       );
2406
      end
2407
 
2408
      defparam delay1.depth=3'b010+2;
2409
      defparam delay1.width=2;
2410
      delay delay1 (
2411
                    .d(fifo_sel_domain_reg),
2412
                    .q(fifo_sel_domain_dly),
2413
                    .clk(sdram_clk),
2414
                    .rst(sdram_rst)
2415
                    );
2416
 
2417
      defparam delay2.depth=3'b010+2;
2418
      defparam delay2.width=1;
2419
      delay delay2 (
2420
                    .d(cmd_read),
2421
                    .q(fifo_wr),
2422
                    .clk(sdram_clk),
2423
                    .rst(sdram_rst)
2424
                    );
2425
 
2426
   endgenerate
2427
 
2428
   // output registers
2429
   assign cs_n_pad_o = 1'b0;
2430
   assign cke_pad_o  = 1'b1;
2431
 
2432
   always @ (posedge sdram_clk)
2433
     dq_i_reg <= dq_i;
2434
 
2435
   always @(posedge sdram_clk)
2436
     dq_i_tmp_reg <= dq_i_reg;
2437
 
2438
   assign fifo_dat_i = {dq_i_tmp_reg, dq_i_reg};
2439
 
2440
   always @ (posedge sdram_clk or posedge sdram_rst)
2441
     if (sdram_rst)
2442
       dq_o_tmp_reg <= 18'h0;
2443
     else
2444
       dq_o_tmp_reg <= {fifo_dat_o[0][19:4],fifo_dat_o[0][1:0]};
2445
 
2446
   // output dq_o mux and dffs
2447
   always @ (posedge sdram_clk or posedge sdram_rst)
2448
     if (sdram_rst)
2449
       dq_o <= 16'h0000;
2450
     else
2451
       if (~count0)
2452
         dq_o <= fifo_dat_o[0][35:20];
2453
       else
2454
         dq_o <= dq_o_tmp_reg[17:2];
2455
 
2456
   /*
2457
    // data mask signals should be not(sel_i) for write and 2'b00 for read
2458
    always @ (posedge sdram_clk or posedge sdram_rst)
2459
    if (sdram_rst)
2460
    dqm_pad_o <= 2'b00;
2461
    else
2462
    if (~count0)
2463
    dqm_pad_o <= ~fifo_dat_o[fifo_sel_domain_reg][3:2];
2464
    else
2465
    dqm_pad_o <= ~dq_o_tmp_reg[1:0];
2466
    */
2467
   /*
2468
    always @ (posedge sdram_clk or posedge sdram_rst)
2469
    if (sdram_rst) begin
2470
    {dq_o, dqm_pad_o} <= {16'h0000,2'b00};
2471
 
2472
    end else
2473
    if (~count0) begin
2474
    dq_o <= fifo_dat_o[fifo_sel_domain_reg][35:20];
2475
    dq_o_tmp_reg[17:2] <= fifo_dat_o[fifo_sel_domain_reg][19:4];
2476
    if (cmd_read)
2477
    dqm_pad_o <= 2'b00;
2478
    else
2479
    dqm_pad_o <= ~fifo_dat_o[fifo_sel_domain_reg][3:2];
2480
    if (cmd_read)
2481
    dq_o_tmp_reg[1:0] <= 2'b00;
2482
    else
2483
    dq_o_tmp_reg[1:0] <= ~fifo_dat_o[fifo_sel_domain_reg][1:0];
2484
       end else
2485
    {dq_o,dqm_pad_o} <= dq_o_tmp_reg;
2486
    */
2487
 
2488
 
2489
 //  `ifdef SDR_16
2490
 
2491
 
2492
 
2493
 
2494
 
2495
 
2496
 
2497
 
2498
 
2499
 
2500
 
2501
 
2502
 
2503
 
2504
 
2505
 
2506
 
2507
 
2508
 
2509
 
2510
 
2511
 
2512
 
2513
 
2514
 
2515
 
2516
 
2517
 
2518
 
2519
 
2520
 
2521
 
2522
 
2523
 
2524
 
2525
 
2526
 
2527
 
2528
 
2529
 
2530
 
2531
 
2532
 
2533
 
2534
 
2535
 
2536
 
2537
 
2538
 
2539
 
2540
 
2541
 
2542
 
2543
 
2544
 
2545
 
2546
 
2547
 
2548
 
2549
 
2550
 
2551
 
2552
 
2553
 
2554
 
2555
 
2556
 
2557
 
2558
 
2559
 
2560
 
2561
 
2562
 
2563
 
2564
 
2565
 
2566
 
2567
 
2568
 
2569
 
2570
 
2571
 
2572
 
2573
 
2574
 
2575
 
2576
 
2577
 
2578
 
2579
 
2580
 
2581
 
2582
 
2583
 
2584
 
2585
 
2586
 
2587
 
2588
 
2589
 
2590
 
2591
 
2592
 
2593
 
2594
 
2595
 
2596
 
2597
 
2598
 
2599
 
2600
 
2601
 
2602
 
2603
 
2604
 
2605
 
2606
 
2607
 
2608
 
2609
 
2610
 
2611
 
2612
 
2613
 
2614
 
2615
 
2616
 
2617
 
2618
 
2619
 
2620
 
2621
 
2622
 
2623
 
2624
 
2625
 
2626
 
2627
 
2628
 
2629
 
2630
 
2631
 
2632
 
2633
 
2634
 
2635
 
2636
 
2637
 
2638
 
2639
 
2640
 
2641
 
2642
 
2643
 
2644
 
2645
 
2646
 
2647
 
2648
 
2649
 
2650
 
2651
 
2652
 
2653
 
2654
 
2655
 
2656
 
2657
 
2658
 
2659
 
2660
 
2661
 
2662
 
2663
 
2664
 
2665
 
2666
 
2667
 
2668
 
2669
 
2670
 
2671
 
2672
 
2673
 
2674
 
2675
 
2676
 
2677
 
2678
 
2679
 
2680
 
2681
 
2682
 
2683
 
2684
 
2685
 
2686
 
2687
 
2688
 
2689
 
2690
 
2691
 
2692
 
2693
 
2694
 
2695
 
2696
 
2697
 
2698
 
2699
 
2700
 
2701
 
2702
 
2703
 
2704
 
2705
 
2706
 
2707
 
2708
 
2709
 
2710
 
2711
 
2712
 
2713
 
2714
 
2715
 
2716
 
2717
 
2718
 
2719
 
2720
 
2721
 
2722
 
2723
 
2724
 
2725
 
2726
 
2727
 
2728
 
2729
 
2730
 
2731
 
2732
 
2733
 
2734
 
2735
 
2736
 
2737
 
2738
 
2739
 
2740
 
2741
 
2742
 
2743
 
2744
 
2745
 
2746
 
2747
 
2748
 
2749
 
2750
 
2751
 
2752
 
2753
 
2754
 
2755
 
2756
 
2757
 
2758
 
2759
 
2760
 
2761
 
2762
 
2763
`line 752 "versatile_mem_ctrl_top.v" 0
2764
 //  `ifdef DDR_16
2765
 
2766
endmodule // wb_sdram_ctrl_top
2767
`line 755 "versatile_mem_ctrl_top.v" 2

powered by: WebSVN 2.1.0

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