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

Subversion Repositories warp

[/] [warp/] [rtl/] [tmu_edgediv.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_edgediv(
20
        input sys_clk,
21
        input sys_rst,
22
 
23
        output busy,
24
 
25
        input pipe_stb_i,
26
        output reg pipe_ack_o,
27
        /* Points pass-through */
28
        input [10:0] A0_S_X,
29
        input [10:0] A0_S_Y,
30
        input [10:0] A0_D_X,
31
        input [10:0] A0_D_Y,
32
        input [10:0] B0_D_Y,
33
        input [10:0] C0_D_Y,
34
        input dx10_positive,
35
        input [10:0] dx10,
36
        input dx20_positive,
37
        input [10:0] dx20,
38
        input dx30_positive,
39
        input [10:0] dx30,
40
        input du10_positive,
41
        input [10:0] du10,
42
        input du20_positive,
43
        input [10:0] du20,
44
        input du30_positive,
45
        input [10:0] du30,
46
        input dv10_positive,
47
        input [10:0] dv10,
48
        input dv20_positive,
49
        input [10:0] dv20,
50
        input dv30_positive,
51
        input [10:0] dv30,
52
        input [10:0] divisor10,
53
        input [10:0] divisor20,
54
        input [10:0] divisor30,
55
 
56
        output reg pipe_stb_o,
57
        input pipe_ack_i,
58
        output reg [10:0] A_S_X,
59
        output reg [10:0] A_S_Y,
60
        output reg [10:0] A_D_X,
61
        output reg [10:0] A_D_Y,
62
        output reg [10:0] B_D_Y,
63
        output reg [10:0] C_D_Y,
64
 
65
        output reg dx1_positive,
66
        output [10:0] dx1_q,
67
        output [10:0] dx1_r,
68
        output reg dx2_positive,
69
        output [10:0] dx2_q,
70
        output [10:0] dx2_r,
71
        output reg dx3_positive,
72
        output [10:0] dx3_q,
73
        output [10:0] dx3_r,
74
 
75
        output reg du1_positive,
76
        output [10:0] du1_q,
77
        output [10:0] du1_r,
78
        output reg du2_positive,
79
        output [10:0] du2_q,
80
        output [10:0] du2_r,
81
        output reg du3_positive,
82
        output [10:0] du3_q,
83
        output [10:0] du3_r,
84
 
85
        output reg dv1_positive,
86
        output [10:0] dv1_q,
87
        output [10:0] dv1_r,
88
        output reg dv2_positive,
89
        output [10:0] dv2_q,
90
        output [10:0] dv2_r,
91
        output reg dv3_positive,
92
        output [10:0] dv3_q,
93
        output [10:0] dv3_r,
94
 
95
        /* Divisors pass-through (needed for Bresenham algorithm) */
96
        output reg [10:0] divisor1,
97
        output reg [10:0] divisor2,
98
        output reg [10:0] divisor3
99
);
100
 
101
/* Divider bank */
102
 
103
reg start;
104
wire ready;
105
 
106
/* X (destination X) */
107
tmu_divider11 d_dx1(
108
        .sys_clk(sys_clk),
109
        .sys_rst(sys_rst),
110
 
111
        .start(start),
112
        .dividend(dx10),
113
        .divisor(divisor10),
114
 
115
        .ready(ready),
116
        .quotient(dx1_q),
117
        .remainder(dx1_r)
118
);
119
tmu_divider11 d_dx2(
120
        .sys_clk(sys_clk),
121
        .sys_rst(sys_rst),
122
 
123
        .start(start),
124
        .dividend(dx20),
125
        .divisor(divisor20),
126
 
127
        .ready(),
128
        .quotient(dx2_q),
129
        .remainder(dx2_r)
130
);
131
tmu_divider11 d_dx3(
132
        .sys_clk(sys_clk),
133
        .sys_rst(sys_rst),
134
 
135
        .start(start),
136
        .dividend(dx30),
137
        .divisor(divisor30),
138
 
139
        .ready(),
140
        .quotient(dx3_q),
141
        .remainder(dx3_r)
142
);
143
 
144
/* U (source X) */
145
tmu_divider11 d_du1(
146
        .sys_clk(sys_clk),
147
        .sys_rst(sys_rst),
148
 
149
        .start(start),
150
        .dividend(du10),
151
        .divisor(divisor10),
152
 
153
        .ready(),
154
        .quotient(du1_q),
155
        .remainder(du1_r)
156
);
157
tmu_divider11 d_du2(
158
        .sys_clk(sys_clk),
159
        .sys_rst(sys_rst),
160
 
161
        .start(start),
162
        .dividend(du20),
163
        .divisor(divisor20),
164
 
165
        .ready(),
166
        .quotient(du2_q),
167
        .remainder(du2_r)
168
);
169
tmu_divider11 d_du3(
170
        .sys_clk(sys_clk),
171
        .sys_rst(sys_rst),
172
 
173
        .start(start),
174
        .dividend(du30),
175
        .divisor(divisor30),
176
 
177
        .ready(),
178
        .quotient(du3_q),
179
        .remainder(du3_r)
180
);
181
 
182
/* V (source Y) */
183
tmu_divider11 d_dv1(
184
        .sys_clk(sys_clk),
185
        .sys_rst(sys_rst),
186
 
187
        .start(start),
188
        .dividend(dv10),
189
        .divisor(divisor10),
190
 
191
        .ready(),
192
        .quotient(dv1_q),
193
        .remainder(dv1_r)
194
);
195
tmu_divider11 d_dv2(
196
        .sys_clk(sys_clk),
197
        .sys_rst(sys_rst),
198
 
199
        .start(start),
200
        .dividend(dv20),
201
        .divisor(divisor20),
202
 
203
        .ready(),
204
        .quotient(dv2_q),
205
        .remainder(dv2_r)
206
);
207
tmu_divider11 d_dv3(
208
        .sys_clk(sys_clk),
209
        .sys_rst(sys_rst),
210
 
211
        .start(start),
212
        .dividend(dv30),
213
        .divisor(divisor30),
214
 
215
        .ready(),
216
        .quotient(dv3_q),
217
        .remainder(dv3_r)
218
);
219
 
220
/* Pipeline pass-through */
221
 
222
always @(posedge sys_clk) begin
223
        if(start) begin
224
                A_S_X <= A0_S_X;
225
                A_S_Y <= A0_S_Y;
226
                A_D_X <= A0_D_X;
227
                A_D_Y <= A0_D_Y;
228
                B_D_Y <= B0_D_Y;
229
                C_D_Y <= C0_D_Y;
230
                dx1_positive <= dx10_positive;
231
                dx2_positive <= dx20_positive;
232
                dx3_positive <= dx30_positive;
233
                du1_positive <= du10_positive;
234
                du2_positive <= du20_positive;
235
                du3_positive <= du30_positive;
236
                dv1_positive <= dv10_positive;
237
                dv2_positive <= dv20_positive;
238
                dv3_positive <= dv30_positive;
239
                divisor1 <= divisor10;
240
                divisor2 <= divisor20;
241
                divisor3 <= divisor30;
242
        end
243
end
244
 
245
/* Glue logic */
246
 
247
reg state;
248
reg next_state;
249
 
250
parameter IDLE = 1'b0;
251
parameter WAIT = 1'b1;
252
 
253
always @(posedge sys_clk) begin
254
        if(sys_rst)
255
                state = IDLE;
256
        else
257
                state = next_state;
258
end
259
 
260
assign busy = state;
261
 
262
always @(*) begin
263
        next_state = state;
264
 
265
        start = 1'b0;
266
        pipe_stb_o = 1'b0;
267
        pipe_ack_o = 1'b0;
268
 
269
        case(state)
270
                IDLE: begin
271
                        pipe_ack_o = 1'b1;
272
                        if(pipe_stb_i) begin
273
                                start = 1'b1;
274
                                next_state = WAIT;
275
                        end
276
                end
277
                WAIT: begin
278
                        if(ready) begin
279
                                pipe_stb_o = 1'b1;
280
                                if(pipe_ack_i)
281
                                        next_state = IDLE;
282
                        end
283
                end
284
        endcase
285
end
286
 
287
endmodule

powered by: WebSVN 2.1.0

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