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

Subversion Repositories djpeg

[/] [djpeg/] [trunk/] [src/] [jpeg_ycbcr.v] - Blame information for rev 6

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

Line No. Rev Author Line
1 3 hidemi
//---------------------------------------------------------------------------
2
// File Name   : jpeg_ycbcr.v
3
// Module Name : jpeg_ycbcr
4
// Description : Convert to RGB from YCbCr 
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
//---------------------------------------------------------------------------
17
// $Id: 
18
//---------------------------------------------------------------------------
19
`timescale 1ps / 1ps
20
 
21
module jpeg_ycbcr
22
  (
23
   rst,
24
   clk,
25
 
26
   DataInEnable,
27
   DataInPage,
28
   DataInCount,
29
   DataInIdle,
30
   Data0In,
31
   Data1In,
32
   DataInBlockWidth,
33
 
34
   OutEnable,
35
   OutPixelX,
36
   OutPixelY,
37
   OutR,
38
   OutG,
39
   OutB
40
   );
41
 
42
   input          rst;
43
   input          clk;
44
 
45
   input          DataInEnable;
46
   input [2:0]    DataInPage;
47
   input [1:0]    DataInCount;
48
   output         DataInIdle;
49
   input [8:0]    Data0In;
50
   input [8:0]    Data1In;
51
   input [11:0]   DataInBlockWidth;
52
 
53
   output         OutEnable;
54
   output [15:0]  OutPixelX;
55
   output [15:0]  OutPixelY;
56
   output [7:0]   OutR;
57
   output [7:0]   OutG;
58
   output [7:0]   OutB;
59
 
60
   reg            DataInBank;
61
   reg [2:0]      DataInColor;
62
   reg [11:0]     DataInBlockX;
63
   reg [11:0]     DataInBlockY;
64
   reg            BankAActive;
65
   reg            BankBActive;
66
   wire           BankAEnable;
67
   wire           BankBEnable;
68
 
69
   wire [8:0]     BankAY;
70
   wire [8:0]     BankACb;
71
   wire [8:0]     BankACr;
72
   wire [8:0]     BankBY;
73
   wire [8:0]     BankBCb;
74
   wire [8:0]     BankBCr;
75
 
76
   reg [11:0]     BankABlockX;
77
   reg [11:0]     BankABlockY;
78
   reg [11:0]     BankBBlockX;
79
   reg [11:0]     BankBBlockY;
80
 
81
   wire           ConvertEnable;
82
   wire           ConvertBank;
83
   wire [7:0]     ConvertAddress;
84
   wire [8:0]     DataY;
85
   wire [8:0]     DataCb;
86
   wire [8:0]     DataCr;
87
   wire [11:0]    ConvertBlockX;
88
   wire [11:0]    ConvertBlockY;
89
 
90
   wire           BankAIdle;
91
   wire           BankBIdle;
92
 
93
   always @(posedge clk or negedge rst) begin
94
      if(!rst) begin
95
         DataInBank   <= 1'b0;
96
         DataInColor  <= 3'b000;
97
         DataInBlockX <= 12'h000;
98
         DataInBlockY <= 12'h000;
99
         BankAActive  <= 1'b0;
100
         BankBActive  <= 1'b0;
101
         BankABlockX  <= 12'h000;
102
         BankABlockY  <= 12'h000;
103
         BankBBlockX  <= 12'h000;
104
         BankBBlockY  <= 12'h000;
105
      end else begin // if (!rst)
106
         if(DataInEnable == 1'b1 & DataInColor == 3'b101 &
107
            DataInPage == 3'b111 & DataInCount == 2'b11) begin
108
         end
109
         if(DataInEnable == 1'b1 & DataInColor == 3'b101 &
110
            DataInPage == 3'b111 & DataInCount == 2'b11 &
111
            DataInBank == 1'b0   & BankAActive == 1'b0) begin
112
            BankAActive <= 1'b1;
113
            BankABlockX <= DataInBlockX;
114
            BankABlockY <= DataInBlockY;
115
         end else if(ConvertBank == 1'b0 & ConvertAddress == 7'b111) begin
116
            BankAActive <= 1'b0;
117
         end
118
         if(DataInEnable == 1'b1 & DataInColor == 3'b101 &
119
            DataInPage == 3'b111 & DataInCount == 2'b11 &
120
            DataInBank == 1'b1   & BankBActive == 1'b0) begin
121
            BankBActive <= 1'b1;
122
            BankBBlockX <= DataInBlockX;
123
            BankBBlockY <= DataInBlockY;
124
         end else if(ConvertBank == 1'b1 & ConvertAddress == 7'b111) begin
125
            BankBActive <= 1'b0;
126
         end
127
         if(DataInEnable == 1'b1 &
128
            DataInPage == 3'b111 & DataInCount == 2'b11) begin
129
            if(DataInColor == 3'b101) begin
130
               DataInColor <= 3'b000;
131
               DataInBank <= ~DataInBank;
132
               if(DataInBlockWidth == DataInBlockX +1) begin
133
                  DataInBlockX <= 12'h000;
134
                  DataInBlockY <= DataInBlockY + 12'h001;
135
               end else begin
136
                  DataInBlockX <= DataInBlockX + 12'h001;
137
               end
138
            end else begin
139
               DataInColor <= DataInColor + 3'b001;
140
            end // else: !if(DataInColor == 3'b101)
141
         end // if (DataInEnable == 1'b1 &...
142
 
143
      end // else: !if(!rst)
144
   end // always @ (posedge clk or negedge rst)
145
 
146
   assign BankAEnable = DataInEnable == 1'b1 & DataInBank == 1'b0;
147
   assign BankBEnable = DataInEnable == 1'b1 & DataInBank == 1'b1;
148
 
149
   /*
150
   assign ConvertBlockX = (ConvertBank)?BankBBlockX:BankABlockX;
151
   assign ConvertBlockY = (ConvertBank)?BankBBlockY:BankABlockY;
152
    */
153
 
154
   assign ConvertEnable = DataInEnable == 1'b1 & DataInColor == 3'b101 &
155
                          DataInPage == 3'b111 & DataInCount == 2'b11;
156
 
157
   assign DataInIdle = BankAActive == 1'b0 | BankBActive == 1'b0;
158
 
159
   //------------------------------------------------------------------------
160
   // YCbCr Memory
161
   //------------------------------------------------------------------------
162
   jpeg_ycbcr_mem u_jpeg_ycbcr_mem0(
163
                                     .clk(clk),
164
 
165
                                     .DataInEnable (BankAEnable),
166
                                     .DataInColor  (DataInColor),
167
                                     .DataInPage   (DataInPage),
168
                                     .DataInCount  (DataInCount),
169
                                     .Data0In      (Data0In),
170
                                     .Data1In      (Data1In),
171
 
172
                                     .DataOutAddress (ConvertAddress),
173
                                     .DataOutY       (BankAY),
174
                                     .DataOutCb      (BankACb),
175
                                     .DataOutCr      (BankACr)
176
                                     );
177
   jpeg_ycbcr_mem u_jpeg_ycbcr_mem1(
178
                                     .clk(clk),
179
 
180
                                     .DataInEnable (BankBEnable),
181
                                     .DataInColor  (DataInColor),
182
                                     .DataInPage   (DataInPage),
183
                                     .DataInCount  (DataInCount),
184
                                     .Data0In      (Data0In),
185
                                     .Data1In      (Data1In),
186
 
187
                                     .DataOutAddress (ConvertAddress),
188
                                     .DataOutY       (BankBY),
189
                                     .DataOutCb      (BankBCb),
190
                                     .DataOutCr      (BankBCr)
191
                                     );
192
 
193
   reg    ConvertBankD;
194
   always @(posedge clk or negedge rst) begin
195
      if(!rst) ConvertBankD <= 1'b0;
196
      else     ConvertBankD <= ConvertBank;
197
   end
198
 
199
 
200
   assign DataY  = (ConvertBankD)?BankBY :BankAY;
201
   assign DataCb = (ConvertBankD)?BankBCb:BankACb;
202
   assign DataCr = (ConvertBankD)?BankBCr:BankACr;
203
 
204
   //------------------------------------------------------------------------
205
   // YCbCr to RGB
206
   //------------------------------------------------------------------------
207
   jpeg_ycbcbr2rgb u_jpeg_ycbcr2rgb(
208
                                    .rst(rst),
209
                                    .clk(clk),
210
 
211
                                    .InEnable  ( ConvertEnable  ),
212
                                    .InBlockX  ( DataInBlockX  ),
213
                                    .InBlockY  ( DataInBlockY  ),
214
                                    .InIdle    ( ConvertIdle    ),
215
                                    .InBank    ( ConvertBank    ),
216
                                    .InAddress ( ConvertAddress ),
217
                                    .InY       ( DataY          ),
218
                                    .InCb      ( DataCb         ),
219
                                    .InCr      ( DataCr         ),
220
 
221
                                    .OutEnable ( OutEnable      ),
222
                                    .OutPixelX ( OutPixelX      ),
223
                                    .OutPixelY ( OutPixelY      ),
224
                                    .OutR      ( OutR           ),
225
                                    .OutG      ( OutG           ),
226
                                    .OutB      ( OutB           )
227
                                    );
228
endmodule // jpeg_ycbcr

powered by: WebSVN 2.1.0

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