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

Subversion Repositories mpmc8

[/] [mpmc8/] [trunk/] [rtl/] [mpmc8.sv] - Blame information for rev 6

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

Line No. Rev Author Line
1 2 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2015-2022  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch@finitron.ca
7
//       ||
8
//
9
// BSD 3-Clause License
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are met:
12
//
13
// 1. Redistributions of source code must retain the above copyright notice, this
14
//    list of conditions and the following disclaimer.
15
//
16
// 2. Redistributions in binary form must reproduce the above copyright notice,
17
//    this list of conditions and the following disclaimer in the documentation
18
//    and/or other materials provided with the distribution.
19
//
20
// 3. Neither the name of the copyright holder nor the names of its
21
//    contributors may be used to endorse or promote products derived from
22
//    this software without specific prior written permission.
23
//
24
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
//
35
// 5000 LUTs, 28 BRAM
36
// ============================================================================
37
//
38
//`define RED_SCREEN    1'b1
39
import mpmc8_pkg::*;
40
 
41
module mpmc8(
42
rst_i, clk100MHz,
43
clk0, cyc0, stb0, ack0, we0, sel0, adr0, dati0, dato0,
44
clk1, cs1, cyc1, stb1, ack1, we1, sel1, adr1, dati1, dato1, sr1, cr1, rb1,
45
clk2, cyc2, stb2, ack2, we2, sel2, adr2, dati2, dato2,
46
clk3, cyc3, stb3, ack3, we3, sel3, adr3, dati3, dato3,
47
clk4, cyc4, stb4, ack4, we4, sel4, adr4, dati4, dato4,
48
clk5, cyc5, stb5, ack5, sel5, adr5, dato5, spriteno,
49
clk6, cyc6, stb6, ack6, we6, sel6, adr6, dati6, dato6,
50
clk7, cs7, cyc7, stb7, ack7, we7, sel7, adr7, dati7, dato7, sr7, cr7, rb7,
51
mem_ui_rst, mem_ui_clk, calib_complete,
52
rstn, app_addr, app_cmd, app_en, app_wdf_data, app_wdf_end, app_wdf_mask, app_wdf_wren,
53
app_rd_data, app_rd_data_valid, app_rd_data_end, app_rdy, app_wdf_rdy,
54
ch, state
55
);
56
input rst_i;
57
input clk100MHz;
58
 
59
// Channel 0 is reserved for bitmapped graphics display.
60
//
61
parameter C0W = 128;    // Channel zero width
62
parameter STREAM0 = TRUE;
63
parameter STRIPS0 = 3'd7;
64
input clk0;
65
input cyc0;
66
input stb0;
67
output ack0;
68
input [C0W/8-1:0] sel0;
69
input we0;
70
input [31:0] adr0;
71
input [C0W-1:0] dati0;
72
output reg [C0W-1:0] dato0;
73
reg [C0W-1:0] dato0n;
74
 
75
// Channel 1 is reserved for cpu1
76
parameter C1W = 128;
77
parameter STREAM1 = FALSE;
78
parameter STRIPS1 = 3'd0;
79
input clk1;
80
input cs1;
81
input cyc1;
82
input stb1;
83
output ack1;
84
input we1;
85
input [C1W/8-1:0] sel1;
86
input [31:0] adr1;
87
input [C1W-1:0] dati1;
88
output reg [C1W-1:0] dato1;
89
input sr1;
90
input cr1;
91
output rb1;
92
 
93
// Channel 2 is reserved for the ethernet controller
94
parameter C2W = 32;
95
parameter STREAM2 = FALSE;
96
parameter STRIPS2 = 3'd0;
97
input clk2;
98
input cyc2;
99
input stb2;
100
output ack2;
101
input we2;
102
input [C2W/8-1:0] sel2;
103
input [31:0] adr2;
104
input [C2W-1:0] dati2;
105
output reg [C2W-1:0] dato2;
106
 
107
// Channel 3 is reserved for the audio controller
108
parameter C3W = 16;
109
parameter STREAM3 = TRUE;
110
parameter STRIPS3 = 3'd0;
111
input clk3;
112
input cyc3;
113
input stb3;
114
output ack3;
115
input we3;
116
input [C3W/8-1:0] sel3;
117
input [31:0] adr3;
118
input [C3W-1:0] dati3;
119
output reg [C3W-1:0] dato3;
120
 
121
// Channel 4 is reserved for the graphics controller
122
parameter C4W = 128;
123
parameter STREAM4 = FALSE;
124
parameter STRIPS4 = 3'd0;
125
input clk4;
126
input cyc4;
127
input stb4;
128
output ack4;
129
input we4;
130
input [C4W/8-1:0] sel4;
131
input [31:0] adr4;
132
input [C4W-1:0] dati4;
133
output reg [C4W-1:0] dato4;
134
 
135
// Channel 5 is reserved for sprite DMA, which is read-only
136
parameter C5W = 64;
137
parameter STREAM5 = TRUE;
138
parameter STRIPS5 = 3'd3;
139
input clk5;
140
input cyc5;
141
input stb5;
142
output ack5;
143
input [C5W/8-1:0] sel5;
144
input [5:0] spriteno;
145
input [31:0] adr5;
146
output reg [C5W-1:0] dato5;
147
 
148
// Channel 6 is reserved for the SD/MMC controller
149
parameter C6W = 128;
150
parameter STREAM6 = FALSE;
151
parameter STRIPS6 = 3'd0;
152
input clk6;
153
input cyc6;
154
input stb6;
155
output ack6;
156
input we6;
157
input [C6W/8-1:0] sel6;
158
input [31:0] adr6;
159
input [C6W-1:0] dati6;
160
output reg [C6W-1:0] dato6;
161
 
162
// Channel 7 is reserved for the cpu
163
parameter C7W = 16;
164
parameter C7R = 16;
165
parameter STREAM7 = FALSE;
166
parameter STRIPS7 = 3'd3;
167
input clk7;
168
input cs7;
169
input cyc7;
170
input stb7;
171
output ack7;
172
input we7;
173
input [C7W/8-1:0] sel7;
174
input [31:0] adr7;
175
input [C7W-1:0] dati7;
176
output reg [C7R-1:0] dato7;
177
input sr7;
178
input cr7;
179
output rb7;
180
 
181
// MIG interface signals
182
input mem_ui_rst;
183
input mem_ui_clk;
184
input calib_complete;
185
output rstn;
186
output [AMSB:0] app_addr;
187
output [2:0] app_cmd;
188
output reg app_en;
189
output reg [127:0] app_wdf_data;
190
output [15:0] app_wdf_mask;
191
output app_wdf_end;
192
output app_wdf_wren;
193
input [127:0] app_rd_data;
194
input app_rd_data_valid;
195
input app_rd_data_end;
196
input app_rdy;
197
input app_wdf_rdy;
198
 
199
// Debugging
200
output reg [3:0] ch;
201
output [3:0] state;
202
 
203
integer n;
204
integer n1;
205
integer n2;
206
 
207
wire [31:0] app_waddr;
208
wire [31:0] adr;
209
wire [127:0] dat128;
210
reg [15:0] wmask;
211
reg [127:0] rmw_data;
212
 
213
reg [3:0] nch;
214
reg [5:0] sreg;
215
reg rstn;
216
reg [5:0] nack_to = 6'd0;
217
reg [5:0] spriteno_r;
218
 
219
wire cs0 = cyc0 && stb0 && adr0[31:29]==3'h0;
220
wire ics1 = cyc1 & stb1 & cs1;
221
wire cs2 = cyc2 && stb2 && adr2[31:29]==3'h0;
222
wire cs3 = cyc3 && stb3 && adr3[31:29]==3'h0;
223
wire cs4 = cyc4 && stb4 && adr4[31:29]==3'h0;
224
wire cs5 = cyc5 && stb5 && adr5[31:29]==3'h0;
225
wire cs6 = cyc6 && stb6 && adr6[31:29]==3'h0;
226
wire ics7 = cyc7 & stb7 & cs7;
227
 
228
reg acki0,acki1,acki2,acki3,acki4,acki5,acki6,acki7;
229
wire do_wr;
230
wire do_wr0;
231
wire do_wr1;
232
wire do_wr2;
233
wire do_wr3;
234
wire do_wr4;
235
wire do_wr5;
236
wire do_wr6;
237
wire do_wr7;
238
 
239
reg [2:0] num_strips;
240
wire [2:0] req_strip_cnt;               // count of requested strips
241
wire [2:0] resp_strip_cnt;              // count of response strips
242
reg [AMSB:0] app_addr;
243
 
244
reg [15:0] refcnt;                              // refreshing not used, its automnatic
245
reg refreq;
246
wire refack;
247
wire [15:0] tocnt;                                      // memory access timeout counter
248
 
249
reg [3:0] resv_ch [0:NAR-1];
250
reg [31:0] resv_adr [0:NAR-1];
251
 
252
// Cross clock domain signals
253
wire cs0xx;
254
wire we0xx;
255
wire [C0W/8-1:0] sel0xx;
256
wire [31:0] adr0xx;
257
wire [C0W-1:0] dati0xx;
258
 
259
wire cs1xx;
260
wire we1xx;
261
wire [15:0] sel1xx;
262
wire [31:0] adr1xx;
263
wire [127:0] dati1xx;
264
wire sr1xx;
265
wire cr1xx;
266
 
267
wire cs2xx;
268
wire we2xx;
269
wire [C2W/8-1:0] sel2xx;
270
wire [31:0] adr2xx;
271
wire [C2W-1:0] dati2xx;
272
 
273
wire cs3xx;
274
wire we3xx;
275
wire [C3W/8-1:0] sel3xx;
276
wire [31:0] adr3xx;
277
wire [C3W-1:0] dati3xx;
278
 
279
wire cs4xx;
280
wire we4xx;
281
wire [C4W/8-1:0] sel4xx;
282
wire [31:0] adr4xx;
283
wire [C4W-1:0] dati4xx;
284
 
285
wire cs5xx;
286
wire we5xx;
287
wire [C5W/8-1:0] sel5xx;
288
wire [31:0] adr5xx;
289
wire [C5W-1:0] dati5xx;
290
wire [5:0] spritenoxx;
291
 
292
wire cs6xx;
293
wire we6xx;
294
wire [C6W/8-1:0] sel6xx;
295
wire [31:0] adr6xx;
296
wire [C6W-1:0] dati6xx;
297
 
298
wire cs7xx;
299
wire we7xx;
300
wire [C7W/8-1:0] sel7xx;
301
wire [31:0] adr7xx;
302
wire [C7W-1:0] dati7xx;
303
wire sr7xx;
304
wire cr7xx;
305
 
306
reg [7:0] to_cnt;
307
 
308
// Terminate the ack signal as soon as the circuit select goes away.
309
assign ack0 = acki0 & cs0;
310
assign ack1 = acki1 & ics1;
311
assign ack2 = acki2 & cs2;
312
assign ack3 = acki3 & cs3;
313
assign ack4 = acki4 & cs4;
314
assign ack5 = acki5 & cs5;
315
assign ack6 = acki6 & cs6;
316
assign ack7 = acki7 & ics7;
317
 
318
wire pre_ack0;
319
wire pre_ack1;
320
wire pre_ack2;
321
wire pre_ack3;
322
wire pre_ack4;
323
wire pre_ack5;
324
wire pre_ack6;
325
wire pre_ack7;
326
 
327
// Used to transition state to IDLE at end of access
328
// We dont transition to idle until a negative edge is seen on ack
329
wire ne_acki0;
330
wire ne_acki1;
331
wire ne_acki2;
332
wire ne_acki3;
333
wire ne_acki4;
334
wire ne_acki5;
335
wire ne_acki6;
336
wire ne_acki7;
337
wire pe_acki0;
338
wire pe_acki1;
339
wire pe_acki2;
340
wire pe_acki3;
341
wire pe_acki4;
342
wire pe_acki5;
343
wire pe_acki6;
344
wire pe_acki7;
345
edge_det ed_acki0 (.rst(rst_i), .clk(mem_ui_clk), .ce(1'b1), .i(acki0), .pe(pe_acki0), .ne(ne_acki0), .ee());
346
edge_det ed_acki1 (.rst(rst_i), .clk(mem_ui_clk), .ce(1'b1), .i(acki1), .pe(pe_acki1), .ne(ne_acki1), .ee());
347
edge_det ed_acki2 (.rst(rst_i), .clk(mem_ui_clk), .ce(1'b1), .i(acki2), .pe(pe_acki2), .ne(ne_acki2), .ee());
348
edge_det ed_acki3 (.rst(rst_i), .clk(mem_ui_clk), .ce(1'b1), .i(acki3), .pe(pe_acki3), .ne(ne_acki3), .ee());
349
edge_det ed_acki4 (.rst(rst_i), .clk(mem_ui_clk), .ce(1'b1), .i(acki4), .pe(pe_acki4), .ne(ne_acki4), .ee());
350
edge_det ed_acki5 (.rst(rst_i), .clk(mem_ui_clk), .ce(1'b1), .i(acki5), .pe(pe_acki5), .ne(ne_acki5), .ee());
351
edge_det ed_acki6 (.rst(rst_i), .clk(mem_ui_clk), .ce(1'b1), .i(acki6), .pe(pe_acki6), .ne(ne_acki6), .ee());
352
edge_det ed_acki7 (.rst(rst_i), .clk(mem_ui_clk), .ce(1'b1), .i(acki7), .pe(pe_acki7), .ne(ne_acki7), .ee());
353
 
354
wire [127:0] ch0_rdat_c, ch0_rdat_s, ch0_rdat;
355
wire [127:0] ch1_rdat, ch1_rdat_c, ch1_rdat_s;
356
wire [127:0] ch2_rdat, ch2_rdat_c, ch2_rdat_s;
357
wire [127:0] ch3_rdat, ch3_rdat_c, ch3_rdat_s;
358
wire [127:0] ch4_rdat, ch4_rdat_c, ch4_rdat_s;
359
wire [127:0] ch5_rdat, ch5_rdat_c, ch5_rdat_s;
360
wire [127:0] ch6_rdat, ch6_rdat_c, ch6_rdat_s;
361
wire [127:0] ch7_rdat, ch7_rdat_c, ch7_rdat_s;
362
reg [127:0] ch0_rdatr;
363
reg [127:0] ch1_rdatr;
364
reg [127:0] ch2_rdatr;
365
reg [127:0] ch3_rdatr;
366
reg [127:0] ch4_rdatr;
367
reg [127:0] ch5_rdatr;
368
reg [127:0] ch6_rdatr;
369
reg [127:0] ch7_rdatr;
370
wire ch0_hit_c, ch0_hit_s;
371
wire ch1_hit_c, ch1_hit_s;
372
wire ch2_hit_c, ch2_hit_s;
373
wire ch3_hit_c, ch3_hit_s;
374
wire ch4_hit_c, ch4_hit_s;
375
wire ch5_hit_c, ch5_hit_s;
376
wire ch6_hit_c, ch6_hit_s;
377
wire ch7_hit_c, ch7_hit_s;
378
wire ch0_hit, ch1_hit, ch2_hit, ch3_hit;
379
wire ch4_hit, ch5_hit, ch6_hit, ch7_hit;
380
 
381
mpmc8_read_cache rc0 (
382
        .rst(rst_i),
383
        .wclk(mem_ui_clk),
384
        .wr(app_rd_data_valid && !(
385
                (STREAM0 && ch==4'd0) ||
386
                (STREAM1 && ch==4'd1) ||
387
                (STREAM2 && ch==4'd2) ||
388
                (STREAM3 && ch==4'd3) ||
389
                (STREAM4 && ch==4'd4) ||
390
                (STREAM5 && ch==4'd5) ||
391
                (STREAM6 && ch==4'd6) ||
392
                (STREAM7 && ch==4'd7)
393
        )),
394
        .wadr({app_waddr[31:4],4'h0}),
395
        .wdat(app_rd_data),
396
        .inv(state==WRITE_DATA0),
397
        .rclk0(STREAM0 ? 1'b0 : clk0),
398
        .radr0(STREAM0 ? 32'h0 : {adr0xx[31:4],4'h0}),
399
        .rdat0(ch0_rdat_c),
400
        .hit0(ch0_hit_c),
401
        .rclk1(STREAM1 ? 1'b0 : mem_ui_clk),
402
        .radr1(STREAM1 ? 32'h0 : {adr1xx[31:4],4'h0}),
403
        .rdat1(ch1_rdat_c),
404
        .hit1(ch1_hit_c),
405
        .rclk2(STREAM2 ? 1'b0 : mem_ui_clk),
406
        .radr2(STREAM2 ? 32'h0 : {adr2xx[31:4],4'h0}),
407
        .rdat2(ch2_rdat_c),
408
        .hit2(ch2_hit_c),
409
        .rclk3(STREAM3 ? 1'b0 : mem_ui_clk),
410
        .radr3(STREAM3 ? 32'h0 : {adr3xx[31:4],4'h0}),
411
        .rdat3(ch3_rdat_c),
412
        .hit3(ch3_hit_c),
413
        .rclk4(STREAM4 ? 1'b0 : mem_ui_clk),
414
        .radr4(STREAM4 ? 32'h0 : {adr4xx[31:4],4'h0}),
415
        .rdat4(ch4_rdat_c),
416
        .hit4(ch4_hit_c),
417
        .rclk5(STREAM5 ? 1'b0 : mem_ui_clk),
418
        .radr5(STREAM5 ? 32'h0 : {adr5xx[31:4],4'h0}),
419
        .rdat5(ch5_rdat_c),
420
        .hit5(ch5_hit_c),
421
        .rclk6(STREAM6 ? 1'b0 : mem_ui_clk),
422
        .radr6(STREAM6 ? 32'h0 : {adr6xx[31:4],4'h0}),
423
        .rdat6(ch6_rdat_c),
424
        .hit6(ch6_hit_c),
425
        .rclk7(STREAM7 ? 1'b0 : mem_ui_clk),
426
        .radr7(STREAM7 ? 32'h0 : {adr7xx[31:4],4'h0}),
427
        .rdat7(ch7_rdat_c),
428
        .hit7(ch7_hit_c)
429
);
430
 
431
mpmc8_strm_read_cache ustrm0
432
(
433
        .rst(rst_i),
434
        .wclk(mem_ui_clk),
435
        .wr(ch==4'd0 && app_rd_data_valid),
436
        .wadr({app_waddr[31:4],4'h0}),
437
        .wdat(app_rd_data),
438
        .inv(1'b0),
439
        .rclk(mem_ui_clk),
440
        .radr({adr0xx[31:4],4'h0}),
441
        .rdat(ch0_rdat_s),
442
        .hit(ch0_hit_s)
443
);
444
 
445
mpmc8_strm_read_cache ustrm1
446
(
447
        .rst(rst_i),
448
        .wclk(mem_ui_clk),
449
        .wr(ch==4'd1 && app_rd_data_valid),
450
        .wadr({app_waddr[31:4],4'h0}),
451
        .wdat(app_rd_data),
452
        .inv(1'b0),
453
        .rclk(mem_ui_clk),
454
        .radr({adr1xx[31:4],4'h0}),
455
        .rdat(ch1_rdat_s),
456
        .hit(ch1_hit_s)
457
);
458
 
459
mpmc8_strm_read_cache ustrm2
460
(
461
        .rst(rst_i),
462
        .wclk(mem_ui_clk),
463
        .wr(ch==4'd2 && app_rd_data_valid),
464
        .wadr({app_waddr[31:4],4'h0}),
465
        .wdat(app_rd_data),
466
        .inv(1'b0),
467
        .rclk(mem_ui_clk),
468
        .radr({adr2xx[31:4],4'h0}),
469
        .rdat(ch2_rdat_s),
470
        .hit(ch2_hit_s)
471
);
472
 
473
mpmc8_strm_read_cache ustrm3
474
(
475
        .rst(rst_i),
476
        .wclk(mem_ui_clk),
477
        .wr(ch==4'd3 && app_rd_data_valid),
478
        .wadr({app_waddr[31:4],4'h0}),
479
        .wdat(app_rd_data),
480
        .inv(1'b0),
481
        .rclk(mem_ui_clk),
482
        .radr({adr3xx[31:4],4'h0}),
483
        .rdat(ch3_rdat_s),
484
        .hit(ch3_hit_s)
485
);
486
 
487
mpmc8_strm_read_cache ustrm4
488
(
489
        .rst(rst_i),
490
        .wclk(mem_ui_clk),
491
        .wr(ch==4'd4 && app_rd_data_valid),
492
        .wadr({app_waddr[31:4],4'h0}),
493
        .wdat(app_rd_data),
494
        .inv(1'b0),
495
        .rclk(mem_ui_clk),
496
        .radr({adr4xx[31:4],4'h0}),
497
        .rdat(ch4_rdat_s),
498
        .hit(ch4_hit_s)
499
);
500
 
501
mpmc8_spr_read_cache usprrc5
502
(
503
        .rst(rst_i),
504
        .wclk(mem_ui_clk),
505
        .spr_num(spriteno[4:0]),
506
        .wr(ch==4'd5 && app_rd_data_valid),
507
        .wadr({app_waddr[31:4],4'h0}),
508
        .wdat(app_rd_data),
509
        .inv(1'b0),
510
        .rclk(mem_ui_clk),
511
        .radr({adr5xx[31:4],4'h0}),
512
        .rdat(ch5_rdat_s),
513
        .hit(ch5_hit_s)
514
);
515
 
516
mpmc8_strm_read_cache ustrm6
517
(
518
        .rst(rst_i),
519
        .wclk(mem_ui_clk),
520
        .wr(ch==4'd6 && app_rd_data_valid),
521
        .wadr({app_waddr[31:4],4'h0}),
522
        .wdat(app_rd_data),
523
        .inv(1'b0),
524
        .rclk(mem_ui_clk),
525
        .radr({adr6xx[31:4],4'h0}),
526
        .rdat(ch6_rdat_s),
527
        .hit(ch6_hit_s)
528
);
529
 
530
mpmc8_strm_read_cache ustrm7
531
(
532
        .rst(rst_i),
533
        .wclk(mem_ui_clk),
534
        .wr(ch==4'd7 && app_rd_data_valid),
535
        .wadr({app_waddr[31:4],4'h0}),
536
        .wdat(app_rd_data),
537
        .inv(1'b0),
538
        .rclk(mem_ui_clk),
539
        .radr({adr7xx[31:4],4'h0}),
540
        .rdat(ch7_rdat_s),
541
        .hit(ch7_hit_s)
542
);
543
 
544
 
545
assign ch0_hit = STREAM0 ? ch0_hit_s : ch0_hit_c;
546
assign ch0_rdat = STREAM0 ? ch0_rdat_s : ch0_rdat_c;
547
assign ch1_hit = STREAM1 ? ch1_hit_s : ch1_hit_c;
548
assign ch1_rdat = STREAM1 ? ch1_rdat_s : ch1_rdat_c;
549
assign ch2_hit = STREAM2 ? ch2_hit_s : ch2_hit_c;
550
assign ch2_rdat = STREAM2 ? ch2_rdat_s : ch2_rdat_c;
551
assign ch3_hit = STREAM3 ? ch3_hit_s : ch3_hit_c;
552
assign ch3_rdat = STREAM3 ? ch3_rdat_s : ch3_rdat_c;
553
assign ch4_hit = STREAM4 ? ch4_hit_s : ch4_hit_c;
554
assign ch4_rdat = STREAM4 ? ch4_rdat_s : ch4_rdat_c;
555
assign ch5_hit = STREAM5 ? ch5_hit_s : ch5_hit_c;
556
assign ch5_rdat = STREAM5 ? ch5_rdat_s : ch5_rdat_c;
557
assign ch6_hit = STREAM6 ? ch6_hit_s : ch6_hit_c;
558
assign ch6_rdat = STREAM6 ? ch6_rdat_s : ch6_rdat_c;
559
assign ch7_hit = STREAM7 ? ch7_hit_s : ch7_hit_c;
560
assign ch7_rdat = STREAM7 ? ch7_rdat_s : ch7_rdat_c;
561
 
562
// Register signals onto mem_ui_clk domain
563
mpmc8_sync #(.W(C0W)) usyn0
564
(
565
        .clk(mem_ui_clk),
566
        .cs_i(cs0),
567
        .we_i(we0),
568
        .sel_i(sel0),
569
        .adr_i(adr0),
570
        .dati_i(dati0),
571
        .sr_i(1'b0),
572
        .cr_i(1'b0),
573
        .cs_o(cs0xx),
574
        .we_o(we0xx),
575
        .sel_o(sel0xx),
576
        .adr_o(adr0xx),
577
        .dati_o(dati0xx),
578
        .sr_o(),
579
        .cr_o()
580
);
581
 
582
mpmc8_sync #(.W(C1W)) usyn1
583
(
584
        .clk(mem_ui_clk),
585
        .cs_i(ics1),
586
        .we_i(we1),
587
        .sel_i(sel1),
588
        .adr_i(adr1),
589
        .dati_i(dati1),
590
        .sr_i(sr1),
591
        .cr_i(cr1),
592
        .cs_o(cs1xx),
593
        .we_o(we1xx),
594
        .sel_o(sel1xx),
595
        .adr_o(adr1xx),
596
        .dati_o(dati1xx),
597
        .sr_o(sr1xx),
598
        .cr_o(cr1xx)
599
);
600
 
601
mpmc8_sync #(.W(C2W)) usyn2
602
(
603
        .clk(mem_ui_clk),
604
        .cs_i(cs2),
605
        .we_i(we2),
606
        .sel_i(sel2),
607
        .adr_i(adr2),
608
        .dati_i(dati2),
609
        .sr_i(1'b0),
610
        .cr_i(1'b0),
611
        .cs_o(cs2xx),
612
        .we_o(we2xx),
613
        .sel_o(sel2xx),
614
        .adr_o(adr2xx),
615
        .dati_o(dati2xx),
616
        .sr_o(),
617
        .cr_o()
618
);
619
 
620
mpmc8_sync #(.W(C3W)) usyn3
621
(
622
        .clk(mem_ui_clk),
623
        .cs_i(cs3),
624
        .we_i(we3),
625
        .sel_i(sel3),
626
        .adr_i(adr3),
627
        .dati_i(dati3),
628
        .sr_i(1'b0),
629
        .cr_i(1'b0),
630
        .cs_o(cs3xx),
631
        .we_o(we3xx),
632
        .sel_o(sel3xx),
633
        .adr_o(adr3xx),
634
        .dati_o(dati3xx),
635
        .sr_o(),
636
        .cr_o()
637
);
638
 
639
mpmc8_sync #(.W(C4W)) usyn4
640
(
641
        .clk(mem_ui_clk),
642
        .cs_i(cs4),
643
        .we_i(we4),
644
        .sel_i(sel4),
645
        .adr_i(adr4),
646
        .dati_i(dati4),
647
        .sr_i(1'b0),
648
        .cr_i(1'b0),
649
        .cs_o(cs4xx),
650
        .we_o(we4xx),
651
        .sel_o(sel4xx),
652
        .adr_o(adr4xx),
653
        .dati_o(dati4xx),
654
        .sr_o(),
655
        .cr_o()
656
);
657
 
658
mpmc8_sync #(.W(C5W)) usyn5
659
(
660
        .clk(mem_ui_clk),
661
        .cs_i(cs5),
662
        .we_i(1'b0),
663
        .sel_i(sel5),
664
        .adr_i(adr5),
665
        .dati_i(dati5),
666
        .sr_i(1'b0),
667
        .cr_i(1'b0),
668
        .cs_o(cs5xx),
669
        .we_o(),
670
        .sel_o(sel5xx),
671
        .adr_o(adr5xx),
672
        .dati_o(dati5xx),
673
        .sr_o(),
674
        .cr_o()
675
);
676
 
677
mpmc8_sync #(.W(C6W)) usyn6
678
(
679
        .clk(mem_ui_clk),
680
        .cs_i(cs6),
681
        .we_i(we6),
682
        .sel_i(sel6),
683
        .adr_i(adr6),
684
        .dati_i(dati6),
685
        .sr_i(1'b0),
686
        .cr_i(1'b0),
687
        .cs_o(cs6xx),
688
        .we_o(we6xx),
689
        .sel_o(sel6xx),
690
        .adr_o(adr6xx),
691
        .dati_o(dati6xx),
692
        .sr_o(),
693
        .cr_o()
694
);
695
 
696
mpmc8_sync #(.W(C7R)) usyn7
697
(
698
        .clk(mem_ui_clk),
699
        .cs_i(cs7),
700
        .we_i(we7),
701
        .sel_i(sel7),
702
        .adr_i(adr7),
703
        .dati_i(dati7),
704
        .sr_i(sr7),
705
        .cr_i(cr7),
706
        .cs_o(cs7xx),
707
        .we_o(we7xx),
708
        .sel_o(sel7xx),
709
        .adr_o(adr7xx),
710
        .dati_o(dati7xx),
711
        .sr_o(sr7xx),
712
        .cr_o(cr7xx)
713
);
714
 
715
reg [19:0] rst_ctr;
716
always @(posedge clk100MHz)
717
if (rst_i)
718
        rst_ctr <= 24'd0;
719
else begin
720
        if (!rst_ctr[15])
721
                rst_ctr <= rst_ctr + 2'd1;
722
        rstn <= rst_ctr[15];
723
end
724
 
725
reg toggle;     // CPU1 / CPU0 priority toggle
726
reg toggle_sr;
727
reg [19:0] resv_to_cnt;
728
reg sr1x,sr7x;
729
reg [127:0] dati128;
730
 
731
// Detect cache hits on read caches
732
// For the sprite channel, reading the 64-bits of a strip not beginning at
733
// a 64-byte aligned paragraph only checks for the 64 bit address adr[5:3].
734
// It's assumed that a 4x128-bit strips were read the by the previous access.
735
// It's also assumed that the strip address won't match because there's more
736
// than one sprite and sprite accesses are essentially random.
737
wire ch0_taghit = cs0xx && !we0xx && ch0_hit;
738
wire ch1_taghit = ics1 && !we1xx && cs1xx && ch1_hit;
739
wire ch2_taghit = !we2xx && cs2xx && ch2_hit;
740
wire ch3_taghit = !we3xx && cs3xx && ch3_hit;
741
wire ch4_taghit = !we4xx && cs4xx && ch4_hit;
742
wire ch5_taghit = cs5xx && ch5_hit;
743
wire ch6_taghit = !we6xx && cs6xx && ch6_hit;
744
wire ch7_taghit = cs7xx && !we7xx && ch7_hit;
745
 
746
always_comb
747
begin
748
        sr1x = FALSE;
749
  if (ch1_taghit)
750
    sr1x = sr1xx;
751
end
752
always_comb
753
begin
754
        sr7x = FALSE;
755
  if (ch7_taghit)
756
    sr7x = sr7xx;
757
end
758
 
759
// Select the channel
760
mpmc8_ch_prioritize uchp1
761
(
762
        .clk(mem_ui_clk),
763
        .state(state),
764
        .cs0(cs0xx),
765
        .cs1(cs1xx),
766
        .cs2(cs2xx),
767
        .cs3(cs3xx),
768
        .cs4(cs4xx),
769
        .cs5(cs5xx),
770
        .cs6(cs6xx),
771
        .cs7(cs7xx),
772
        .we0(we0xx),
773
        .we1(we1xx),
774
        .we2(we2xx),
775
        .we3(we3xx),
776
        .we4(we4xx),
777
        .we5(1'b0),
778
        .we6(we6xx),
779
        .we7(we7xx),
780
        .ch0_taghit(ch0_taghit),
781
        .ch1_taghit(ch1_taghit),
782
        .ch2_taghit(ch2_taghit),
783
        .ch3_taghit(ch3_taghit),
784
        .ch4_taghit(ch4_taghit),
785
        .ch5_taghit(ch5_taghit),
786
        .ch6_taghit(ch6_taghit),
787
        .ch7_taghit(ch7_taghit),
788
        .ch(nch)
789
);
790
 
791
 
792
always_ff @(posedge mem_ui_clk)
793
if (state==IDLE || (state==PRESET1 && do_wr))
794
        ch <= nch;
795
 
796
mpmc8_addr_select
797
#(
798
        .S0(STRIPS0),
799
        .S1(STRIPS1),
800
        .S2(STRIPS2),
801
        .S3(STRIPS3),
802
        .S4(STRIPS4),
803
        .S5(STRIPS5),
804
        .S6(STRIPS6),
805
        .S7(STRIPS7)
806
)
807
uadrs1
808
(
809
        .rst(mem_ui_rst),
810
        .clk(mem_ui_clk),
811
        .state(state),
812
        .ch(nch),
813
        .we0(we0xx),
814
        .we1(we1xx),
815
        .we2(we2xx),
816
        .we3(we3xx),
817
        .we4(we4xx),
818
        .we5(1'b0),
819
        .we6(we6xx),
820
        .we7(we7xx),
821
        .adr0(adr0xx),
822
        .adr1(adr1xx),
823
        .adr2(adr2xx),
824
        .adr3(adr3xx),
825
        .adr4(adr4xx),
826
        .adr5(adr5xx),
827
        .adr6(adr6xx),
828
        .adr7(adr7xx),
829
        .adr(adr)
830
);
831
 
832
wire [2:0] app_addr3;
833
 
834
mpmc8_addr_gen uagen1
835
(
836
        .rst(mem_ui_rst),
837
        .clk(mem_ui_clk),
838
        .state(state),
839
        .rdy(app_rdy),
840
        .num_strips(num_strips),
841
        .strip_cnt(req_strip_cnt),
842
        .addr_base(adr),
843
        .addr({app_addr3,app_addr})
844
);
845
 
846
mpmc8_waddr_gen uwadgen1
847
(
848
        .rst(mem_ui_rst),
849
        .clk(mem_ui_clk),
850
        .state(state),
851
        .valid(app_rd_data_valid),
852
        .num_strips(num_strips),
853
        .strip_cnt(resp_strip_cnt),
854
        .addr_base(adr),
855
        .addr(app_waddr)
856
);
857
 
858
// Setting the write mask
859
reg [15:0] wmask0;
860
reg [15:0] wmask1;
861
reg [15:0] wmask2;
862
reg [15:0] wmask3;
863
reg [15:0] wmask4;
864
reg [15:0] wmask5;
865
reg [15:0] wmask6;
866
reg [15:0] wmask7;
867
 
868
mpmc8_set_write_mask
869
#(
870
        .C0W(C0W),
871
        .C1W(C1W),
872
        .C2W(C2W),
873
        .C3W(C3W),
874
        .C4W(C4W),
875
        .C5W(C5W),
876
        .C6W(C6W),
877
        .C7W(C7W)
878
)
879
uswm1
880
(
881
        .clk(mem_ui_clk),
882
        .state(state),
883
        .we0(we0xx),
884
        .we1(we1xx),
885
        .we2(we2xx),
886
        .we3(we3xx),
887
        .we4(we4xx),
888
        .we5(1'b0),
889
        .we6(we6xx),
890
        .we7(we7xx),
891
        .sel0(sel0xx),
892
        .sel1(sel1xx),
893
        .sel2(sel2xx),
894
        .sel3(sel3xx),
895
        .sel4(sel4xx),
896
        .sel5(sel5xx),
897
        .sel6(sel6xx),
898
        .sel7(sel7xx),
899
        .adr0(adr0xx),
900
        .adr1(adr1xx),
901
        .adr2(adr2xx),
902
        .adr3(adr3xx),
903
        .adr4(adr4xx),
904
        .adr5(adr5xx),
905
        .adr6(adr6xx),
906
        .adr7(adr7xx),
907
        .mask0(wmask0),
908
        .mask1(wmask1),
909
        .mask2(wmask2),
910
        .mask3(wmask3),
911
        .mask4(wmask4),
912
        .mask5(wmask5),
913
        .mask6(wmask6),
914
        .mask7(wmask7)
915
);
916
 
917
// Setting the write data
918
mpmc8_data_select
919
#(
920
        .C0W(C0W),
921
        .C1W(C1W),
922
        .C2W(C2W),
923
        .C3W(C3W),
924
        .C4W(C4W),
925
        .C5W(C5W),
926
        .C6W(C6W),
927
        .C7W(C7W)
928
)
929
uds1
930
(
931
        .clk(mem_ui_clk),
932
        .state(state),
933
        .ch(nch),
934
        .dati0(dati0xx),
935
        .dati1(dati1xx),
936
        .dati2(dati2xx),
937
        .dati3(dati3xx),
938
        .dati4(dati4xx),
939
        .dati5('d0),
940
        .dati6(dati6xx),
941
        .dati7(dati7xx),
942
        .dato(dat128)
943
);
944
 
945
// Setting the data value. Unlike reads there is only a single strip involved.
946
// Force unselected byte lanes to $FF
947
wire [15:0] mem_wdf_mask2;
948
reg [127:0] dat128x;
949
genvar g;
950
generate begin : gMemData
951
        for (g = 0; g < 16; g = g + 1)
952
                always_comb
953
                        if (mem_wdf_mask2[g])
954
                                dat128x[g*8+7:g*8] = 8'hFF;
955
                        else
956
                                dat128x[g*8+7:g*8] = dat128[g*8+7:g*8];
957
end
958
endgenerate
959
 
960
always_ff @(posedge mem_ui_clk)
961
if (mem_ui_rst)
962
  app_wdf_data <= 128'd0;
963
else begin
964
        if (state==PRESET2)
965
                app_wdf_data <= dat128x;
966
        else if (state==WRITE_TRAMP1)
967
                app_wdf_data <= rmw_data;
968
end
969
 
970
generate begin : gRMW
971
for (g = 0; g < 16; g = g + 1) begin
972
        always_ff @(posedge mem_ui_clk)
973
        begin
974
                if (state==WRITE_TRAMP) begin
975
                        if (app_wdf_mask[g])
976
                                rmw_data[g*8+7:g*8] <= app_wdf_data[g*8+7:g*8];
977
                        else
978
                                rmw_data[g*8+7:g*8] <= app_rd_data[g*8+7:g*8];
979
                end
980
        end
981
end
982
end
983
endgenerate
984
 
985
always_ff @(posedge mem_ui_clk)
986
if (state==IDLE)
987
        spriteno_r <= spritenoxx;
988
 
989
// Setting burst length
990
mpmc8_set_num_strips
991
#(
992
        .S0(STRIPS0),
993
        .S1(STRIPS1),
994
        .S2(STRIPS2),
995
        .S3(STRIPS3),
996
        .S4(STRIPS4),
997
        .S5(STRIPS5),
998
        .S6(STRIPS6),
999
        .S7(STRIPS7)
1000
)
1001
usns1
1002
(
1003
        .clk(mem_ui_clk),
1004
        .state(state),
1005
        .ch(nch),
1006
        .we0(we0xx),
1007
        .we1(we1xx),
1008
        .we2(we2xx),
1009
        .we3(we3xx),
1010
        .we4(we4xx),
1011
        .we5(we5xx),
1012
        .we6(we6xx),
1013
        .we7(we7xx),
1014
        .num_strips(num_strips)
1015
);
1016
 
1017
// Setting the data mask. Values are enabled when the data mask is zero.
1018
mpmc8_mask_select umsks1
1019
(
1020
        .rst(mem_ui_rst),
1021
        .clk(mem_ui_clk),
1022
        .state(state),
1023
        .ch(ch),
1024
        .wmask0(wmask0),
1025
        .wmask1(wmask1),
1026
        .wmask2(wmask2),
1027
        .wmask3(wmask3),
1028
        .wmask4(wmask4),
1029
        .wmask5(wmask5),
1030
        .wmask6(wmask6),
1031
        .wmask7(wmask7),
1032
        .mask(app_wdf_mask),
1033
        .mask2(mem_wdf_mask2)
1034
);
1035
 
1036
// Setting output data. Force output data to zero when not selected to allow
1037
// wire-oring the data.
1038
mpmc8_data_output udo1
1039
(
1040
        .clk0(clk0), .cs0(cs0), .adr0(adr0), .ch0_rdat(ch0_rdat), .dato0(dato0),
1041
        .clk1(clk1), .cs1(cs1), .adr1(adr1), .ch1_rdat(ch1_rdat), .dato1(dato1),
1042
        .clk2(clk2), .cs2(cs2), .adr2(adr2), .ch2_rdat(ch2_rdat), .dato2(dato2),
1043
        .clk3(clk3), .cs3(cs3), .adr3(adr3), .ch3_rdat(ch3_rdat), .dato3(dato3),
1044
        .clk4(clk4), .cs4(cs4), .adr4(adr4), .ch4_rdat(ch4_rdat), .dato4(dato4),
1045
        .clk5(clk5), .cs5(cs5), .adr5(adr5), .ch5_rdat(ch5_rdat), .dato5(dato5),
1046
        .clk6(clk6), .cs6(cs6), .adr6(adr6), .ch6_rdat(ch6_rdat), .dato6(dato6),
1047
        .clk7(clk7), .cs7(cs7), .adr7(adr7), .ch7_rdat(ch7_rdat), .dato7(dato7)
1048
);
1049
 
1050
mpmc8_ack_gen #(.N(0)) uackg0
1051
(
1052
        .rst(rst_i|mem_ui_rst),
1053
        .clk(mem_ui_clk),
1054
        .state(state),
1055
        .ch(ch),
1056
        .cs(cs0),
1057
        .adr(adr0xx),
1058
        .cr(1'b0),
1059
        .wr(do_wr),
1060
        .to(tocnt[9]),
1061
        .taghit(ch0_taghit),
1062
        .resv_ch(resv_ch),
1063
        .resv_adr(resv_adr),
1064
        .ack(acki0),
1065
        .pre_ack(pre_ack0)
1066
);
1067
 
1068
mpmc8_ack_gen #(.N(1)) uackg1
1069
(
1070
        .rst(rst_i|mem_ui_rst),
1071
        .clk(mem_ui_clk),
1072
        .state(state),
1073
        .ch(ch),
1074
        .cs(cs1&ics1),
1075
        .adr(adr1xx),
1076
        .cr(cr1xx),
1077
        .wr(do_wr),
1078
        .to(tocnt[9]),
1079
        .taghit(ch1_taghit),
1080
        .resv_ch(resv_ch),
1081
        .resv_adr(resv_adr),
1082
        .ack(acki1),
1083
        .pre_ack(pre_ack1)
1084
);
1085
 
1086
mpmc8_ack_gen #(.N(2)) uackg2
1087
(
1088
        .rst(rst_i|mem_ui_rst),
1089
        .clk(mem_ui_clk),
1090
        .state(state),
1091
        .ch(ch),
1092
        .cs(cs2),
1093
        .adr(adr2xx),
1094
        .cr(1'b0),
1095
        .wr(do_wr),
1096
        .to(tocnt[9]),
1097
        .taghit(ch2_taghit),
1098
        .resv_ch(resv_ch),
1099
        .resv_adr(resv_adr),
1100
        .ack(acki2),
1101
        .pre_ack(pre_ack2)
1102
);
1103
 
1104
mpmc8_ack_gen #(.N(3)) uackg3
1105
(
1106
        .rst(rst_i|mem_ui_rst),
1107
        .clk(mem_ui_clk),
1108
        .state(state),
1109
        .ch(ch),
1110
        .cs(cs3),
1111
        .adr(adr3xx),
1112
        .cr(1'b0),
1113
        .wr(do_wr),
1114
        .to(tocnt[9]),
1115
        .taghit(ch3_taghit),
1116
        .resv_ch(resv_ch),
1117
        .resv_adr(resv_adr),
1118
        .ack(acki3),
1119
        .pre_ack(pre_ack3)
1120
);
1121
 
1122
mpmc8_ack_gen #(.N(4)) uackg4
1123
(
1124
        .rst(rst_i|mem_ui_rst),
1125
        .clk(mem_ui_clk),
1126
        .state(state),
1127
        .ch(ch),
1128
        .cs(cs4),
1129
        .adr(adr4xx),
1130
        .cr(1'b0),
1131
        .wr(do_wr),
1132
        .to(tocnt[9]),
1133
        .taghit(ch4_taghit),
1134
        .resv_ch(resv_ch),
1135
        .resv_adr(resv_adr),
1136
        .ack(acki4),
1137
        .pre_ack(pre_ack4)
1138
);
1139
 
1140
mpmc8_ack_gen #(.N(5)) uackg5
1141
(
1142
        .rst(rst_i|mem_ui_rst),
1143
        .clk(mem_ui_clk),
1144
        .state(state),
1145
        .ch(ch),
1146
        .cs(cs5),
1147
        .adr(adr5xx),
1148
        .cr(1'b0),
1149
        .wr(do_wr),
1150
        .to(tocnt[9]),
1151
        .taghit(ch5_taghit),
1152
        .resv_ch(resv_ch),
1153
        .resv_adr(resv_adr),
1154
        .ack(acki5),
1155
        .pre_ack(pre_ack5)
1156
);
1157
 
1158
mpmc8_ack_gen #(.N(6)) uackg6
1159
(
1160
        .rst(rst_i|mem_ui_rst),
1161
        .clk(mem_ui_clk),
1162
        .state(state),
1163
        .ch(ch),
1164
        .cs(cs6),
1165
        .adr(adr6xx),
1166
        .cr(1'b0),
1167
        .wr(do_wr),
1168
        .to(tocnt[9]),
1169
        .taghit(ch6_taghit),
1170
        .resv_ch(resv_ch),
1171
        .resv_adr(resv_adr),
1172
        .ack(acki6),
1173
        .pre_ack(pre_ack6)
1174
);
1175
 
1176
mpmc8_ack_gen #(.N(7)) uackg7
1177
(
1178
        .rst(rst_i|mem_ui_rst),
1179
        .clk(mem_ui_clk),
1180
        .state(state),
1181
        .ch(ch),
1182
        .cs(ics7),
1183
        .adr(adr7xx),
1184
        .cr(cr7xx),
1185
        .wr(do_wr),
1186
        .to(tocnt[9]),
1187
        .taghit(ch7_taghit),
1188
        .resv_ch(resv_ch),
1189
        .resv_adr(resv_adr),
1190
        .ack(acki7),
1191
        .pre_ack(pre_ack7)
1192
);
1193
 
1194
wire ne_data_valid;
1195
edge_det ued1 (.rst(rst_i), .clk(mem_ui_clk), .ce(1'b1), .i(app_rd_data_valid), .pe(), .ne(ne_data_valid), .ee());
1196
 
1197
mpmc8_state_machine ustmac1
1198
(
1199
        .rst(rst_i|mem_ui_rst),
1200
        .clk(mem_ui_clk),
1201
        .ch(nch),
1202
        .acki0(acki0),
1203
        .acki1(acki1),
1204
        .acki2(acki2),
1205
        .acki3(acki3),
1206
        .acki4(acki4),
1207
        .acki5(acki5),
1208
        .acki6(acki6),
1209
        .acki7(acki7),
1210
        .ch0_taghit(ch0_taghit),
1211
        .ch1_taghit(ch1_taghit),
1212
        .ch2_taghit(ch2_taghit),
1213
        .ch3_taghit(ch3_taghit),
1214
        .ch4_taghit(ch4_taghit),
1215
        .ch5_taghit(ch5_taghit),
1216
        .ch6_taghit(ch6_taghit),
1217
        .ch7_taghit(ch7_taghit),
1218
        .wdf_rdy(app_wdf_rdy),
1219
        .rdy(app_rdy),
1220
        .do_wr(do_wr),
1221
        .rd_data_valid(app_rd_data_valid),
1222
        .num_strips(num_strips),
1223
        .req_strip_cnt(req_strip_cnt),
1224
        .resp_strip_cnt(resp_strip_cnt),
1225
        .to(tocnt[9]),
1226
        .cr1(cr1xx),
1227
        .cr7(cr7xx),
1228
        .adr1(adr1xx),
1229
        .adr7(adr7xx),
1230
        .resv_ch(resv_ch),
1231
        .resv_adr(resv_adr),
1232
        .state(state)
1233
);
1234
 
1235
 
1236
wire [3:0] prev_state;
1237
 
1238
mpmc8_to_cnt utoc1
1239
(
1240
        .clk(mem_ui_clk),
1241
        .state(state),
1242
        .prev_state(prev_state),
1243
        .to_cnt(tocnt)
1244
);
1245
 
1246
mpmc8_prev_state upst1
1247
(
1248
        .clk(mem_ui_clk),
1249
        .state(state),
1250
        .prev_state(prev_state)
1251
);
1252
 
1253
mpmc8_app_en_gen ueng1
1254
(
1255
        .clk(mem_ui_clk),
1256
        .state(state),
1257
        .rdy(app_rdy),
1258
        .strip_cnt(req_strip_cnt),
1259
        .num_strips(num_strips),
1260
        .en(app_en)
1261
);
1262
 
1263
mpmc8_app_cmd_gen ucg1
1264
(
1265
        .clk(mem_ui_clk),
1266
        .state(state),
1267
        .cmd(app_cmd)
1268
);
1269
 
1270
mpmc8_app_wdf_wren_gen uwreng1
1271
(
1272
        .clk(mem_ui_clk),
1273
        .state(state),
1274
        .rdy(app_wdf_rdy),
1275
        .wren(app_wdf_wren)
1276
);
1277
 
1278
mpmc8_app_wdf_end_gen uwendg1
1279
(
1280
        .clk(mem_ui_clk),
1281
        .state(state),
1282
        .rdy(app_wdf_rdy),
1283
        .wend(app_wdf_end)
1284
);
1285
 
1286
mpmc8_req_strip_cnt ursc1
1287
(
1288
        .clk(mem_ui_clk),
1289
        .state(state),
1290
        .wdf_rdy(app_wdf_rdy),
1291
        .rdy(app_rdy),
1292
        .num_strips(num_strips),
1293
        .strip_cnt(req_strip_cnt)
1294
);
1295
 
1296
mpmc8_resp_strip_cnt urespsc1
1297
(
1298
        .clk(mem_ui_clk),
1299
        .state(state),
1300
        .valid(app_rd_data_valid),
1301
        .num_strips(num_strips),
1302
        .strip_cnt(resp_strip_cnt)
1303
);
1304
 
1305
 
1306
mpmc8_do_wr udowr0
1307
(
1308
        .we(we0xx),
1309
        .cr(1'b0),
1310
        .adr(adr0xx),
1311
        .resv_ch(resv_ch),
1312
        .resv_adr(resv_adr),
1313
        .do_wr(do_wr0)
1314
);
1315
 
1316
mpmc8_do_wr udowr1
1317
(
1318
        .we(we1xx),
1319
        .cr(cr1xx),
1320
        .adr(adr1xx),
1321
        .resv_ch(resv_ch),
1322
        .resv_adr(resv_adr),
1323
        .do_wr(do_wr1)
1324
);
1325
 
1326
mpmc8_do_wr udowr2
1327
(
1328
        .we(we2xx),
1329
        .cr(1'b0),
1330
        .adr(adr2xx),
1331
        .resv_ch(resv_ch),
1332
        .resv_adr(resv_adr),
1333
        .do_wr(do_wr2)
1334
);
1335
 
1336
mpmc8_do_wr udowr3
1337
(
1338
        .we(we3xx),
1339
        .cr(1'b0),
1340
        .adr(adr3xx),
1341
        .resv_ch(resv_ch),
1342
        .resv_adr(resv_adr),
1343
        .do_wr(do_wr3)
1344
);
1345
 
1346
mpmc8_do_wr udowr4
1347
(
1348
        .we(we4xx),
1349
        .cr(1'b0),
1350
        .adr(adr4xx),
1351
        .resv_ch(resv_ch),
1352
        .resv_adr(resv_adr),
1353
        .do_wr(do_wr4)
1354
);
1355
 
1356
mpmc8_do_wr udowr5
1357
(
1358
        .we(1'b0),
1359
        .cr(1'b0),
1360
        .adr(adr5xx),
1361
        .resv_ch(resv_ch),
1362
        .resv_adr(resv_adr),
1363
        .do_wr(do_wr5)
1364
);
1365
 
1366
mpmc8_do_wr udowr6
1367
(
1368
        .we(we6xx),
1369
        .cr(1'b0),
1370
        .adr(adr6xx),
1371
        .resv_ch(resv_ch),
1372
        .resv_adr(resv_adr),
1373
        .do_wr(do_wr6)
1374
);
1375
 
1376
mpmc8_do_wr udowr7
1377
(
1378
        .we(we7xx),
1379
        .cr(cr7xx),
1380
        .adr(adr7xx),
1381
        .resv_ch(resv_ch),
1382
        .resv_adr(resv_adr),
1383
        .do_wr(do_wr7)
1384
);
1385
 
1386
mpmc8_do_wr_select udws1
1387
(
1388
        .clk(mem_ui_clk),
1389
        .state(state),
1390
        .ch(nch),
1391
        .wr0(do_wr0),
1392
        .wr1(do_wr1),
1393
        .wr2(do_wr2),
1394
        .wr3(do_wr3),
1395
        .wr4(do_wr4),
1396
        .wr5(do_wr5),
1397
        .wr6(do_wr6),
1398
        .wr7(do_wr7),
1399
        .wr(do_wr)
1400
);
1401
 
1402
// Reservation status bit
1403
mpmc8_resv_bit ursb1
1404
(
1405
        .clk(mem_ui_clk),
1406
        .state(state),
1407
        .cs(cs1xx),
1408
        .we(we1xx),
1409
        .ack(acki1),
1410
        .cr(cr1xx),
1411
        .adr(adr1xx),
1412
        .resv_ch(resv_ch),
1413
        .resv_adr(resv_adr),
1414
        .rb(rb1)
1415
);
1416
 
1417
mpmc8_resv_bit ursb7
1418
(
1419
        .clk(mem_ui_clk),
1420
        .state(state),
1421
        .cs(cs7xx),
1422
        .we(we7xx),
1423
        .ack(acki7),
1424
        .cr(cr7xx),
1425
        .adr(adr7xx),
1426
        .resv_ch(resv_ch),
1427
        .resv_adr(resv_adr),
1428
        .rb(rb7)
1429
);
1430
 
1431
// Managing address reservations
1432
mpmc8_addr_resv_man uarman1
1433
(
1434
        .rst(mem_ui_rst),
1435
        .clk(mem_ui_clk),
1436
        .state(state),
1437
        .cs1(cs1xx),
1438
        .ack1(acki1),
1439
        .we1(we1xx),
1440
        .adr1(adr1xx),
1441
        .sr1(sr1x),
1442
        .cr1(cr1xx),
1443
        .ch1_taghit(ch1_taghit),
1444
        .cs7(cs7xx),
1445
        .ack7(acki7),
1446
        .we7(we7xx),
1447
        .adr7(adr7xx),
1448
        .sr7(sr7x),
1449
        .cr7(cr7xx),
1450
        .ch7_taghit(ch7_taghit),
1451
        .resv_ch(resv_ch),
1452
        .resv_adr(resv_adr)
1453
);
1454
 
1455
endmodule

powered by: WebSVN 2.1.0

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