?? jpeg_encoder.v
字號:
///////////////////////////////////////////////////////////////////////// //////// Discrete Cosine Transform Testbench (ITU-T.81 & ITU-T.83) //////// //////// Author: Richard Herveille //////// richard@asics.ws //////// www.asics.ws //////// ///////////////////////////////////////////////////////////////////////////// //////// Copyright (C) 2002 Richard Herveille //////// richard@asics.ws //////// //////// This source file may be used and distributed without //////// restriction provided that this copyright statement is not //////// removed from the file and that any derivative work contains //////// the original copyright notice and the associated disclaimer.//////// //////// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY //////// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED //////// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS //////// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR //////// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, //////// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES //////// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE //////// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR //////// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF //////// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT //////// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT //////// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE //////// POSSIBILITY OF SUCH DAMAGE. //////// /////////////////////////////////////////////////////////////////////////// CVS Log//// $Id: bench_top.v,v 1.1 2002/10/23 09:07:01 rherveille Exp $//// $Date: 2002/10/23 09:07:01 $// $Revision: 1.1 $// $Author: rherveille $// $Locker: $// $State: Exp $//// Change History:// $Log: bench_top.v,v $// Revision 1.1 2002/10/23 09:07:01 rherveille// Improved many files.// Fixed some bugs in Run-Length-Encoder.// Removed dependency on ud_cnt and ro_cnt.// Started (Motion)JPEG hardware encoder project.////`include "timescale.v"module bench_top(); //////////////////////////////////////////////////////////////////// // // // ITU-T.81, ITU-T.83 & Coefficient resolution notes // // // //////////////////////////////////////////////////////////////////// // // // Worst case error (all input values -128) is // // zero (i.e. no errors) when using 15bit coefficients // // // // Using less bits for the coefficients produces a biterror // // approx. equal to (15 - used_coefficient-bits). // // e.g. 14bit coefficients, errors in dout-bit[0] only // // 13bit coefficients, errors in dout-bits[1:0] // // 12bit coefficients, errors in dout-bits[2:0] etc. // // Tests with real non-continous tone image data have shown that // // even when using 13bit coefficients errors remain in the lsb // // only (i.e. FDCT dout-bit[0]) // // // // The amount of coefficient-bits needed is dependent on the // // desired quality. // // The JPEG-standard compliance specs.(ITU-T.83) prescribe // // that the output of the combined DCT AND Quantization unit // // shall not exceed 1 for the desired quality. // // // // This means for high quantization levels, lesser bits // // for the DCT unit can be used. // // // // Looking at the recommended "quantization tables for generic // // compliance testing of DCT-based processes" (ITU-T.83 annex B) // // it can be noticed that relatively large quantization values // // are being used. Errors in the lower-order bits should // // therefore not be visible. // // Tests with real continuous and non-continous tone image data // // have shown that when using the example quantization tables // // from ITU-T.81 annex K, 10bits coefficients are sufficient to // // comply to the ITU-T.83 specs. Compliance tests have been met // // using as little as 9bit coefficients. // // For certain applications some of the lower-order bits could // // actually be discarded. When looking at the luminance and // // chrominance example quantization tables (ITU-T.81 annex K) // // it can be seen that the smallest quantization value is ten // // (qnt_val_min = 10). This means that the lower 2bits can be // // discarded (set to zero '0') without having any effect on the // // final result. In this example 11 bit or 12 bit coefficients // // would be sufficient. // // // //////////////////////////////////////////////////////////////////// parameter coef_width = 13; //9; // amount of 8x8 data packets to use for tests (current max. = 4) parameter input_lists_start = 1; parameter input_lists_end = 4; // // internal wires // reg clk; reg rst; reg dstrb; reg [7:0] din; wire den; wire [10:0] dout; wire [ 3:0] size, rlen; wire [11:0] amp; reg [ 7:0] input_list [(input_lists_end*64) -1:0]; reg [7:0] qnt_list [63:0]; wire [5:0] qnt_cnt; reg [7:0] qnt_val; integer x,y; integer n, list_cnt; // // JPEG Encoder unit // jpeg_encoder #(coef_width) jpeg_enc ( .clk(clk), .ena(1'b1), .rst(rst), .dstrb(dstrb), .din(din), .qnt_val(qnt_val), .qnt_cnt(qnt_cnt), .size(size), .rlen(rlen), .amp(amp),// .dout(dout), .douten(den) ); // generate Quantization memory always @(posedge clk) qnt_val <= #1 qnt_list[qnt_cnt]; // hookup checker-modules fdct_qnr_checker #(input_lists_start, input_lists_end) output_check ( .clk(clk), .rst(rst), .dstrb(jpeg_enc.dqnr_doe), .din(jpeg_enc.qnr_dout) ); // // testbench body // // generate clock always #2.5 clk <= ~clk; // initial statements initial begin // waves statement `ifdef WAVES $shm_open("waves"); $shm_probe("AS",bench_top,"AS"); $display("INFO: Signal dump enabled ...\n\n"); `endif // // fill input-table // // input list 1 input_list[00] <= 8'd139; input_list[01] <= 8'd144; input_list[02] <= 8'd149; input_list[03] <= 8'd153; input_list[04] <= 8'd155; input_list[05] <= 8'd155; input_list[06] <= 8'd155; input_list[07] <= 8'd155; input_list[08] <= 8'd144; input_list[09] <= 8'd151; input_list[10] <= 8'd153; input_list[11] <= 8'd156; input_list[12] <= 8'd159; input_list[13] <= 8'd156; input_list[14] <= 8'd156; input_list[15] <= 8'd156; input_list[16] <= 8'd150; input_list[17] <= 8'd155; input_list[18] <= 8'd160; input_list[19] <= 8'd163; input_list[20] <= 8'd158; input_list[21] <= 8'd156; input_list[22] <= 8'd156; input_list[23] <= 8'd156; input_list[24] <= 8'd159; input_list[25] <= 8'd161; input_list[26] <= 8'd162; input_list[27] <= 8'd160; input_list[28] <= 8'd160; input_list[29] <= 8'd159; input_list[30] <= 8'd159; input_list[31] <= 8'd159; input_list[32] <= 8'd159; input_list[33] <= 8'd160; input_list[34] <= 8'd161; input_list[35] <= 8'd162; input_list[36] <= 8'd162; input_list[37] <= 8'd155; input_list[38] <= 8'd155; input_list[39] <= 8'd155; input_list[40] <= 8'd161; input_list[41] <= 8'd161; input_list[42] <= 8'd161; input_list[43] <= 8'd161; input_list[44] <= 8'd160; input_list[45] <= 8'd157; input_list[46] <= 8'd157; input_list[47] <= 8'd157; input_list[48] <= 8'd162; input_list[49] <= 8'd162; input_list[50] <= 8'd161; input_list[51] <= 8'd163; input_list[52] <= 8'd162; input_list[53] <= 8'd157; input_list[54] <= 8'd157; input_list[55] <= 8'd157; input_list[56] <= 8'd162; input_list[57] <= 8'd162; input_list[58] <= 8'd161; input_list[59] <= 8'd161; input_list[60] <= 8'd163; input_list[61] <= 8'd158; input_list[62] <= 8'd158; input_list[63] <= 8'd158; // input list 2 input_list[064] <= 8'd0; input_list[065] <= 8'd0; input_list[066] <= 8'd0; input_list[067] <= 8'd0; input_list[068] <= 8'd0; input_list[069] <= 8'd0; input_list[070] <= 8'd0; input_list[071] <= 8'd0; input_list[072] <= 8'd0; input_list[073] <= 8'd0; input_list[074] <= 8'd0; input_list[075] <= 8'd0; input_list[076] <= 8'd0; input_list[077] <= 8'd0; input_list[078] <= 8'd0; input_list[079] <= 8'd0; input_list[080] <= 8'd0; input_list[081] <= 8'd0; input_list[082] <= 8'd0; input_list[083] <= 8'd0; input_list[084] <= 8'd0; input_list[085] <= 8'd0; input_list[086] <= 8'd0; input_list[087] <= 8'd0; input_list[088] <= 8'd0; input_list[089] <= 8'd0; input_list[090] <= 8'd0; input_list[091] <= 8'd0; input_list[092] <= 8'd0; input_list[093] <= 8'd0; input_list[094] <= 8'd0; input_list[095] <= 8'd0; input_list[096] <= 8'd0; input_list[097] <= 8'd0; input_list[098] <= 8'd0; input_list[099] <= 8'd0; input_list[100] <= 8'd0; input_list[101] <= 8'd0; input_list[102] <= 8'd0; input_list[103] <= 8'd0; input_list[104] <= 8'd0; input_list[105] <= 8'd0; input_list[106] <= 8'd0; input_list[107] <= 8'd0; input_list[108] <= 8'd0; input_list[109] <= 8'd0; input_list[110] <= 8'd0; input_list[111] <= 8'd0; input_list[112] <= 8'd0; input_list[113] <= 8'd0; input_list[114] <= 8'd0; input_list[115] <= 8'd0; input_list[116] <= 8'd0; input_list[117] <= 8'd0; input_list[118] <= 8'd0; input_list[119] <= 8'd0; input_list[120] <= 8'd0; input_list[121] <= 8'd0; input_list[122] <= 8'd0; input_list[123] <= 8'd0; input_list[124] <= 8'd0; input_list[125] <= 8'd0; input_list[126] <= 8'd0; input_list[127] <= 8'd0; // input list 3 input_list[128] <= 8'd70; input_list[129] <= 8'd72; input_list[130] <= 8'd70; input_list[131] <= 8'd70; input_list[132] <= 8'd72; input_list[133] <= 8'd68; input_list[134] <= 8'd68; input_list[135] <= 8'd64; input_list[136] <= 8'd103; input_list[137] <= 8'd101; input_list[138] <= 8'd103; input_list[139] <= 8'd100; input_list[140] <= 8'd99; input_list[141] <= 8'd97; input_list[142] <= 8'd94; input_list[143] <= 8'd94; input_list[144] <= 8'd132; input_list[145] <= 8'd132; input_list[146] <= 8'd132; input_list[147] <= 8'd130; input_list[148] <= 8'd129; input_list[149] <= 8'd129; input_list[150] <= 8'd125; input_list[151] <= 8'd121; input_list[152] <= 8'd157; input_list[153] <= 8'd157; input_list[154] <= 8'd155; input_list[155] <= 8'd154; input_list[156] <= 8'd153; input_list[157] <= 8'd150; input_list[158] <= 8'd148; input_list[159] <= 8'd145; input_list[160] <= 8'd168; input_list[161] <= 8'd163; input_list[162] <= 8'd164; input_list[163] <= 8'd162; input_list[164] <= 8'd163; input_list[165] <= 8'd161; input_list[166] <= 8'd161; input_list[167] <= 8'd156; input_list[168] <= 8'd172; input_list[169] <= 8'd170; input_list[170] <= 8'd165; input_list[171] <= 8'd166; input_list[172] <= 8'd163; input_list[173] <= 8'd163; input_list[174] <= 8'd162; input_list[175] <= 8'd158; input_list[176] <= 8'd174; input_list[177] <= 8'd170; input_list[178] <= 8'd167; input_list[179] <= 8'd167; input_list[180] <= 8'd164; input_list[181] <= 8'd163; input_list[182] <= 8'd164; input_list[183] <= 8'd159; input_list[184] <= 8'd174; input_list[185] <= 8'd173; input_list[186] <= 8'd170; input_list[187] <= 8'd167; input_list[188] <= 8'd167; input_list[189] <= 8'd166; input_list[190] <= 8'd166; input_list[191] <= 8'd160; // input list 4 input_list[192] <= 8'd151; input_list[193] <= 8'd147; input_list[194] <= 8'd152; input_list[195] <= 8'd140; input_list[196] <= 8'd138; input_list[197] <= 8'd125; input_list[198] <= 8'd136; input_list[199] <= 8'd160; input_list[200] <= 8'd157; input_list[201] <= 8'd148; input_list[202] <= 8'd152; input_list[203] <= 8'd137; input_list[204] <= 8'd124; input_list[205] <= 8'd105; input_list[206] <= 8'd108; input_list[207] <= 8'd144; input_list[208] <= 8'd152; input_list[209] <= 8'd151; input_list[210] <= 8'd146; input_list[211] <= 8'd128; input_list[212] <= 8'd99; input_list[213] <= 8'd73; input_list[214] <= 8'd75; input_list[215] <= 8'd116; input_list[216] <= 8'd154; input_list[217] <= 8'd148; input_list[218] <= 8'd145; input_list[219] <= 8'd111; input_list[220] <= 8'd91; input_list[221] <= 8'd68; input_list[222] <= 8'd62; input_list[223] <= 8'd98; input_list[224] <= 8'd156; input_list[225] <= 8'd144; input_list[226] <= 8'd147; input_list[227] <= 8'd93; input_list[228] <= 8'd97; input_list[229] <= 8'd105; input_list[230] <= 8'd61; input_list[231] <= 8'd82; input_list[232] <= 8'd155; input_list[233] <= 8'd139; input_list[234] <= 8'd149; input_list[235] <= 8'd76; input_list[236] <= 8'd101; input_list[237] <= 8'd140; input_list[238] <= 8'd59; input_list[239] <= 8'd74; input_list[240] <= 8'd148; input_list[241] <= 8'd135; input_list[242] <= 8'd147; input_list[243] <= 8'd71; input_list[244] <= 8'd114; input_list[245] <= 8'd158; input_list[246] <= 8'd79; input_list[247] <= 8'd66; input_list[248] <= 8'd135; input_list[249] <= 8'd120; input_list[250] <= 8'd133; input_list[251] <= 8'd92; input_list[252] <= 8'd133; input_list[253] <= 8'd176; input_list[254] <= 8'd103; input_list[255] <= 8'd60; //
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -