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

Subversion Repositories djpeg

[/] [djpeg/] [trunk/] [src/] [jpeg_decode.v] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 hidemi
//---------------------------------------------------------------------------
2
// File Name   : jpeg_decode.v
3
// Module Name : jpeg_decode
4
// Description : JPEG Deocder top module
5
// Project     : JPEG Decoder
6
// Belong to   : 
7
// Author      : H.Ishihara
8
// E-Mail      : hidemi@sweetcafe.jp
9
// HomePage    : http://www.sweetcafe.jp/
10
// Date        : 2006/10/01
11
// Rev.        : 1.1
12
//---------------------------------------------------------------------------
13
// Rev. Date       Description
14
//---------------------------------------------------------------------------
15
// 1.01 2006/10/01 1st Release
16
// 1.02 2006/10/04 add ProcessIdle register
17
//---------------------------------------------------------------------------
18
// $Id: 
19
//---------------------------------------------------------------------------
20
`timescale 1ps / 1ps
21
 
22
module jpeg_decode
23
  (
24
   rst,
25
   clk,
26
 
27
   // From FIFO
28
   DataIn,
29
   DataInEnable,
30
   DataInRead,
31
 
32
   JpegDecodeStart, // 
33
   JpegDecodeIdle,  // Deocdeer Process Idle(1:Idle, 0:Run)
34
 
35
   OutEnable,
36
   OutWidth,
37
   OutHeight,
38
   OutPixelX,
39
   OutPixelY,
40
   OutR,
41
   OutG,
42
   OutB
43
 
44
   );
45
 
46
   input          rst;
47
   input          clk;
48
 
49
   input [31:0]   DataIn;
50
   input          DataInEnable;
51
   output         DataInRead;
52
 
53
   input          JpegDecodeStart;
54
   output         JpegDecodeIdle;
55
 
56
   output         OutEnable;
57
   output [15:0]  OutWidth;
58
   output [15:0]  OutHeight;
59
   output [15:0]  OutPixelX;
60
   output [15:0]  OutPixelY;
61
   output [7:0]   OutR;
62
   output [7:0]   OutG;
63
   output [7:0]   OutB;
64
 
65
   wire [31:0]    JpegData;
66
   wire           JpegDataEnable;
67
   wire           JpegDataEnd;
68
 
69
   wire           UseBit;
70
   wire [6:0]     UseWidth;
71
   wire           UseByte;
72
   wire           UseWord;
73
 
74
   wire           ImageEnable;
75
   wire           EnableFF00;
76
 
77
   //--------------------------------------------------------------------------
78
   // Read JPEG Data from FIFO
79
   //--------------------------------------------------------------------------
80
   jpeg_regdata u_jpeg_regdata(
81
                               .rst(rst),
82
                               .clk(clk),
83
 
84
                               // Read Data
85
                               .DataInStart   ( JpegDecodeStart     ),
86
                               .DataIn        ( DataIn              ),
87
                               .DataInEnable  ( DataInEnable        ),
88
                               .DataInRead    ( DataInRead          ),
89
 
90
                               // DataOut
91
                               .DataOut       ( JpegData            ),
92
                               .DataOutEnable ( JpegDataEnable      ),
93
                               .DataOutEnd    ( JpegDataEnd         ),
94
 
95
                               //
96
                               .ImageEnable   ( EnableFF00          ),
97
 
98
                               // UseData
99
                               .UseBit        ( UseBit              ),
100
                               .UseWidth      ( UseWidth            ),
101
                               .UseByte       ( UseByte             ),
102
                               .UseWord       ( UseWord             )
103
                               );
104
 
105
   //--------------------------------------------------------------------------
106
   // Read Maker from Jpeg Data
107
   //--------------------------------------------------------------------------
108
   wire           DqtEnable;
109
   wire           DqtTable;
110
   wire [5:0]      DqtCount;
111
   wire [7:0]      DqtData;
112
 
113
   wire           DhtEnable;
114
   wire [1:0]      DhtTable;
115
   wire [7:0]      DhtCount;
116
   wire [7:0]      DhtData;
117
 
118
   //
119
   wire           HaffumanEnable;
120
   wire [1:0]      HaffumanTable;
121
   wire [3:0]      HaffumanCount;
122
   wire [15:0]     HaffumanData;
123
   wire [7:0]      HaffumanStart;
124
 
125
   wire [11:0]     JpegBlockWidth;
126
 
127
   jpeg_decode_fsm u_jpeg_decode_fsm(
128
                                     .rst(rst),
129
                                     .clk(clk),
130
 
131
                                     // From FIFO
132
                                     .DataInEnable    ( JpegDataEnable  ),
133
                                     .DataIn          ( JpegData        ),
134
 
135
                                     .JpegDecodeStart ( JpegDecodeStart ),
136
                                     .JpegDecodeIdle  (                 ),
137
 
138
                                     .OutWidth        ( OutWidth        ),
139
                                     .OutHeight       ( OutHeight       ),
140
                                     .OutBlockWidth   ( JpegBlockWidth  ),
141
 
142
                                     //
143
                                     .DqtEnable       ( DqtEnable       ),
144
                                     .DqtTable        ( DqtTable        ),
145
                                     .DqtCount        ( DqtCount        ),
146
                                     .DqtData         ( DqtData         ),
147
 
148
                                     //
149
                                     .DhtEnable       ( DhtEnable       ),
150
                                     .DhtTable        ( DhtTable        ),
151
                                     .DhtCount        ( DhtCount        ),
152
                                     .DhtData         ( DhtData         ),
153
 
154
                                     //
155
                                     .HaffumanEnable  ( HaffumanEnable  ),
156
                                     .HaffumanTable   ( HaffumanTable   ),
157
                                     .HaffumanCount   ( HaffumanCount   ),
158
                                     .HaffumanData    ( HaffumanData    ),
159
                                     .HaffumanStart   ( HaffumanStart   ),
160
 
161
                                     //
162
                                     .ImageEnable     ( ImageEnable     ),
163
                                     .ImageEnd        ( JpegDataEnd     ),
164
                                     .EnableFF00      ( EnableFF00      ),
165
 
166
                                     //
167
                                     .UseByte         ( UseByte         ),
168
                                     .UseWord         ( UseWord         )
169
                                     );
170
 
171
 
172
   wire           HmDecEnable;
173
   wire [2:0]     HmDecColor;
174
 
175
   wire           HmDecSel;
176
   wire           HmDecRelease;
177
 
178
   wire [15:0]    Hm00Data;
179
   wire [15:0]    Hm01Data;
180
   wire [15:0]    Hm02Data;
181
   wire [15:0]    Hm03Data;
182
   wire [15:0]    Hm04Data;
183
   wire [15:0]    Hm05Data;
184
   wire [15:0]    Hm06Data;
185
   wire [15:0]    Hm07Data;
186
   wire [15:0]    Hm08Data;
187
   wire [15:0]    Hm09Data;
188
   wire [15:0]    Hm10Data;
189
   wire [15:0]    Hm11Data;
190
   wire [15:0]    Hm12Data;
191
   wire [15:0]    Hm13Data;
192
   wire [15:0]    Hm14Data;
193
   wire [15:0]    Hm15Data;
194
   wire [15:0]    Hm16Data;
195
   wire [15:0]    Hm17Data;
196
   wire [15:0]    Hm18Data;
197
   wire [15:0]    Hm19Data;
198
   wire [15:0]    Hm20Data;
199
   wire [15:0]    Hm21Data;
200
   wire [15:0]    Hm22Data;
201
   wire [15:0]    Hm23Data;
202
   wire [15:0]    Hm24Data;
203
   wire [15:0]    Hm25Data;
204
   wire [15:0]    Hm26Data;
205
   wire [15:0]    Hm27Data;
206
   wire [15:0]    Hm28Data;
207
   wire [15:0]    Hm29Data;
208
   wire [15:0]    Hm30Data;
209
   wire [15:0]    Hm31Data;
210
   wire [15:0]    Hm32Data;
211
   wire [15:0]    Hm33Data;
212
   wire [15:0]    Hm34Data;
213
   wire [15:0]    Hm35Data;
214
   wire [15:0]    Hm36Data;
215
   wire [15:0]    Hm37Data;
216
   wire [15:0]    Hm38Data;
217
   wire [15:0]    Hm39Data;
218
   wire [15:0]    Hm40Data;
219
   wire [15:0]    Hm41Data;
220
   wire [15:0]    Hm42Data;
221
   wire [15:0]    Hm43Data;
222
   wire [15:0]    Hm44Data;
223
   wire [15:0]    Hm45Data;
224
   wire [15:0]    Hm46Data;
225
   wire [15:0]    Hm47Data;
226
   wire [15:0]    Hm48Data;
227
   wire [15:0]    Hm49Data;
228
   wire [15:0]    Hm50Data;
229
   wire [15:0]    Hm51Data;
230
   wire [15:0]    Hm52Data;
231
   wire [15:0]    Hm53Data;
232
   wire [15:0]    Hm54Data;
233
   wire [15:0]    Hm55Data;
234
   wire [15:0]    Hm56Data;
235
   wire [15:0]    Hm57Data;
236
   wire [15:0]    Hm58Data;
237
   wire [15:0]    Hm59Data;
238
   wire [15:0]    Hm60Data;
239
   wire [15:0]    Hm61Data;
240
   wire [15:0]    Hm62Data;
241
   wire [15:0]    Hm63Data;
242
 
243
   wire           DctIdle;
244
 
245
   jpeg_haffuman u_jpeg_haffuman(
246
                                 .rst(rst),
247
                                 .clk(clk),
248
 
249
                                 // DQT Table
250
                                 .DqtInEnable ( DqtEnable ),
251
                                 .DqtInColor  ( DqtTable ),
252
                                 .DqtInCount  ( DqtCount[5:0] ),
253
                                 .DqtInData   ( DqtData ),
254
 
255
                                 // DHT Table
256
                                 .DhtInEnable ( DhtEnable ),
257
                                 .DhtInColor  ( DhtTable  ),
258
                                 .DhtInCount  ( DhtCount  ),
259
                                 .DhtInData   ( DhtData   ),
260
 
261
                                 // Haffuman Table   
262
                                 .HaffumanTableEnable ( HaffumanEnable ),
263
                                 .HaffumanTableColor  ( HaffumanTable  ),
264
                                 .HaffumanTableCount  ( HaffumanCount  ),
265
                                 .HaffumanTableCode   ( HaffumanData   ),
266
                                 .HaffumanTableStart  ( HaffumanStart  ),
267
 
268
                                 // Haffuman Decode
269
                                 .DataInRun      ( ImageEnable    ),
270
                                 .DataInEnable   ( JpegDataEnable ),
271
                                 .DataIn         ( JpegData       ),
272
 
273
                                 // Output decode data   
274
                                 .DecodeUseBit   ( UseBit       ),
275
                                 .DecodeUseWidth ( UseWidth     ),
276
 
277
                                 // Data Out
278
                                 .DataOutIdle   ( DctIdle     ),
279
                                 .DataOutEnable ( HmDecEnable ),
280
                                 .DataOutColor  ( HmDecColor  ),
281
                                 .DataOutSel    ( HmDecSel    ),
282
                                 .Data00Reg    ( Hm00Data ),
283
                                 .Data01Reg    ( Hm01Data ),
284
                                 .Data02Reg    ( Hm02Data ),
285
                                 .Data03Reg    ( Hm03Data ),
286
                                 .Data04Reg    ( Hm04Data ),
287
                                 .Data05Reg    ( Hm05Data ),
288
                                 .Data06Reg    ( Hm06Data ),
289
                                 .Data07Reg    ( Hm07Data ),
290
                                 .Data08Reg    ( Hm08Data ),
291
                                 .Data09Reg    ( Hm09Data ),
292
                                 .Data10Reg    ( Hm10Data ),
293
                                 .Data11Reg    ( Hm11Data ),
294
                                 .Data12Reg    ( Hm12Data ),
295
                                 .Data13Reg    ( Hm13Data ),
296
                                 .Data14Reg    ( Hm14Data ),
297
                                 .Data15Reg    ( Hm15Data ),
298
                                 .Data16Reg    ( Hm16Data ),
299
                                 .Data17Reg    ( Hm17Data ),
300
                                 .Data18Reg    ( Hm18Data ),
301
                                 .Data19Reg    ( Hm19Data ),
302
                                 .Data20Reg    ( Hm20Data ),
303
                                 .Data21Reg    ( Hm21Data ),
304
                                 .Data22Reg    ( Hm22Data ),
305
                                 .Data23Reg    ( Hm23Data ),
306
                                 .Data24Reg    ( Hm24Data ),
307
                                 .Data25Reg    ( Hm25Data ),
308
                                 .Data26Reg    ( Hm26Data ),
309
                                 .Data27Reg    ( Hm27Data ),
310
                                 .Data28Reg    ( Hm28Data ),
311
                                 .Data29Reg    ( Hm29Data ),
312
                                 .Data30Reg    ( Hm30Data ),
313
                                 .Data31Reg    ( Hm31Data ),
314
                                 .Data32Reg    ( Hm32Data ),
315
                                 .Data33Reg    ( Hm33Data ),
316
                                 .Data34Reg    ( Hm34Data ),
317
                                 .Data35Reg    ( Hm35Data ),
318
                                 .Data36Reg    ( Hm36Data ),
319
                                 .Data37Reg    ( Hm37Data ),
320
                                 .Data38Reg    ( Hm38Data ),
321
                                 .Data39Reg    ( Hm39Data ),
322
                                 .Data40Reg    ( Hm40Data ),
323
                                 .Data41Reg    ( Hm41Data ),
324
                                 .Data42Reg    ( Hm42Data ),
325
                                 .Data43Reg    ( Hm43Data ),
326
                                 .Data44Reg    ( Hm44Data ),
327
                                 .Data45Reg    ( Hm45Data ),
328
                                 .Data46Reg    ( Hm46Data ),
329
                                 .Data47Reg    ( Hm47Data ),
330
                                 .Data48Reg    ( Hm48Data ),
331
                                 .Data49Reg    ( Hm49Data ),
332
                                 .Data50Reg    ( Hm50Data ),
333
                                 .Data51Reg    ( Hm51Data ),
334
                                 .Data52Reg    ( Hm52Data ),
335
                                 .Data53Reg    ( Hm53Data ),
336
                                 .Data54Reg    ( Hm54Data ),
337
                                 .Data55Reg    ( Hm55Data ),
338
                                 .Data56Reg    ( Hm56Data ),
339
                                 .Data57Reg    ( Hm57Data ),
340
                                 .Data58Reg    ( Hm58Data ),
341
                                 .Data59Reg    ( Hm59Data ),
342
                                 .Data60Reg    ( Hm60Data ),
343
                                 .Data61Reg    ( Hm61Data ),
344
                                 .Data62Reg    ( Hm62Data ),
345
                                 .Data63Reg    ( Hm63Data ),
346
                                 .DataOutRelease (HmDecRelase)
347
                                 );
348
 
349
   wire           DctEnable;
350
   wire [2:0]     DctColor;
351
   wire [2:0]     DctPage;
352
   wire [1:0]     DctCount;
353
   wire [8:0]     Dct0Data;
354
   wire [8:0]     Dct1Data;
355
 
356
   wire [15:0]    DctWidth;
357
   wire [15:0]    DctHeight;
358
   wire [11:0]    DctBlockX;
359
   wire [11:0]    DctBlockY;
360
 
361
   wire           YCbCrIdle;
362
 
363
   jpeg_idct u_jpeg_idct(
364
                         .rst(rst),
365
                         .clk(clk),
366
 
367
                         .DataInEnable( HmDecEnable ),
368
                         .DataInSel( HmDecSel ),
369
                         .Data00In( Hm00Data ),
370
                         .Data01In( Hm01Data ),
371
                         .Data02In( Hm02Data ),
372
                         .Data03In( Hm03Data ),
373
                         .Data04In( Hm04Data ),
374
                         .Data05In( Hm05Data ),
375
                         .Data06In( Hm06Data ),
376
                         .Data07In( Hm07Data ),
377
                         .Data08In( Hm08Data ),
378
                         .Data09In( Hm09Data ),
379
                         .Data10In( Hm10Data ),
380
                         .Data11In( Hm11Data ),
381
                         .Data12In( Hm12Data ),
382
                         .Data13In( Hm13Data ),
383
                         .Data14In( Hm14Data ),
384
                         .Data15In( Hm15Data ),
385
                         .Data16In( Hm16Data ),
386
                         .Data17In( Hm17Data ),
387
                         .Data18In( Hm18Data ),
388
                         .Data19In( Hm19Data ),
389
                         .Data20In( Hm20Data ),
390
                         .Data21In( Hm21Data ),
391
                         .Data22In( Hm22Data ),
392
                         .Data23In( Hm23Data ),
393
                         .Data24In( Hm24Data ),
394
                         .Data25In( Hm25Data ),
395
                         .Data26In( Hm26Data ),
396
                         .Data27In( Hm27Data ),
397
                         .Data28In( Hm28Data ),
398
                         .Data29In( Hm29Data ),
399
                         .Data30In( Hm30Data ),
400
                         .Data31In( Hm31Data ),
401
                         .Data32In( Hm32Data ),
402
                         .Data33In( Hm33Data ),
403
                         .Data34In( Hm34Data ),
404
                         .Data35In( Hm35Data ),
405
                         .Data36In( Hm36Data ),
406
                         .Data37In( Hm37Data ),
407
                         .Data38In( Hm38Data ),
408
                         .Data39In( Hm39Data ),
409
                         .Data40In( Hm40Data ),
410
                         .Data41In( Hm41Data ),
411
                         .Data42In( Hm42Data ),
412
                         .Data43In( Hm43Data ),
413
                         .Data44In( Hm44Data ),
414
                         .Data45In( Hm45Data ),
415
                         .Data46In( Hm46Data ),
416
                         .Data47In( Hm47Data ),
417
                         .Data48In( Hm48Data ),
418
                         .Data49In( Hm49Data ),
419
                         .Data50In( Hm50Data ),
420
                         .Data51In( Hm51Data ),
421
                         .Data52In( Hm52Data ),
422
                         .Data53In( Hm53Data ),
423
                         .Data54In( Hm54Data ),
424
                         .Data55In( Hm55Data ),
425
                         .Data56In( Hm56Data ),
426
                         .Data57In( Hm57Data ),
427
                         .Data58In( Hm58Data ),
428
                         .Data59In( Hm59Data ),
429
                         .Data60In( Hm60Data ),
430
                         .Data61In( Hm61Data ),
431
                         .Data62In( Hm62Data ),
432
                         .Data63In( Hm63Data ),
433
                         .DataInIdle( DctIdle ),
434
                         .DataInRelease( HmDecRelase ),
435
 
436
                         .DataOutEnable ( DctEnable ),
437
                         .DataOutPage   ( DctPage   ),
438
                         .DataOutCount  ( DctCount  ),
439
                         .Data0Out      ( Dct0Data  ),
440
                         .Data1Out      ( Dct1Data  )
441
                         );
442
 
443
   jpeg_ycbcr u_jpeg_ycbcr(
444
                           .rst(rst),
445
                           .clk(clk),
446
 
447
                           .DataInEnable     ( DctEnable ),
448
                           .DataInPage       ( DctPage   ),
449
                           .DataInCount      ( DctCount  ),
450
                           .DataInIdle       ( YCbCrIdle ),
451
                           .Data0In          ( Dct0Data  ),
452
                           .Data1In          ( Dct1Data  ),
453
                           .DataInBlockWidth ( JpegBlockWidth ),
454
 
455
                           .OutEnable    ( OutEnable ),
456
                           .OutPixelX    ( OutPixelX ),
457
                           .OutPixelY    ( OutPixelY ),
458
                           .OutR         ( OutR      ),
459
                           .OutG         ( OutG      ),
460
                           .OutB         ( OutB      )
461
                           );
462
 
463
   reg            ProcessIdle;
464
 
465
   //
466
   always @(posedge clk or negedge rst) begin
467
      if(!rst) begin
468
         ProcessIdle <= 1'b1;
469
      end else begin
470
         if(JpegDecodeStart == 1'b1) ProcessIdle <= 1'b0;
471
         else if(ProcessIdle <= 1'b0 &
472
                 OutWidth == OutPixelX -1 &
473
                 OutHeight == OutPixelY -1) ProcessIdle <= 1'b1;
474
      end
475
   end
476
   assign JpegDecodeIdle = ProcessIdle;
477
 
478
endmodule // jpeg_decode

powered by: WebSVN 2.1.0

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