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

Subversion Repositories mpeg2fpga

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kdv
/*
2
 * vlc_tables.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
 * vlc_tables - Variable Length Code Tables. Tables B-1 to B-5 and B-9 to B-15 from ISO/IEC 13818-2.
21
 */
22
 
23
/*
24
  Function macroblock_address_increment_dec translates
25
  macroblock address increment vlc code to {codelength, codeword} pairs
26
  as in table B-1 from ISO/IEC 13818-2.
27
  First 4 bits of output are` code length, next 5 bits of output are code value.
28
*/
29
 
30
function [10:0]macroblock_address_increment_dec;
31
  input [10:0]codeword;
32
  begin
33
    casex(codeword)
34
      11'b0000_0100_011: macroblock_address_increment_dec = {4'd11, 6'd22, 1'b0};
35
      11'b0000_0100_010: macroblock_address_increment_dec = {4'd11, 6'd23, 1'b0};
36
      11'b0000_0100_001: macroblock_address_increment_dec = {4'd11, 6'd24, 1'b0};
37
      11'b0000_0100_000: macroblock_address_increment_dec = {4'd11, 6'd25, 1'b0};
38
      11'b0000_0011_111: macroblock_address_increment_dec = {4'd11, 6'd26, 1'b0};
39
      11'b0000_0011_110: macroblock_address_increment_dec = {4'd11, 6'd27, 1'b0};
40
      11'b0000_0011_101: macroblock_address_increment_dec = {4'd11, 6'd28, 1'b0};
41
      11'b0000_0011_100: macroblock_address_increment_dec = {4'd11, 6'd29, 1'b0};
42
      11'b0000_0011_011: macroblock_address_increment_dec = {4'd11, 6'd30, 1'b0};
43
      11'b0000_0011_010: macroblock_address_increment_dec = {4'd11, 6'd31, 1'b0};
44
      11'b0000_0011_001: macroblock_address_increment_dec = {4'd11, 6'd32, 1'b0};
45
      11'b0000_0011_000: macroblock_address_increment_dec = {4'd11, 6'd33, 1'b0};
46
      11'b0000_0001_000: macroblock_address_increment_dec = {4'd11, 6'd33, 1'b1}; // macroblock_escape
47
      11'b0000_0101_11x: macroblock_address_increment_dec = {4'd10, 6'd16, 1'b0};
48
      11'b0000_0101_10x: macroblock_address_increment_dec = {4'd10, 6'd17, 1'b0};
49
      11'b0000_0101_01x: macroblock_address_increment_dec = {4'd10, 6'd18, 1'b0};
50
      11'b0000_0101_00x: macroblock_address_increment_dec = {4'd10, 6'd19, 1'b0};
51
      11'b0000_0100_11x: macroblock_address_increment_dec = {4'd10, 6'd20, 1'b0};
52
      11'b0000_0100_10x: macroblock_address_increment_dec = {4'd10, 6'd21, 1'b0};
53
      11'b0000_1011_xxx: macroblock_address_increment_dec = {4'd8,  6'd10, 1'b0};
54
      11'b0000_1010_xxx: macroblock_address_increment_dec = {4'd8,  6'd11, 1'b0};
55
      11'b0000_1001_xxx: macroblock_address_increment_dec = {4'd8,  6'd12, 1'b0};
56
      11'b0000_1000_xxx: macroblock_address_increment_dec = {4'd8,  6'd13, 1'b0};
57
      11'b0000_0111_xxx: macroblock_address_increment_dec = {4'd8,  6'd14, 1'b0};
58
      11'b0000_0110_xxx: macroblock_address_increment_dec = {4'd8,  6'd15, 1'b0};
59
      11'b0000_111x_xxx: macroblock_address_increment_dec = {4'd7,  6'd8,  1'b0};
60
      11'b0000_110x_xxx: macroblock_address_increment_dec = {4'd7,  6'd9,  1'b0};
61
      11'b0001_1xxx_xxx: macroblock_address_increment_dec = {4'd5,  6'd6,  1'b0};
62
      11'b0001_0xxx_xxx: macroblock_address_increment_dec = {4'd5,  6'd7,  1'b0};
63
      11'b0011_xxxx_xxx: macroblock_address_increment_dec = {4'd4,  6'd4,  1'b0};
64
      11'b0010_xxxx_xxx: macroblock_address_increment_dec = {4'd4,  6'd5,  1'b0};
65
      11'b011x_xxxx_xxx: macroblock_address_increment_dec = {4'd3,  6'd2,  1'b0};
66
      11'b010x_xxxx_xxx: macroblock_address_increment_dec = {4'd3,  6'd3,  1'b0};
67
      11'b1xxx_xxxx_xxx: macroblock_address_increment_dec = {4'd1,  6'd1,  1'b0};
68
      default            macroblock_address_increment_dec = {4'd0,  6'd0,  1'b0}; // Error
69
    endcase
70
  end
71
endfunction
72
 
73
/*
74
  Function macroblock_type_dec translates
75
  macroblock type vlc code to {codelength, codeword} pairs
76
  in tables B-2 to B-5 from ISO/IEC 13818-2, as selected by picture_coding_type.
77
  I don't do scalability, hence scalable_mode and tables B-6 to B-8 are not used.
78
  First 4 bits of output are code length, next 6 bits of output are code value.
79
  Typical use:
80
  {next_shift[3:0], macroblock_quant, macroblock_motion_forward, macroblock_motion_backward,
81
   macroblock_pattern, macroblock_intra, spatial_temporal_weight_code_flag} =
82
   macroblock_type_dec(.picture_coding_type(picture_coding_type), .codeword(codeword));
83
*/
84
 
85
function [9:0]macroblock_type_dec;
86
  input [5:0]codeword;
87
  input [2:0]picture_coding_type;
88
  begin
89
    casex(picture_coding_type)
90
      3'b001: // intra-coded (I)
91
        casex(codeword)
92
          6'b01xx_xx: macroblock_type_dec = {4'd2,  6'b100010};
93
          6'b1xxx_xx: macroblock_type_dec = {4'd1,  6'b000010};
94
          default     macroblock_type_dec = {4'd0,  6'b111111}; // Error
95
        endcase
96
      3'b010: // predictive-coded (P)
97
        casex(codeword)
98
          6'b0000_01: macroblock_type_dec = {4'd6,  6'b100010};
99
          6'b0001_1x: macroblock_type_dec = {4'd5,  6'b000010};
100
          6'b0001_0x: macroblock_type_dec = {4'd5,  6'b110100};
101
          6'b0000_1x: macroblock_type_dec = {4'd5,  6'b100100};
102
          6'b001x_xx: macroblock_type_dec = {4'd3,  6'b010000};
103
          6'b01xx_xx: macroblock_type_dec = {4'd2,  6'b000100};
104
          6'b1xxx_xx: macroblock_type_dec = {4'd1,  6'b010100};
105
          default     macroblock_type_dec = {4'd0,  6'b111111}; // Error
106
        endcase
107
      3'b011: // bidirectionally-predictive-coded (B)
108
        casex(codeword)
109
          6'b0000_11: macroblock_type_dec = {4'd6,  6'b110100};
110
          6'b0000_10: macroblock_type_dec = {4'd6,  6'b101100};
111
          6'b0000_01: macroblock_type_dec = {4'd6,  6'b100010};
112
          6'b0001_1x: macroblock_type_dec = {4'd5,  6'b000010};
113
          6'b0001_0x: macroblock_type_dec = {4'd5,  6'b111100};
114
          6'b0010_xx: macroblock_type_dec = {4'd4,  6'b010000};
115
          6'b0011_xx: macroblock_type_dec = {4'd4,  6'b010100};
116
          6'b010x_xx: macroblock_type_dec = {4'd3,  6'b001000};
117
          6'b011x_xx: macroblock_type_dec = {4'd3,  6'b001100};
118
          6'b10xx_xx: macroblock_type_dec = {4'd2,  6'b011000};
119
          6'b11xx_xx: macroblock_type_dec = {4'd2,  6'b011100};
120
          default     macroblock_type_dec = {4'd0,  6'b111111}; // Error
121
        endcase
122
      default // error
123
                      macroblock_type_dec = {4'd0,  6'b111111}; // Error
124
    endcase
125
  end
126
endfunction
127
 
128
 
129
/*
130
  Function coded_block_pattern_dec translates
131
  coded block pattern vlc code to {codelength, codeword} pairs
132
  as in table B-9 from ISO/IEC 13818-2.
133
  First 4 bits of output are` code length, next 6 bits of output are code value.
134
*/
135
 
136
function [9:0]coded_block_pattern_dec;
137
  input [8:0]codeword;
138
  begin
139
    casex(codeword)
140
      9'b0000_0011_1: coded_block_pattern_dec = {4'd9,  6'd31};
141
      9'b0000_0011_0: coded_block_pattern_dec = {4'd9,  6'd47};
142
      9'b0000_0010_1: coded_block_pattern_dec = {4'd9,  6'd55};
143
      9'b0000_0010_0: coded_block_pattern_dec = {4'd9,  6'd59};
144
      9'b0000_0001_1: coded_block_pattern_dec = {4'd9,  6'd27};
145
      9'b0000_0001_0: coded_block_pattern_dec = {4'd9,  6'd39};
146
      9'b0000_0000_1: coded_block_pattern_dec = {4'd9,  6'd0};
147
      9'b0001_1111_x: coded_block_pattern_dec = {4'd8,  6'd7};
148
      9'b0001_1110_x: coded_block_pattern_dec = {4'd8,  6'd11};
149
      9'b0001_1101_x: coded_block_pattern_dec = {4'd8,  6'd19};
150
      9'b0001_1100_x: coded_block_pattern_dec = {4'd8,  6'd35};
151
      9'b0001_1011_x: coded_block_pattern_dec = {4'd8,  6'd13};
152
      9'b0001_1010_x: coded_block_pattern_dec = {4'd8,  6'd49};
153
      9'b0001_1001_x: coded_block_pattern_dec = {4'd8,  6'd21};
154
      9'b0001_1000_x: coded_block_pattern_dec = {4'd8,  6'd41};
155
      9'b0001_0111_x: coded_block_pattern_dec = {4'd8,  6'd14};
156
      9'b0001_0110_x: coded_block_pattern_dec = {4'd8,  6'd50};
157
      9'b0001_0101_x: coded_block_pattern_dec = {4'd8,  6'd22};
158
      9'b0001_0100_x: coded_block_pattern_dec = {4'd8,  6'd42};
159
      9'b0001_0011_x: coded_block_pattern_dec = {4'd8,  6'd15};
160
      9'b0001_0010_x: coded_block_pattern_dec = {4'd8,  6'd51};
161
      9'b0001_0001_x: coded_block_pattern_dec = {4'd8,  6'd23};
162
      9'b0001_0000_x: coded_block_pattern_dec = {4'd8,  6'd43};
163
      9'b0000_1111_x: coded_block_pattern_dec = {4'd8,  6'd25};
164
      9'b0000_1110_x: coded_block_pattern_dec = {4'd8,  6'd37};
165
      9'b0000_1101_x: coded_block_pattern_dec = {4'd8,  6'd26};
166
      9'b0000_1100_x: coded_block_pattern_dec = {4'd8,  6'd38};
167
      9'b0000_1011_x: coded_block_pattern_dec = {4'd8,  6'd29};
168
      9'b0000_1010_x: coded_block_pattern_dec = {4'd8,  6'd45};
169
      9'b0000_1001_x: coded_block_pattern_dec = {4'd8,  6'd53};
170
      9'b0000_1000_x: coded_block_pattern_dec = {4'd8,  6'd57};
171
      9'b0000_0111_x: coded_block_pattern_dec = {4'd8,  6'd30};
172
      9'b0000_0110_x: coded_block_pattern_dec = {4'd8,  6'd46};
173
      9'b0000_0101_x: coded_block_pattern_dec = {4'd8,  6'd54};
174
      9'b0000_0100_x: coded_block_pattern_dec = {4'd8,  6'd58};
175
      9'b0010_111x_x: coded_block_pattern_dec = {4'd7,  6'd5};
176
      9'b0010_110x_x: coded_block_pattern_dec = {4'd7,  6'd9};
177
      9'b0010_101x_x: coded_block_pattern_dec = {4'd7,  6'd17};
178
      9'b0010_100x_x: coded_block_pattern_dec = {4'd7,  6'd33};
179
      9'b0010_011x_x: coded_block_pattern_dec = {4'd7,  6'd6};
180
      9'b0010_010x_x: coded_block_pattern_dec = {4'd7,  6'd10};
181
      9'b0010_001x_x: coded_block_pattern_dec = {4'd7,  6'd18};
182
      9'b0010_000x_x: coded_block_pattern_dec = {4'd7,  6'd34};
183
      9'b0011_11xx_x: coded_block_pattern_dec = {4'd6,  6'd24};
184
      9'b0011_10xx_x: coded_block_pattern_dec = {4'd6,  6'd36};
185
      9'b0011_01xx_x: coded_block_pattern_dec = {4'd6,  6'd3};
186
      9'b0011_00xx_x: coded_block_pattern_dec = {4'd6,  6'd63};
187
      9'b1001_1xxx_x: coded_block_pattern_dec = {4'd5,  6'd12};
188
      9'b1001_0xxx_x: coded_block_pattern_dec = {4'd5,  6'd48};
189
      9'b1000_1xxx_x: coded_block_pattern_dec = {4'd5,  6'd20};
190
      9'b1000_0xxx_x: coded_block_pattern_dec = {4'd5,  6'd40};
191
      9'b0111_1xxx_x: coded_block_pattern_dec = {4'd5,  6'd28};
192
      9'b0111_0xxx_x: coded_block_pattern_dec = {4'd5,  6'd44};
193
      9'b0110_1xxx_x: coded_block_pattern_dec = {4'd5,  6'd52};
194
      9'b0110_0xxx_x: coded_block_pattern_dec = {4'd5,  6'd56};
195
      9'b0101_1xxx_x: coded_block_pattern_dec = {4'd5,  6'd1};
196
      9'b0101_0xxx_x: coded_block_pattern_dec = {4'd5,  6'd61};
197
      9'b0100_1xxx_x: coded_block_pattern_dec = {4'd5,  6'd2};
198
      9'b0100_0xxx_x: coded_block_pattern_dec = {4'd5,  6'd62};
199
      9'b1101_xxxx_x: coded_block_pattern_dec = {4'd4,  6'd4};
200
      9'b1100_xxxx_x: coded_block_pattern_dec = {4'd4,  6'd8};
201
      9'b1011_xxxx_x: coded_block_pattern_dec = {4'd4,  6'd16};
202
      9'b1010_xxxx_x: coded_block_pattern_dec = {4'd4,  6'd32};
203
      9'b111x_xxxx_x: coded_block_pattern_dec = {4'd3,  6'd60};
204
      default         coded_block_pattern_dec = {4'd0,  6'd0}; // Error
205
    endcase
206
  end
207
endfunction
208
 
209
/*
210
  Function motion_code_dec translates
211
  motion code vlc to {codelength, codeword, sign} triplets
212
  as in table B-10 from ISO/IEC 13818-2.
213
  First 4 bits of output are` code length,
214
  next 5 bits of output are code value,
215
  last bit is sign (1 = negative, 0 = positive).
216
*/
217
 
218
function [9:0]motion_code_dec;
219
  input [10:0]codeword;
220
  begin
221
    casex(codeword)
222
      11'b0000_0011_001: motion_code_dec = {4'd11, 5'd16, 1'b1};
223
      11'b0000_0011_011: motion_code_dec = {4'd11, 5'd15, 1'b1};
224
      11'b0000_0011_101: motion_code_dec = {4'd11, 5'd14, 1'b1};
225
      11'b0000_0011_111: motion_code_dec = {4'd11, 5'd13, 1'b1};
226
      11'b0000_0100_001: motion_code_dec = {4'd11, 5'd12, 1'b1};
227
      11'b0000_0100_011: motion_code_dec = {4'd11, 5'd11, 1'b1};
228
      11'b0000_0100_010: motion_code_dec = {4'd11, 5'd11, 1'b0};
229
      11'b0000_0100_000: motion_code_dec = {4'd11, 5'd12, 1'b0};
230
      11'b0000_0011_110: motion_code_dec = {4'd11, 5'd13, 1'b0};
231
      11'b0000_0011_100: motion_code_dec = {4'd11, 5'd14, 1'b0};
232
      11'b0000_0011_010: motion_code_dec = {4'd11, 5'd15, 1'b0};
233
      11'b0000_0011_000: motion_code_dec = {4'd11, 5'd16, 1'b0};
234
      11'b0000_0100_11x: motion_code_dec = {4'd10, 5'd10, 1'b1};
235
      11'b0000_0101_01x: motion_code_dec = {4'd10, 5'd9,  1'b1};
236
      11'b0000_0101_11x: motion_code_dec = {4'd10, 5'd8,  1'b1};
237
      11'b0000_0101_10x: motion_code_dec = {4'd10, 5'd8,  1'b0};
238
      11'b0000_0101_00x: motion_code_dec = {4'd10, 5'd9,  1'b0};
239
      11'b0000_0100_10x: motion_code_dec = {4'd10, 5'd10, 1'b0};
240
      11'b0000_0111_xxx: motion_code_dec = {4'd8,  5'd7,  1'b1};
241
      11'b0000_1001_xxx: motion_code_dec = {4'd8,  5'd6,  1'b1};
242
      11'b0000_1011_xxx: motion_code_dec = {4'd8,  5'd5,  1'b1};
243
      11'b0000_1010_xxx: motion_code_dec = {4'd8,  5'd5,  1'b0};
244
      11'b0000_1000_xxx: motion_code_dec = {4'd8,  5'd6,  1'b0};
245
      11'b0000_0110_xxx: motion_code_dec = {4'd8,  5'd7,  1'b0};
246
      11'b0000_111x_xxx: motion_code_dec = {4'd7,  5'd4,  1'b1};
247
      11'b0000_110x_xxx: motion_code_dec = {4'd7,  5'd4,  1'b0};
248
      11'b0001_1xxx_xxx: motion_code_dec = {4'd5,  5'd3,  1'b1};
249
      11'b0001_0xxx_xxx: motion_code_dec = {4'd5,  5'd3,  1'b0};
250
      11'b0011_xxxx_xxx: motion_code_dec = {4'd4,  5'd2,  1'b1};
251
      11'b0010_xxxx_xxx: motion_code_dec = {4'd4,  5'd2,  1'b0};
252
      11'b011x_xxxx_xxx: motion_code_dec = {4'd3,  5'd1,  1'b1};
253
      11'b010x_xxxx_xxx: motion_code_dec = {4'd3,  5'd1,  1'b0};
254
      11'b1xxx_xxxx_xxx: motion_code_dec = {4'd1,  5'd0,  1'b0};
255
      default            motion_code_dec = {4'd0,  5'd0,  1'b0}; // Error
256
    endcase
257
  end
258
endfunction
259
 
260
 
261
/*
262
  Function dmvector_dec translates
263
  dmvector vlc code to {codelength, codeword, sign} triplets
264
  as in table B-11 from ISO/IEC 13818-2.
265
  First 2 bits of output are` code length, next bit of output is code value.
266
  Last bit is sign (1 if negative, 0 if positive).
267
*/
268
 
269
function [3:0]dmvector_dec;
270
  input [1:0]codeword;
271
  begin
272
    casex(codeword)
273
      2'b11:  dmvector_dec = {2'd2,  1'd1, 1'b1};
274
      2'b10:  dmvector_dec = {2'd2,  1'd1, 1'b0};
275
      2'b0x:  dmvector_dec = {2'd1,  1'd0, 1'b0};
276
      default dmvector_dec = {2'd0,  1'd0, 1'b0}; // Error
277
    endcase
278
  end
279
endfunction
280
 
281
/*
282
  Function dct_dc_size_luminance_dec translates
283
  dct_dc_size_luminance vlc code to {codelength, codeword} pairs
284
  as in table B-12 from ISO/IEC 13818-2.
285
  First 4 bits of output are code length, next 5 bits are code value.
286
*/
287
 
288
function [8:0]dct_dc_size_luminance_dec;
289
  input [8:0]codeword;
290
  begin
291
    `ifdef DEBUG_VLC
292
    $strobe("%m\tcodeword:                    %b", codeword);
293
    $strobe("%m\tdct_dc_size_luminance_dec:   %b", dct_dc_size_luminance_dec);
294
    `endif
295
    casex(codeword)
296
      9'b1111_1111_0: dct_dc_size_luminance_dec = {4'd9, 5'd10};
297
      9'b1111_1111_1: dct_dc_size_luminance_dec = {4'd9, 5'd11};
298
      9'b1111_1110_x: dct_dc_size_luminance_dec = {4'd8, 5'd9};
299
      9'b1111_110x_x: dct_dc_size_luminance_dec = {4'd7, 5'd8};
300
      9'b1111_10xx_x: dct_dc_size_luminance_dec = {4'd6, 5'd7};
301
      9'b1111_0xxx_x: dct_dc_size_luminance_dec = {4'd5, 5'd6};
302
      9'b1110_xxxx_x: dct_dc_size_luminance_dec = {4'd4, 5'd5};
303
      9'b100x_xxxx_x: dct_dc_size_luminance_dec = {4'd3, 5'd0};
304
      9'b101x_xxxx_x: dct_dc_size_luminance_dec = {4'd3, 5'd3};
305
      9'b110x_xxxx_x: dct_dc_size_luminance_dec = {4'd3, 5'd4};
306
      9'b00xx_xxxx_x: dct_dc_size_luminance_dec = {4'd2, 5'd1};
307
      9'b01xx_xxxx_x: dct_dc_size_luminance_dec = {4'd2, 5'd2};
308
      default         dct_dc_size_luminance_dec = {4'd0, 5'd0}; // Error
309
    endcase
310
  end
311
endfunction
312
 
313
/*
314
  Function dct_dc_size_chrominance_dec translates
315
  dct_dc_size_chrominance vlc code to {codelength, codeword} pairs
316
  as in table B-13 from ISO/IEC 13818-2.
317
  First 4 bits of output are code length, next 5 bits are code value.
318
*/
319
 
320
function [8:0]dct_dc_size_chrominance_dec;
321
  input [9:0]codeword;
322
  begin
323
    `ifdef DEBUG_VLC
324
    $strobe("%m\tcodeword:                    %b", codeword);
325
    $strobe("%m\tdct_dc_size_chrominance_dec: %b", dct_dc_size_chrominance_dec);
326
    `endif
327
    casex(codeword)
328
      10'b1111_1111_10: dct_dc_size_chrominance_dec = {4'd10, 5'd10};
329
      10'b1111_1111_11: dct_dc_size_chrominance_dec = {4'd10, 5'd11};
330
      10'b1111_1111_0x: dct_dc_size_chrominance_dec = {4'd9, 5'd9};
331
      10'b1111_1110_xx: dct_dc_size_chrominance_dec = {4'd8, 5'd8};
332
      10'b1111_110x_xx: dct_dc_size_chrominance_dec = {4'd7, 5'd7};
333
      10'b1111_10xx_xx: dct_dc_size_chrominance_dec = {4'd6, 5'd6};
334
      10'b1111_0xxx_xx: dct_dc_size_chrominance_dec = {4'd5, 5'd5};
335
      10'b1110_xxxx_xx: dct_dc_size_chrominance_dec = {4'd4, 5'd4};
336
      10'b110x_xxxx_xx: dct_dc_size_chrominance_dec = {4'd3, 5'd3};
337
      10'b00xx_xxxx_xx: dct_dc_size_chrominance_dec = {4'd2, 5'd0};
338
      10'b01xx_xxxx_xx: dct_dc_size_chrominance_dec = {4'd2, 5'd1};
339
      10'b10xx_xxxx_xx: dct_dc_size_chrominance_dec = {4'd2, 5'd2};
340
      default           dct_dc_size_chrominance_dec = {4'd0, 5'd0};
341
    endcase
342
  end
343
endfunction
344
 
345
/*
346
  Function dct_coefficient_0_dec translates
347
  dct coefficient table zero vlc code to {codelength, run , level} triplets
348
  as in table B-14 from ISO/IEC 13818-2.
349
  First 5 bits are code length,
350
  next 5 bits are run value,
351
  next 6 bits are unsigned level value.
352
  Code length includes sign bit.
353
*/
354
 
355
function [15:0]dct_coefficient_0_dec;
356
  input [15:0]codeword;
357
  begin
358
    `ifdef DEBUG_VLC
359
    $strobe("%m\tcodeword:                    %b", codeword);
360
    $strobe("%m\tdct_coefficient_0_dec:       %b", dct_coefficient_0_dec);
361
    `endif
362
    casex(codeword)
363
      16'b0000000000010011: dct_coefficient_0_dec = {5'd17, 5'd01, 6'd15}; // codeword = 0000000000010011, run =  1, level =  15
364
      16'b0000000000010010: dct_coefficient_0_dec = {5'd17, 5'd01, 6'd16}; // codeword = 0000000000010010, run =  1, level =  16
365
      16'b0000000000010001: dct_coefficient_0_dec = {5'd17, 5'd01, 6'd17}; // codeword = 0000000000010001, run =  1, level =  17
366
      16'b0000000000010000: dct_coefficient_0_dec = {5'd17, 5'd01, 6'd18}; // codeword = 0000000000010000, run =  1, level =  18
367
      16'b0000000000010100: dct_coefficient_0_dec = {5'd17, 5'd06, 6'd03}; // codeword = 0000000000010100, run =  6, level =   3
368
      16'b0000000000011010: dct_coefficient_0_dec = {5'd17, 5'd11, 6'd02}; // codeword = 0000000000011010, run = 11, level =   2
369
      16'b0000000000011001: dct_coefficient_0_dec = {5'd17, 5'd12, 6'd02}; // codeword = 0000000000011001, run = 12, level =   2
370
      16'b0000000000011000: dct_coefficient_0_dec = {5'd17, 5'd13, 6'd02}; // codeword = 0000000000011000, run = 13, level =   2
371
      16'b0000000000010111: dct_coefficient_0_dec = {5'd17, 5'd14, 6'd02}; // codeword = 0000000000010111, run = 14, level =   2
372
      16'b0000000000010110: dct_coefficient_0_dec = {5'd17, 5'd15, 6'd02}; // codeword = 0000000000010110, run = 15, level =   2
373
      16'b0000000000010101: dct_coefficient_0_dec = {5'd17, 5'd16, 6'd02}; // codeword = 0000000000010101, run = 16, level =   2
374
      16'b0000000000011111: dct_coefficient_0_dec = {5'd17, 5'd27, 6'd01}; // codeword = 0000000000011111, run = 27, level =   1
375
      16'b0000000000011110: dct_coefficient_0_dec = {5'd17, 5'd28, 6'd01}; // codeword = 0000000000011110, run = 28, level =   1
376
      16'b0000000000011101: dct_coefficient_0_dec = {5'd17, 5'd29, 6'd01}; // codeword = 0000000000011101, run = 29, level =   1
377
      16'b0000000000011100: dct_coefficient_0_dec = {5'd17, 5'd30, 6'd01}; // codeword = 0000000000011100, run = 30, level =   1
378
      16'b0000000000011011: dct_coefficient_0_dec = {5'd17, 5'd31, 6'd01}; // codeword = 0000000000011011, run = 31, level =   1
379
      16'b000000000011000x: dct_coefficient_0_dec = {5'd16, 5'd00, 6'd32}; // codeword = 000000000011000 , run =  0, level =  32
380
      16'b000000000010111x: dct_coefficient_0_dec = {5'd16, 5'd00, 6'd33}; // codeword = 000000000010111 , run =  0, level =  33
381
      16'b000000000010110x: dct_coefficient_0_dec = {5'd16, 5'd00, 6'd34}; // codeword = 000000000010110 , run =  0, level =  34
382
      16'b000000000010101x: dct_coefficient_0_dec = {5'd16, 5'd00, 6'd35}; // codeword = 000000000010101 , run =  0, level =  35
383
      16'b000000000010100x: dct_coefficient_0_dec = {5'd16, 5'd00, 6'd36}; // codeword = 000000000010100 , run =  0, level =  36
384
      16'b000000000010011x: dct_coefficient_0_dec = {5'd16, 5'd00, 6'd37}; // codeword = 000000000010011 , run =  0, level =  37
385
      16'b000000000010010x: dct_coefficient_0_dec = {5'd16, 5'd00, 6'd38}; // codeword = 000000000010010 , run =  0, level =  38
386
      16'b000000000010001x: dct_coefficient_0_dec = {5'd16, 5'd00, 6'd39}; // codeword = 000000000010001 , run =  0, level =  39
387
      16'b000000000010000x: dct_coefficient_0_dec = {5'd16, 5'd00, 6'd40}; // codeword = 000000000010000 , run =  0, level =  40
388
      16'b000000000011111x: dct_coefficient_0_dec = {5'd16, 5'd01, 6'd08}; // codeword = 000000000011111 , run =  1, level =   8
389
      16'b000000000011110x: dct_coefficient_0_dec = {5'd16, 5'd01, 6'd09}; // codeword = 000000000011110 , run =  1, level =   9
390
      16'b000000000011101x: dct_coefficient_0_dec = {5'd16, 5'd01, 6'd10}; // codeword = 000000000011101 , run =  1, level =  10
391
      16'b000000000011100x: dct_coefficient_0_dec = {5'd16, 5'd01, 6'd11}; // codeword = 000000000011100 , run =  1, level =  11
392
      16'b000000000011011x: dct_coefficient_0_dec = {5'd16, 5'd01, 6'd12}; // codeword = 000000000011011 , run =  1, level =  12
393
      16'b000000000011010x: dct_coefficient_0_dec = {5'd16, 5'd01, 6'd13}; // codeword = 000000000011010 , run =  1, level =  13
394
      16'b000000000011001x: dct_coefficient_0_dec = {5'd16, 5'd01, 6'd14}; // codeword = 000000000011001 , run =  1, level =  14
395
      16'b00000000011111xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd16}; // codeword = 00000000011111  , run =  0, level =  16
396
      16'b00000000011110xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd17}; // codeword = 00000000011110  , run =  0, level =  17
397
      16'b00000000011101xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd18}; // codeword = 00000000011101  , run =  0, level =  18
398
      16'b00000000011100xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd19}; // codeword = 00000000011100  , run =  0, level =  19
399
      16'b00000000011011xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd20}; // codeword = 00000000011011  , run =  0, level =  20
400
      16'b00000000011010xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd21}; // codeword = 00000000011010  , run =  0, level =  21
401
      16'b00000000011001xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd22}; // codeword = 00000000011001  , run =  0, level =  22
402
      16'b00000000011000xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd23}; // codeword = 00000000011000  , run =  0, level =  23
403
      16'b00000000010111xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd24}; // codeword = 00000000010111  , run =  0, level =  24
404
      16'b00000000010110xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd25}; // codeword = 00000000010110  , run =  0, level =  25
405
      16'b00000000010101xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd26}; // codeword = 00000000010101  , run =  0, level =  26
406
      16'b00000000010100xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd27}; // codeword = 00000000010100  , run =  0, level =  27
407
      16'b00000000010011xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd28}; // codeword = 00000000010011  , run =  0, level =  28
408
      16'b00000000010010xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd29}; // codeword = 00000000010010  , run =  0, level =  29
409
      16'b00000000010001xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd30}; // codeword = 00000000010001  , run =  0, level =  30
410
      16'b00000000010000xx: dct_coefficient_0_dec = {5'd15, 5'd00, 6'd31}; // codeword = 00000000010000  , run =  0, level =  31
411
      16'b0000000011010xxx: dct_coefficient_0_dec = {5'd14, 5'd00, 6'd12}; // codeword = 0000000011010   , run =  0, level =  12
412
      16'b0000000011001xxx: dct_coefficient_0_dec = {5'd14, 5'd00, 6'd13}; // codeword = 0000000011001   , run =  0, level =  13
413
      16'b0000000011000xxx: dct_coefficient_0_dec = {5'd14, 5'd00, 6'd14}; // codeword = 0000000011000   , run =  0, level =  14
414
      16'b0000000010111xxx: dct_coefficient_0_dec = {5'd14, 5'd00, 6'd15}; // codeword = 0000000010111   , run =  0, level =  15
415
      16'b0000000010110xxx: dct_coefficient_0_dec = {5'd14, 5'd01, 6'd06}; // codeword = 0000000010110   , run =  1, level =   6
416
      16'b0000000010101xxx: dct_coefficient_0_dec = {5'd14, 5'd01, 6'd07}; // codeword = 0000000010101   , run =  1, level =   7
417
      16'b0000000010100xxx: dct_coefficient_0_dec = {5'd14, 5'd02, 6'd05}; // codeword = 0000000010100   , run =  2, level =   5
418
      16'b0000000010011xxx: dct_coefficient_0_dec = {5'd14, 5'd03, 6'd04}; // codeword = 0000000010011   , run =  3, level =   4
419
      16'b0000000010010xxx: dct_coefficient_0_dec = {5'd14, 5'd05, 6'd03}; // codeword = 0000000010010   , run =  5, level =   3
420
      16'b0000000010001xxx: dct_coefficient_0_dec = {5'd14, 5'd09, 6'd02}; // codeword = 0000000010001   , run =  9, level =   2
421
      16'b0000000010000xxx: dct_coefficient_0_dec = {5'd14, 5'd10, 6'd02}; // codeword = 0000000010000   , run = 10, level =   2
422
      16'b0000000011111xxx: dct_coefficient_0_dec = {5'd14, 5'd22, 6'd01}; // codeword = 0000000011111   , run = 22, level =   1
423
      16'b0000000011110xxx: dct_coefficient_0_dec = {5'd14, 5'd23, 6'd01}; // codeword = 0000000011110   , run = 23, level =   1
424
      16'b0000000011101xxx: dct_coefficient_0_dec = {5'd14, 5'd24, 6'd01}; // codeword = 0000000011101   , run = 24, level =   1
425
      16'b0000000011100xxx: dct_coefficient_0_dec = {5'd14, 5'd25, 6'd01}; // codeword = 0000000011100   , run = 25, level =   1
426
      16'b0000000011011xxx: dct_coefficient_0_dec = {5'd14, 5'd26, 6'd01}; // codeword = 0000000011011   , run = 26, level =   1
427
      16'b000000011101xxxx: dct_coefficient_0_dec = {5'd13, 5'd00, 6'd08}; // codeword = 000000011101    , run =  0, level =   8
428
      16'b000000011000xxxx: dct_coefficient_0_dec = {5'd13, 5'd00, 6'd09}; // codeword = 000000011000    , run =  0, level =   9
429
      16'b000000010011xxxx: dct_coefficient_0_dec = {5'd13, 5'd00, 6'd10}; // codeword = 000000010011    , run =  0, level =  10
430
      16'b000000010000xxxx: dct_coefficient_0_dec = {5'd13, 5'd00, 6'd11}; // codeword = 000000010000    , run =  0, level =  11
431
      16'b000000011011xxxx: dct_coefficient_0_dec = {5'd13, 5'd01, 6'd05}; // codeword = 000000011011    , run =  1, level =   5
432
      16'b000000010100xxxx: dct_coefficient_0_dec = {5'd13, 5'd02, 6'd04}; // codeword = 000000010100    , run =  2, level =   4
433
      16'b000000011100xxxx: dct_coefficient_0_dec = {5'd13, 5'd03, 6'd03}; // codeword = 000000011100    , run =  3, level =   3
434
      16'b000000010010xxxx: dct_coefficient_0_dec = {5'd13, 5'd04, 6'd03}; // codeword = 000000010010    , run =  4, level =   3
435
      16'b000000011110xxxx: dct_coefficient_0_dec = {5'd13, 5'd06, 6'd02}; // codeword = 000000011110    , run =  6, level =   2
436
      16'b000000010101xxxx: dct_coefficient_0_dec = {5'd13, 5'd07, 6'd02}; // codeword = 000000010101    , run =  7, level =   2
437
      16'b000000010001xxxx: dct_coefficient_0_dec = {5'd13, 5'd08, 6'd02}; // codeword = 000000010001    , run =  8, level =   2
438
      16'b000000011111xxxx: dct_coefficient_0_dec = {5'd13, 5'd17, 6'd01}; // codeword = 000000011111    , run = 17, level =   1
439
      16'b000000011010xxxx: dct_coefficient_0_dec = {5'd13, 5'd18, 6'd01}; // codeword = 000000011010    , run = 18, level =   1
440
      16'b000000011001xxxx: dct_coefficient_0_dec = {5'd13, 5'd19, 6'd01}; // codeword = 000000011001    , run = 19, level =   1
441
      16'b000000010111xxxx: dct_coefficient_0_dec = {5'd13, 5'd20, 6'd01}; // codeword = 000000010111    , run = 20, level =   1
442
      16'b000000010110xxxx: dct_coefficient_0_dec = {5'd13, 5'd21, 6'd01}; // codeword = 000000010110    , run = 21, level =   1
443
      16'b0000001010xxxxxx: dct_coefficient_0_dec = {5'd11, 5'd00, 6'd07}; // codeword = 0000001010      , run =  0, level =   7
444
      16'b0000001100xxxxxx: dct_coefficient_0_dec = {5'd11, 5'd01, 6'd04}; // codeword = 0000001100      , run =  1, level =   4
445
      16'b0000001011xxxxxx: dct_coefficient_0_dec = {5'd11, 5'd02, 6'd03}; // codeword = 0000001011      , run =  2, level =   3
446
      16'b0000001111xxxxxx: dct_coefficient_0_dec = {5'd11, 5'd04, 6'd02}; // codeword = 0000001111      , run =  4, level =   2
447
      16'b0000001001xxxxxx: dct_coefficient_0_dec = {5'd11, 5'd05, 6'd02}; // codeword = 0000001001      , run =  5, level =   2
448
      16'b0000001110xxxxxx: dct_coefficient_0_dec = {5'd11, 5'd14, 6'd01}; // codeword = 0000001110      , run = 14, level =   1
449
      16'b0000001101xxxxxx: dct_coefficient_0_dec = {5'd11, 5'd15, 6'd01}; // codeword = 0000001101      , run = 15, level =   1
450
      16'b0000001000xxxxxx: dct_coefficient_0_dec = {5'd11, 5'd16, 6'd01}; // codeword = 0000001000      , run = 16, level =   1
451
      16'b00100110xxxxxxxx: dct_coefficient_0_dec = {5'd09, 5'd00, 6'd05}; // codeword = 00100110        , run =  0, level =   5
452
      16'b00100001xxxxxxxx: dct_coefficient_0_dec = {5'd09, 5'd00, 6'd06}; // codeword = 00100001        , run =  0, level =   6
453
      16'b00100101xxxxxxxx: dct_coefficient_0_dec = {5'd09, 5'd01, 6'd03}; // codeword = 00100101        , run =  1, level =   3
454
      16'b00100100xxxxxxxx: dct_coefficient_0_dec = {5'd09, 5'd03, 6'd02}; // codeword = 00100100        , run =  3, level =   2
455
      16'b00100111xxxxxxxx: dct_coefficient_0_dec = {5'd09, 5'd10, 6'd01}; // codeword = 00100111        , run = 10, level =   1
456
      16'b00100011xxxxxxxx: dct_coefficient_0_dec = {5'd09, 5'd11, 6'd01}; // codeword = 00100011        , run = 11, level =   1
457
      16'b00100010xxxxxxxx: dct_coefficient_0_dec = {5'd09, 5'd12, 6'd01}; // codeword = 00100010        , run = 12, level =   1
458
      16'b00100000xxxxxxxx: dct_coefficient_0_dec = {5'd09, 5'd13, 6'd01}; // codeword = 00100000        , run = 13, level =   1
459
      16'b0000110xxxxxxxxx: dct_coefficient_0_dec = {5'd08, 5'd00, 6'd04}; // codeword = 0000110         , run =  0, level =   4
460
      16'b0000100xxxxxxxxx: dct_coefficient_0_dec = {5'd08, 5'd02, 6'd02}; // codeword = 0000100         , run =  2, level =   2
461
      16'b0000111xxxxxxxxx: dct_coefficient_0_dec = {5'd08, 5'd08, 6'd01}; // codeword = 0000111         , run =  8, level =   1
462
      16'b0000101xxxxxxxxx: dct_coefficient_0_dec = {5'd08, 5'd09, 6'd01}; // codeword = 0000101         , run =  9, level =   1
463
      16'b000110xxxxxxxxxx: dct_coefficient_0_dec = {5'd07, 5'd01, 6'd02}; // codeword = 000110          , run =  1, level =   2
464
      16'b000111xxxxxxxxxx: dct_coefficient_0_dec = {5'd07, 5'd05, 6'd01}; // codeword = 000111          , run =  5, level =   1
465
      16'b000101xxxxxxxxxx: dct_coefficient_0_dec = {5'd07, 5'd06, 6'd01}; // codeword = 000101          , run =  6, level =   1
466
      16'b000100xxxxxxxxxx: dct_coefficient_0_dec = {5'd07, 5'd07, 6'd01}; // codeword = 000100          , run =  7, level =   1
467
      16'b000001xxxxxxxxxx: dct_coefficient_0_dec = {5'd06, 5'd00, 6'd00}; // codeword = 000001          , escape (no sign bit)
468
      16'b00101xxxxxxxxxxx: dct_coefficient_0_dec = {5'd06, 5'd00, 6'd03}; // codeword = 00101           , run =  0, level =   3
469
      16'b00111xxxxxxxxxxx: dct_coefficient_0_dec = {5'd06, 5'd03, 6'd01}; // codeword = 00111           , run =  3, level =   1
470
      16'b00110xxxxxxxxxxx: dct_coefficient_0_dec = {5'd06, 5'd04, 6'd01}; // codeword = 00110           , run =  4, level =   1
471
      16'b0100xxxxxxxxxxxx: dct_coefficient_0_dec = {5'd05, 5'd00, 6'd02}; // codeword = 0100            , run =  0, level =   2
472
      16'b0101xxxxxxxxxxxx: dct_coefficient_0_dec = {5'd05, 5'd02, 6'd01}; // codeword = 0101            , run =  2, level =   1
473
      16'b011xxxxxxxxxxxxx: dct_coefficient_0_dec = {5'd04, 5'd01, 6'd01}; // codeword = 011             , run =  1, level =   1
474
      16'b10xxxxxxxxxxxxxx: dct_coefficient_0_dec = {5'd02, 5'd00, 6'd00}; // codeword = 10              , end of block (no sign bit)
475
      16'b11xxxxxxxxxxxxxx: dct_coefficient_0_dec = {5'd03, 5'd00, 6'd01}; // codeword = 11              , run =  0, level =   1
476
      default               dct_coefficient_0_dec = {5'd00, 5'd00, 6'd00}; // Error
477
    endcase
478
  end
479
endfunction
480
 
481
/*
482
  Function dct_coefficient_1_dec translates
483
  dct coefficient table one vlc code to {codelength, run, level} triplets
484
  as in table B-15 from ISO/IEC 13818-2.
485
  First 5 bits are code length,
486
  next 5 bits are run value,
487
  next 6 bits are unsigned level value.
488
  Code length includes sign bit.
489
*/
490
 
491
function [15:0]dct_coefficient_1_dec;
492
  input [15:0]codeword;
493
  begin
494
    `ifdef DEBUG_VLC
495
    $strobe("%m\tcodeword:                    %b", codeword);
496
    $strobe("%m\tdct_coefficient_1_dec:       %b", dct_coefficient_1_dec);
497
    `endif
498
    casex(codeword)
499
      16'b0000000000010011: dct_coefficient_1_dec = {5'd17, 5'd01, 6'd15}; // codeword = 0000000000010011, run =  1, level =  15
500
      16'b0000000000010010: dct_coefficient_1_dec = {5'd17, 5'd01, 6'd16}; // codeword = 0000000000010010, run =  1, level =  16
501
      16'b0000000000010001: dct_coefficient_1_dec = {5'd17, 5'd01, 6'd17}; // codeword = 0000000000010001, run =  1, level =  17
502
      16'b0000000000010000: dct_coefficient_1_dec = {5'd17, 5'd01, 6'd18}; // codeword = 0000000000010000, run =  1, level =  18
503
      16'b0000000000010100: dct_coefficient_1_dec = {5'd17, 5'd06, 6'd03}; // codeword = 0000000000010100, run =  6, level =   3
504
      16'b0000000000011010: dct_coefficient_1_dec = {5'd17, 5'd11, 6'd02}; // codeword = 0000000000011010, run = 11, level =   2
505
      16'b0000000000011001: dct_coefficient_1_dec = {5'd17, 5'd12, 6'd02}; // codeword = 0000000000011001, run = 12, level =   2
506
      16'b0000000000011000: dct_coefficient_1_dec = {5'd17, 5'd13, 6'd02}; // codeword = 0000000000011000, run = 13, level =   2
507
      16'b0000000000010111: dct_coefficient_1_dec = {5'd17, 5'd14, 6'd02}; // codeword = 0000000000010111, run = 14, level =   2
508
      16'b0000000000010110: dct_coefficient_1_dec = {5'd17, 5'd15, 6'd02}; // codeword = 0000000000010110, run = 15, level =   2
509
      16'b0000000000010101: dct_coefficient_1_dec = {5'd17, 5'd16, 6'd02}; // codeword = 0000000000010101, run = 16, level =   2
510
      16'b0000000000011111: dct_coefficient_1_dec = {5'd17, 5'd27, 6'd01}; // codeword = 0000000000011111, run = 27, level =   1
511
      16'b0000000000011110: dct_coefficient_1_dec = {5'd17, 5'd28, 6'd01}; // codeword = 0000000000011110, run = 28, level =   1
512
      16'b0000000000011101: dct_coefficient_1_dec = {5'd17, 5'd29, 6'd01}; // codeword = 0000000000011101, run = 29, level =   1
513
      16'b0000000000011100: dct_coefficient_1_dec = {5'd17, 5'd30, 6'd01}; // codeword = 0000000000011100, run = 30, level =   1
514
      16'b0000000000011011: dct_coefficient_1_dec = {5'd17, 5'd31, 6'd01}; // codeword = 0000000000011011, run = 31, level =   1
515
      16'b000000000011000x: dct_coefficient_1_dec = {5'd16, 5'd00, 6'd32}; // codeword = 000000000011000 , run =  0, level =  32
516
      16'b000000000010111x: dct_coefficient_1_dec = {5'd16, 5'd00, 6'd33}; // codeword = 000000000010111 , run =  0, level =  33
517
      16'b000000000010110x: dct_coefficient_1_dec = {5'd16, 5'd00, 6'd34}; // codeword = 000000000010110 , run =  0, level =  34
518
      16'b000000000010101x: dct_coefficient_1_dec = {5'd16, 5'd00, 6'd35}; // codeword = 000000000010101 , run =  0, level =  35
519
      16'b000000000010100x: dct_coefficient_1_dec = {5'd16, 5'd00, 6'd36}; // codeword = 000000000010100 , run =  0, level =  36
520
      16'b000000000010011x: dct_coefficient_1_dec = {5'd16, 5'd00, 6'd37}; // codeword = 000000000010011 , run =  0, level =  37
521
      16'b000000000010010x: dct_coefficient_1_dec = {5'd16, 5'd00, 6'd38}; // codeword = 000000000010010 , run =  0, level =  38
522
      16'b000000000010001x: dct_coefficient_1_dec = {5'd16, 5'd00, 6'd39}; // codeword = 000000000010001 , run =  0, level =  39
523
      16'b000000000010000x: dct_coefficient_1_dec = {5'd16, 5'd00, 6'd40}; // codeword = 000000000010000 , run =  0, level =  40
524
      16'b000000000011111x: dct_coefficient_1_dec = {5'd16, 5'd01, 6'd08}; // codeword = 000000000011111 , run =  1, level =   8
525
      16'b000000000011110x: dct_coefficient_1_dec = {5'd16, 5'd01, 6'd09}; // codeword = 000000000011110 , run =  1, level =   9
526
      16'b000000000011101x: dct_coefficient_1_dec = {5'd16, 5'd01, 6'd10}; // codeword = 000000000011101 , run =  1, level =  10
527
      16'b000000000011100x: dct_coefficient_1_dec = {5'd16, 5'd01, 6'd11}; // codeword = 000000000011100 , run =  1, level =  11
528
      16'b000000000011011x: dct_coefficient_1_dec = {5'd16, 5'd01, 6'd12}; // codeword = 000000000011011 , run =  1, level =  12
529
      16'b000000000011010x: dct_coefficient_1_dec = {5'd16, 5'd01, 6'd13}; // codeword = 000000000011010 , run =  1, level =  13
530
      16'b000000000011001x: dct_coefficient_1_dec = {5'd16, 5'd01, 6'd14}; // codeword = 000000000011001 , run =  1, level =  14
531
      16'b00000000011111xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd16}; // codeword = 00000000011111  , run =  0, level =  16
532
      16'b00000000011110xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd17}; // codeword = 00000000011110  , run =  0, level =  17
533
      16'b00000000011101xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd18}; // codeword = 00000000011101  , run =  0, level =  18
534
      16'b00000000011100xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd19}; // codeword = 00000000011100  , run =  0, level =  19
535
      16'b00000000011011xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd20}; // codeword = 00000000011011  , run =  0, level =  20
536
      16'b00000000011010xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd21}; // codeword = 00000000011010  , run =  0, level =  21
537
      16'b00000000011001xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd22}; // codeword = 00000000011001  , run =  0, level =  22
538
      16'b00000000011000xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd23}; // codeword = 00000000011000  , run =  0, level =  23
539
      16'b00000000010111xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd24}; // codeword = 00000000010111  , run =  0, level =  24
540
      16'b00000000010110xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd25}; // codeword = 00000000010110  , run =  0, level =  25
541
      16'b00000000010101xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd26}; // codeword = 00000000010101  , run =  0, level =  26
542
      16'b00000000010100xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd27}; // codeword = 00000000010100  , run =  0, level =  27
543
      16'b00000000010011xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd28}; // codeword = 00000000010011  , run =  0, level =  28
544
      16'b00000000010010xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd29}; // codeword = 00000000010010  , run =  0, level =  29
545
      16'b00000000010001xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd30}; // codeword = 00000000010001  , run =  0, level =  30
546
      16'b00000000010000xx: dct_coefficient_1_dec = {5'd15, 5'd00, 6'd31}; // codeword = 00000000010000  , run =  0, level =  31
547
      16'b0000000010110xxx: dct_coefficient_1_dec = {5'd14, 5'd01, 6'd06}; // codeword = 0000000010110   , run =  1, level =   6
548
      16'b0000000010101xxx: dct_coefficient_1_dec = {5'd14, 5'd01, 6'd07}; // codeword = 0000000010101   , run =  1, level =   7
549
      16'b0000000010100xxx: dct_coefficient_1_dec = {5'd14, 5'd02, 6'd05}; // codeword = 0000000010100   , run =  2, level =   5
550
      16'b0000000010011xxx: dct_coefficient_1_dec = {5'd14, 5'd03, 6'd04}; // codeword = 0000000010011   , run =  3, level =   4
551
      16'b0000000010010xxx: dct_coefficient_1_dec = {5'd14, 5'd05, 6'd03}; // codeword = 0000000010010   , run =  5, level =   3
552
      16'b0000000010001xxx: dct_coefficient_1_dec = {5'd14, 5'd09, 6'd02}; // codeword = 0000000010001   , run =  9, level =   2
553
      16'b0000000010000xxx: dct_coefficient_1_dec = {5'd14, 5'd10, 6'd02}; // codeword = 0000000010000   , run = 10, level =   2
554
      16'b0000000011111xxx: dct_coefficient_1_dec = {5'd14, 5'd22, 6'd01}; // codeword = 0000000011111   , run = 22, level =   1
555
      16'b0000000011110xxx: dct_coefficient_1_dec = {5'd14, 5'd23, 6'd01}; // codeword = 0000000011110   , run = 23, level =   1
556
      16'b0000000011101xxx: dct_coefficient_1_dec = {5'd14, 5'd24, 6'd01}; // codeword = 0000000011101   , run = 24, level =   1
557
      16'b0000000011100xxx: dct_coefficient_1_dec = {5'd14, 5'd25, 6'd01}; // codeword = 0000000011100   , run = 25, level =   1
558
      16'b0000000011011xxx: dct_coefficient_1_dec = {5'd14, 5'd26, 6'd01}; // codeword = 0000000011011   , run = 26, level =   1
559
      16'b000000011100xxxx: dct_coefficient_1_dec = {5'd13, 5'd03, 6'd03}; // codeword = 000000011100    , run =  3, level =   3
560
      16'b000000010010xxxx: dct_coefficient_1_dec = {5'd13, 5'd04, 6'd03}; // codeword = 000000010010    , run =  4, level =   3
561
      16'b000000011110xxxx: dct_coefficient_1_dec = {5'd13, 5'd06, 6'd02}; // codeword = 000000011110    , run =  6, level =   2
562
      16'b000000010101xxxx: dct_coefficient_1_dec = {5'd13, 5'd07, 6'd02}; // codeword = 000000010101    , run =  7, level =   2
563
      16'b000000010001xxxx: dct_coefficient_1_dec = {5'd13, 5'd08, 6'd02}; // codeword = 000000010001    , run =  8, level =   2
564
      16'b000000011111xxxx: dct_coefficient_1_dec = {5'd13, 5'd17, 6'd01}; // codeword = 000000011111    , run = 17, level =   1
565
      16'b000000011010xxxx: dct_coefficient_1_dec = {5'd13, 5'd18, 6'd01}; // codeword = 000000011010    , run = 18, level =   1
566
      16'b000000011001xxxx: dct_coefficient_1_dec = {5'd13, 5'd19, 6'd01}; // codeword = 000000011001    , run = 19, level =   1
567
      16'b000000010111xxxx: dct_coefficient_1_dec = {5'd13, 5'd20, 6'd01}; // codeword = 000000010111    , run = 20, level =   1
568
      16'b000000010110xxxx: dct_coefficient_1_dec = {5'd13, 5'd21, 6'd01}; // codeword = 000000010110    , run = 21, level =   1
569
      16'b0000001101xxxxxx: dct_coefficient_1_dec = {5'd11, 5'd16, 6'd01}; // codeword = 0000001101      , run = 16, level =   1
570
      16'b0000001100xxxxxx: dct_coefficient_1_dec = {5'd11, 5'd02, 6'd04}; // codeword = 0000001100      , run =  2, level =   4
571
      16'b000000100xxxxxxx: dct_coefficient_1_dec = {5'd10, 5'd05, 6'd02}; // codeword = 000000100       , run =  5, level =   2
572
      16'b000000101xxxxxxx: dct_coefficient_1_dec = {5'd10, 5'd14, 6'd01}; // codeword = 000000101       , run = 14, level =   1
573
      16'b000000111xxxxxxx: dct_coefficient_1_dec = {5'd10, 5'd15, 6'd01}; // codeword = 000000111       , run = 15, level =   1
574
      16'b00100110xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd03, 6'd02}; // codeword = 00100110        , run =  3, level =   2
575
      16'b00100001xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd11, 6'd01}; // codeword = 00100001        , run = 11, level =   1
576
      16'b00100101xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd12, 6'd01}; // codeword = 00100101        , run = 12, level =   1
577
      16'b00100100xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd13, 6'd01}; // codeword = 00100100        , run = 13, level =   1
578
      16'b00100111xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd01, 6'd04}; // codeword = 00100111        , run =  1, level =   4
579
      16'b11111100xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd02, 6'd03}; // codeword = 11111100        , run =  2, level =   3
580
      16'b11111101xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd04, 6'd02}; // codeword = 11111101        , run =  4, level =   2
581
      16'b00100011xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd00, 6'd10}; // codeword = 00100011        , run =  0, level =  10
582
      16'b00100010xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd00, 6'd11}; // codeword = 00100010        , run =  0, level =  11
583
      16'b00100000xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd01, 6'd05}; // codeword = 00100000        , run =  1, level =   5
584
      16'b11111010xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd00, 6'd12}; // codeword = 11111010        , run =  0, level =  12
585
      16'b11111011xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd00, 6'd13}; // codeword = 11111011        , run =  0, level =  13
586
      16'b11111110xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd00, 6'd14}; // codeword = 11111110        , run =  0, level =  14
587
      16'b11111111xxxxxxxx: dct_coefficient_1_dec = {5'd09, 5'd00, 6'd15}; // codeword = 11111111        , run =  0, level =  15
588
      16'b0000110xxxxxxxxx: dct_coefficient_1_dec = {5'd08, 5'd06, 6'd01}; // codeword = 0000110         , run =  6, level =   1
589
      16'b0000100xxxxxxxxx: dct_coefficient_1_dec = {5'd08, 5'd07, 6'd01}; // codeword = 0000100         , run =  7, level =   1
590
      16'b0000111xxxxxxxxx: dct_coefficient_1_dec = {5'd08, 5'd02, 6'd02}; // codeword = 0000111         , run =  2, level =   2
591
      16'b0000101xxxxxxxxx: dct_coefficient_1_dec = {5'd08, 5'd08, 6'd01}; // codeword = 0000101         , run =  8, level =   1
592
      16'b1111000xxxxxxxxx: dct_coefficient_1_dec = {5'd08, 5'd09, 6'd01}; // codeword = 1111000         , run =  9, level =   1
593
      16'b1111001xxxxxxxxx: dct_coefficient_1_dec = {5'd08, 5'd01, 6'd03}; // codeword = 1111001         , run =  1, level =   3
594
      16'b1111010xxxxxxxxx: dct_coefficient_1_dec = {5'd08, 5'd10, 6'd01}; // codeword = 1111010         , run = 10, level =   1
595
      16'b1111011xxxxxxxxx: dct_coefficient_1_dec = {5'd08, 5'd00, 6'd08}; // codeword = 1111011         , run =  0, level =   8
596
      16'b1111100xxxxxxxxx: dct_coefficient_1_dec = {5'd08, 5'd00, 6'd09}; // codeword = 1111100         , run =  0, level =   9
597
      16'b000110xxxxxxxxxx: dct_coefficient_1_dec = {5'd07, 5'd04, 6'd01}; // codeword = 000110          , run =  4, level =   1
598
      16'b000111xxxxxxxxxx: dct_coefficient_1_dec = {5'd07, 5'd05, 6'd01}; // codeword = 000111          , run =  5, level =   1
599
      16'b000001xxxxxxxxxx: dct_coefficient_1_dec = {5'd06, 5'd00, 6'd00}; // codeword = 000001          , escape (no sign bit)
600
      16'b000101xxxxxxxxxx: dct_coefficient_1_dec = {5'd07, 5'd00, 6'd06}; // codeword = 000101          , run =  0, level =   6
601
      16'b000100xxxxxxxxxx: dct_coefficient_1_dec = {5'd07, 5'd00, 6'd07}; // codeword = 000100          , run =  0, level =   7
602
      16'b00101xxxxxxxxxxx: dct_coefficient_1_dec = {5'd06, 5'd02, 6'd01}; // codeword = 00101           , run =  2, level =   1
603
      16'b00111xxxxxxxxxxx: dct_coefficient_1_dec = {5'd06, 5'd03, 6'd01}; // codeword = 00111           , run =  3, level =   1
604
      16'b00110xxxxxxxxxxx: dct_coefficient_1_dec = {5'd06, 5'd01, 6'd02}; // codeword = 00110           , run =  1, level =   2
605
      16'b11100xxxxxxxxxxx: dct_coefficient_1_dec = {5'd06, 5'd00, 6'd04}; // codeword = 11100           , run =  0, level =   4
606
      16'b11101xxxxxxxxxxx: dct_coefficient_1_dec = {5'd06, 5'd00, 6'd05}; // codeword = 11101           , run =  0, level =   5
607
      16'b0110xxxxxxxxxxxx: dct_coefficient_1_dec = {5'd04, 5'd00, 6'd00}; // codeword = 0110            , end of block (no sign bit)
608
      16'b0111xxxxxxxxxxxx: dct_coefficient_1_dec = {5'd05, 5'd00, 6'd03}; // codeword = 0111            , run =  0, level =   3
609
      16'b010xxxxxxxxxxxxx: dct_coefficient_1_dec = {5'd04, 5'd01, 6'd01}; // codeword = 010             , run =  1, level =   1
610
      16'b110xxxxxxxxxxxxx: dct_coefficient_1_dec = {5'd04, 5'd00, 6'd02}; // codeword = 110             , run =  0, level =   2
611
      16'b10xxxxxxxxxxxxxx: dct_coefficient_1_dec = {5'd03, 5'd00, 6'd01}; // codeword = 10              , run =  0, level =   1
612
      default               dct_coefficient_1_dec = {5'd00, 5'd00, 6'd00}; // Error 
613
    endcase
614
  end
615
endfunction
616
/* not truncated */

powered by: WebSVN 2.1.0

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