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

Subversion Repositories djpeg

[/] [djpeg/] [trunk/] [src/] [jpeg_hm_decode.v] - Diff between revs 6 and 9

Show entire file | Details | Blame | View Log

Rev 6 Rev 9
Line 1... Line 1...
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// File Name   : jpeg_hm_decode.v
// File Name   : jpeg_hm_decode.v
// Module Name : jpeg_hm_decode
// Module Name : jpeg_hm_decode
// Description : Decode of Haffuman data
// Description  : Decode of Huffman data
// Project     : JPEG Decoder
// Project     : JPEG Decoder
// Belong to   : 
// Belong to   : 
// Author      : H.Ishihara
// Author      : H.Ishihara
// E-Mail      : hidemi@sweetcafe.jp
// E-Mail      : hidemi@sweetcafe.jp
// HomePage    : http://www.sweetcafe.jp/
// HomePage    : http://www.sweetcafe.jp/
// Date        : 2006/10/01
// Date         : 2008/03/23
// Rev.        : 1.1
// Rev.         : 2.0
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Rev. Date       Description
// Rev. Date       Description
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 1.01 2006/10/01 1st Release
// 1.01 2006/10/01 1st Release
// 1.02 2006/10/04 move for a comment widh OutData,OutDhtNumber register.
// 1.02 2006/10/04 move for a comment widh OutData,OutDhtNumber register.
//                 remove a ProcessColorNumber,tempPlace register.
//                 remove a ProcessColorNumber,tempPlace register.
//---------------------------------------------------------------------------
// 2.00 2008/03/23 Replace Space.
// $Id: 
//                 ReTiming DataOutEnable
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
`timescale 1ps / 1ps
`timescale 1ps / 1ps
 
 
module jpeg_hm_decode
module jpeg_hm_decode(
  (
 
   rst, // Reset
   rst, // Reset
   clk, // Clock
   clk, // Clock
 
 
   // Haffuman Table   
    // Huffman Table    
   HaffumanTableEnable, // Table Data In Enable
    HuffmanTableEnable, // Table Data In Enable
   HaffumanTableColor,  // Haffuman Table Color Number
    HuffmanTableColor,  // Huffman Table Color Number
   HaffumanTableCount,  // Table Number
    HuffmanTableCount,  // Table Number
   HaffumanTableCode,   // Haffuman Table Code
    HuffmanTableCode,   // Huffman Table Code
   HaffumanTableStart,  // Haffuman Table Start Number
    HuffmanTableStart,  // Huffman Table Start Number
 
 
   // Haffuman Decode
    // Huffman Decode
   DataInRun,           // Data In Start
   DataInRun,           // Data In Start
   DataInEnable,        // Data In Enable
   DataInEnable,        // Data In Enable
   DataIn,              // Data In
   DataIn,              // Data In
 
 
   // DHT table
   // DHT table
Line 65... Line 64...
 
 
   //--------------------------------------------------------------------------
   //--------------------------------------------------------------------------
   // Input/Output
   // Input/Output
   //--------------------------------------------------------------------------
   //--------------------------------------------------------------------------
   input         rst,clk;             // Reset and Clock
   input         rst,clk;             // Reset and Clock
   input         HaffumanTableEnable; // Table Data In Enable
    input           HuffmanTableEnable; // Table Data In Enable
   input [1:0]   HaffumanTableColor;
    input [1:0]     HuffmanTableColor;
   input [3:0]   HaffumanTableCount;  // Table Number
    input [3:0]     HuffmanTableCount;  // Table Number
   input [15:0]  HaffumanTableCode;   // Haffuman Table Data
    input [15:0]    HuffmanTableCode;   // Huffman Table Data
   input [7:0]   HaffumanTableStart;  // Haffuman Table Start Number
    input [7:0]     HuffmanTableStart;  // Huffman Table Start Number
 
 
   input         DataInRun;
   input         DataInRun;
   input         DataInEnable;        // Data In Enable
   input         DataInEnable;        // Data In Enable
   input [31:0]  DataIn;              // Data In
   input [31:0]  DataIn;              // Data In
 
 
Line 88... Line 87...
 
 
   input         DataOutIdle;
   input         DataOutIdle;
   output        DataOutEnable;
   output        DataOutEnable;
   output [2:0]  DataOutColor;
   output [2:0]  DataOutColor;
 
 
 
 
   output        DecodeUseBit;
   output        DecodeUseBit;
   output [6:0]  DecodeUseWidth;   // Used Data Width
   output [6:0]  DecodeUseWidth;   // Used Data Width
   output        DecodeEnable;     // Data Out Enable
   output        DecodeEnable;     // Data Out Enable
   output [2:0]  DecodeColor;
   output [2:0]  DecodeColor;
   output [5:0]  DecodeCount;
   output [5:0]  DecodeCount;
   output [3:0]  DecodeZero;       // Data Out with Zero Count
   output [3:0]  DecodeZero;       // Data Out with Zero Count
   output [15:0] DecodeCode;       // Data Out with Code
   output [15:0] DecodeCode;       // Data Out with Code
 
 
   //--------------------------------------------------------------------------
   //--------------------------------------------------------------------------
   // Register Haffuman Table(YCbCr)
    // Register Huffman Table(YCbCr)
   //--------------------------------------------------------------------------
   //--------------------------------------------------------------------------
   // Y-DC Haffuman Table
    // Y-DC Huffman Table
   reg [15:0]    HaffumanTable0r [0:15]; // Y-DC Haffuman Table
    reg [15:0]      HuffmanTable0r [0:15];  // Y-DC Huffman Table
   reg [15:0]    HaffumanTable1r [0:15]; // Y-AC Haffuman Table
    reg [15:0]      HuffmanTable1r [0:15];  // Y-AC Huffman Table
   reg [15:0]    HaffumanTable2r [0:15]; // C-DC Haffuman Table
    reg [15:0]      HuffmanTable2r [0:15];  // C-DC Huffman Table
   reg [15:0]    HaffumanTable3r [0:15]; // C-AC Haffuman Table
    reg [15:0]      HuffmanTable3r [0:15];  // C-AC Huffman Table
 
 
   reg [15:0]    HaffumanNumber0r [0:15]; // Y-DC Haffuman Number
    reg [7:0]       HuffmanNumber0r [0:15]; // Y-DC Huffman Number
   reg [15:0]    HaffumanNumber1r [0:15]; // Y-AC Haffuman Number
    reg [7:0]       HuffmanNumber1r [0:15]; // Y-AC Huffman Number
   reg [15:0]    HaffumanNumber2r [0:15]; // C-DC Haffuman Number
    reg [7:0]       HuffmanNumber2r [0:15]; // C-DC Huffman Number
   reg [15:0]    HaffumanNumber3r [0:15]; // C-AC Haffuman Number
    reg [7:0]       HuffmanNumber3r [0:15]; // C-AC Huffman Number
 
 
   integer       i;
 
 
 
   always @(posedge clk or negedge rst) begin
   always @(posedge clk or negedge rst) begin
      if(!rst) begin
      if(!rst) begin
            HaffumanTable0r[0]  <= 16'h0000;
            HuffmanTable0r[0]  <= 16'h0000;
            HaffumanNumber0r[0] <=  8'h00;
            HuffmanNumber0r[0] <=  8'h00;
            HaffumanTable1r[0]  <= 16'h0000;
            HuffmanTable1r[0]  <= 16'h0000;
            HaffumanNumber1r[0] <=  8'h00;
            HuffmanNumber1r[0] <=  8'h00;
            HaffumanTable2r[0]  <= 16'h0000;
            HuffmanTable2r[0]  <= 16'h0000;
            HaffumanNumber2r[0] <=  8'h00;
            HuffmanNumber2r[0] <=  8'h00;
            HaffumanTable3r[0]  <= 16'h0000;
            HuffmanTable3r[0]  <= 16'h0000;
            HaffumanNumber3r[0] <=  8'h00;
            HuffmanNumber3r[0] <=  8'h00;
 
 
            HaffumanTable0r[1]  <= 16'h0000;
            HuffmanTable0r[1]  <= 16'h0000;
            HaffumanNumber0r[1] <=  8'h00;
            HuffmanNumber0r[1] <=  8'h00;
            HaffumanTable1r[1]  <= 16'h0000;
            HuffmanTable1r[1]  <= 16'h0000;
            HaffumanNumber1r[1] <=  8'h00;
            HuffmanNumber1r[1] <=  8'h00;
            HaffumanTable2r[1]  <= 16'h0000;
            HuffmanTable2r[1]  <= 16'h0000;
            HaffumanNumber2r[1] <=  8'h00;
            HuffmanNumber2r[1] <=  8'h00;
            HaffumanTable3r[1]  <= 16'h0000;
            HuffmanTable3r[1]  <= 16'h0000;
            HaffumanNumber3r[1] <=  8'h00;
            HuffmanNumber3r[1] <=  8'h00;
 
 
            HaffumanTable0r[2]  <= 16'h0000;
            HuffmanTable0r[2]  <= 16'h0000;
            HaffumanNumber0r[2] <=  8'h00;
            HuffmanNumber0r[2] <=  8'h00;
            HaffumanTable1r[2]  <= 16'h0000;
            HuffmanTable1r[2]  <= 16'h0000;
            HaffumanNumber1r[2] <=  8'h00;
            HuffmanNumber1r[2] <=  8'h00;
            HaffumanTable2r[2]  <= 16'h0000;
            HuffmanTable2r[2]  <= 16'h0000;
            HaffumanNumber2r[2] <=  8'h00;
            HuffmanNumber2r[2] <=  8'h00;
            HaffumanTable3r[2]  <= 16'h0000;
            HuffmanTable3r[2]  <= 16'h0000;
            HaffumanNumber3r[2] <=  8'h00;
            HuffmanNumber3r[2] <=  8'h00;
 
 
            HaffumanTable0r[3]  <= 16'h0000;
            HuffmanTable0r[3]  <= 16'h0000;
            HaffumanNumber0r[3] <=  8'h00;
            HuffmanNumber0r[3] <=  8'h00;
            HaffumanTable1r[3]  <= 16'h0000;
            HuffmanTable1r[3]  <= 16'h0000;
            HaffumanNumber1r[3] <=  8'h00;
            HuffmanNumber1r[3] <=  8'h00;
            HaffumanTable2r[3]  <= 16'h0000;
            HuffmanTable2r[3]  <= 16'h0000;
            HaffumanNumber2r[3] <=  8'h00;
            HuffmanNumber2r[3] <=  8'h00;
            HaffumanTable3r[3]  <= 16'h0000;
            HuffmanTable3r[3]  <= 16'h0000;
            HaffumanNumber3r[3] <=  8'h00;
            HuffmanNumber3r[3] <=  8'h00;
 
 
            HaffumanTable0r[4]  <= 16'h0000;
            HuffmanTable0r[4]  <= 16'h0000;
            HaffumanNumber0r[4] <=  8'h00;
            HuffmanNumber0r[4] <=  8'h00;
            HaffumanTable1r[4]  <= 16'h0000;
            HuffmanTable1r[4]  <= 16'h0000;
            HaffumanNumber1r[4] <=  8'h00;
            HuffmanNumber1r[4] <=  8'h00;
            HaffumanTable2r[4]  <= 16'h0000;
            HuffmanTable2r[4]  <= 16'h0000;
            HaffumanNumber2r[4] <=  8'h00;
            HuffmanNumber2r[4] <=  8'h00;
            HaffumanTable3r[4]  <= 16'h0000;
            HuffmanTable3r[4]  <= 16'h0000;
            HaffumanNumber3r[4] <=  8'h00;
            HuffmanNumber3r[4] <=  8'h00;
 
 
            HaffumanTable0r[5]  <= 16'h0000;
            HuffmanTable0r[5]  <= 16'h0000;
            HaffumanNumber0r[5] <=  8'h00;
            HuffmanNumber0r[5] <=  8'h00;
            HaffumanTable1r[5]  <= 16'h0000;
            HuffmanTable1r[5]  <= 16'h0000;
            HaffumanNumber1r[5] <=  8'h00;
            HuffmanNumber1r[5] <=  8'h00;
            HaffumanTable2r[5]  <= 16'h0000;
            HuffmanTable2r[5]  <= 16'h0000;
            HaffumanNumber2r[5] <=  8'h00;
            HuffmanNumber2r[5] <=  8'h00;
            HaffumanTable3r[5]  <= 16'h0000;
            HuffmanTable3r[5]  <= 16'h0000;
            HaffumanNumber3r[5] <=  8'h00;
            HuffmanNumber3r[5] <=  8'h00;
 
 
            HaffumanTable0r[6]  <= 16'h0000;
            HuffmanTable0r[6]  <= 16'h0000;
            HaffumanNumber0r[6] <=  8'h00;
            HuffmanNumber0r[6] <=  8'h00;
            HaffumanTable1r[6]  <= 16'h0000;
            HuffmanTable1r[6]  <= 16'h0000;
            HaffumanNumber1r[6] <=  8'h00;
            HuffmanNumber1r[6] <=  8'h00;
            HaffumanTable2r[6]  <= 16'h0000;
            HuffmanTable2r[6]  <= 16'h0000;
            HaffumanNumber2r[6] <=  8'h00;
            HuffmanNumber2r[6] <=  8'h00;
            HaffumanTable3r[6]  <= 16'h0000;
            HuffmanTable3r[6]  <= 16'h0000;
            HaffumanNumber3r[6] <=  8'h00;
            HuffmanNumber3r[6] <=  8'h00;
 
 
            HaffumanTable0r[7]  <= 16'h0000;
            HuffmanTable0r[7]  <= 16'h0000;
            HaffumanNumber0r[7] <=  8'h00;
            HuffmanNumber0r[7] <=  8'h00;
            HaffumanTable1r[7]  <= 16'h0000;
            HuffmanTable1r[7]  <= 16'h0000;
            HaffumanNumber1r[7] <=  8'h00;
            HuffmanNumber1r[7] <=  8'h00;
            HaffumanTable2r[7]  <= 16'h0000;
            HuffmanTable2r[7]  <= 16'h0000;
            HaffumanNumber2r[7] <=  8'h00;
            HuffmanNumber2r[7] <=  8'h00;
            HaffumanTable3r[7]  <= 16'h0000;
            HuffmanTable3r[7]  <= 16'h0000;
            HaffumanNumber3r[7] <=  8'h00;
            HuffmanNumber3r[7] <=  8'h00;
 
 
            HaffumanTable0r[8]  <= 16'h0000;
            HuffmanTable0r[8]  <= 16'h0000;
            HaffumanNumber0r[8] <=  8'h00;
            HuffmanNumber0r[8] <=  8'h00;
            HaffumanTable1r[8]  <= 16'h0000;
            HuffmanTable1r[8]  <= 16'h0000;
            HaffumanNumber1r[8] <=  8'h00;
            HuffmanNumber1r[8] <=  8'h00;
            HaffumanTable2r[8]  <= 16'h0000;
            HuffmanTable2r[8]  <= 16'h0000;
            HaffumanNumber2r[8] <=  8'h00;
            HuffmanNumber2r[8] <=  8'h00;
            HaffumanTable3r[8]  <= 16'h0000;
            HuffmanTable3r[8]  <= 16'h0000;
            HaffumanNumber3r[8] <=  8'h00;
            HuffmanNumber3r[8] <=  8'h00;
 
 
            HaffumanTable0r[9]  <= 16'h0000;
            HuffmanTable0r[9]  <= 16'h0000;
            HaffumanNumber0r[9] <=  8'h00;
            HuffmanNumber0r[9] <=  8'h00;
            HaffumanTable1r[9]  <= 16'h0000;
            HuffmanTable1r[9]  <= 16'h0000;
            HaffumanNumber1r[9] <=  8'h00;
            HuffmanNumber1r[9] <=  8'h00;
            HaffumanTable2r[9]  <= 16'h0000;
            HuffmanTable2r[9]  <= 16'h0000;
            HaffumanNumber2r[9] <=  8'h00;
            HuffmanNumber2r[9] <=  8'h00;
            HaffumanTable3r[9]  <= 16'h0000;
            HuffmanTable3r[9]  <= 16'h0000;
            HaffumanNumber3r[9] <=  8'h00;
            HuffmanNumber3r[9] <=  8'h00;
 
 
            HaffumanTable0r[10]  <= 16'h0000;
            HuffmanTable0r[10]  <= 16'h0000;
            HaffumanNumber0r[10] <=  8'h00;
            HuffmanNumber0r[10] <=  8'h00;
            HaffumanTable1r[10]  <= 16'h0000;
            HuffmanTable1r[10]  <= 16'h0000;
            HaffumanNumber1r[10] <=  8'h00;
            HuffmanNumber1r[10] <=  8'h00;
            HaffumanTable2r[10]  <= 16'h0000;
            HuffmanTable2r[10]  <= 16'h0000;
            HaffumanNumber2r[10] <=  8'h00;
            HuffmanNumber2r[10] <=  8'h00;
            HaffumanTable3r[10]  <= 16'h0000;
            HuffmanTable3r[10]  <= 16'h0000;
            HaffumanNumber3r[10] <=  8'h00;
            HuffmanNumber3r[10] <=  8'h00;
 
 
            HaffumanTable0r[11]  <= 16'h0000;
            HuffmanTable0r[11]  <= 16'h0000;
            HaffumanNumber0r[11] <=  8'h00;
            HuffmanNumber0r[11] <=  8'h00;
            HaffumanTable1r[11]  <= 16'h0000;
            HuffmanTable1r[11]  <= 16'h0000;
            HaffumanNumber1r[11] <=  8'h00;
            HuffmanNumber1r[11] <=  8'h00;
            HaffumanTable2r[11]  <= 16'h0000;
            HuffmanTable2r[11]  <= 16'h0000;
            HaffumanNumber2r[11] <=  8'h00;
            HuffmanNumber2r[11] <=  8'h00;
            HaffumanTable3r[11]  <= 16'h0000;
            HuffmanTable3r[11]  <= 16'h0000;
            HaffumanNumber3r[11] <=  8'h00;
            HuffmanNumber3r[11] <=  8'h00;
 
 
            HaffumanTable0r[12]  <= 16'h0000;
            HuffmanTable0r[12]  <= 16'h0000;
            HaffumanNumber0r[12] <=  8'h00;
            HuffmanNumber0r[12] <=  8'h00;
            HaffumanTable1r[12]  <= 16'h0000;
            HuffmanTable1r[12]  <= 16'h0000;
            HaffumanNumber1r[12] <=  8'h00;
            HuffmanNumber1r[12] <=  8'h00;
            HaffumanTable2r[12]  <= 16'h0000;
            HuffmanTable2r[12]  <= 16'h0000;
            HaffumanNumber2r[12] <=  8'h00;
            HuffmanNumber2r[12] <=  8'h00;
            HaffumanTable3r[12]  <= 16'h0000;
            HuffmanTable3r[12]  <= 16'h0000;
            HaffumanNumber3r[12] <=  8'h00;
            HuffmanNumber3r[12] <=  8'h00;
 
 
            HaffumanTable0r[13]  <= 16'h0000;
            HuffmanTable0r[13]  <= 16'h0000;
            HaffumanNumber0r[13] <=  8'h00;
            HuffmanNumber0r[13] <=  8'h00;
            HaffumanTable1r[13]  <= 16'h0000;
            HuffmanTable1r[13]  <= 16'h0000;
            HaffumanNumber1r[13] <=  8'h00;
            HuffmanNumber1r[13] <=  8'h00;
            HaffumanTable2r[13]  <= 16'h0000;
            HuffmanTable2r[13]  <= 16'h0000;
            HaffumanNumber2r[13] <=  8'h00;
            HuffmanNumber2r[13] <=  8'h00;
            HaffumanTable3r[13]  <= 16'h0000;
            HuffmanTable3r[13]  <= 16'h0000;
            HaffumanNumber3r[13] <=  8'h00;
            HuffmanNumber3r[13] <=  8'h00;
 
 
            HaffumanTable0r[14]  <= 16'h0000;
            HuffmanTable0r[14]  <= 16'h0000;
            HaffumanNumber0r[14] <=  8'h00;
            HuffmanNumber0r[14] <=  8'h00;
            HaffumanTable1r[14]  <= 16'h0000;
            HuffmanTable1r[14]  <= 16'h0000;
            HaffumanNumber1r[14] <=  8'h00;
            HuffmanNumber1r[14] <=  8'h00;
            HaffumanTable2r[14]  <= 16'h0000;
            HuffmanTable2r[14]  <= 16'h0000;
            HaffumanNumber2r[14] <=  8'h00;
            HuffmanNumber2r[14] <=  8'h00;
            HaffumanTable3r[14]  <= 16'h0000;
            HuffmanTable3r[14]  <= 16'h0000;
            HaffumanNumber3r[14] <=  8'h00;
            HuffmanNumber3r[14] <=  8'h00;
 
 
            HaffumanTable0r[15]  <= 16'h0000;
            HuffmanTable0r[15]  <= 16'h0000;
            HaffumanNumber0r[15] <=  8'h00;
            HuffmanNumber0r[15] <=  8'h00;
            HaffumanTable1r[15]  <= 16'h0000;
            HuffmanTable1r[15]  <= 16'h0000;
            HaffumanNumber1r[15] <=  8'h00;
            HuffmanNumber1r[15] <=  8'h00;
            HaffumanTable2r[15]  <= 16'h0000;
            HuffmanTable2r[15]  <= 16'h0000;
            HaffumanNumber2r[15] <=  8'h00;
            HuffmanNumber2r[15] <=  8'h00;
            HaffumanTable3r[15]  <= 16'h0000;
            HuffmanTable3r[15]  <= 16'h0000;
            HaffumanNumber3r[15] <=  8'h00;
            HuffmanNumber3r[15] <=  8'h00;
      end else begin // if (!rst)
        end else begin
         if(HaffumanTableEnable ==2'b1) begin
            if(HuffmanTableEnable ==2'b1) begin
            if(HaffumanTableColor ==2'b00) begin
                if(HuffmanTableColor ==2'b00) begin
               HaffumanTable0r[HaffumanTableCount]  <= HaffumanTableCode;
                    HuffmanTable0r[HuffmanTableCount]  <= HuffmanTableCode;
               HaffumanNumber0r[HaffumanTableCount] <= HaffumanTableStart;
                    HuffmanNumber0r[HuffmanTableCount] <= HuffmanTableStart;
            end else if(HaffumanTableColor ==2'b01) begin
                end else if(HuffmanTableColor ==2'b01) begin
               HaffumanTable1r[HaffumanTableCount]  <= HaffumanTableCode;
                    HuffmanTable1r[HuffmanTableCount]  <= HuffmanTableCode;
               HaffumanNumber1r[HaffumanTableCount] <= HaffumanTableStart;
                    HuffmanNumber1r[HuffmanTableCount] <= HuffmanTableStart;
            end else if(HaffumanTableColor ==2'b10) begin
                end else if(HuffmanTableColor ==2'b10) begin
               HaffumanTable2r[HaffumanTableCount]  <= HaffumanTableCode;
                    HuffmanTable2r[HuffmanTableCount]  <= HuffmanTableCode;
               HaffumanNumber2r[HaffumanTableCount] <= HaffumanTableStart;
                    HuffmanNumber2r[HuffmanTableCount] <= HuffmanTableStart;
            end else begin
                end else begin
               HaffumanTable3r[HaffumanTableCount]  <= HaffumanTableCode;
                    HuffmanTable3r[HuffmanTableCount]  <= HuffmanTableCode;
               HaffumanNumber3r[HaffumanTableCount] <= HaffumanTableStart;
                    HuffmanNumber3r[HuffmanTableCount] <= HuffmanTableStart;
            end
                end
         end // if (HaffumanTableEnable ==2'b1)
            end
      end // else: !if(!rst)
        end
   end // always @ (posedge clk or negedge rst)
    end
 
 
   //--------------------------------------------------------------------------
   //--------------------------------------------------------------------------
   // Decode Process
   // Decode Process
   //--------------------------------------------------------------------------
   //--------------------------------------------------------------------------
   reg [3:0]       Process;            // Process State
   reg [3:0]       Process;            // Process State
   reg [31:0]       ProcessData;        // Data
   reg [31:0]       ProcessData;        // Data
 
 
   // Haffuman Table
    // Huffman Table
   reg [15:0]       HaffumanTable [0:15];
    reg [15:0]  HuffmanTable [0:15];
   // Haffuman Table Number
    // Huffman Table Number
   reg [7:0]        HaffumanNumber [0:15];
    reg [7:0]   HuffmanNumber [0:15];
 
 
   reg [15:0]       Place;           // Place bit
   reg [15:0]       Place;           // Place bit
   reg [15:0]       TableCode;       // Table Code
   reg [15:0]       TableCode;       // Table Code
   reg [7:0]        NumberCode;      // Start Number of Table Code
   reg [7:0]        NumberCode;      // Start Number of Table Code
   reg [3:0]        CodeNumber;      // Haffuman code width
    reg [3:0]   CodeNumber;     // Huffman code width
   reg [15:0]       DataNumber;      // Haffuman code
    reg [15:0]  DataNumber;     // Huffman code
   //reg [15:0]    SubData;         // Haffuman Dht Number
 
 
 
   //reg [7:0]     OutDhtNumber;    // Output Dht Number
 
 
 
   reg [2:0]        ProcessColor;
   reg [2:0]        ProcessColor;
   reg [6:0]        ProcessCount;
    reg [5:0]   ProcessCount;
   reg [6:0]        NextProcessCount;
 
 
 
   reg             OutEnable;       // Output Enable
   reg             OutEnable;       // Output Enable
   reg [3:0]        OutZero;         // Output Zero Count
   reg [3:0]        OutZero;         // Output Zero Count
   reg [15:0]       OutCode;         // Output Data Code
   reg [15:0]       OutCode;         // Output Data Code
   wire [15:0]      OutCodeP;        // Output Data Code
   wire [15:0]      OutCodeP;        // Output Data Code
 
 
   reg [4:0]        UseWidth;        // Output used width
   reg [4:0]        UseWidth;        // Output used width
 
 
   //reg [23:0]            OutData;
//    reg                 DataOutEnable;
 
 
   reg             DataOutEnable;
 
   reg [2:0]        DataOutColor;
   reg [2:0]        DataOutColor;
 
 
   reg signed [31:0] PreData [0:2];
   reg signed [31:0] PreData [0:2];
 
 
   wire [15:0]        SubCode;
   wire [15:0]        SubCode;
Line 326... Line 316...
   parameter         Phase4   = 4'h4;
   parameter         Phase4   = 4'h4;
   parameter         Phase5   = 4'h5;
   parameter         Phase5   = 4'h5;
   parameter         Phase6   = 4'h6;
   parameter         Phase6   = 4'h6;
   parameter         Phase7   = 4'h7;
   parameter         Phase7   = 4'h7;
   parameter         Phase8   = 4'h8;
   parameter         Phase8   = 4'h8;
   parameter         Phase9   = 4'h9;
 
   parameter         Phase10  = 4'hA;
 
   parameter         Phase11  = 4'hB;
 
 
 
/*
 
   always @(*) begin
 
      case (DhtWidth)
 
        4'h0: OutCodeP <= 16'h0000;
 
        4'h1: OutCodeP <= {15'h0000,ProcessData[31]};
 
        4'h2: OutCodeP <= {14'h0000,ProcessData[31:30]};
 
        4'h3: OutCodeP <= {13'h0000,ProcessData[31:29]};
 
        4'h4: OutCodeP <= {12'h000, ProcessData[31:28]};
 
        4'h5: OutCodeP <= {11'h000, ProcessData[31:27]};
 
        4'h6: OutCodeP <= {10'h000, ProcessData[31:26]};
 
        4'h7: OutCodeP <= {9'h000,  ProcessData[31:25]};
 
        4'h8: OutCodeP <= {8'h00,   ProcessData[31:24]};
 
        4'h9: OutCodeP <= {7'h00,   ProcessData[31:23]};
 
        4'hA: OutCodeP <= {6'h00,   ProcessData[31:22]};
 
        4'hB: OutCodeP <= {5'h00,   ProcessData[31:21]};
 
        4'hC: OutCodeP <= {4'h0,    ProcessData[31:20]};
 
        4'hD: OutCodeP <= {3'h0,    ProcessData[31:19]};
 
        4'hE: OutCodeP <= {2'h0,    ProcessData[31:18]};
 
        4'hF: OutCodeP <= {1'h0,    ProcessData[31:17]};
 
      endcase // case(DhtWidth)
 
      case (DhtWidth)
 
        4'h0: SubCode <= 16'hFFFF;
 
        4'h1: SubCode <= 16'hFFFE;
 
        4'h2: SubCode <= 16'hFFFC;
 
        4'h3: SubCode <= 16'hFFF8;
 
        4'h4: SubCode <= 16'hFFF0;
 
        4'h5: SubCode <= 16'hFFE0;
 
        4'h6: SubCode <= 16'hFFC0;
 
        4'h7: SubCode <= 16'hFF80;
 
        4'h8: SubCode <= 16'hFF00;
 
        4'h9: SubCode <= 16'hFE00;
 
        4'hA: SubCode <= 16'hFC00;
 
        4'hB: SubCode <= 16'hF800;
 
        4'hC: SubCode <= 16'hF000;
 
        4'hD: SubCode <= 16'hE000;
 
        4'hE: SubCode <= 16'hC000;
 
        4'hF: SubCode <= 16'h8000;
 
      endcase // case(DhtWidth)
 
   end // always @ (*)
 
*/
 
 
 
        function [15:0] OutCodePSel;
        function [15:0] OutCodePSel;
                input [3:0]      DhtWidth;
                input [3:0]      DhtWidth;
                input [31:0]     ProcessData;
                input [31:0]     ProcessData;
        begin
        begin
Line 392... Line 338...
        4'hB: OutCodePSel = {5'h00,   ProcessData[31:21]};
        4'hB: OutCodePSel = {5'h00,   ProcessData[31:21]};
        4'hC: OutCodePSel = {4'h0,    ProcessData[31:20]};
        4'hC: OutCodePSel = {4'h0,    ProcessData[31:20]};
        4'hD: OutCodePSel = {3'h0,    ProcessData[31:19]};
        4'hD: OutCodePSel = {3'h0,    ProcessData[31:19]};
        4'hE: OutCodePSel = {2'h0,    ProcessData[31:18]};
        4'hE: OutCodePSel = {2'h0,    ProcessData[31:18]};
        4'hF: OutCodePSel = {1'h0,    ProcessData[31:17]};
        4'hF: OutCodePSel = {1'h0,    ProcessData[31:17]};
                endcase // case(DhtWidth)
            endcase
        end
        end
        endfunction
        endfunction
        assign OutCodeP = OutCodePSel(DhtWidth, ProcessData);
        assign OutCodeP = OutCodePSel(DhtWidth, ProcessData);
 
 
        function [15:0] SubCodeSel;
        function [15:0] SubCodeSel;
Line 417... Line 363...
        4'hB: SubCodeSel = 16'hF800;
        4'hB: SubCodeSel = 16'hF800;
        4'hC: SubCodeSel = 16'hF000;
        4'hC: SubCodeSel = 16'hF000;
        4'hD: SubCodeSel = 16'hE000;
        4'hD: SubCodeSel = 16'hE000;
        4'hE: SubCodeSel = 16'hC000;
        4'hE: SubCodeSel = 16'hC000;
        4'hF: SubCodeSel = 16'h8000;
        4'hF: SubCodeSel = 16'h8000;
      endcase // case(DhtWidth)
        endcase
        end
        end
        endfunction
        endfunction
        assign SubCode = SubCodeSel(DhtWidth);
        assign SubCode = SubCodeSel(DhtWidth);
 
 
   always @(posedge clk or negedge rst) begin
   always @(posedge clk or negedge rst) begin
      if(!rst) begin
      if(!rst) begin
         Process       <= ProcIdle;
         Process       <= ProcIdle;
         ProcessData   <= 32'h00000000;
         ProcessData   <= 32'h00000000;
 
            ProcessCount    <= 6'd0;
         OutEnable     <= 1'b0;
         OutEnable     <= 1'b0;
         DataOutEnable <= 1'b0;
//            DataOutEnable <= 1'b0;
         DataOutColor  <= 3'b000;
         DataOutColor  <= 3'b000;
         PreData[0]    <= 32'h00000000;
         PreData[0]    <= 32'h00000000;
         PreData[1]    <= 32'h00000000;
         PreData[1]    <= 32'h00000000;
         PreData[2]    <= 32'h00000000;
         PreData[2]    <= 32'h00000000;
         UseWidth      <= 7'h00;
            UseWidth        <= 5'h00;
         CodeNumber             <= 4'd0;
         CodeNumber             <= 4'd0;
      end else begin // if (!rst)
        end else begin
         case (Process)
         case (Process)
           ProcIdle: begin
           ProcIdle: begin
              if(DataInRun == 1'b1) begin
              if(DataInRun == 1'b1) begin
                 Process <= Phase1;
                 Process <= Phase1;
              end else begin
              end else begin
Line 447... Line 394...
                 PreData[1] <= 32'h00000000;
                 PreData[1] <= 32'h00000000;
                 PreData[2] <= 32'h00000000;
                 PreData[2] <= 32'h00000000;
              end
              end
              OutEnable     <= 1'b0;
              OutEnable     <= 1'b0;
              ProcessColor  <= 3'b000;
              ProcessColor  <= 3'b000;
              ProcessCount  <= 0;
                    ProcessCount    <= 6'd0;
              DataOutEnable <= 1'b0;
//                  DataOutEnable   <= 1'b0;
              DataOutColor  <= 3'b000;
              DataOutColor  <= 3'b000;
           end // case: ProcIdle
                end
           // get a table-data and table-number
           // get a table-data and table-number
           Phase1: begin
           Phase1: begin
              if(DataInEnable ==1'b1 & DataOutIdle == 1'b1) begin
                    if(DataInRun == 1'b0) begin
 
                        Process     <= ProcIdle;
 
                    end else if(DataInEnable == 1'b1 & DataOutIdle == 1'b1) begin
                 Process     <= Phase2;
                 Process     <= Phase2;
                 ProcessData <= DataIn;
                 ProcessData <= DataIn;
              end
              end
              OutEnable <= 1'b0;
              OutEnable <= 1'b0;
              DataOutEnable <= 1'b0;
//                  DataOutEnable <= 1'b0;
              if(ProcessColor[2] == 1'b0) begin
              if(ProcessColor[2] == 1'b0) begin
                 if(ProcessCount == 0) begin
                 if(ProcessCount == 0) begin
                       HaffumanTable[0]  <= HaffumanTable0r[0];
                            HuffmanTable[0]  <= HuffmanTable0r[0];
                       HaffumanNumber[0] <= HaffumanNumber0r[0];
                            HuffmanNumber[0] <= HuffmanNumber0r[0];
                       HaffumanTable[1]  <= HaffumanTable0r[1];
                            HuffmanTable[1]  <= HuffmanTable0r[1];
                       HaffumanNumber[1] <= HaffumanNumber0r[1];
                            HuffmanNumber[1] <= HuffmanNumber0r[1];
                       HaffumanTable[2]  <= HaffumanTable0r[2];
                            HuffmanTable[2]  <= HuffmanTable0r[2];
                       HaffumanNumber[2] <= HaffumanNumber0r[2];
                            HuffmanNumber[2] <= HuffmanNumber0r[2];
                       HaffumanTable[3]  <= HaffumanTable0r[3];
                            HuffmanTable[3]  <= HuffmanTable0r[3];
                       HaffumanNumber[3] <= HaffumanNumber0r[3];
                            HuffmanNumber[3] <= HuffmanNumber0r[3];
                       HaffumanTable[4]  <= HaffumanTable0r[4];
                            HuffmanTable[4]  <= HuffmanTable0r[4];
                       HaffumanNumber[4] <= HaffumanNumber0r[4];
                            HuffmanNumber[4] <= HuffmanNumber0r[4];
                       HaffumanTable[5]  <= HaffumanTable0r[5];
                            HuffmanTable[5]  <= HuffmanTable0r[5];
                       HaffumanNumber[5] <= HaffumanNumber0r[5];
                            HuffmanNumber[5] <= HuffmanNumber0r[5];
                       HaffumanTable[6]  <= HaffumanTable0r[6];
                            HuffmanTable[6]  <= HuffmanTable0r[6];
                       HaffumanNumber[6] <= HaffumanNumber0r[6];
                            HuffmanNumber[6] <= HuffmanNumber0r[6];
                       HaffumanTable[7]  <= HaffumanTable0r[7];
                            HuffmanTable[7]  <= HuffmanTable0r[7];
                       HaffumanNumber[7] <= HaffumanNumber0r[7];
                            HuffmanNumber[7] <= HuffmanNumber0r[7];
                       HaffumanTable[8]  <= HaffumanTable0r[8];
                            HuffmanTable[8]  <= HuffmanTable0r[8];
                       HaffumanNumber[8] <= HaffumanNumber0r[8];
                            HuffmanNumber[8] <= HuffmanNumber0r[8];
                       HaffumanTable[9]  <= HaffumanTable0r[9];
                            HuffmanTable[9]  <= HuffmanTable0r[9];
                       HaffumanNumber[9] <= HaffumanNumber0r[9];
                            HuffmanNumber[9] <= HuffmanNumber0r[9];
                       HaffumanTable[10]  <= HaffumanTable0r[10];
                            HuffmanTable[10]  <= HuffmanTable0r[10];
                       HaffumanNumber[10] <= HaffumanNumber0r[10];
                            HuffmanNumber[10] <= HuffmanNumber0r[10];
                       HaffumanTable[11]  <= HaffumanTable0r[11];
                            HuffmanTable[11]  <= HuffmanTable0r[11];
                       HaffumanNumber[11] <= HaffumanNumber0r[11];
                            HuffmanNumber[11] <= HuffmanNumber0r[11];
                       HaffumanTable[12]  <= HaffumanTable0r[12];
                            HuffmanTable[12]  <= HuffmanTable0r[12];
                       HaffumanNumber[12] <= HaffumanNumber0r[12];
                            HuffmanNumber[12] <= HuffmanNumber0r[12];
                       HaffumanTable[13]  <= HaffumanTable0r[13];
                            HuffmanTable[13]  <= HuffmanTable0r[13];
                       HaffumanNumber[13] <= HaffumanNumber0r[13];
                            HuffmanNumber[13] <= HuffmanNumber0r[13];
                       HaffumanTable[14]  <= HaffumanTable0r[14];
                            HuffmanTable[14]  <= HuffmanTable0r[14];
                       HaffumanNumber[14] <= HaffumanNumber0r[14];
                            HuffmanNumber[14] <= HuffmanNumber0r[14];
                       HaffumanTable[15]  <= HaffumanTable0r[15];
                            HuffmanTable[15]  <= HuffmanTable0r[15];
                       HaffumanNumber[15] <= HaffumanNumber0r[15];
                            HuffmanNumber[15] <= HuffmanNumber0r[15];
                 end else begin
                        end else begin
                       HaffumanTable[0]  <= HaffumanTable1r[0];
                            HuffmanTable[0]  <= HuffmanTable1r[0];
                       HaffumanNumber[0] <= HaffumanNumber1r[0];
                            HuffmanNumber[0] <= HuffmanNumber1r[0];
                       HaffumanTable[1]  <= HaffumanTable1r[1];
                            HuffmanTable[1]  <= HuffmanTable1r[1];
                       HaffumanNumber[1] <= HaffumanNumber1r[1];
                            HuffmanNumber[1] <= HuffmanNumber1r[1];
                       HaffumanTable[2]  <= HaffumanTable1r[2];
                            HuffmanTable[2]  <= HuffmanTable1r[2];
                       HaffumanNumber[2] <= HaffumanNumber1r[2];
                            HuffmanNumber[2] <= HuffmanNumber1r[2];
                       HaffumanTable[3]  <= HaffumanTable1r[3];
                            HuffmanTable[3]  <= HuffmanTable1r[3];
                       HaffumanNumber[3] <= HaffumanNumber1r[3];
                            HuffmanNumber[3] <= HuffmanNumber1r[3];
                       HaffumanTable[4]  <= HaffumanTable1r[4];
                            HuffmanTable[4]  <= HuffmanTable1r[4];
                       HaffumanNumber[4] <= HaffumanNumber1r[4];
                            HuffmanNumber[4] <= HuffmanNumber1r[4];
                       HaffumanTable[5]  <= HaffumanTable1r[5];
                            HuffmanTable[5]  <= HuffmanTable1r[5];
                       HaffumanNumber[5] <= HaffumanNumber1r[5];
                            HuffmanNumber[5] <= HuffmanNumber1r[5];
                       HaffumanTable[6]  <= HaffumanTable1r[6];
                            HuffmanTable[6]  <= HuffmanTable1r[6];
                       HaffumanNumber[6] <= HaffumanNumber1r[6];
                            HuffmanNumber[6] <= HuffmanNumber1r[6];
                       HaffumanTable[7]  <= HaffumanTable1r[7];
                            HuffmanTable[7]  <= HuffmanTable1r[7];
                       HaffumanNumber[7] <= HaffumanNumber1r[7];
                            HuffmanNumber[7] <= HuffmanNumber1r[7];
                       HaffumanTable[8]  <= HaffumanTable1r[8];
                            HuffmanTable[8]  <= HuffmanTable1r[8];
                       HaffumanNumber[8] <= HaffumanNumber1r[8];
                            HuffmanNumber[8] <= HuffmanNumber1r[8];
                       HaffumanTable[9]  <= HaffumanTable1r[9];
                            HuffmanTable[9]  <= HuffmanTable1r[9];
                       HaffumanNumber[9] <= HaffumanNumber1r[9];
                            HuffmanNumber[9] <= HuffmanNumber1r[9];
                       HaffumanTable[10]  <= HaffumanTable1r[10];
                            HuffmanTable[10]  <= HuffmanTable1r[10];
                       HaffumanNumber[10] <= HaffumanNumber1r[10];
                            HuffmanNumber[10] <= HuffmanNumber1r[10];
                       HaffumanTable[11]  <= HaffumanTable1r[11];
                            HuffmanTable[11]  <= HuffmanTable1r[11];
                       HaffumanNumber[11] <= HaffumanNumber1r[11];
                            HuffmanNumber[11] <= HuffmanNumber1r[11];
                       HaffumanTable[12]  <= HaffumanTable1r[12];
                            HuffmanTable[12]  <= HuffmanTable1r[12];
                       HaffumanNumber[12] <= HaffumanNumber1r[12];
                            HuffmanNumber[12] <= HuffmanNumber1r[12];
                       HaffumanTable[13]  <= HaffumanTable1r[13];
                            HuffmanTable[13]  <= HuffmanTable1r[13];
                       HaffumanNumber[13] <= HaffumanNumber1r[13];
                            HuffmanNumber[13] <= HuffmanNumber1r[13];
                       HaffumanTable[14]  <= HaffumanTable1r[14];
                            HuffmanTable[14]  <= HuffmanTable1r[14];
                       HaffumanNumber[14] <= HaffumanNumber1r[14];
                            HuffmanNumber[14] <= HuffmanNumber1r[14];
                       HaffumanTable[15]  <= HaffumanTable1r[15];
                            HuffmanTable[15]  <= HuffmanTable1r[15];
                       HaffumanNumber[15] <= HaffumanNumber1r[15];
                            HuffmanNumber[15] <= HuffmanNumber1r[15];
                 end // else: !if(ProcessCount == 0)
                        end
              end else begin // if (ProcessColor[2] == 1'b0)
                    end else begin
                 if(ProcessCount == 0) begin
                 if(ProcessCount == 0) begin
                       HaffumanTable[0]  <= HaffumanTable2r[0];
                            HuffmanTable[0]  <= HuffmanTable2r[0];
                       HaffumanNumber[0] <= HaffumanNumber2r[0];
                            HuffmanNumber[0] <= HuffmanNumber2r[0];
                       HaffumanTable[1]  <= HaffumanTable2r[1];
                            HuffmanTable[1]  <= HuffmanTable2r[1];
                       HaffumanNumber[1] <= HaffumanNumber2r[1];
                            HuffmanNumber[1] <= HuffmanNumber2r[1];
                       HaffumanTable[2]  <= HaffumanTable2r[2];
                            HuffmanTable[2]  <= HuffmanTable2r[2];
                       HaffumanNumber[2] <= HaffumanNumber2r[2];
                            HuffmanNumber[2] <= HuffmanNumber2r[2];
                       HaffumanTable[3]  <= HaffumanTable2r[3];
                            HuffmanTable[3]  <= HuffmanTable2r[3];
                       HaffumanNumber[3] <= HaffumanNumber2r[3];
                            HuffmanNumber[3] <= HuffmanNumber2r[3];
                       HaffumanTable[4]  <= HaffumanTable2r[4];
                            HuffmanTable[4]  <= HuffmanTable2r[4];
                       HaffumanNumber[4] <= HaffumanNumber2r[4];
                            HuffmanNumber[4] <= HuffmanNumber2r[4];
                       HaffumanTable[5]  <= HaffumanTable2r[5];
                            HuffmanTable[5]  <= HuffmanTable2r[5];
                       HaffumanNumber[5] <= HaffumanNumber2r[5];
                            HuffmanNumber[5] <= HuffmanNumber2r[5];
                       HaffumanTable[6]  <= HaffumanTable2r[6];
                            HuffmanTable[6]  <= HuffmanTable2r[6];
                       HaffumanNumber[6] <= HaffumanNumber2r[6];
                            HuffmanNumber[6] <= HuffmanNumber2r[6];
                       HaffumanTable[7]  <= HaffumanTable2r[7];
                            HuffmanTable[7]  <= HuffmanTable2r[7];
                       HaffumanNumber[7] <= HaffumanNumber2r[7];
                            HuffmanNumber[7] <= HuffmanNumber2r[7];
                       HaffumanTable[8]  <= HaffumanTable2r[8];
                            HuffmanTable[8]  <= HuffmanTable2r[8];
                       HaffumanNumber[8] <= HaffumanNumber2r[8];
                            HuffmanNumber[8] <= HuffmanNumber2r[8];
                       HaffumanTable[9]  <= HaffumanTable2r[9];
                            HuffmanTable[9]  <= HuffmanTable2r[9];
                       HaffumanNumber[9] <= HaffumanNumber2r[9];
                            HuffmanNumber[9] <= HuffmanNumber2r[9];
                       HaffumanTable[10]  <= HaffumanTable2r[10];
                            HuffmanTable[10]  <= HuffmanTable2r[10];
                       HaffumanNumber[10] <= HaffumanNumber2r[10];
                            HuffmanNumber[10] <= HuffmanNumber2r[10];
                       HaffumanTable[11]  <= HaffumanTable2r[11];
                            HuffmanTable[11]  <= HuffmanTable2r[11];
                       HaffumanNumber[11] <= HaffumanNumber2r[11];
                            HuffmanNumber[11] <= HuffmanNumber2r[11];
                       HaffumanTable[12]  <= HaffumanTable2r[12];
                            HuffmanTable[12]  <= HuffmanTable2r[12];
                       HaffumanNumber[12] <= HaffumanNumber2r[12];
                            HuffmanNumber[12] <= HuffmanNumber2r[12];
                       HaffumanTable[13]  <= HaffumanTable2r[13];
                            HuffmanTable[13]  <= HuffmanTable2r[13];
                       HaffumanNumber[13] <= HaffumanNumber2r[13];
                            HuffmanNumber[13] <= HuffmanNumber2r[13];
                       HaffumanTable[14]  <= HaffumanTable2r[14];
                            HuffmanTable[14]  <= HuffmanTable2r[14];
                       HaffumanNumber[14] <= HaffumanNumber2r[14];
                            HuffmanNumber[14] <= HuffmanNumber2r[14];
                       HaffumanTable[15]  <= HaffumanTable2r[15];
                            HuffmanTable[15]  <= HuffmanTable2r[15];
                       HaffumanNumber[15] <= HaffumanNumber2r[15];
                            HuffmanNumber[15] <= HuffmanNumber2r[15];
                 end else begin
                        end else begin
                       HaffumanTable[0]  <= HaffumanTable3r[0];
                            HuffmanTable[0]  <= HuffmanTable3r[0];
                       HaffumanNumber[0] <= HaffumanNumber3r[0];
                            HuffmanNumber[0] <= HuffmanNumber3r[0];
                       HaffumanTable[1]  <= HaffumanTable3r[1];
                            HuffmanTable[1]  <= HuffmanTable3r[1];
                       HaffumanNumber[1] <= HaffumanNumber3r[1];
                            HuffmanNumber[1] <= HuffmanNumber3r[1];
                       HaffumanTable[2]  <= HaffumanTable3r[2];
                            HuffmanTable[2]  <= HuffmanTable3r[2];
                       HaffumanNumber[2] <= HaffumanNumber3r[2];
                            HuffmanNumber[2] <= HuffmanNumber3r[2];
                       HaffumanTable[3]  <= HaffumanTable3r[3];
                            HuffmanTable[3]  <= HuffmanTable3r[3];
                       HaffumanNumber[3] <= HaffumanNumber3r[3];
                            HuffmanNumber[3] <= HuffmanNumber3r[3];
                       HaffumanTable[4]  <= HaffumanTable3r[4];
                            HuffmanTable[4]  <= HuffmanTable3r[4];
                       HaffumanNumber[4] <= HaffumanNumber3r[4];
                            HuffmanNumber[4] <= HuffmanNumber3r[4];
                       HaffumanTable[5]  <= HaffumanTable3r[5];
                            HuffmanTable[5]  <= HuffmanTable3r[5];
                       HaffumanNumber[5] <= HaffumanNumber3r[5];
                            HuffmanNumber[5] <= HuffmanNumber3r[5];
                       HaffumanTable[6]  <= HaffumanTable3r[6];
                            HuffmanTable[6]  <= HuffmanTable3r[6];
                       HaffumanNumber[6] <= HaffumanNumber3r[6];
                            HuffmanNumber[6] <= HuffmanNumber3r[6];
                       HaffumanTable[7]  <= HaffumanTable3r[7];
                            HuffmanTable[7]  <= HuffmanTable3r[7];
                       HaffumanNumber[7] <= HaffumanNumber3r[7];
                            HuffmanNumber[7] <= HuffmanNumber3r[7];
                       HaffumanTable[8]  <= HaffumanTable3r[8];
                            HuffmanTable[8]  <= HuffmanTable3r[8];
                       HaffumanNumber[8] <= HaffumanNumber3r[8];
                            HuffmanNumber[8] <= HuffmanNumber3r[8];
                       HaffumanTable[9]  <= HaffumanTable3r[9];
                            HuffmanTable[9]  <= HuffmanTable3r[9];
                       HaffumanNumber[9] <= HaffumanNumber3r[9];
                            HuffmanNumber[9] <= HuffmanNumber3r[9];
                       HaffumanTable[10]  <= HaffumanTable3r[10];
                            HuffmanTable[10]  <= HuffmanTable3r[10];
                       HaffumanNumber[10] <= HaffumanNumber3r[10];
                            HuffmanNumber[10] <= HuffmanNumber3r[10];
                       HaffumanTable[11]  <= HaffumanTable3r[11];
                            HuffmanTable[11]  <= HuffmanTable3r[11];
                       HaffumanNumber[11] <= HaffumanNumber3r[11];
                            HuffmanNumber[11] <= HuffmanNumber3r[11];
                       HaffumanTable[12]  <= HaffumanTable3r[12];
                            HuffmanTable[12]  <= HuffmanTable3r[12];
                       HaffumanNumber[12] <= HaffumanNumber3r[12];
                            HuffmanNumber[12] <= HuffmanNumber3r[12];
                       HaffumanTable[13]  <= HaffumanTable3r[13];
                            HuffmanTable[13]  <= HuffmanTable3r[13];
                       HaffumanNumber[13] <= HaffumanNumber3r[13];
                            HuffmanNumber[13] <= HuffmanNumber3r[13];
                       HaffumanTable[14]  <= HaffumanTable3r[14];
                            HuffmanTable[14]  <= HuffmanTable3r[14];
                       HaffumanNumber[14] <= HaffumanNumber3r[14];
                            HuffmanNumber[14] <= HuffmanNumber3r[14];
                       HaffumanTable[15]  <= HaffumanTable3r[15];
                            HuffmanTable[15]  <= HuffmanTable3r[15];
                       HaffumanNumber[15] <= HaffumanNumber3r[15];
                            HuffmanNumber[15] <= HuffmanNumber3r[15];
                 end // else: !if(ProcessCount == 0)
                        end
              end // else: !if(ProcessColor[2] == 1'b0)
                    end
           end // case: Phase1
                end
           // compare table
           // compare table
           Phase2: begin
           Phase2: begin
              Process    <= Phase4;
              Process    <= Phase4;
                                if(ProcessData[31:16] >= HaffumanTable[0])       Place[0] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[0])   Place[0] <= 1'b1;
                                else                                                                                            Place[0] <= 1'b0;
                                else                                                                                            Place[0] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[1])      Place[1] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[1])   Place[1] <= 1'b1;
                                else                                                                                            Place[1] <= 1'b0;
                                else                                                                                            Place[1] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[2])      Place[2] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[2])   Place[2] <= 1'b1;
                                else                                                                                            Place[2] <= 1'b0;
                                else                                                                                            Place[2] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[3])      Place[3] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[3])   Place[3] <= 1'b1;
                                else                                                                                            Place[3] <= 1'b0;
                                else                                                                                            Place[3] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[4])      Place[4] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[4])   Place[4] <= 1'b1;
                                else                                                                                            Place[4] <= 1'b0;
                                else                                                                                            Place[4] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[5])      Place[5] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[5])   Place[5] <= 1'b1;
                                else                                                                                            Place[5] <= 1'b0;
                                else                                                                                            Place[5] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[6])      Place[6] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[6])   Place[6] <= 1'b1;
                                else                                                                                            Place[6] <= 1'b0;
                                else                                                                                            Place[6] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[7])      Place[7] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[7])   Place[7] <= 1'b1;
                                else                                                                                            Place[7] <= 1'b0;
                                else                                                                                            Place[7] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[8])      Place[8] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[8])   Place[8] <= 1'b1;
                                else                                                                                            Place[8] <= 1'b0;
                                else                                                                                            Place[8] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[9])      Place[9] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[9])   Place[9] <= 1'b1;
                                else                                                                                            Place[9] <= 1'b0;
                                else                                                                                            Place[9] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[10])     Place[10] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[10])  Place[10] <= 1'b1;
                                else                                                                                            Place[10] <= 1'b0;
                                else                                                                                            Place[10] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[11])     Place[11] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[11])  Place[11] <= 1'b1;
                                else                                                                                            Place[11] <= 1'b0;
                                else                                                                                            Place[11] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[12])     Place[12] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[12])  Place[12] <= 1'b1;
                                else                                                                                            Place[12] <= 1'b0;
                                else                                                                                            Place[12] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[13])     Place[13] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[13])  Place[13] <= 1'b1;
                                else                                                                                            Place[13] <= 1'b0;
                                else                                                                                            Place[13] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[14])     Place[14] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[14])  Place[14] <= 1'b1;
                                else                                                                                            Place[14] <= 1'b0;
                                else                                                                                            Place[14] <= 1'b0;
                                if(ProcessData[31:16] >= HaffumanTable[15])     Place[15] <= 1'b1;
                    if(ProcessData[31:16] >= HuffmanTable[15])  Place[15] <= 1'b1;
                                else                                                                                            Place[15] <= 1'b0;
                                else                                                                                            Place[15] <= 1'b0;
           end
           end
           // shift code
           // shift code
           Phase4: begin
           Phase4: begin
              Process <= Phase6;
                    Process <= Phase5;
              case (Place)
              case (Place)
                16'b0000000000000001: begin
                16'b0000000000000001: begin
                   TableCode   <= {15'h0000,HaffumanTable[0][15]};
                            TableCode   <= {15'h0000,HuffmanTable[0][15]};
                   NumberCode  <= HaffumanNumber[0];
                            NumberCode  <= HuffmanNumber[0];
                   CodeNumber  <= 4'h0;
                   CodeNumber  <= 4'h0;
                   DataNumber  <= {15'h0000,ProcessData[31]};
                   DataNumber  <= {15'h0000,ProcessData[31]};
                   ProcessData <= {ProcessData[30:0],1'b0};
                   ProcessData <= {ProcessData[30:0],1'b0};
                end
                end
                16'b0000000000000011: begin
                16'b0000000000000011: begin
                   TableCode   <= {14'h0000,HaffumanTable[1][15:14]};
                            TableCode   <= {14'h0000,HuffmanTable[1][15:14]};
                   NumberCode  <= HaffumanNumber[1];
                            NumberCode  <= HuffmanNumber[1];
                   CodeNumber  <= 4'h1;
                   CodeNumber  <= 4'h1;
                   DataNumber  <= {14'h0000,ProcessData[31:30]};
                   DataNumber  <= {14'h0000,ProcessData[31:30]};
                   ProcessData <= {ProcessData[29:0],2'b00};
                   ProcessData <= {ProcessData[29:0],2'b00};
                end
                end
                16'b0000000000000111: begin
                16'b0000000000000111: begin
                   TableCode   <= {13'h0000,HaffumanTable[2][15:13]};
                            TableCode   <= {13'h0000,HuffmanTable[2][15:13]};
                   NumberCode  <= HaffumanNumber[2];
                            NumberCode  <= HuffmanNumber[2];
                   CodeNumber  <= 4'h2;
                   CodeNumber  <= 4'h2;
                   DataNumber  <= {13'h0000,ProcessData[31:29]};
                   DataNumber  <= {13'h0000,ProcessData[31:29]};
                   ProcessData <= {ProcessData[28:0],3'b000};
                   ProcessData <= {ProcessData[28:0],3'b000};
                end
                end
                16'b0000000000001111: begin
                16'b0000000000001111: begin
                   TableCode   <= {12'h000,HaffumanTable[3][15:12]};
                            TableCode   <= {12'h000,HuffmanTable[3][15:12]};
                   NumberCode  <= HaffumanNumber[3];
                            NumberCode  <= HuffmanNumber[3];
                   CodeNumber  <= 4'h3;
                   CodeNumber  <= 4'h3;
                   DataNumber  <= {12'h000,ProcessData[31:28]};
                   DataNumber  <= {12'h000,ProcessData[31:28]};
                   ProcessData <= {ProcessData[27:0],4'h0};
                   ProcessData <= {ProcessData[27:0],4'h0};
                end
                end
                16'b0000000000011111: begin
                16'b0000000000011111: begin
                   TableCode   <= {11'h000,HaffumanTable[4][15:11]};
                            TableCode   <= {11'h000,HuffmanTable[4][15:11]};
                   NumberCode  <= HaffumanNumber[4];
                            NumberCode  <= HuffmanNumber[4];
                   CodeNumber  <= 4'h4;
                   CodeNumber  <= 4'h4;
                   DataNumber  <= {11'h000,ProcessData[31:27]};
                   DataNumber  <= {11'h000,ProcessData[31:27]};
                   ProcessData <= {ProcessData[26:0],5'h00};
                   ProcessData <= {ProcessData[26:0],5'h00};
                end
                end
                16'b0000000000111111: begin
                16'b0000000000111111: begin
                   TableCode   <= {10'h000,HaffumanTable[5][15:10]};
                            TableCode   <= {10'h000,HuffmanTable[5][15:10]};
                   NumberCode  <= HaffumanNumber[5];
                            NumberCode  <= HuffmanNumber[5];
                   CodeNumber  <= 4'h5;
                   CodeNumber  <= 4'h5;
                   DataNumber  <= {10'h000,ProcessData[31:26]};
                   DataNumber  <= {10'h000,ProcessData[31:26]};
                   ProcessData <= {ProcessData[25:0],6'h00};
                   ProcessData <= {ProcessData[25:0],6'h00};
                end
                end
                16'b0000000001111111: begin
                16'b0000000001111111: begin
                   TableCode   <= {9'h000,HaffumanTable[6][15:9]};
                            TableCode   <= {9'h000,HuffmanTable[6][15:9]};
                   NumberCode  <= HaffumanNumber[6];
                            NumberCode  <= HuffmanNumber[6];
                   CodeNumber  <= 4'h6;
                   CodeNumber  <= 4'h6;
                   DataNumber  <= {9'h000,ProcessData[31:25]};
                   DataNumber  <= {9'h000,ProcessData[31:25]};
                   ProcessData <= {ProcessData[24:0],7'h00};
                   ProcessData <= {ProcessData[24:0],7'h00};
                end
                end
                16'b0000000011111111: begin
                16'b0000000011111111: begin
                   TableCode   <= {8'h00,HaffumanTable[7][15:8]};
                            TableCode   <= {8'h00,HuffmanTable[7][15:8]};
                   NumberCode  <= HaffumanNumber[7];
                            NumberCode  <= HuffmanNumber[7];
                   CodeNumber  <= 4'h7;
                   CodeNumber  <= 4'h7;
                   DataNumber  <= {8'h00,ProcessData[31:24]};
                   DataNumber  <= {8'h00,ProcessData[31:24]};
                   ProcessData <= {ProcessData[23:0],8'h00};
                   ProcessData <= {ProcessData[23:0],8'h00};
                end
                end
                16'b0000000111111111: begin
                16'b0000000111111111: begin
                   TableCode   <= {7'h00,HaffumanTable[8][15:7]};
                            TableCode   <= {7'h00,HuffmanTable[8][15:7]};
                   NumberCode  <= HaffumanNumber[8];
                            NumberCode  <= HuffmanNumber[8];
                   CodeNumber  <= 4'h8;
                   CodeNumber  <= 4'h8;
                   DataNumber  <= {7'h00,ProcessData[31:23]};
                   DataNumber  <= {7'h00,ProcessData[31:23]};
                   ProcessData <= {ProcessData[22:0],9'h000};
                   ProcessData <= {ProcessData[22:0],9'h000};
                end
                end
                16'b0000001111111111: begin
                16'b0000001111111111: begin
                   TableCode   <= {6'h00,HaffumanTable[9][15:6]};
                            TableCode   <= {6'h00,HuffmanTable[9][15:6]};
                   NumberCode  <= HaffumanNumber[9];
                            NumberCode  <= HuffmanNumber[9];
                   CodeNumber  <= 4'h9;
                   CodeNumber  <= 4'h9;
                   DataNumber  <= {6'h00,ProcessData[31:22]};
                   DataNumber  <= {6'h00,ProcessData[31:22]};
                   ProcessData <= {ProcessData[21:0],10'h000};
                   ProcessData <= {ProcessData[21:0],10'h000};
                end
                end
                16'b0000011111111111: begin
                16'b0000011111111111: begin
                   TableCode   <= {5'h00,HaffumanTable[10][15:5]};
                            TableCode   <= {5'h00,HuffmanTable[10][15:5]};
                   NumberCode  <= HaffumanNumber[10];
                            NumberCode  <= HuffmanNumber[10];
                   CodeNumber  <= 4'hA;
                   CodeNumber  <= 4'hA;
                   DataNumber  <= {5'h00,ProcessData[31:21]};
                   DataNumber  <= {5'h00,ProcessData[31:21]};
                   ProcessData <= {ProcessData[20:0],11'h000};
                   ProcessData <= {ProcessData[20:0],11'h000};
                end
                end
                16'b0000111111111111: begin
                16'b0000111111111111: begin
                   TableCode   <= {4'h0,HaffumanTable[11][15:4]};
                            TableCode   <= {4'h0,HuffmanTable[11][15:4]};
                   NumberCode  <= HaffumanNumber[11];
                            NumberCode  <= HuffmanNumber[11];
                   CodeNumber  <= 4'hB;
                   CodeNumber  <= 4'hB;
                   DataNumber  <= {4'h0,ProcessData[31:20]};
                   DataNumber  <= {4'h0,ProcessData[31:20]};
                   ProcessData <= {ProcessData[19:0],12'h000};
                   ProcessData <= {ProcessData[19:0],12'h000};
                end
                end
                16'b0001111111111111: begin
                16'b0001111111111111: begin
                   TableCode   <= {3'h0,HaffumanTable[12][15:3]};
                            TableCode   <= {3'h0,HuffmanTable[12][15:3]};
                   NumberCode  <= HaffumanNumber[12];
                            NumberCode  <= HuffmanNumber[12];
                   CodeNumber  <= 4'hC;
                   CodeNumber  <= 4'hC;
                   DataNumber  <= {3'h0,ProcessData[31:19]};
                   DataNumber  <= {3'h0,ProcessData[31:19]};
                   ProcessData <= {ProcessData[18:0],13'h0000};
                   ProcessData <= {ProcessData[18:0],13'h0000};
                end
                end
                16'b0011111111111111: begin
                16'b0011111111111111: begin
                   TableCode   <= {2'h0,HaffumanTable[13][15:2]};
                            TableCode   <= {2'h0,HuffmanTable[13][15:2]};
                   NumberCode  <= HaffumanNumber[13];
                            NumberCode  <= HuffmanNumber[13];
                   CodeNumber  <= 4'hD;
                   CodeNumber  <= 4'hD;
                   DataNumber  <= {2'h0,ProcessData[31:18]};
                   DataNumber  <= {2'h0,ProcessData[31:18]};
                   ProcessData <= {ProcessData[17:0],14'h0000};
                   ProcessData <= {ProcessData[17:0],14'h0000};
                end
                end
                16'b0111111111111111: begin
                16'b0111111111111111: begin
                   TableCode   <= {1'h0,HaffumanTable[14][15:1]};
                            TableCode   <= {1'h0,HuffmanTable[14][15:1]};
                   NumberCode  <= HaffumanNumber[14];
                            NumberCode  <= HuffmanNumber[14];
                   CodeNumber  <= 4'hE;
                   CodeNumber  <= 4'hE;
                   DataNumber  <= {1'h0,ProcessData[31:17]};
                   DataNumber  <= {1'h0,ProcessData[31:17]};
                   ProcessData <= {ProcessData[16:0],15'h0000};
                   ProcessData <= {ProcessData[16:0],15'h0000};
                end
                end
                16'b1111111111111111: begin
                16'b1111111111111111: begin
                   TableCode   <= HaffumanTable[15];
                            TableCode   <= HuffmanTable[15];
                   NumberCode  <= HaffumanNumber[15];
                            NumberCode  <= HuffmanNumber[15];
                   CodeNumber  <= 4'hF;
                   CodeNumber  <= 4'hF;
                   DataNumber  <= ProcessData[31:16] ;
                   DataNumber  <= ProcessData[31:16] ;
                   ProcessData <= {ProcessData[15:0],16'h0000};
                   ProcessData <= {ProcessData[15:0],16'h0000};
                end
                end
              endcase // case(Place)
                    endcase
           end // case: Phase4
                end
           Phase5: begin
           Phase5: begin
              Process <= Phase6;
                    if(DataOutIdle == 1'b1) Process <= Phase6;
              //SubData <= DataNumber - TableCode;
 
              //OutDhtNumber <= DataNumber - TableCode + NumberCode;
 
           end
           end
           Phase6: begin
           Phase6: begin
              if(DataOutIdle == 1'b1) Process   <= Phase7;
                    Process     <= Phase7;
              //DhtNumber <= SubData[7:0] + NumberCode;
 
           end
 
           Phase7: begin
 
              Process          <= Phase9;
 
              OutZero          <= DhtZero;
              OutZero          <= DhtZero;
              UseWidth         <= CodeNumber   + DhtWidth +1;
                    UseWidth    <= CodeNumber + DhtWidth +5'd1;
              if(ProcessCount == 0) begin
              if(ProcessCount == 0) begin
                 NextProcessCount <= 7'd1;
 
                 OutEnable        <= 1'b1;
                 OutEnable        <= 1'b1;
              end else begin
              end else begin
                 if(DhtZero == 4'h0 & DhtWidth == 4'h0) begin
                 if(DhtZero == 4'h0 & DhtWidth == 4'h0) begin
                    ProcessCount     <= 7'd64;
                            ProcessCount    <= 6'd63;
                    NextProcessCount <= 7'd64;
 
                    OutEnable        <= 1'b0;
                    OutEnable        <= 1'b0;
                 end else if(DhtZero == 4'hF & DhtWidth == 4'h0) begin
                 end else if(DhtZero == 4'hF & DhtWidth == 4'h0) begin
                    ProcessCount     <= ProcessCount + 4'hF;
                            ProcessCount    <= ProcessCount + 6'd15;
                    NextProcessCount <= ProcessCount + 4'hF;
 
                    OutEnable        <= 1'b0;
                    OutEnable        <= 1'b0;
                 end else begin
                 end else begin
                    ProcessCount     <= ProcessCount + DhtZero;
                    ProcessCount     <= ProcessCount + DhtZero;
                    NextProcessCount <= ProcessCount + DhtZero +1;
 
                    OutEnable        <= 1'b1;
                    OutEnable        <= 1'b1;
                 end
                 end
              end // else: !if(ProcessCount == 0)
                    end
 
 
              if(ProcessData[31] == 1'b0 & DhtWidth != 0) begin
              if(ProcessData[31] == 1'b0 & DhtWidth != 0) begin
                 OutCode <= (OutCodeP | SubCode) + 16'h0001;
                 OutCode <= (OutCodeP | SubCode) + 16'h0001;
              end else begin
              end else begin
                 OutCode <= OutCodeP;
                 OutCode <= OutCodeP;
              end
              end
           end // case: Phase7
 
           Phase8: begin
 
              Process <= Phase9;
 
           end
           end
           Phase9: begin
                Phase7: begin
              Process <= Phase11;
                    Process <= Phase8;
              if(ProcessCount == 0) begin
              if(ProcessCount == 0) begin
                 if(ProcessColor[2] == 1'b0) begin
                 if(ProcessColor[2] == 1'b0) begin
                    OutCode    <= OutCode + PreData[0];
                            OutCode     <= OutCode + PreData[0][15:0];
                    PreData[0] <= OutCode + PreData[0];
                    PreData[0] <= OutCode + PreData[0];
                 end else begin
                 end else begin
                    if(ProcessColor[0] == 1'b0) begin
                    if(ProcessColor[0] == 1'b0) begin
                       OutCode    <= OutCode + PreData[1];
                                OutCode     <= OutCode + PreData[1][15:0];
                       PreData[1] <= OutCode + PreData[1];
                       PreData[1] <= OutCode + PreData[1];
                    end else begin
                    end else begin
                       OutCode    <= OutCode + PreData[2];
                                OutCode     <= OutCode + PreData[2][15:0];
                       PreData[2] <= OutCode + PreData[2];
                       PreData[2] <= OutCode + PreData[2];
                    end
                    end
                 end // else: !if(ProcessColor[2] == 1'b0)
 
              end // if (ProcessCount == 0)
 
           end // case: Phase9
 
           Phase10: begin
 
              Process   <= Phase11;
 
              //OutData   <= DqtData * OutCode;
 
           end
           end
           Phase11: begin
                    end
 
                end
 
                Phase8: begin
              OutEnable <= 1'b0;
              OutEnable <= 1'b0;
              if(NextProcessCount <64) begin
                    if(ProcessCount <6'd63) begin
                 Process      <= Phase1;
                 Process      <= Phase1;
                 ProcessCount <= NextProcessCount;
                        ProcessCount    <= ProcessCount +6'd1;
              end else begin
              end else begin
                 ProcessCount  <= 7'd0;
                        ProcessCount  <= 6'd0;
                 DataOutEnable <= 1'b1;
//                      DataOutEnable <= 1'b1;
                 DataOutColor  <= ProcessColor;
                 DataOutColor  <= ProcessColor;
                 if(ProcessColor == 5) begin
                 if(ProcessColor == 5) begin
                    ProcessColor <= 3'b000;
                    ProcessColor <= 3'b000;
                    if(DataInRun == 1'b0) Process <= ProcIdle;
                            Process         <= Phase1;
                    else Process <= Phase1;
 
                 end else begin
                 end else begin
                    Process <= Phase1;
                    Process <= Phase1;
                    ProcessColor <= ProcessColor +1;
                            ProcessColor    <= ProcessColor +3'd1;
 
                        end
 
                    end
 
                end
 
            endcase
 
        end
                 end
                 end
              end // else: !if(NextProcessCount <64)
 
           end // case: Phase11
 
         endcase // case(Process)
 
      end // else: !if(!rst)
 
   end // always @ (posedge clk or negedge rst)
 
 
 
   assign DhtColor[1]    = ProcessColor[2];
   assign DhtColor[1]    = ProcessColor[2];
   assign DhtColor[0]    = ProcessCount != 0;
    assign DhtColor[0]      = ProcessCount != 6'd0;
   //assign DhtNumber      = OutDhtNumber[7:0];
 
   assign DhtNumber      = DataNumber - TableCode + NumberCode;
   assign DhtNumber      = DataNumber - TableCode + NumberCode;
 
 
   assign DqtColor       = ProcessColor[2];
   assign DqtColor       = ProcessColor[2];
   assign DqtNumber      = ProcessCount[5:0];
   assign DqtNumber      = ProcessCount[5:0];
 
 
   //assign DecodeUseBit   = Process == Phase8;
    assign DecodeUseBit     = Process == Phase7;
   assign DecodeUseBit   = Process == Phase9;
 
   assign DecodeUseWidth = UseWidth;
   assign DecodeUseWidth = UseWidth;
 
 
   assign DecodeEnable   = OutEnable == 1'b1 & Process == Phase11;
    assign DecodeEnable     = OutEnable == 1'b1 & Process == Phase8;
   assign DecodeColor    = ProcessColor;
   assign DecodeColor    = ProcessColor;
   assign DecodeCount    = ProcessCount[5:0];
   assign DecodeCount    = ProcessCount[5:0];
   assign DecodeZero     = OutZero;
   assign DecodeZero     = OutZero;
   //assign DecodeCode     = OutData[15:0];
 
   assign DecodeCode     = DqtData * OutCode;
   assign DecodeCode     = DqtData * OutCode;
 
 
endmodule // jpeg_hm_decode
    assign DataOutEnable    = (Process == Phase8) & (ProcessCount == 6'd63);
 
 
 
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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