1 |
2 |
fukuchi |
/////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// WISHBONE DMA Priority Encoder ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// ////
|
6 |
|
|
//// Author: Rudolf Usselmann ////
|
7 |
|
|
//// rudi@asics.ws ////
|
8 |
|
|
//// ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// Downloaded from: http://www.opencores.org/cores/wb_dma/ ////
|
11 |
|
|
//// ////
|
12 |
|
|
/////////////////////////////////////////////////////////////////////
|
13 |
|
|
//// ////
|
14 |
|
|
//// Copyright (C) 2000-2002 Rudolf Usselmann ////
|
15 |
|
|
//// www.asics.ws ////
|
16 |
|
|
//// rudi@asics.ws ////
|
17 |
|
|
//// ////
|
18 |
|
|
//// This source file may be used and distributed without ////
|
19 |
|
|
//// restriction provided that this copyright statement is not ////
|
20 |
|
|
//// removed from the file and that any derivative work contains ////
|
21 |
|
|
//// the original copyright notice and the associated disclaimer.////
|
22 |
|
|
//// ////
|
23 |
|
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
24 |
|
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
25 |
|
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
26 |
|
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
27 |
|
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
28 |
|
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
29 |
|
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
30 |
|
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
31 |
|
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
32 |
|
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
33 |
|
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
34 |
|
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
35 |
|
|
//// POSSIBILITY OF SUCH DAMAGE. ////
|
36 |
|
|
//// ////
|
37 |
|
|
/////////////////////////////////////////////////////////////////////
|
38 |
|
|
|
39 |
|
|
// CVS Log
|
40 |
|
|
//
|
41 |
|
|
// $Id: wb_dma_ch_pri_enc.v,v 1.1.1.1 2006-05-29 13:45:12 fukuchi Exp $
|
42 |
|
|
//
|
43 |
|
|
// $Date: 2006-05-29 13:45:12 $
|
44 |
|
|
// $Revision: 1.1.1.1 $
|
45 |
|
|
// $Author: fukuchi $
|
46 |
|
|
// $Locker: $
|
47 |
|
|
// $State: Exp $
|
48 |
|
|
//
|
49 |
|
|
// Change History:
|
50 |
|
|
// $Log: not supported by cvs2svn $
|
51 |
|
|
// Revision 1.5 2002/02/01 01:54:44 rudi
|
52 |
|
|
//
|
53 |
|
|
// - Minor cleanup
|
54 |
|
|
//
|
55 |
|
|
// Revision 1.4 2001/10/19 04:35:04 rudi
|
56 |
|
|
//
|
57 |
|
|
// - Made the core parameterized
|
58 |
|
|
//
|
59 |
|
|
// Revision 1.3 2001/08/15 05:40:30 rudi
|
60 |
|
|
//
|
61 |
|
|
// - Changed IO names to be more clear.
|
62 |
|
|
// - Uniquifyed define names to be core specific.
|
63 |
|
|
// - Added Section 3.10, describing DMA restart.
|
64 |
|
|
//
|
65 |
|
|
// Revision 1.2 2001/08/07 08:00:43 rudi
|
66 |
|
|
//
|
67 |
|
|
//
|
68 |
|
|
// Split up priority encoder modules to separate files
|
69 |
|
|
//
|
70 |
|
|
// Revision 1.1 2001/07/29 08:57:02 rudi
|
71 |
|
|
//
|
72 |
|
|
//
|
73 |
|
|
// 1) Changed Directory Structure
|
74 |
|
|
// 2) Added restart signal (REST)
|
75 |
|
|
//
|
76 |
|
|
// Revision 1.2 2001/06/05 10:22:36 rudi
|
77 |
|
|
//
|
78 |
|
|
//
|
79 |
|
|
// - Added Support of up to 31 channels
|
80 |
|
|
// - Added support for 2,4 and 8 priority levels
|
81 |
|
|
// - Now can have up to 31 channels
|
82 |
|
|
// - Added many configuration items
|
83 |
|
|
// - Changed reset to async
|
84 |
|
|
//
|
85 |
|
|
// Revision 1.1.1.1 2001/03/19 13:10:50 rudi
|
86 |
|
|
// Initial Release
|
87 |
|
|
//
|
88 |
|
|
//
|
89 |
|
|
//
|
90 |
|
|
|
91 |
|
|
`include "wb_dma_defines.v"
|
92 |
|
|
|
93 |
|
|
// Priority Encoder
|
94 |
|
|
//
|
95 |
|
|
// Determines the channel with the highest priority, also takes
|
96 |
|
|
// the valid bit in consideration
|
97 |
|
|
|
98 |
|
|
module wb_dma_ch_pri_enc(clk, valid,
|
99 |
|
|
pri0, pri1, pri2, pri3,
|
100 |
|
|
pri4, pri5, pri6, pri7,
|
101 |
|
|
pri8, pri9, pri10, pri11,
|
102 |
|
|
pri12, pri13, pri14, pri15,
|
103 |
|
|
pri16, pri17, pri18, pri19,
|
104 |
|
|
pri20, pri21, pri22, pri23,
|
105 |
|
|
pri24, pri25, pri26, pri27,
|
106 |
|
|
pri28, pri29, pri30,
|
107 |
|
|
pri_out);
|
108 |
|
|
|
109 |
|
|
////////////////////////////////////////////////////////////////////
|
110 |
|
|
//
|
111 |
|
|
// Module Parameters
|
112 |
|
|
//
|
113 |
|
|
|
114 |
|
|
// chXX_conf = { CBUF, ED, ARS, EN }
|
115 |
|
|
parameter [1:0] pri_sel = 2'd0;
|
116 |
|
|
parameter [3:0] ch0_conf = 4'h1;
|
117 |
|
|
parameter [3:0] ch1_conf = 4'h0;
|
118 |
|
|
parameter [3:0] ch2_conf = 4'h0;
|
119 |
|
|
parameter [3:0] ch3_conf = 4'h0;
|
120 |
|
|
parameter [3:0] ch4_conf = 4'h0;
|
121 |
|
|
parameter [3:0] ch5_conf = 4'h0;
|
122 |
|
|
parameter [3:0] ch6_conf = 4'h0;
|
123 |
|
|
parameter [3:0] ch7_conf = 4'h0;
|
124 |
|
|
parameter [3:0] ch8_conf = 4'h0;
|
125 |
|
|
parameter [3:0] ch9_conf = 4'h0;
|
126 |
|
|
parameter [3:0] ch10_conf = 4'h0;
|
127 |
|
|
parameter [3:0] ch11_conf = 4'h0;
|
128 |
|
|
parameter [3:0] ch12_conf = 4'h0;
|
129 |
|
|
parameter [3:0] ch13_conf = 4'h0;
|
130 |
|
|
parameter [3:0] ch14_conf = 4'h0;
|
131 |
|
|
parameter [3:0] ch15_conf = 4'h0;
|
132 |
|
|
parameter [3:0] ch16_conf = 4'h0;
|
133 |
|
|
parameter [3:0] ch17_conf = 4'h0;
|
134 |
|
|
parameter [3:0] ch18_conf = 4'h0;
|
135 |
|
|
parameter [3:0] ch19_conf = 4'h0;
|
136 |
|
|
parameter [3:0] ch20_conf = 4'h0;
|
137 |
|
|
parameter [3:0] ch21_conf = 4'h0;
|
138 |
|
|
parameter [3:0] ch22_conf = 4'h0;
|
139 |
|
|
parameter [3:0] ch23_conf = 4'h0;
|
140 |
|
|
parameter [3:0] ch24_conf = 4'h0;
|
141 |
|
|
parameter [3:0] ch25_conf = 4'h0;
|
142 |
|
|
parameter [3:0] ch26_conf = 4'h0;
|
143 |
|
|
parameter [3:0] ch27_conf = 4'h0;
|
144 |
|
|
parameter [3:0] ch28_conf = 4'h0;
|
145 |
|
|
parameter [3:0] ch29_conf = 4'h0;
|
146 |
|
|
parameter [3:0] ch30_conf = 4'h0;
|
147 |
|
|
|
148 |
|
|
////////////////////////////////////////////////////////////////////
|
149 |
|
|
//
|
150 |
|
|
// Module IOs
|
151 |
|
|
//
|
152 |
|
|
|
153 |
|
|
input clk;
|
154 |
|
|
input [30:0] valid; // Channel Valid bits
|
155 |
|
|
input [2:0] pri0, pri1, pri2, pri3; // Channel Priorities
|
156 |
|
|
input [2:0] pri4, pri5, pri6, pri7;
|
157 |
|
|
input [2:0] pri8, pri9, pri10, pri11;
|
158 |
|
|
input [2:0] pri12, pri13, pri14, pri15;
|
159 |
|
|
input [2:0] pri16, pri17, pri18, pri19;
|
160 |
|
|
input [2:0] pri20, pri21, pri22, pri23;
|
161 |
|
|
input [2:0] pri24, pri25, pri26, pri27;
|
162 |
|
|
input [2:0] pri28, pri29, pri30;
|
163 |
|
|
output [2:0] pri_out; // Highest unserviced priority
|
164 |
|
|
|
165 |
|
|
wire [7:0] pri0_out, pri1_out, pri2_out, pri3_out;
|
166 |
|
|
wire [7:0] pri4_out, pri5_out, pri6_out, pri7_out;
|
167 |
|
|
wire [7:0] pri8_out, pri9_out, pri10_out, pri11_out;
|
168 |
|
|
wire [7:0] pri12_out, pri13_out, pri14_out, pri15_out;
|
169 |
|
|
wire [7:0] pri16_out, pri17_out, pri18_out, pri19_out;
|
170 |
|
|
wire [7:0] pri20_out, pri21_out, pri22_out, pri23_out;
|
171 |
|
|
wire [7:0] pri24_out, pri25_out, pri26_out, pri27_out;
|
172 |
|
|
wire [7:0] pri28_out, pri29_out, pri30_out;
|
173 |
|
|
|
174 |
|
|
wire [7:0] pri_out_tmp;
|
175 |
|
|
reg [2:0] pri_out;
|
176 |
|
|
reg [2:0] pri_out2;
|
177 |
|
|
reg [2:0] pri_out1;
|
178 |
|
|
reg [2:0] pri_out0;
|
179 |
|
|
|
180 |
|
|
wb_dma_pri_enc_sub #(ch1_conf,pri_sel) u0( // Use channel config 1 for channel 0 encoder
|
181 |
|
|
.valid( valid[0] ),
|
182 |
|
|
.pri_in( pri0 ),
|
183 |
|
|
.pri_out( pri0_out )
|
184 |
|
|
);
|
185 |
|
|
wb_dma_pri_enc_sub #(ch1_conf,pri_sel) u1(
|
186 |
|
|
.valid( valid[1] ),
|
187 |
|
|
.pri_in( pri1 ),
|
188 |
|
|
.pri_out( pri1_out )
|
189 |
|
|
);
|
190 |
|
|
wb_dma_pri_enc_sub #(ch2_conf,pri_sel) u2(
|
191 |
|
|
.valid( valid[2] ),
|
192 |
|
|
.pri_in( pri2 ),
|
193 |
|
|
.pri_out( pri2_out )
|
194 |
|
|
);
|
195 |
|
|
wb_dma_pri_enc_sub #(ch3_conf,pri_sel) u3(
|
196 |
|
|
.valid( valid[3] ),
|
197 |
|
|
.pri_in( pri3 ),
|
198 |
|
|
.pri_out( pri3_out )
|
199 |
|
|
);
|
200 |
|
|
wb_dma_pri_enc_sub #(ch4_conf,pri_sel) u4(
|
201 |
|
|
.valid( valid[4] ),
|
202 |
|
|
.pri_in( pri4 ),
|
203 |
|
|
.pri_out( pri4_out )
|
204 |
|
|
);
|
205 |
|
|
wb_dma_pri_enc_sub #(ch5_conf,pri_sel) u5(
|
206 |
|
|
.valid( valid[5] ),
|
207 |
|
|
.pri_in( pri5 ),
|
208 |
|
|
.pri_out( pri5_out )
|
209 |
|
|
);
|
210 |
|
|
wb_dma_pri_enc_sub #(ch6_conf,pri_sel) u6(
|
211 |
|
|
.valid( valid[6] ),
|
212 |
|
|
.pri_in( pri6 ),
|
213 |
|
|
.pri_out( pri6_out )
|
214 |
|
|
);
|
215 |
|
|
wb_dma_pri_enc_sub #(ch7_conf,pri_sel) u7(
|
216 |
|
|
.valid( valid[7] ),
|
217 |
|
|
.pri_in( pri7 ),
|
218 |
|
|
.pri_out( pri7_out )
|
219 |
|
|
);
|
220 |
|
|
wb_dma_pri_enc_sub #(ch8_conf,pri_sel) u8(
|
221 |
|
|
.valid( valid[8] ),
|
222 |
|
|
.pri_in( pri8 ),
|
223 |
|
|
.pri_out( pri8_out )
|
224 |
|
|
);
|
225 |
|
|
wb_dma_pri_enc_sub #(ch9_conf,pri_sel) u9(
|
226 |
|
|
.valid( valid[9] ),
|
227 |
|
|
.pri_in( pri9 ),
|
228 |
|
|
.pri_out( pri9_out )
|
229 |
|
|
);
|
230 |
|
|
wb_dma_pri_enc_sub #(ch10_conf,pri_sel) u10(
|
231 |
|
|
.valid( valid[10] ),
|
232 |
|
|
.pri_in( pri10 ),
|
233 |
|
|
.pri_out( pri10_out )
|
234 |
|
|
);
|
235 |
|
|
wb_dma_pri_enc_sub #(ch11_conf,pri_sel) u11(
|
236 |
|
|
.valid( valid[11] ),
|
237 |
|
|
.pri_in( pri11 ),
|
238 |
|
|
.pri_out( pri11_out )
|
239 |
|
|
);
|
240 |
|
|
wb_dma_pri_enc_sub #(ch12_conf,pri_sel) u12(
|
241 |
|
|
.valid( valid[12] ),
|
242 |
|
|
.pri_in( pri12 ),
|
243 |
|
|
.pri_out( pri12_out )
|
244 |
|
|
);
|
245 |
|
|
wb_dma_pri_enc_sub #(ch13_conf,pri_sel) u13(
|
246 |
|
|
.valid( valid[13] ),
|
247 |
|
|
.pri_in( pri13 ),
|
248 |
|
|
.pri_out( pri13_out )
|
249 |
|
|
);
|
250 |
|
|
wb_dma_pri_enc_sub #(ch14_conf,pri_sel) u14(
|
251 |
|
|
.valid( valid[14] ),
|
252 |
|
|
.pri_in( pri14 ),
|
253 |
|
|
.pri_out( pri14_out )
|
254 |
|
|
);
|
255 |
|
|
wb_dma_pri_enc_sub #(ch15_conf,pri_sel) u15(
|
256 |
|
|
.valid( valid[15] ),
|
257 |
|
|
.pri_in( pri15 ),
|
258 |
|
|
.pri_out( pri15_out )
|
259 |
|
|
);
|
260 |
|
|
wb_dma_pri_enc_sub #(ch16_conf,pri_sel) u16(
|
261 |
|
|
.valid( valid[16] ),
|
262 |
|
|
.pri_in( pri16 ),
|
263 |
|
|
.pri_out( pri16_out )
|
264 |
|
|
);
|
265 |
|
|
wb_dma_pri_enc_sub #(ch17_conf,pri_sel) u17(
|
266 |
|
|
.valid( valid[17] ),
|
267 |
|
|
.pri_in( pri17 ),
|
268 |
|
|
.pri_out( pri17_out )
|
269 |
|
|
);
|
270 |
|
|
wb_dma_pri_enc_sub #(ch18_conf,pri_sel) u18(
|
271 |
|
|
.valid( valid[18] ),
|
272 |
|
|
.pri_in( pri18 ),
|
273 |
|
|
.pri_out( pri18_out )
|
274 |
|
|
);
|
275 |
|
|
wb_dma_pri_enc_sub #(ch19_conf,pri_sel) u19(
|
276 |
|
|
.valid( valid[19] ),
|
277 |
|
|
.pri_in( pri19 ),
|
278 |
|
|
.pri_out( pri19_out )
|
279 |
|
|
);
|
280 |
|
|
wb_dma_pri_enc_sub #(ch20_conf,pri_sel) u20(
|
281 |
|
|
.valid( valid[20] ),
|
282 |
|
|
.pri_in( pri20 ),
|
283 |
|
|
.pri_out( pri20_out )
|
284 |
|
|
);
|
285 |
|
|
wb_dma_pri_enc_sub #(ch21_conf,pri_sel) u21(
|
286 |
|
|
.valid( valid[21] ),
|
287 |
|
|
.pri_in( pri21 ),
|
288 |
|
|
.pri_out( pri21_out )
|
289 |
|
|
);
|
290 |
|
|
wb_dma_pri_enc_sub #(ch22_conf,pri_sel) u22(
|
291 |
|
|
.valid( valid[22] ),
|
292 |
|
|
.pri_in( pri22 ),
|
293 |
|
|
.pri_out( pri22_out )
|
294 |
|
|
);
|
295 |
|
|
wb_dma_pri_enc_sub #(ch23_conf,pri_sel) u23(
|
296 |
|
|
.valid( valid[23] ),
|
297 |
|
|
.pri_in( pri23 ),
|
298 |
|
|
.pri_out( pri23_out )
|
299 |
|
|
);
|
300 |
|
|
wb_dma_pri_enc_sub #(ch24_conf,pri_sel) u24(
|
301 |
|
|
.valid( valid[24] ),
|
302 |
|
|
.pri_in( pri24 ),
|
303 |
|
|
.pri_out( pri24_out )
|
304 |
|
|
);
|
305 |
|
|
wb_dma_pri_enc_sub #(ch25_conf,pri_sel) u25(
|
306 |
|
|
.valid( valid[25] ),
|
307 |
|
|
.pri_in( pri25 ),
|
308 |
|
|
.pri_out( pri25_out )
|
309 |
|
|
);
|
310 |
|
|
wb_dma_pri_enc_sub #(ch26_conf,pri_sel) u26(
|
311 |
|
|
.valid( valid[26] ),
|
312 |
|
|
.pri_in( pri26 ),
|
313 |
|
|
.pri_out( pri26_out )
|
314 |
|
|
);
|
315 |
|
|
wb_dma_pri_enc_sub #(ch27_conf,pri_sel) u27(
|
316 |
|
|
.valid( valid[27] ),
|
317 |
|
|
.pri_in( pri27 ),
|
318 |
|
|
.pri_out( pri27_out )
|
319 |
|
|
);
|
320 |
|
|
wb_dma_pri_enc_sub #(ch28_conf,pri_sel) u28(
|
321 |
|
|
.valid( valid[28] ),
|
322 |
|
|
.pri_in( pri28 ),
|
323 |
|
|
.pri_out( pri28_out )
|
324 |
|
|
);
|
325 |
|
|
wb_dma_pri_enc_sub #(ch29_conf,pri_sel) u29(
|
326 |
|
|
.valid( valid[29] ),
|
327 |
|
|
.pri_in( pri29 ),
|
328 |
|
|
.pri_out( pri29_out )
|
329 |
|
|
);
|
330 |
|
|
wb_dma_pri_enc_sub #(ch30_conf,pri_sel) u30(
|
331 |
|
|
.valid( valid[30] ),
|
332 |
|
|
.pri_in( pri30 ),
|
333 |
|
|
.pri_out( pri30_out )
|
334 |
|
|
);
|
335 |
|
|
|
336 |
|
|
assign pri_out_tmp = pri0_out | pri1_out | pri2_out | pri3_out |
|
337 |
|
|
pri4_out | pri5_out | pri6_out | pri7_out |
|
338 |
|
|
pri8_out | pri9_out | pri10_out | pri11_out |
|
339 |
|
|
pri12_out | pri13_out | pri14_out | pri15_out |
|
340 |
|
|
pri16_out | pri17_out | pri18_out | pri19_out |
|
341 |
|
|
pri20_out | pri21_out | pri22_out | pri23_out |
|
342 |
|
|
pri24_out | pri25_out | pri26_out | pri27_out |
|
343 |
|
|
pri28_out | pri29_out | pri30_out;
|
344 |
|
|
|
345 |
|
|
// 8 Priority Levels
|
346 |
|
|
always @(posedge clk)
|
347 |
|
|
if(pri_out_tmp[7]) pri_out2 <= #1 3'h7;
|
348 |
|
|
else
|
349 |
|
|
if(pri_out_tmp[6]) pri_out2 <= #1 3'h6;
|
350 |
|
|
else
|
351 |
|
|
if(pri_out_tmp[5]) pri_out2 <= #1 3'h5;
|
352 |
|
|
else
|
353 |
|
|
if(pri_out_tmp[4]) pri_out2 <= #1 3'h4;
|
354 |
|
|
else
|
355 |
|
|
if(pri_out_tmp[3]) pri_out2 <= #1 3'h3;
|
356 |
|
|
else
|
357 |
|
|
if(pri_out_tmp[2]) pri_out2 <= #1 3'h2;
|
358 |
|
|
else
|
359 |
|
|
if(pri_out_tmp[1]) pri_out2 <= #1 3'h1;
|
360 |
|
|
else pri_out2 <= #1 3'h0;
|
361 |
|
|
|
362 |
|
|
// 4 Priority Levels
|
363 |
|
|
always @(posedge clk)
|
364 |
|
|
if(pri_out_tmp[3]) pri_out1 <= #1 3'h3;
|
365 |
|
|
else
|
366 |
|
|
if(pri_out_tmp[2]) pri_out1 <= #1 3'h2;
|
367 |
|
|
else
|
368 |
|
|
if(pri_out_tmp[1]) pri_out1 <= #1 3'h1;
|
369 |
|
|
else pri_out1 <= #1 3'h0;
|
370 |
|
|
|
371 |
|
|
// 2 Priority Levels
|
372 |
|
|
always @(posedge clk)
|
373 |
|
|
if(pri_out_tmp[1]) pri_out0 <= #1 3'h1;
|
374 |
|
|
else pri_out0 <= #1 3'h0;
|
375 |
|
|
|
376 |
|
|
// Select configured priority
|
377 |
|
|
always @(pri_sel or pri_out0 or pri_out1 or pri_out2)
|
378 |
|
|
case(pri_sel) // synopsys parallel_case full_case
|
379 |
|
|
2'd0: pri_out = pri_out0;
|
380 |
|
|
2'd1: pri_out = pri_out1;
|
381 |
|
|
2'd2: pri_out = pri_out2;
|
382 |
|
|
endcase
|
383 |
|
|
|
384 |
|
|
endmodule
|