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

Subversion Repositories djpeg

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

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 9 hidemi
// Date        : 2008/03/05
11
// Rev.        : 2.00
12 3 hidemi
//---------------------------------------------------------------------------
13
// Rev. Date       Description
14
//---------------------------------------------------------------------------
15
// 1.01 2006/10/01 1st Release
16
// 1.02 2006/10/04 add ProcessIdle register
17 9 hidemi
// 1.99 2007/04/11 
18
// 2.00 2008/03/05 New Verion
19 3 hidemi
//---------------------------------------------------------------------------
20
`timescale 1ps / 1ps
21
 
22 9 hidemi
module jpeg_decode(
23
    rst,
24
    clk,
25 3 hidemi
 
26 9 hidemi
    // From FIFO
27
    DataIn,
28
    DataInEnable,
29
    DataInRead,
30 3 hidemi
 
31 9 hidemi
    JpegDecodeIdle,  // Deocdeer Process Idle(1:Idle, 0:Run)
32 3 hidemi
 
33 9 hidemi
    OutEnable,
34
    OutWidth,
35
    OutHeight,
36
    OutPixelX,
37
    OutPixelY,
38
    OutR,
39
    OutG,
40
    OutB
41
);
42 3 hidemi
 
43 9 hidemi
    input           rst;
44
    input           clk;
45
 
46
    input [31:0]    DataIn;
47
    input           DataInEnable;
48
    output          DataInRead;
49
 
50
    output          JpegDecodeIdle;
51
 
52
    output          OutEnable;
53
    output [15:0]   OutWidth;
54
    output [15:0]   OutHeight;
55
    output [15:0]   OutPixelX;
56
    output [15:0]   OutPixelY;
57
    output [7:0]    OutR;
58
    output [7:0]    OutG;
59
    output [7:0]    OutB;
60
 
61
    wire [31:0]     JpegData;
62
    wire            JpegDataEnable;
63
    wire            JpegDecodeIdle;
64
 
65
    wire            UseBit;
66
    wire [6:0]      UseWidth;
67
    wire            UseByte;
68
    wire            UseWord;
69
 
70
    wire            ImageEnable;
71
    wire            EnableFF00;
72
 
73
    //reg             ProcessIdle;
74
 
75
    //--------------------------------------------------------------------------
76
    // Read JPEG Data from FIFO
77
    //--------------------------------------------------------------------------
78
    jpeg_regdata u_jpeg_regdata(
79
        .rst(rst),
80
        .clk(clk),
81
 
82
        // Read Data
83
        .DataIn         ( DataIn            ),
84
        .DataInEnable   ( DataInEnable      ),
85
        .DataInRead     ( DataInRead        ),
86
 
87
        // DataOut
88
        .DataOut        ( JpegData          ),
89
        .DataOutEnable  ( JpegDataEnable    ),
90
 
91
        //
92
        .ImageEnable    ( ImageEnable       ),
93
        .ProcessIdle    ( JpegDecodeIdle    ),
94
 
95
        // UseData
96
        .UseBit         ( UseBit            ),
97
        .UseWidth       ( UseWidth          ),
98
        .UseByte        ( UseByte           ),
99
        .UseWord        ( UseWord           )
100
        );
101 3 hidemi
 
102 9 hidemi
    //--------------------------------------------------------------------------
103
    // Read Maker from Jpeg Data
104
    //--------------------------------------------------------------------------
105
    wire            DqtEnable;
106
    wire            DqtTable;
107
    wire [5:0]      DqtCount;
108
    wire [7:0]      DqtData;
109
 
110
    wire            DhtEnable;
111
    wire [1:0]      DhtTable;
112
    wire [7:0]      DhtCount;
113
    wire [7:0]      DhtData;
114
 
115
    //
116
    wire            HuffmanEnable;
117
    wire [1:0]      HuffmanTable;
118
    wire [3:0]      HuffmanCount;
119
    wire [15:0]     HuffmanData;
120
    wire [7:0]      HuffmanStart;
121
 
122
    wire [11:0]     JpegBlockWidth;
123
 
124
    jpeg_decode_fsm u_jpeg_decode_fsm(
125
        .rst            ( rst               ),
126
        .clk            ( clk               ),
127
 
128
        // From FIFO
129
        .DataInEnable   ( JpegDataEnable    ),
130
        .DataIn         ( JpegData          ),
131
 
132
        .JpegDecodeIdle ( JpegDecodeIdle    ),
133
 
134
        .OutWidth       ( OutWidth          ),
135
        .OutHeight      ( OutHeight         ),
136
        .OutBlockWidth  ( JpegBlockWidth    ),
137
        .OutEnable      ( OutEnable         ),
138
        .OutPixelX      ( OutPixelX         ),
139
        .OutPixelY      ( OutPixelY         ),
140
 
141
        //
142
        .DqtEnable      ( DqtEnable         ),
143
        .DqtTable       ( DqtTable          ),
144
        .DqtCount       ( DqtCount          ),
145
        .DqtData        ( DqtData           ),
146
 
147
        //
148
        .DhtEnable      ( DhtEnable         ),
149
        .DhtTable       ( DhtTable          ),
150
        .DhtCount       ( DhtCount          ),
151
        .DhtData        ( DhtData           ),
152
 
153
        //
154
        .HuffmanEnable  ( HuffmanEnable     ),
155
        .HuffmanTable   ( HuffmanTable      ),
156
        .HuffmanCount   ( HuffmanCount      ),
157
        .HuffmanData    ( HuffmanData       ),
158
        .HuffmanStart   ( HuffmanStart      ),
159
 
160
        //
161
        .ImageEnable    ( ImageEnable       ),
162
 
163
        //
164
        .UseByte        ( UseByte           ),
165
        .UseWord        ( UseWord           )
166
        );
167
 
168
 
169
    wire            HmDecEnable;
170
    wire [2:0]      HmDecColor;
171
    wire            HmRead;
172
    wire [4:0]      HmAddress;
173
 
174
    wire [15:0]     HmDataA, HmDataB;
175
 
176
 
177
    jpeg_huffman u_jpeg_huffman(
178
        .rst                ( rst               ),
179
        .clk                ( clk               ),
180
 
181
        .ProcessInit        ( JpegDecodeIdle    ),
182
 
183
        // DQT Table
184
        .DqtInEnable        ( DqtEnable         ),
185
        .DqtInColor         ( DqtTable          ),
186
        .DqtInCount         ( DqtCount[5:0]     ),
187
        .DqtInData          ( DqtData           ),
188
 
189
        // DHT Table
190
        .DhtInEnable        ( DhtEnable         ),
191
        .DhtInColor         ( DhtTable          ),
192
        .DhtInCount         ( DhtCount          ),
193
        .DhtInData          ( DhtData           ),
194
 
195
        // Huffman Table   
196
        .HuffmanTableEnable ( HuffmanEnable     ),
197
        .HuffmanTableColor  ( HuffmanTable      ),
198
        .HuffmanTableCount  ( HuffmanCount      ),
199
        .HuffmanTableCode   ( HuffmanData       ),
200
        .HuffmanTableStart  ( HuffmanStart      ),
201
 
202
        // Huffman Decode
203
        .DataInRun          ( ImageEnable       ),
204
        .DataInEnable       ( JpegDataEnable    ),
205
        .DataIn             ( JpegData          ),
206
 
207
        // Output decode data   
208
        .DecodeUseBit       ( UseBit            ),
209
        .DecodeUseWidth     ( UseWidth          ),
210
 
211
        // Data Out
212
        .DataOutEnable      ( HmDecEnable       ),
213
        .DataOutRead        ( HmRead            ),
214
        .DataOutAddress     ( HmAddress         ),
215
        .DataOutColor       ( HmDecColor        ),
216
        .DataOutA           ( HmDataA           ),
217
        .DataOutB           ( HmDataB           )
218
        );
219
 
220
    wire            DctEnable;
221
    wire [2:0]      DctColor;
222
    wire [2:0]      DctPage;
223
    wire [1:0]      DctCount;
224
    wire [8:0]      Dct0Data, Dct1Data;
225
 
226
    wire [15:0]     DctWidth, DctHeight;
227
    wire [11:0]     DctBlockX, DctBlockY;
228
 
229
    wire            YCbCrIdle;
230
 
231
    jpeg_idct u_jpeg_idct(
232
        .rst            ( rst           ),
233
        .clk            ( clk           ),
234
 
235
        .ProcessInit    ( JpegDecodeIdle    ),
236
 
237
        .DataInEnable   ( HmDecEnable   ),
238
        .DataInRead     ( HmRead        ),
239
        .DataInAddress  ( HmAddress     ),
240
        .DataInA        ( HmDataA       ),
241
        .DataInB        ( HmDataB       ),
242
 
243
        .DataOutEnable  ( DctEnable     ),
244
        .DataOutPage    ( DctPage       ),
245
        .DataOutCount   ( DctCount      ),
246
        .Data0Out       ( Dct0Data      ),
247
        .Data1Out       ( Dct1Data      )
248
        );
249
 
250
    wire            ColorEnable;
251
    wire [15:0]     ColorPixelX, ColorPixelY;
252
    wire [7:0]      ColorR, ColorG, ColorB;
253
    jpeg_ycbcr u_jpeg_ycbcr(
254
        .rst                ( rst               ),
255
        .clk                ( clk               ),
256
 
257
        .ProcessInit        ( JpegDecodeIdle    ),
258
 
259
        .DataInEnable       ( DctEnable         ),
260
        .DataInPage         ( DctPage           ),
261
        .DataInCount        ( DctCount          ),
262
        .DataInIdle         ( YCbCrIdle         ),
263
        .Data0In            ( Dct0Data          ),
264
        .Data1In            ( Dct1Data          ),
265
        .DataInBlockWidth   ( JpegBlockWidth    ),
266
 
267
        .OutEnable          ( ColorEnable       ),
268
        .OutPixelX          ( ColorPixelX       ),
269
        .OutPixelY          ( ColorPixelY       ),
270
        .OutR               ( ColorR            ),
271
        .OutG               ( ColorG            ),
272
        .OutB               ( ColorB            )
273
        );
274
    // OutData
275
    assign OutEnable = (ImageEnable)?ColorEnable:1'b0;
276
    assign OutPixelX = (ImageEnable)?ColorPixelX:16'd0;
277
    assign OutPixelY = (ImageEnable)?ColorPixelY:16'd0;
278
    assign OutR      = (ImageEnable)?ColorR:8'd0;
279
    assign OutG      = (ImageEnable)?ColorG:8'd0;
280
    assign OutB      = (ImageEnable)?ColorB:8'd0;
281 3 hidemi
 
282 9 hidemi
endmodule

powered by: WebSVN 2.1.0

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