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

Subversion Repositories warp

[/] [warp/] [rtl/] [tmu_ctlif.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_ctlif #(
20
        parameter csr_addr = 4'h0,
21
        parameter fml_depth = 26
22
) (
23
        input sys_clk,
24
        input sys_rst,
25
 
26
        input [13:0] csr_a,
27
        input csr_we,
28
        input [31:0] csr_di,
29
        output reg [31:0] csr_do,
30
 
31
        output reg irq,
32
 
33
        output reg start,
34
        input busy,
35
 
36
        output reg [29:0] mesh_base, /* in 32-bit words */
37
        output reg [6:0] hmesh_count,
38
        output reg [6:0] hmesh_size,
39
        output reg [6:0] vmesh_count,
40
        output reg [6:0] vmesh_size,
41
 
42
        output reg [fml_depth-1-1:0] src_base, /* in 16-bit words */
43
        output reg [10:0] src_hres,
44
        output reg [10:0] src_vres,
45
 
46
        output reg [fml_depth-1-1:0] dst_base, /* in 16-bit words */
47
        output reg [10:0] dst_hres,
48
        output reg [10:0] dst_vres,
49
        output reg [10:0] hoffset,
50
        output reg [10:0] voffset,
51
 
52
        output reg [5:0] brightness,
53
 
54
        input [31:0] perf_pixels,
55
        input [31:0] perf_clocks,
56
        input [31:0] perf_stall1,
57
        input [31:0] perf_complete1,
58
        input [31:0] perf_stall2,
59
        input [31:0] perf_complete2,
60
        input [31:0] perf_misses
61
);
62
 
63
reg old_busy;
64
always @(posedge sys_clk) begin
65
        if(sys_rst)
66
                old_busy <= 1'b0;
67
        else
68
                old_busy <= busy;
69
end
70
 
71
wire trigger_irq = old_busy & ~busy;
72
 
73
wire csr_selected = csr_a[13:10] == csr_addr;
74
 
75
always @(posedge sys_clk) begin
76
        if(sys_rst) begin
77
                csr_do <= 32'd0;
78
                irq <= 1'b0;
79
                start <= 1'b0;
80
 
81
                mesh_base <= 30'd0;
82
                hmesh_count <= 7'd32;
83
                hmesh_size <= 7'd20;
84
                vmesh_count <= 7'd24;
85
                vmesh_size <= 7'd20;
86
 
87
                src_base <= {fml_depth{1'b0}};
88
                src_hres <= 11'd640;
89
                src_vres <= 11'd480;
90
 
91
                dst_base <= {fml_depth{1'b0}};
92
                dst_hres <= 11'd640;
93
                dst_vres <= 11'd480;
94
                hoffset <= 11'd0;
95
                voffset <= 11'd0;
96
 
97
                brightness <= 6'd63;
98
        end else begin
99
                if(trigger_irq) irq <= 1'b1;
100
 
101
                csr_do <= 32'd0;
102
                start <= 1'b0;
103
                if(csr_selected) begin
104
                        if(csr_we) begin
105
                                case(csr_a[3:0])
106
                                        4'b0000: begin
107
                                                start <= csr_di[0];
108
                                                irq <= 1'b0;
109
                                        end
110
 
111
                                        4'b0001: mesh_base <= csr_di[31:2];
112
                                        4'b0010: hmesh_count <= csr_di[6:0];
113
                                        4'b0011: hmesh_size <= csr_di[6:0];
114
                                        4'b0100: vmesh_count <= csr_di[6:0];
115
                                        4'b0101: vmesh_size <= csr_di[6:0];
116
 
117
                                        4'b0110: src_base <= csr_di[fml_depth-1:1];
118
                                        4'b0111: src_hres <= csr_di[10:0];
119
                                        4'b1000: src_vres <= csr_di[10:0];
120
 
121
                                        4'b1001: dst_base <= csr_di[fml_depth-1:1];
122
                                        4'b1010: dst_hres <= csr_di[10:0];
123
                                        4'b1011: dst_vres <= csr_di[10:0];
124
                                        4'b1100: hoffset <= csr_di[10:0];
125
                                        4'b1101: voffset <= csr_di[10:0];
126
 
127
                                        4'b1110: brightness <= csr_di[5:0];
128
                                        default:;
129
                                endcase
130
                        end
131
                        case(csr_a[4:0])
132
                                5'b00000: csr_do <= {irq, busy};
133
 
134
                                5'b00001: csr_do <= {mesh_base, 2'b00};
135
                                5'b00010: csr_do <= hmesh_count;
136
                                5'b00011: csr_do <= hmesh_size;
137
                                5'b00100: csr_do <= vmesh_count;
138
                                5'b00101: csr_do <= vmesh_size;
139
 
140
                                5'b00110: csr_do <= {src_base, 1'b0};
141
                                5'b00111: csr_do <= src_hres;
142
                                5'b01000: csr_do <= src_vres;
143
 
144
                                5'b01001: csr_do <= {dst_base, 1'b0};
145
                                5'b01010: csr_do <= dst_hres;
146
                                5'b01011: csr_do <= dst_vres;
147
                                5'b01100: csr_do <= hoffset;
148
                                5'b01101: csr_do <= voffset;
149
 
150
                                5'b01110: csr_do <= brightness;
151
 
152
                                /* Performance counters */
153
                                5'b10000: csr_do <= perf_pixels;
154
                                5'b10001: csr_do <= perf_clocks;
155
 
156
                                5'b10010: csr_do <= perf_stall1;
157
                                5'b10011: csr_do <= perf_complete1;
158
                                5'b10100: csr_do <= perf_stall2;
159
                                5'b10101: csr_do <= perf_complete2;
160
 
161
                                5'b10110: csr_do <= perf_misses;
162
                                default: csr_do <= 32'bx;
163
                        endcase
164
                end
165
        end
166
end
167
 
168
endmodule

powered by: WebSVN 2.1.0

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