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

Subversion Repositories djpeg

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

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
`timescale 1ps / 1ps
18
 
19 9 hidemi
module jpeg_ycbcr(
20
    rst,
21
    clk,
22 3 hidemi
 
23 9 hidemi
    ProcessInit,
24 3 hidemi
 
25 9 hidemi
    DataInEnable,
26
    DataInPage,
27
    DataInCount,
28
    DataInIdle,
29
    Data0In,
30
    Data1In,
31
    DataInBlockWidth,
32 3 hidemi
 
33 9 hidemi
    OutEnable,
34
    OutPixelX,
35
    OutPixelY,
36
    OutR,
37
    OutG,
38
    OutB
39
    );
40 3 hidemi
 
41 9 hidemi
    input           rst;
42
    input           clk;
43
 
44
    input           ProcessInit;
45
 
46
    input           DataInEnable;
47
    input [2:0]     DataInPage;
48
    input [1:0]     DataInCount;
49
    output          DataInIdle;
50
    input [8:0]     Data0In;
51
    input [8:0]     Data1In;
52
    input [11:0]    DataInBlockWidth;
53
 
54
    output          OutEnable;
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
    reg [2:0]       DataInColor;
62
    reg [11:0]      DataInBlockX;
63
    reg [11:0]      DataInBlockY;
64 3 hidemi
 
65 9 hidemi
    wire            ConvertEnable;
66
    wire            ConvertRead;
67
    wire            ConvertBank;
68
    wire [7:0]      ConvertAddress;
69
    wire [8:0]      DataY;
70
    wire [8:0]      DataCb;
71
    wire [8:0]      DataCr;
72
    wire [11:0]     ConvertBlockX;
73
    wire [11:0]     ConvertBlockY;
74
 
75
    always @(posedge clk or negedge rst) begin
76
        if(!rst) begin
77
            DataInColor  <= 3'b000;
78
        end else begin
79
            if(ProcessInit) begin
80
                DataInColor <= 3'b000;
81
            end else if(DataInEnable == 1'b1 & DataInPage == 3'b111 & DataInCount == 2'b11) begin
82
                if(DataInColor == 3'b101) begin
83
                    DataInColor <= 3'b000;
84
                end else begin
85
                    DataInColor <= DataInColor + 3'b001;
86
                end
87
            end
88
 
89
        end
90
    end
91
 
92
    //------------------------------------------------------------------------
93
    // YCbCr Memory
94
    //------------------------------------------------------------------------
95
    jpeg_ycbcr_mem u_jpeg_ycbcr_mem(
96
        .rst            ( rst               ),
97
        .clk            ( clk               ),
98
 
99
        .DataInit       ( ProcessInit       ),
100
 
101
        .DataInEnable   ( DataInEnable      ),
102
        .DataInColor    ( DataInColor       ),
103
        .DataInPage     ( DataInPage        ),
104
        .DataInCount    ( DataInCount       ),
105
        .Data0In        ( Data0In           ),
106
        .Data1In        ( Data1In           ),
107
 
108
        .DataOutEnable  ( ConvertEnable     ),
109
        .DataOutAddress ( ConvertAddress    ),
110
        .DataOutRead    ( ConvertRead       ),
111
        .DataOutY       ( DataY             ),
112
        .DataOutCb      ( DataCb            ),
113
        .DataOutCr      ( DataCr            )
114
    );
115
    //------------------------------------------------------------------------
116
    // YCbCr to RGB
117
    //------------------------------------------------------------------------
118
    always @(posedge clk or negedge rst) begin
119
        if(!rst) begin
120
            DataInBlockX <= 12'h000;
121
            DataInBlockY <= 12'h000;
122
        end else begin
123
            if(ProcessInit) begin
124
                DataInBlockX <= 12'h000;
125
                DataInBlockY <= 12'h000;
126
            end else if((ConvertRead == 1'b1) && (ConvertAddress == 5'h1F)) begin
127
                if(DataInBlockWidth == DataInBlockX +1) begin
128
                    DataInBlockX <= 12'h000;
129
                    DataInBlockY <= DataInBlockY + 12'h001;
130
                end else begin
131
                    DataInBlockX <= DataInBlockX + 12'h001;
132
                end
133
            end
134
        end
135
    end
136 3 hidemi
 
137 9 hidemi
    jpeg_ycbcr2rgb u_jpeg_yccr2rgb(
138
        .rst        ( rst               ),
139
        .clk        ( clk               ),
140
 
141
        .InEnable   ( ConvertEnable     ),
142
        .InRead     ( ConvertRead       ),
143
        .InBlockX   ( DataInBlockX      ),
144
        .InBlockY   ( DataInBlockY      ),
145
        .InAddress  ( ConvertAddress    ),
146
        .InY        ( DataY             ),
147
        .InCb       ( DataCb            ),
148
        .InCr       ( DataCr            ),
149
 
150
        .OutEnable  ( OutEnable         ),
151
        .OutPixelX  ( OutPixelX         ),
152
        .OutPixelY  ( OutPixelY         ),
153
        .OutR       ( OutR              ),
154
        .OutG       ( OutG              ),
155
        .OutB       ( OutB              )
156
    );
157
endmodule

powered by: WebSVN 2.1.0

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