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

Subversion Repositories warp

[/] [warp/] [rtl/] [tmu.v] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 lekernel
/*
2
 * Milkymist VJ SoC
3
 * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
4
 *
5
 * This program is free and excepted software; you can use it, redistribute it
6
 * and/or modify it under the terms of the Exception General Public License as
7
 * published by the Exception License Foundation; either version 2 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful, but WITHOUT
11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
 * FOR A PARTICULAR PURPOSE. See the Exception General Public License for more
13
 * details.
14
 *
15
 * You should have received a copy of the Exception General Public License along
16
 * with this project; if not, write to the Exception License Foundation.
17
 */
18
 
19
module tmu #(
20
        parameter csr_addr = 4'h0,
21
        parameter fml_depth = 26,
22
        parameter pixin_cache_depth = 12 /* 4kb cache */
23
) (
24
        /* Global clock and reset signals */
25
        input sys_clk,
26
        input sys_rst,
27
 
28
        /* Control interface */
29
        input [13:0] csr_a,
30
        input csr_we,
31
        input [31:0] csr_di,
32
        output [31:0] csr_do,
33
 
34
        output irq,
35
 
36
        /* WB master - Mesh read. */
37
        output [31:0] wbm_adr_o,
38
        output [2:0] wbm_cti_o,
39
        output wbm_cyc_o,
40
        output wbm_stb_o,
41
        input wbm_ack_i,
42
        input [31:0] wbm_dat_i,
43
 
44
        /* FML master - Pixel read. fml_we=0 is assumed. */
45
        output [fml_depth-1:0] fmlr_adr,
46
        output fmlr_stb,
47
        input fmlr_ack,
48
        input [63:0] fmlr_di,
49
 
50
        /* FML master - Pixel write. fml_we=1 is assumed. */
51
        output [fml_depth-1:0] fmlw_adr,
52
        output fmlw_stb,
53
        input fmlw_ack,
54
        output [7:0] fmlw_sel,
55
        output [63:0] fmlw_do
56
);
57
 
58
wire start;
59
reg busy;
60
wire [29:0] mesh_base;
61
wire [6:0] hmesh_count;
62
wire [6:0] hmesh_size;
63
wire [6:0] vmesh_count;
64
wire [6:0] vmesh_size;
65
wire [fml_depth-1-1:0] src_base;
66
wire [10:0] src_hres;
67
wire [10:0] src_vres;
68
wire [fml_depth-1-1:0] dst_base;
69
wire [10:0] dst_hres;
70
wire [10:0] dst_vres;
71
wire [10:0] hoffset;
72
wire [10:0] voffset;
73
wire [5:0] brightness;
74
wire [31:0] perf_pixels;
75
wire [31:0] perf_clocks;
76
wire [31:0] perf_stall1;
77
wire [31:0] perf_complete1;
78
wire [31:0] perf_stall2;
79
wire [31:0] perf_complete2;
80
wire [31:0] perf_misses;
81
 
82
tmu_ctlif #(
83
        .csr_addr(csr_addr),
84
        .fml_depth(fml_depth)
85
) ctlif (
86
        .sys_clk(sys_clk),
87
        .sys_rst(sys_rst),
88
 
89
        .csr_a(csr_a),
90
        .csr_we(csr_we),
91
        .csr_di(csr_di),
92
        .csr_do(csr_do),
93
 
94
        .irq(irq),
95
 
96
        .start(start),
97
        .busy(busy),
98
        .mesh_base(mesh_base),
99
        .hmesh_count(hmesh_count),
100
        .hmesh_size(hmesh_size),
101
        .vmesh_count(vmesh_count),
102
        .vmesh_size(vmesh_size),
103
        .src_base(src_base),
104
        .src_hres(src_hres),
105
        .src_vres(src_vres),
106
        .dst_base(dst_base),
107
        .dst_hres(dst_hres),
108
        .dst_vres(dst_vres),
109
        .hoffset(hoffset),
110
        .voffset(voffset),
111
        .brightness(brightness),
112
 
113
        .perf_pixels(perf_pixels),
114
        .perf_clocks(perf_clocks),
115
        .perf_stall1(perf_stall1),
116
        .perf_complete1(perf_complete1),
117
        .perf_stall2(perf_stall2),
118
        .perf_complete2(perf_complete2),
119
        .perf_misses(perf_misses)
120
);
121
 
122
/* Stage 1 - Fetch vertexes */
123
wire meshgen_busy;
124
wire meshgen_pipe_stb;
125
wire meshgen_pipe_ack;
126
wire [10:0] A0_S_X;
127
wire [10:0] A0_S_Y;
128
wire [10:0] B0_S_X;
129
wire [10:0] B0_S_Y;
130
wire [10:0] C0_S_X;
131
wire [10:0] C0_S_Y;
132
wire [10:0] A0_D_X;
133
wire [10:0] A0_D_Y;
134
wire [10:0] B0_D_X;
135
wire [10:0] B0_D_Y;
136
wire [10:0] C0_D_X;
137
wire [10:0] C0_D_Y;
138
 
139
tmu_meshgen meshgen(
140
        .sys_clk(sys_clk),
141
        .sys_rst(sys_rst),
142
 
143
        .wbm_adr_o(wbm_adr_o),
144
        .wbm_cti_o(wbm_cti_o),
145
        .wbm_cyc_o(wbm_cyc_o),
146
        .wbm_stb_o(wbm_stb_o),
147
        .wbm_ack_i(wbm_ack_i),
148
        .wbm_dat_i(wbm_dat_i),
149
 
150
        .start(start),
151
        .busy(meshgen_busy),
152
 
153
        .mesh_base(mesh_base),
154
        .hmesh_count(hmesh_count),
155
        .hmesh_size(hmesh_size),
156
        .vmesh_count(vmesh_count),
157
        .vmesh_size(vmesh_size),
158
 
159
        .pipe_stb(meshgen_pipe_stb),
160
        .pipe_ack(meshgen_pipe_ack),
161
        .A_S_X(A0_S_X),
162
        .A_S_Y(A0_S_Y),
163
        .B_S_X(B0_S_X),
164
        .B_S_Y(B0_S_Y),
165
        .C_S_X(C0_S_X),
166
        .C_S_Y(C0_S_Y),
167
        .A_D_X(A0_D_X),
168
        .A_D_Y(A0_D_Y),
169
        .B_D_X(B0_D_X),
170
        .B_D_Y(B0_D_Y),
171
        .C_D_X(C0_D_X),
172
        .C_D_Y(C0_D_Y)
173
);
174
 
175
/* Stage 2 - Vertex reordering (A_D_Y <= B_D_Y <= C_D_Y) */
176
wire reorder_busy;
177
wire reorder_pipe_stb;
178
wire reorder_pipe_ack;
179
wire [10:0] A_S_X;
180
wire [10:0] A_S_Y;
181
wire [10:0] B_S_X;
182
wire [10:0] B_S_Y;
183
wire [10:0] C_S_X;
184
wire [10:0] C_S_Y;
185
wire [10:0] A_D_X;
186
wire [10:0] A_D_Y;
187
wire [10:0] B_D_X;
188
wire [10:0] B_D_Y;
189
wire [10:0] C_D_X;
190
wire [10:0] C_D_Y;
191
 
192
tmu_reorder reorder(
193
        .sys_clk(sys_clk),
194
        .sys_rst(sys_rst),
195
 
196
        .busy(reorder_busy),
197
 
198
        .pipe_stb_i(meshgen_pipe_stb),
199
        .pipe_ack_o(meshgen_pipe_ack),
200
        .A0_S_X(A0_S_X),
201
        .A0_S_Y(A0_S_Y),
202
        .B0_S_X(B0_S_X),
203
        .B0_S_Y(B0_S_Y),
204
        .C0_S_X(C0_S_X),
205
        .C0_S_Y(C0_S_Y),
206
        .A0_D_X(A0_D_X),
207
        .A0_D_Y(A0_D_Y),
208
        .B0_D_X(B0_D_X),
209
        .B0_D_Y(B0_D_Y),
210
        .C0_D_X(C0_D_X),
211
        .C0_D_Y(C0_D_Y),
212
 
213
        .pipe_stb_o(reorder_pipe_stb),
214
        .pipe_ack_i(reorder_pipe_ack),
215
        .A_S_X(A_S_X),
216
        .A_S_Y(A_S_Y),
217
        .B_S_X(B_S_X),
218
        .B_S_Y(B_S_Y),
219
        .C_S_X(C_S_X),
220
        .C_S_Y(C_S_Y),
221
        .A_D_X(A_D_X),
222
        .A_D_Y(A_D_Y),
223
        .B_D_X(B_D_X),
224
        .B_D_Y(B_D_Y),
225
        .C_D_X(C_D_X),
226
        .C_D_Y(C_D_Y)
227
);
228
 
229
/* Stage 3 - Compute edge division operands */
230
wire edgedivops_busy;
231
wire edgedivops_pipe_stb;
232
wire edgedivops_pipe_ack;
233
wire [10:0] A1_S_X;
234
wire [10:0] A1_S_Y;
235
wire [10:0] A1_D_X;
236
wire [10:0] A1_D_Y;
237
wire [10:0] B1_D_Y;
238
wire [10:0] C1_D_Y;
239
wire dx10_positive;
240
wire [10:0] dx10;
241
wire dx20_positive;
242
wire [10:0] dx20;
243
wire dx30_positive;
244
wire [10:0] dx30;
245
wire du10_positive;
246
wire [10:0] du10;
247
wire du20_positive;
248
wire [10:0] du20;
249
wire du30_positive;
250
wire [10:0] du30;
251
wire dv10_positive;
252
wire [10:0] dv10;
253
wire dv20_positive;
254
wire [10:0] dv20;
255
wire dv30_positive;
256
wire [10:0] dv30;
257
wire [10:0] divisor10;
258
wire [10:0] divisor20;
259
wire [10:0] divisor30;
260
 
261
tmu_edgedivops edgedivops(
262
        .sys_clk(sys_clk),
263
        .sys_rst(sys_rst),
264
 
265
        .busy(edgedivops_busy),
266
 
267
        .pipe_stb_i(reorder_pipe_stb),
268
        .pipe_ack_o(reorder_pipe_ack),
269
        .A0_S_X(A_S_X),
270
        .A0_S_Y(A_S_Y),
271
        .B0_S_X(B_S_X),
272
        .B0_S_Y(B_S_Y),
273
        .C0_S_X(C_S_X),
274
        .C0_S_Y(C_S_Y),
275
        .A0_D_X(A_D_X),
276
        .A0_D_Y(A_D_Y),
277
        .B0_D_X(B_D_X),
278
        .B0_D_Y(B_D_Y),
279
        .C0_D_X(C_D_X),
280
        .C0_D_Y(C_D_Y),
281
 
282
        .pipe_stb_o(edgedivops_pipe_stb),
283
        .pipe_ack_i(edgedivops_pipe_ack),
284
        .A_S_X(A1_S_X),
285
        .A_S_Y(A1_S_Y),
286
        .A_D_X(A1_D_X),
287
        .A_D_Y(A1_D_Y),
288
        .B_D_Y(B1_D_Y),
289
        .C_D_Y(C1_D_Y),
290
        .dx1_positive(dx10_positive),
291
        .dx1(dx10),
292
        .dx2_positive(dx20_positive),
293
        .dx2(dx20),
294
        .dx3_positive(dx30_positive),
295
        .dx3(dx30),
296
        .du1_positive(du10_positive),
297
        .du1(du10),
298
        .du2_positive(du20_positive),
299
        .du2(du20),
300
        .du3_positive(du30_positive),
301
        .du3(du30),
302
        .dv1_positive(dv10_positive),
303
        .dv1(dv10),
304
        .dv2_positive(dv20_positive),
305
        .dv2(dv20),
306
        .dv3_positive(dv30_positive),
307
        .dv3(dv30),
308
        .divisor1(divisor10),
309
        .divisor2(divisor20),
310
        .divisor3(divisor30)
311
);
312
 
313
/* Stage 4 - Edge division */
314
wire edgediv_busy;
315
wire edgediv_pipe_stb;
316
wire edgediv_pipe_ack;
317
wire [10:0] A2_S_X;
318
wire [10:0] A2_S_Y;
319
wire [10:0] A2_D_X;
320
wire [10:0] A2_D_Y;
321
wire [10:0] B2_D_Y;
322
wire [10:0] C2_D_Y;
323
wire dx1_positive;
324
wire [10:0] dx1_q;
325
wire [10:0] dx1_r;
326
wire dx2_positive;
327
wire [10:0] dx2_q;
328
wire [10:0] dx2_r;
329
wire dx3_positive;
330
wire [10:0] dx3_q;
331
wire [10:0] dx3_r;
332
wire du1_positive;
333
wire [10:0] du1_q;
334
wire [10:0] du1_r;
335
wire du2_positive;
336
wire [10:0] du2_q;
337
wire [10:0] du2_r;
338
wire du3_positive;
339
wire [10:0] du3_q;
340
wire [10:0] du3_r;
341
wire dv1_positive;
342
wire [10:0] dv1_q;
343
wire [10:0] dv1_r;
344
wire dv2_positive;
345
wire [10:0] dv2_q;
346
wire [10:0] dv2_r;
347
wire dv3_positive;
348
wire [10:0] dv3_q;
349
wire [10:0] dv3_r;
350
wire [10:0] divisor1;
351
wire [10:0] divisor2;
352
wire [10:0] divisor3;
353
 
354
tmu_edgediv edgediv(
355
        .sys_clk(sys_clk),
356
        .sys_rst(sys_rst),
357
 
358
        .busy(edgediv_busy),
359
 
360
        .pipe_stb_i(edgedivops_pipe_stb),
361
        .pipe_ack_o(edgedivops_pipe_ack),
362
        .A0_S_X(A1_S_X),
363
        .A0_S_Y(A1_S_Y),
364
        .A0_D_X(A1_D_X),
365
        .A0_D_Y(A1_D_Y),
366
        .B0_D_Y(B1_D_Y),
367
        .C0_D_Y(C1_D_Y),
368
        .dx10_positive(dx10_positive),
369
        .dx10(dx10),
370
        .dx20_positive(dx20_positive),
371
        .dx20(dx20),
372
        .dx30_positive(dx30_positive),
373
        .dx30(dx30),
374
        .du10_positive(du10_positive),
375
        .du10(du10),
376
        .du20_positive(du20_positive),
377
        .du20(du20),
378
        .du30_positive(du30_positive),
379
        .du30(du30),
380
        .dv10_positive(dv10_positive),
381
        .dv10(dv10),
382
        .dv20_positive(dv20_positive),
383
        .dv20(dv20),
384
        .dv30_positive(dv30_positive),
385
        .dv30(dv30),
386
        .divisor10(divisor10),
387
        .divisor20(divisor20),
388
        .divisor30(divisor30),
389
 
390
        .pipe_stb_o(edgediv_pipe_stb),
391
        .pipe_ack_i(edgediv_pipe_ack),
392
        .A_S_X(A2_S_X),
393
        .A_S_Y(A2_S_Y),
394
        .A_D_X(A2_D_X),
395
        .A_D_Y(A2_D_Y),
396
        .B_D_Y(B2_D_Y),
397
        .C_D_Y(C2_D_Y),
398
        .dx1_positive(dx1_positive),
399
        .dx1_q(dx1_q),
400
        .dx1_r(dx1_r),
401
        .dx2_positive(dx2_positive),
402
        .dx2_q(dx2_q),
403
        .dx2_r(dx2_r),
404
        .dx3_positive(dx3_positive),
405
        .dx3_q(dx3_q),
406
        .dx3_r(dx3_r),
407
        .du1_positive(du1_positive),
408
        .du1_q(du1_q),
409
        .du1_r(du1_r),
410
        .du2_positive(du2_positive),
411
        .du2_q(du2_q),
412
        .du2_r(du2_r),
413
        .du3_positive(du3_positive),
414
        .du3_q(du3_q),
415
        .du3_r(du3_r),
416
        .dv1_positive(dv1_positive),
417
        .dv1_q(dv1_q),
418
        .dv1_r(dv1_r),
419
        .dv2_positive(dv2_positive),
420
        .dv2_q(dv2_q),
421
        .dv2_r(dv2_r),
422
        .dv3_positive(dv3_positive),
423
        .dv3_q(dv3_q),
424
        .dv3_r(dv3_r),
425
        .divisor1(divisor1),
426
        .divisor2(divisor2),
427
        .divisor3(divisor3)
428
);
429
 
430
/* Stage 5 - Edge trace */
431
wire edgetrace_busy;
432
wire edgetrace_pipe_stb;
433
wire edgetrace_pipe_ack;
434
wire [10:0] Y0;
435
wire [10:0] S_X0;
436
wire [10:0] S_U0;
437
wire [10:0] S_V0;
438
wire [10:0] E_X0;
439
wire [10:0] E_U0;
440
wire [10:0] E_V0;
441
 
442
tmu_edgetrace edgetrace(
443
        .sys_clk(sys_clk),
444
        .sys_rst(sys_rst),
445
 
446
        .busy(edgetrace_busy),
447
 
448
        .pipe_stb_i(edgediv_pipe_stb),
449
        .pipe_ack_o(edgediv_pipe_ack),
450
        .A_S_X(A2_S_X),
451
        .A_S_Y(A2_S_Y),
452
        .A_D_X(A2_D_X),
453
        .A_D_Y(A2_D_Y),
454
        .B_D_Y(B2_D_Y),
455
        .C_D_Y(C2_D_Y),
456
        .dx1_positive(dx1_positive),
457
        .dx1_q(dx1_q),
458
        .dx1_r(dx1_r),
459
        .dx2_positive(dx2_positive),
460
        .dx2_q(dx2_q),
461
        .dx2_r(dx2_r),
462
        .dx3_positive(dx3_positive),
463
        .dx3_q(dx3_q),
464
        .dx3_r(dx3_r),
465
        .du1_positive(du1_positive),
466
        .du1_q(du1_q),
467
        .du1_r(du1_r),
468
        .du2_positive(du2_positive),
469
        .du2_q(du2_q),
470
        .du2_r(du2_r),
471
        .du3_positive(du3_positive),
472
        .du3_q(du3_q),
473
        .du3_r(du3_r),
474
        .dv1_positive(dv1_positive),
475
        .dv1_q(dv1_q),
476
        .dv1_r(dv1_r),
477
        .dv2_positive(dv2_positive),
478
        .dv2_q(dv2_q),
479
        .dv2_r(dv2_r),
480
        .dv3_positive(dv3_positive),
481
        .dv3_q(dv3_q),
482
        .dv3_r(dv3_r),
483
        .divisor1(divisor1),
484
        .divisor2(divisor2),
485
        .divisor3(divisor3),
486
 
487
        .pipe_stb_o(edgetrace_pipe_stb),
488
        .pipe_ack_i(edgetrace_pipe_ack),
489
        .Y(Y0),
490
        .S_X(S_X0),
491
        .S_U(S_U0),
492
        .S_V(S_V0),
493
        .E_X(E_X0),
494
        .E_U(E_U0),
495
        .E_V(E_V0)
496
);
497
 
498
/* Stage 6 - Compute scanline division operands */
499
wire scandivops_busy;
500
wire scandivops_pipe_stb;
501
wire scandivops_pipe_ack;
502
wire [10:0] Y;
503
wire [10:0] S_X;
504
wire [10:0] S_U;
505
wire [10:0] S_V;
506
wire [10:0] E_X;
507
wire du0_positive;
508
wire [10:0] du0;
509
wire dv0_positive;
510
wire [10:0] dv0;
511
wire [10:0] divisor0;
512
 
513
tmu_scandivops scandivops(
514
        .sys_clk(sys_clk),
515
        .sys_rst(sys_rst),
516
 
517
        .busy(scandivops_busy),
518
 
519
        .pipe_stb_i(edgetrace_pipe_stb),
520
        .pipe_ack_o(edgetrace_pipe_ack),
521
        .Y0(Y0),
522
        .S_X0(S_X0),
523
        .S_U0(S_U0),
524
        .S_V0(S_V0),
525
        .E_X0(E_X0),
526
        .E_U0(E_U0),
527
        .E_V0(E_V0),
528
 
529
        .pipe_stb_o(scandivops_pipe_stb),
530
        .pipe_ack_i(scandivops_pipe_ack),
531
        .Y(Y),
532
        .S_X(S_X),
533
        .S_U(S_U),
534
        .S_V(S_V),
535
        .E_X(E_X),
536
        .du_positive(du0_positive),
537
        .du(du0),
538
        .dv_positive(dv0_positive),
539
        .dv(dv0),
540
        .divisor(divisor0)
541
);
542
 
543
/* Stage 7 - Scanline division */
544
wire scandiv_busy;
545
wire scandiv_pipe_stb;
546
wire scandiv_pipe_ack;
547
wire [10:0] Y1;
548
wire [10:0] S_X1;
549
wire [10:0] S_U1;
550
wire [10:0] S_V1;
551
wire [10:0] E_X1;
552
wire du_positive;
553
wire [10:0] du_q;
554
wire [10:0] du_r;
555
wire dv_positive;
556
wire [10:0] dv_q;
557
wire [10:0] dv_r;
558
wire [10:0] divisor;
559
 
560
tmu_scandiv scandiv(
561
        .sys_clk(sys_clk),
562
        .sys_rst(sys_rst),
563
 
564
        .busy(scandiv_busy),
565
 
566
        .pipe_stb_i(scandivops_pipe_stb),
567
        .pipe_ack_o(scandivops_pipe_ack),
568
        .Y0(Y),
569
        .S_X0(S_X),
570
        .S_U0(S_U),
571
        .S_V0(S_V),
572
        .E_X0(E_X),
573
        .du0_positive(du0_positive),
574
        .du0(du0),
575
        .dv0_positive(dv0_positive),
576
        .dv0(dv0),
577
        .divisor0(divisor0),
578
 
579
        .pipe_stb_o(scandiv_pipe_stb),
580
        .pipe_ack_i(scandiv_pipe_ack),
581
        .Y(Y1),
582
        .S_X(S_X1),
583
        .S_U(S_U1),
584
        .S_V(S_V1),
585
        .E_X(E_X1),
586
        .du_positive(du_positive),
587
        .du_q(du_q),
588
        .du_r(du_r),
589
        .dv_positive(dv_positive),
590
        .dv_q(dv_q),
591
        .dv_r(dv_r),
592
        .divisor(divisor)
593
);
594
 
595
/* Stage 8 - Scanline trace */
596
wire scantrace_busy;
597
wire scantrace_pipe_stb;
598
wire scantrace_pipe_ack;
599
wire [10:0] P_X;
600
wire [10:0] P_Y;
601
wire [10:0] P_U;
602
wire [10:0] P_V;
603
 
604
tmu_scantrace scantrace(
605
        .sys_clk(sys_clk),
606
        .sys_rst(sys_rst),
607
 
608
        .busy(scantrace_busy),
609
 
610
        .pipe_stb_i(scandiv_pipe_stb),
611
        .pipe_ack_o(scandiv_pipe_ack),
612
        .Y(Y1),
613
        .S_X(S_X1),
614
        .S_U(S_U1),
615
        .S_V(S_V1),
616
        .E_X(E_X1),
617
        .du_positive(du_positive),
618
        .du_q(du_q),
619
        .du_r(du_r),
620
        .dv_positive(dv_positive),
621
        .dv_q(dv_q),
622
        .dv_r(dv_r),
623
        .divisor(divisor),
624
 
625
        .pipe_stb_o(scantrace_pipe_stb),
626
        .pipe_ack_i(scantrace_pipe_ack),
627
        .P_X(P_X),
628
        .P_Y(P_Y),
629
        .P_U(P_U),
630
        .P_V(P_V)
631
);
632
 
633
/* Stage 9 - Filter out off-screen points */
634
wire filter_busy;
635
wire filter_pipe_stb;
636
wire filter_pipe_ack;
637
wire [10:0] P_Xf;
638
wire [10:0] P_Yf;
639
wire [10:0] P_Uf;
640
wire [10:0] P_Vf;
641
 
642
tmu_filter filter(
643
        .sys_clk(sys_clk),
644
        .sys_rst(sys_rst),
645
 
646
        .busy(filter_busy),
647
 
648
        .src_hres(src_hres),
649
        .src_vres(src_vres),
650
        .dst_hres(dst_hres),
651
        .dst_vres(dst_vres),
652
        .hoffset(hoffset),
653
        .voffset(voffset),
654
 
655
        .pipe_stb_i(scantrace_pipe_stb),
656
        .pipe_ack_o(scantrace_pipe_ack),
657
        .P_X(P_X),
658
        .P_Y(P_Y),
659
        .P_U(P_U),
660
        .P_V(P_V),
661
 
662
        .pipe_stb_o(filter_pipe_stb),
663
        .pipe_ack_i(filter_pipe_ack),
664
        .P_Xf(P_Xf),
665
        .P_Yf(P_Yf),
666
        .P_Uf(P_Uf),
667
        .P_Vf(P_Vf)
668
);
669
 
670
/* Stage 10 - Compute memory addresses */
671
wire addresses_busy;
672
wire addresses_pipe_stb;
673
wire addresses_pipe_ack;
674
wire [fml_depth-1-1:0] src_addr;
675
wire [fml_depth-1-1:0] dst_addr;
676
 
677
tmu_addresses #(
678
        .fml_depth(fml_depth)
679
) addresses (
680
        .sys_clk(sys_clk),
681
        .sys_rst(sys_rst),
682
 
683
        .busy(addresses_busy),
684
 
685
        .src_base(src_base),
686
        .src_hres(src_hres),
687
        .dst_base(dst_base),
688
        .dst_hres(dst_hres),
689
 
690
        .pipe_stb_i(filter_pipe_stb),
691
        .pipe_ack_o(filter_pipe_ack),
692
        .P_X(P_Xf),
693
        .P_Y(P_Yf),
694
        .P_U(P_Uf),
695
        .P_V(P_Vf),
696
 
697
        .pipe_stb_o(addresses_pipe_stb),
698
        .pipe_ack_i(addresses_pipe_ack),
699
        .src_addr(src_addr),
700
        .dst_addr(dst_addr)
701
);
702
 
703
/* Stage 11 - Pixel input */
704
wire pixin_busy;
705
wire pixin_pipe_stb;
706
wire pixin_pipe_ack;
707
wire [15:0] src_pixel;
708
wire [fml_depth-1-1:0] dst_addr1;
709
wire inc_misses;
710
 
711
tmu_pixin #(
712
        .fml_depth(fml_depth),
713
        .cache_depth(pixin_cache_depth)
714
) pixin (
715
        .sys_clk(sys_clk),
716
        .sys_rst(sys_rst),
717
 
718
        .fml_adr(fmlr_adr),
719
        .fml_stb(fmlr_stb),
720
        .fml_ack(fmlr_ack),
721
        .fml_di(fmlr_di),
722
 
723
        .flush(start),
724
        .busy(pixin_busy),
725
 
726
        .pipe_stb_i(addresses_pipe_stb),
727
        .pipe_ack_o(addresses_pipe_ack),
728
        .src_addr(src_addr),
729
        .dst_addr(dst_addr),
730
 
731
        .pipe_stb_o(pixin_pipe_stb),
732
        .pipe_ack_i(pixin_pipe_ack),
733
        .src_pixel(src_pixel),
734
        .dst_addr1(dst_addr1),
735
 
736
        .inc_misses(inc_misses)
737
);
738
 
739
/* Stage 12 - Apply decay effect */
740
wire decay_busy;
741
wire decay_pipe_stb;
742
wire decay_pipe_ack;
743
wire [15:0] src_pixel_d;
744
wire [fml_depth-1-1:0] dst_addr2;
745
 
746
tmu_decay #(
747
        .fml_depth(fml_depth)
748
) decay (
749
        .sys_clk(sys_clk),
750
        .sys_rst(sys_rst),
751
 
752
        .busy(decay_busy),
753
 
754
        .brightness(brightness),
755
 
756
        .pipe_stb_i(pixin_pipe_stb),
757
        .pipe_ack_o(pixin_pipe_ack),
758
        .src_pixel(src_pixel),
759
        .dst_addr(dst_addr1),
760
 
761
        .pipe_stb_o(decay_pipe_stb),
762
        .pipe_ack_i(decay_pipe_ack),
763
        .src_pixel_d(src_pixel_d),
764
        .dst_addr1(dst_addr2)
765
);
766
 
767
/* Stage 13 - Burst assembler */
768
reg burst_flush;
769
wire burst_busy;
770
wire burst_pipe_stb;
771
wire burst_pipe_ack;
772
wire [fml_depth-5-1:0] burst_addr;
773
wire [15:0] burst_sel;
774
wire [255:0] burst_do;
775
 
776
tmu_burst #(
777
        .fml_depth(fml_depth)
778
) burst (
779
        .sys_clk(sys_clk),
780
        .sys_rst(sys_rst),
781
 
782
        .flush(burst_flush),
783
        .busy(burst_busy),
784
 
785
        .pipe_stb_i(decay_pipe_stb),
786
        .pipe_ack_o(decay_pipe_ack),
787
        .src_pixel_d(src_pixel_d),
788
        .dst_addr(dst_addr2),
789
 
790
        .pipe_stb_o(burst_pipe_stb),
791
        .pipe_ack_i(burst_pipe_ack),
792
        .burst_addr(burst_addr),
793
        .burst_sel(burst_sel),
794
        .burst_do(burst_do)
795
);
796
 
797
/* Stage 14 - Pixel output */
798
wire pixout_busy;
799
 
800
tmu_pixout #(
801
        .fml_depth(fml_depth)
802
) pixout (
803
        .sys_clk(sys_clk),
804
        .sys_rst(sys_rst),
805
 
806
        .busy(pixout_busy),
807
 
808
        .pipe_stb_i(burst_pipe_stb),
809
        .pipe_ack_o(burst_pipe_ack),
810
        .burst_addr(burst_addr),
811
        .burst_sel(burst_sel),
812
        .burst_do(burst_do),
813
 
814
        .fml_adr(fmlw_adr),
815
        .fml_stb(fmlw_stb),
816
        .fml_ack(fmlw_ack),
817
        .fml_sel(fmlw_sel),
818
        .fml_do(fmlw_do)
819
);
820
 
821
/* FSM to flush the burst assembler at the end */
822
 
823
wire pipeline_busy = meshgen_busy|reorder_busy
824
        |edgedivops_busy|edgediv_busy|edgetrace_busy
825
        |scandivops_busy|scandiv_busy|scantrace_busy
826
        |filter_busy|addresses_busy|pixin_busy
827
        |decay_busy|burst_busy|pixout_busy;
828
 
829
parameter IDLE          = 2'd0;
830
parameter WAIT_PROCESS  = 2'd1;
831
parameter FLUSH         = 2'd2;
832
parameter WAIT_FLUSH    = 2'd3;
833
 
834
reg [1:0] state;
835
reg [1:0] next_state;
836
 
837
always @(posedge sys_clk) begin
838
        if(sys_rst)
839
                state <= IDLE;
840
        else
841
                state <= next_state;
842
end
843
 
844
always @(*) begin
845
        next_state = state;
846
 
847
        busy = 1'b1;
848
        burst_flush = 1'b0;
849
 
850
        case(state)
851
                IDLE: begin
852
                        busy = 1'b0;
853
                        if(start)
854
                                next_state = WAIT_PROCESS;
855
                end
856
                WAIT_PROCESS: begin
857
                        if(~pipeline_busy)
858
                                next_state = FLUSH;
859
                end
860
                FLUSH: begin
861
                        burst_flush = 1'b1;
862
                        next_state = WAIT_FLUSH;
863
                end
864
                WAIT_FLUSH: begin
865
                        if(~pipeline_busy)
866
                                next_state = IDLE;
867
                end
868
        endcase
869
end
870
 
871
/* Performance counters */
872
 
873
tmu_perfcounters perfcounters(
874
        .sys_clk(sys_clk),
875
        .sys_rst(sys_rst),
876
 
877
        .start(start),
878
        .busy(busy),
879
 
880
        /* When the filter puts out a pixel that is acked,
881
         * this pixel will be drawn sooner or later.
882
         * So counting the cycles with both these signals
883
         * asserted gives the total number of traced pixels.
884
         */
885
        .inc_pixels(filter_pipe_stb & filter_pipe_ack),
886
 
887
        /* Measure read efficiency */
888
        .stb1(filter_pipe_stb),
889
        .ack1(filter_pipe_ack),
890
 
891
        /* Measure write efficiency */
892
        .stb2(decay_pipe_stb),
893
        .ack2(decay_pipe_ack),
894
 
895
        .inc_misses(inc_misses),
896
 
897
        .perf_pixels(perf_pixels),
898
        .perf_clocks(perf_clocks),
899
        .perf_stall1(perf_stall1),
900
        .perf_complete1(perf_complete1),
901
        .perf_stall2(perf_stall2),
902
        .perf_complete2(perf_complete2),
903
        .perf_misses(perf_misses)
904
);
905
 
906
endmodule

powered by: WebSVN 2.1.0

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