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

Subversion Repositories mpeg2fpga

[/] [mpeg2fpga/] [trunk/] [rtl/] [mpeg2/] [zigzag_table.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kdv
/*
2
 * zigzag_table.v
3
 *
4
 * Copyright (c) 2007 Koen De Vleeschauwer.
5
 *
6
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
10
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
12
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
15
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16
 * SUCH DAMAGE.
17
 */
18
 
19
/*
20
 * zigzag_table - different zig-zag scanning orders.
21
 */
22
 
23
  function [5:0]scan_forward;
24
    input      alternate_scan;
25
    input [5:0]u_v;
26
    begin
27
      if (alternate_scan)
28
        /*
29
         * zig-zag scanning order 1. par. 7.3
30
         */
31
        casex(u_v)
32
          6'd00: scan_forward = 6'd0;
33
          6'd01: scan_forward = 6'd4;
34
          6'd02: scan_forward = 6'd6;
35
          6'd03: scan_forward = 6'd20;
36
          6'd04: scan_forward = 6'd22;
37
          6'd05: scan_forward = 6'd36;
38
          6'd06: scan_forward = 6'd38;
39
          6'd07: scan_forward = 6'd52;
40
          6'd08: scan_forward = 6'd1;
41
          6'd09: scan_forward = 6'd5;
42
          6'd10: scan_forward = 6'd7;
43
          6'd11: scan_forward = 6'd21;
44
          6'd12: scan_forward = 6'd23;
45
          6'd13: scan_forward = 6'd37;
46
          6'd14: scan_forward = 6'd39;
47
          6'd15: scan_forward = 6'd53;
48
          6'd16: scan_forward = 6'd2;
49
          6'd17: scan_forward = 6'd8;
50
          6'd18: scan_forward = 6'd19;
51
          6'd19: scan_forward = 6'd24;
52
          6'd20: scan_forward = 6'd34;
53
          6'd21: scan_forward = 6'd40;
54
          6'd22: scan_forward = 6'd50;
55
          6'd23: scan_forward = 6'd54;
56
          6'd24: scan_forward = 6'd3;
57
          6'd25: scan_forward = 6'd9;
58
          6'd26: scan_forward = 6'd18;
59
          6'd27: scan_forward = 6'd25;
60
          6'd28: scan_forward = 6'd35;
61
          6'd29: scan_forward = 6'd41;
62
          6'd30: scan_forward = 6'd51;
63
          6'd31: scan_forward = 6'd55;
64
          6'd32: scan_forward = 6'd10;
65
          6'd33: scan_forward = 6'd17;
66
          6'd34: scan_forward = 6'd26;
67
          6'd35: scan_forward = 6'd30;
68
          6'd36: scan_forward = 6'd42;
69
          6'd37: scan_forward = 6'd46;
70
          6'd38: scan_forward = 6'd56;
71
          6'd39: scan_forward = 6'd60;
72
          6'd40: scan_forward = 6'd11;
73
          6'd41: scan_forward = 6'd16;
74
          6'd42: scan_forward = 6'd27;
75
          6'd43: scan_forward = 6'd31;
76
          6'd44: scan_forward = 6'd43;
77
          6'd45: scan_forward = 6'd47;
78
          6'd46: scan_forward = 6'd57;
79
          6'd47: scan_forward = 6'd61;
80
          6'd48: scan_forward = 6'd12;
81
          6'd49: scan_forward = 6'd15;
82
          6'd50: scan_forward = 6'd28;
83
          6'd51: scan_forward = 6'd32;
84
          6'd52: scan_forward = 6'd44;
85
          6'd53: scan_forward = 6'd48;
86
          6'd54: scan_forward = 6'd58;
87
          6'd55: scan_forward = 6'd62;
88
          6'd56: scan_forward = 6'd13;
89
          6'd57: scan_forward = 6'd14;
90
          6'd58: scan_forward = 6'd29;
91
          6'd59: scan_forward = 6'd33;
92
          6'd60: scan_forward = 6'd45;
93
          6'd61: scan_forward = 6'd49;
94
          6'd62: scan_forward = 6'd59;
95
          6'd63: scan_forward = 6'd63;
96
        endcase
97
      else
98
        /*
99
         * zig-zag scanning order 0. par. 7.3
100
         */
101
        casex(u_v)
102
          6'd0: scan_forward = 6'd0;
103
          6'd1: scan_forward = 6'd1;
104
          6'd2: scan_forward = 6'd5;
105
          6'd3: scan_forward = 6'd6;
106
          6'd4: scan_forward = 6'd14;
107
          6'd5: scan_forward = 6'd15;
108
          6'd6: scan_forward = 6'd27;
109
          6'd7: scan_forward = 6'd28;
110
          6'd8: scan_forward = 6'd2;
111
          6'd9: scan_forward = 6'd4;
112
          6'd10: scan_forward = 6'd7;
113
          6'd11: scan_forward = 6'd13;
114
          6'd12: scan_forward = 6'd16;
115
          6'd13: scan_forward = 6'd26;
116
          6'd14: scan_forward = 6'd29;
117
          6'd15: scan_forward = 6'd42;
118
          6'd16: scan_forward = 6'd3;
119
          6'd17: scan_forward = 6'd8;
120
          6'd18: scan_forward = 6'd12;
121
          6'd19: scan_forward = 6'd17;
122
          6'd20: scan_forward = 6'd25;
123
          6'd21: scan_forward = 6'd30;
124
          6'd22: scan_forward = 6'd41;
125
          6'd23: scan_forward = 6'd43;
126
          6'd24: scan_forward = 6'd9;
127
          6'd25: scan_forward = 6'd11;
128
          6'd26: scan_forward = 6'd18;
129
          6'd27: scan_forward = 6'd24;
130
          6'd28: scan_forward = 6'd31;
131
          6'd29: scan_forward = 6'd40;
132
          6'd30: scan_forward = 6'd44;
133
          6'd31: scan_forward = 6'd53;
134
          6'd32: scan_forward = 6'd10;
135
          6'd33: scan_forward = 6'd19;
136
          6'd34: scan_forward = 6'd23;
137
          6'd35: scan_forward = 6'd32;
138
          6'd36: scan_forward = 6'd39;
139
          6'd37: scan_forward = 6'd45;
140
          6'd38: scan_forward = 6'd52;
141
          6'd39: scan_forward = 6'd54;
142
          6'd40: scan_forward = 6'd20;
143
          6'd41: scan_forward = 6'd22;
144
          6'd42: scan_forward = 6'd33;
145
          6'd43: scan_forward = 6'd38;
146
          6'd44: scan_forward = 6'd46;
147
          6'd45: scan_forward = 6'd51;
148
          6'd46: scan_forward = 6'd55;
149
          6'd47: scan_forward = 6'd60;
150
          6'd48: scan_forward = 6'd21;
151
          6'd49: scan_forward = 6'd34;
152
          6'd50: scan_forward = 6'd37;
153
          6'd51: scan_forward = 6'd47;
154
          6'd52: scan_forward = 6'd50;
155
          6'd53: scan_forward = 6'd56;
156
          6'd54: scan_forward = 6'd59;
157
          6'd55: scan_forward = 6'd61;
158
          6'd56: scan_forward = 6'd35;
159
          6'd57: scan_forward = 6'd36;
160
          6'd58: scan_forward = 6'd48;
161
          6'd59: scan_forward = 6'd49;
162
          6'd60: scan_forward = 6'd57;
163
          6'd61: scan_forward = 6'd58;
164
          6'd62: scan_forward = 6'd62;
165
          6'd63: scan_forward = 6'd63;
166
        endcase
167
    end
168
  endfunction
169
 
170
 
171
  function [5:0]scan_reverse;
172
    input      alternate_scan;
173
    input [5:0]u_v;
174
    begin
175
      if (alternate_scan)
176
        /*
177
         * inverse zig-zag scanning order 1. par. 7.3
178
         */
179
        casex(u_v)
180
          6'd00: scan_reverse = 6'd0;
181
          6'd04: scan_reverse = 6'd1;
182
          6'd06: scan_reverse = 6'd2;
183
          6'd20: scan_reverse = 6'd3;
184
          6'd22: scan_reverse = 6'd4;
185
          6'd36: scan_reverse = 6'd5;
186
          6'd38: scan_reverse = 6'd6;
187
          6'd52: scan_reverse = 6'd7;
188
          6'd01: scan_reverse = 6'd8;
189
          6'd05: scan_reverse = 6'd9;
190
          6'd07: scan_reverse = 6'd10;
191
          6'd21: scan_reverse = 6'd11;
192
          6'd23: scan_reverse = 6'd12;
193
          6'd37: scan_reverse = 6'd13;
194
          6'd39: scan_reverse = 6'd14;
195
          6'd53: scan_reverse = 6'd15;
196
          6'd02: scan_reverse = 6'd16;
197
          6'd08: scan_reverse = 6'd17;
198
          6'd19: scan_reverse = 6'd18;
199
          6'd24: scan_reverse = 6'd19;
200
          6'd34: scan_reverse = 6'd20;
201
          6'd40: scan_reverse = 6'd21;
202
          6'd50: scan_reverse = 6'd22;
203
          6'd54: scan_reverse = 6'd23;
204
          6'd03: scan_reverse = 6'd24;
205
          6'd09: scan_reverse = 6'd25;
206
          6'd18: scan_reverse = 6'd26;
207
          6'd25: scan_reverse = 6'd27;
208
          6'd35: scan_reverse = 6'd28;
209
          6'd41: scan_reverse = 6'd29;
210
          6'd51: scan_reverse = 6'd30;
211
          6'd55: scan_reverse = 6'd31;
212
          6'd10: scan_reverse = 6'd32;
213
          6'd17: scan_reverse = 6'd33;
214
          6'd26: scan_reverse = 6'd34;
215
          6'd30: scan_reverse = 6'd35;
216
          6'd42: scan_reverse = 6'd36;
217
          6'd46: scan_reverse = 6'd37;
218
          6'd56: scan_reverse = 6'd38;
219
          6'd60: scan_reverse = 6'd39;
220
          6'd11: scan_reverse = 6'd40;
221
          6'd16: scan_reverse = 6'd41;
222
          6'd27: scan_reverse = 6'd42;
223
          6'd31: scan_reverse = 6'd43;
224
          6'd43: scan_reverse = 6'd44;
225
          6'd47: scan_reverse = 6'd45;
226
          6'd57: scan_reverse = 6'd46;
227
          6'd61: scan_reverse = 6'd47;
228
          6'd12: scan_reverse = 6'd48;
229
          6'd15: scan_reverse = 6'd49;
230
          6'd28: scan_reverse = 6'd50;
231
          6'd32: scan_reverse = 6'd51;
232
          6'd44: scan_reverse = 6'd52;
233
          6'd48: scan_reverse = 6'd53;
234
          6'd58: scan_reverse = 6'd54;
235
          6'd62: scan_reverse = 6'd55;
236
          6'd13: scan_reverse = 6'd56;
237
          6'd14: scan_reverse = 6'd57;
238
          6'd29: scan_reverse = 6'd58;
239
          6'd33: scan_reverse = 6'd59;
240
          6'd45: scan_reverse = 6'd60;
241
          6'd49: scan_reverse = 6'd61;
242
          6'd59: scan_reverse = 6'd62;
243
          6'd63: scan_reverse = 6'd63;
244
        endcase
245
      else
246
        /*
247
         * inverse zig-zag scanning order 0. par. 7.3
248
         */
249
        casex(u_v)
250
          6'd00: scan_reverse = 6'd0;
251
          6'd01: scan_reverse = 6'd1;
252
          6'd05: scan_reverse = 6'd2;
253
          6'd06: scan_reverse = 6'd3;
254
          6'd14: scan_reverse = 6'd4;
255
          6'd15: scan_reverse = 6'd5;
256
          6'd27: scan_reverse = 6'd6;
257
          6'd28: scan_reverse = 6'd7;
258
          6'd02: scan_reverse = 6'd8;
259
          6'd04: scan_reverse = 6'd9;
260
          6'd07: scan_reverse = 6'd10;
261
          6'd13: scan_reverse = 6'd11;
262
          6'd16: scan_reverse = 6'd12;
263
          6'd26: scan_reverse = 6'd13;
264
          6'd29: scan_reverse = 6'd14;
265
          6'd42: scan_reverse = 6'd15;
266
          6'd03: scan_reverse = 6'd16;
267
          6'd08: scan_reverse = 6'd17;
268
          6'd12: scan_reverse = 6'd18;
269
          6'd17: scan_reverse = 6'd19;
270
          6'd25: scan_reverse = 6'd20;
271
          6'd30: scan_reverse = 6'd21;
272
          6'd41: scan_reverse = 6'd22;
273
          6'd43: scan_reverse = 6'd23;
274
          6'd09: scan_reverse = 6'd24;
275
          6'd11: scan_reverse = 6'd25;
276
          6'd18: scan_reverse = 6'd26;
277
          6'd24: scan_reverse = 6'd27;
278
          6'd31: scan_reverse = 6'd28;
279
          6'd40: scan_reverse = 6'd29;
280
          6'd44: scan_reverse = 6'd30;
281
          6'd53: scan_reverse = 6'd31;
282
          6'd10: scan_reverse = 6'd32;
283
          6'd19: scan_reverse = 6'd33;
284
          6'd23: scan_reverse = 6'd34;
285
          6'd32: scan_reverse = 6'd35;
286
          6'd39: scan_reverse = 6'd36;
287
          6'd45: scan_reverse = 6'd37;
288
          6'd52: scan_reverse = 6'd38;
289
          6'd54: scan_reverse = 6'd39;
290
          6'd20: scan_reverse = 6'd40;
291
          6'd22: scan_reverse = 6'd41;
292
          6'd33: scan_reverse = 6'd42;
293
          6'd38: scan_reverse = 6'd43;
294
          6'd46: scan_reverse = 6'd44;
295
          6'd51: scan_reverse = 6'd45;
296
          6'd55: scan_reverse = 6'd46;
297
          6'd60: scan_reverse = 6'd47;
298
          6'd21: scan_reverse = 6'd48;
299
          6'd34: scan_reverse = 6'd49;
300
          6'd37: scan_reverse = 6'd50;
301
          6'd47: scan_reverse = 6'd51;
302
          6'd50: scan_reverse = 6'd52;
303
          6'd56: scan_reverse = 6'd53;
304
          6'd59: scan_reverse = 6'd54;
305
          6'd61: scan_reverse = 6'd55;
306
          6'd35: scan_reverse = 6'd56;
307
          6'd36: scan_reverse = 6'd57;
308
          6'd48: scan_reverse = 6'd58;
309
          6'd49: scan_reverse = 6'd59;
310
          6'd57: scan_reverse = 6'd60;
311
          6'd58: scan_reverse = 6'd61;
312
          6'd62: scan_reverse = 6'd62;
313
          6'd63: scan_reverse = 6'd63;
314
        endcase
315
    end
316
  endfunction
317
/* not truncated */

powered by: WebSVN 2.1.0

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