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 |
|
|
/* This is the top level module of the JPEG Encoder Core.
|
35 |
|
|
This module takes the output from the fifo_out module and sends it
|
36 |
|
|
to the ff_checker module to check for FF's in the bitstream. When it finds an
|
37 |
|
|
FF, it puts a 00 after it, and then continues with the rest of the bitstream.
|
38 |
|
|
At the end of the file, if there is not a full 32 bit set of JPEG data, then the
|
39 |
|
|
signal "eof_data_partial_ready" will go high, to indicate there
|
40 |
|
|
are less than 32 valid JPEG bits in the bitstream. The number of valid bits in the
|
41 |
|
|
last JPEG_bitstream value is written to the signal "end_of_file_bitstream_count".
|
42 |
|
|
*/
|
43 |
|
|
|
44 |
|
|
`timescale 1ns / 100ps
|
45 |
|
|
|
46 |
|
|
module jpeg_top(clk, rst, end_of_file_signal, enable, data_in, JPEG_bitstream,
|
47 |
|
|
data_ready, end_of_file_bitstream_count, eof_data_partial_ready);
|
48 |
|
|
input clk;
|
49 |
|
|
input rst;
|
50 |
|
|
input end_of_file_signal;
|
51 |
|
|
input enable;
|
52 |
|
|
input [23:0] data_in;
|
53 |
|
|
output [31:0] JPEG_bitstream;
|
54 |
|
|
output data_ready;
|
55 |
|
|
output [4:0] end_of_file_bitstream_count;
|
56 |
|
|
output eof_data_partial_ready;
|
57 |
|
|
|
58 |
|
|
wire [31:0] JPEG_FF;
|
59 |
|
|
wire data_ready_FF;
|
60 |
|
|
wire [4:0] orc_reg_in;
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
fifo_out u19 (.clk(clk), .rst(rst), .enable(enable), .data_in(data_in),
|
64 |
|
|
.JPEG_bitstream(JPEG_FF), .data_ready(data_ready_FF), .orc_reg(orc_reg_in));
|
65 |
|
|
|
66 |
|
|
ff_checker u20 (.clk(clk), .rst(rst),
|
67 |
|
|
.end_of_file_signal(end_of_file_signal), .JPEG_in(JPEG_FF),
|
68 |
|
|
.data_ready_in(data_ready_FF), .orc_reg_in(orc_reg_in),
|
69 |
|
|
.JPEG_bitstream_1(JPEG_bitstream),
|
70 |
|
|
.data_ready_1(data_ready), .orc_reg(end_of_file_bitstream_count),
|
71 |
|
|
.eof_data_partial_ready(eof_data_partial_ready));
|
72 |
|
|
|
73 |
|
|
endmodule
|