| 1 |
2 |
davidklun |
/////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//// ////
|
| 3 |
|
|
//// JPEG Encoder Core - Verilog ////
|
| 4 |
|
|
//// ////
|
| 5 |
|
|
//// Author: David Lundgren ////
|
| 6 |
|
|
//// davidklun@gmail.com ////
|
| 7 |
|
|
//// ////
|
| 8 |
|
|
/////////////////////////////////////////////////////////////////////
|
| 9 |
|
|
//// ////
|
| 10 |
|
|
//// Copyright (C) 2009 David Lundgren ////
|
| 11 |
|
|
//// davidklun@gmail.com ////
|
| 12 |
|
|
//// ////
|
| 13 |
|
|
//// This source file may be used and distributed without ////
|
| 14 |
|
|
//// restriction provided that this copyright statement is not ////
|
| 15 |
|
|
//// removed from the file and that any derivative work contains ////
|
| 16 |
|
|
//// the original copyright notice and the associated disclaimer.////
|
| 17 |
|
|
//// ////
|
| 18 |
|
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
| 19 |
|
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
| 20 |
|
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
| 21 |
|
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
| 22 |
|
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
| 23 |
|
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
| 24 |
|
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
| 25 |
|
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
| 26 |
|
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
| 27 |
|
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
| 28 |
|
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
| 29 |
|
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
| 30 |
|
|
//// POSSIBILITY OF SUCH DAMAGE. ////
|
| 31 |
|
|
//// ////
|
| 32 |
|
|
/////////////////////////////////////////////////////////////////////
|
| 33 |
|
|
|
| 34 |
|
|
|
| 35 |
|
|
/* This module combines the Y, Cb, and Cr blocks, and the RGB to Y, Cb, and Cr
|
| 36 |
|
|
converter. */
|
| 37 |
|
|
|
| 38 |
|
|
`timescale 1ns / 100ps
|
| 39 |
|
|
|
| 40 |
|
|
module pre_fifo(clk, rst, enable, data_in, cr_JPEG_bitstream, cr_data_ready,
|
| 41 |
|
|
cr_orc, cb_JPEG_bitstream, cb_data_ready, cb_orc, y_JPEG_bitstream,
|
| 42 |
|
|
y_data_ready, y_orc, y_eob_output,
|
| 43 |
|
|
y_eob_empty, cb_eob_empty, cr_eob_empty);
|
| 44 |
|
|
input clk, rst, enable;
|
| 45 |
|
|
input [23:0] data_in;
|
| 46 |
|
|
output [31:0] cr_JPEG_bitstream;
|
| 47 |
|
|
output cr_data_ready;
|
| 48 |
|
|
output [4:0] cr_orc;
|
| 49 |
|
|
output [31:0] cb_JPEG_bitstream;
|
| 50 |
|
|
output cb_data_ready;
|
| 51 |
|
|
output [4:0] cb_orc;
|
| 52 |
|
|
output [31:0] y_JPEG_bitstream;
|
| 53 |
|
|
output y_data_ready;
|
| 54 |
|
|
output [4:0] y_orc;
|
| 55 |
|
|
output y_eob_output;
|
| 56 |
|
|
output y_eob_empty, cb_eob_empty, cr_eob_empty;
|
| 57 |
|
|
|
| 58 |
|
|
|
| 59 |
|
|
wire rgb_enable;
|
| 60 |
|
|
wire [23:0] dct_data_in;
|
| 61 |
|
|
|
| 62 |
|
|
|
| 63 |
|
|
RGB2YCBCR u4(.clk(clk), .rst(rst), .enable(enable),
|
| 64 |
|
|
.data_in(data_in), .data_out(dct_data_in), .enable_out(rgb_enable));
|
| 65 |
|
|
|
| 66 |
|
|
crd_q_h u11(.clk(clk), .rst(rst), .enable(rgb_enable), .data_in(dct_data_in[23:16]),
|
| 67 |
|
|
.JPEG_bitstream(cr_JPEG_bitstream),
|
| 68 |
|
|
.data_ready(cr_data_ready), .cr_orc(cr_orc),
|
| 69 |
|
|
.end_of_block_empty(cr_eob_empty));
|
| 70 |
|
|
|
| 71 |
|
|
cbd_q_h u12(.clk(clk), .rst(rst), .enable(rgb_enable), .data_in(dct_data_in[15:8]),
|
| 72 |
|
|
.JPEG_bitstream(cb_JPEG_bitstream),
|
| 73 |
|
|
.data_ready(cb_data_ready), .cb_orc(cb_orc),
|
| 74 |
|
|
.end_of_block_empty(cb_eob_empty));
|
| 75 |
|
|
|
| 76 |
|
|
yd_q_h u13(.clk(clk), .rst(rst), .enable(rgb_enable), .data_in(dct_data_in[7:0]),
|
| 77 |
|
|
.JPEG_bitstream(y_JPEG_bitstream),
|
| 78 |
|
|
.data_ready(y_data_ready), .y_orc(y_orc),
|
| 79 |
|
|
.end_of_block_output(y_eob_output), .end_of_block_empty(y_eob_empty));
|
| 80 |
|
|
|
| 81 |
|
|
endmodule
|