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

Subversion Repositories djpeg

[/] [djpeg/] [trunk/] [src/] [jpeg_regdata.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_regdata.v
// File Name    : jpeg_regdata.v
// Module Name  : jpeg_regdata
// Module Name  : jpeg_regdata
// Description  : get Data
// Description  : Get 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                 : 2007/04/11
// Date         : 2008/02/27
// Rev.                 : 1.03
// Rev.         : 2.00
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 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 Remove a RegEnd register.
// 1.02 2006/10/04 Remove a RegEnd register.
//                                        When reset, clear on OutEnable,PreEnable,DataOut registers.
//                                        When reset, clear on OutEnable,PreEnable,DataOut registers.
//                                        Remove some comments.
//                                        Remove some comments.
// 1.03 2007/04/11 Don't OutEnable, ImageEnable == 1 and DataOut == 0xFFD9XXXX
// 1.03 2007/04/11 Don't OutEnable, ImageEnable == 1 and DataOut == 0xFFD9XXXX
//                 Stop ReadEnable with DataEnd(after 0xFFD9 of ImageData)
//                 Stop ReadEnable with DataEnd(after 0xFFD9 of ImageData)
//---------------------------------------------------------------------------
// 1.04 2007/10/16 Modify (RegData[31:0] == 0xFF00FF00) process
// $Id: 
//                        not convert 0xFF00 -> 0xFF after convert [7:0] == 0xFF
 
// 2.00 2008/02/27 Modify RegValid, when ImageEnable == 1 then RegWidth > 64
 
//                                  when ImageEnable == 0 then RegWidth > 32
 
//                 Add    SliceData Pattern
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
`timescale 1ps / 1ps
`timescale 1ps / 1ps
 
 
module jpeg_regdata(
module jpeg_regdata(
        rst,
        rst,
Line 65... Line 68...
        input                   UseByte;
        input                   UseByte;
        input                   UseWord;
        input                   UseWord;
 
 
        wire                    RegValid;
        wire                    RegValid;
        reg [95:0]              RegData;
        reg [95:0]              RegData;
        reg [7:0]               RegWidth;
    reg [6:0]       RegWidth;
 
    reg             CheckMode;
        reg                             DataEnd;
        reg                             DataEnd;
 
 
        assign                  RegValid        = RegWidth > 64;
    assign RegValid     = (ImageEnable)?(RegWidth > 7'd64):(RegWidth > 7'd32);
        assign                  DataInRead      = RegValid == 1'b0 & DataInEnable == 1'b1;
    assign DataInRead   = ((RegValid == 1'b0) & (DataInEnable == 1'b1) & (DataEnd == 1'b0));
 
 
        always @(posedge clk or negedge rst) begin
        always @(posedge clk or negedge rst) begin
                if(!rst) begin
                if(!rst) begin
                        RegData  <= 96'd0;
                        RegData  <= 96'd0;
                        RegWidth <= 8'h00;
            RegWidth  <= 7'd0;
 
            CheckMode <= 1'b0;
                end else begin
                end else begin
                        if(RegValid == 1'b0 & (DataInEnable == 1'b1 | DataEnd == 1'b1)) begin
            if(DataEnd == 1'b1 & ProcessIdle == 1'b1) begin
 
                RegData   <= 96'd0;
 
                RegWidth  <= 7'd0;
 
                CheckMode <= 1'b0;
 
            end else if(RegValid == 1'b0 & (DataInEnable == 1'b1 | DataEnd == 1'b1)) begin
                                if(ImageEnable == 1'b1) begin
                                if(ImageEnable == 1'b1) begin
                                        if(RegData[39: 8] == 32'hFF00FF00) begin
                    if(RegData[39: 8] == 32'hFF00FF00 & CheckMode != 1'b1) begin
                                                RegWidth                <= RegWidth + 16;
                        RegWidth        <= RegWidth + 7'd16;
                                                RegData[95:64]  <= {8'h00,RegData[71:48]};
                                                RegData[95:64]  <= {8'h00,RegData[71:48]};
                                                RegData[63:32]  <= {RegData[47:40],16'hFFFF,RegData[7:0]};
                                                RegData[63:32]  <= {RegData[47:40],16'hFFFF,RegData[7:0]};
                                        end else if(RegData[39:24] == 16'hFF00 &
                        CheckMode       <= 1'b0;
                                                RegData[15: 0] == 16'hFF00) begin
                    end else if(RegData[39:24] == 16'hFF00 & RegData[15: 0] == 16'hFF00 & CheckMode != 1'b1) begin
                                                RegWidth                <= RegWidth + 16;
                        RegWidth        <= RegWidth + 7'd16;
                                                RegData[95:64]  <= {8'h00,RegData[71:48]};
                                                RegData[95:64]  <= {8'h00,RegData[71:48]};
                                                RegData[63:32]  <= {RegData[47:40],8'hFF,RegData[23:16],8'hFF};
                                                RegData[63:32]  <= {RegData[47:40],8'hFF,RegData[23:16],8'hFF};
 
                        CheckMode       <= 1'b1;
                                        end else if(RegData[31: 0] == 32'hFF00FF00) begin
                                        end else if(RegData[31: 0] == 32'hFF00FF00) begin
                                                RegWidth                <= RegWidth + 16;
                        RegWidth        <= RegWidth + 7'd16;
                                                RegData[95:64]  <= {16'h0000,RegData[71:56]};
                        RegData[95:64]  <= {16'h0000,RegData[63:48]};
                                                RegData[63:32]  <= {RegData[55:40],16'hFFFF};
                        RegData[63:32]  <= {RegData[47:32],16'hFFFF};
                                        end else if(RegData[39:24] == 16'hFF00) begin
                        CheckMode       <= 1'b1;
                                                RegWidth                <= RegWidth + 24;
                    end else if(RegData[39:24] == 16'hFF00 & CheckMode != 1'b1) begin
 
                        RegWidth        <= RegWidth + 7'd24;
                                                RegData[95:64]  <= {RegData[71:40]};
                                                RegData[95:64]  <= {RegData[71:40]};
                                                RegData[63:32]  <= {8'hFF,RegData[23:0]};
                                                RegData[63:32]  <= {8'hFF,RegData[23:0]};
 
                        CheckMode       <= 1'b0;
                                        end else if(RegData[31:16] == 16'hFF00) begin
                                        end else if(RegData[31:16] == 16'hFF00) begin
                                                RegWidth                <= RegWidth + 24;
                        RegWidth        <= RegWidth + 7'd24;
                                                RegData[95:64]  <= {RegData[71:40]};
                                                RegData[95:64]  <= {RegData[71:40]};
                                                RegData[63:32]  <= {RegData[39:32],8'hFF,RegData[15:0]};
                                                RegData[63:32]  <= {RegData[39:32],8'hFF,RegData[15:0]};
 
                        CheckMode       <= 1'b0;
                                        end else if(RegData[23: 8] == 16'hFF00) begin
                                        end else if(RegData[23: 8] == 16'hFF00) begin
                                                RegWidth                <= RegWidth + 24;
                        RegWidth        <= RegWidth + 7'd24;
                                                RegData[95:64]  <= {RegData[71:40]};
                                                RegData[95:64]  <= {RegData[71:40]};
                                                RegData[63:32]  <= {RegData[39:32],RegData[31:24],8'hFF,RegData[7:0]};
                                                RegData[63:32]  <= {RegData[39:32],RegData[31:24],8'hFF,RegData[7:0]};
 
                        CheckMode       <= 1'b0;
                                        end else if(RegData[15: 0] == 16'hFF00) begin
                                        end else if(RegData[15: 0] == 16'hFF00) begin
                                                RegWidth                <= RegWidth + 24;
                        RegWidth        <= RegWidth + 7'd24;
                                                RegData[95:64]  <= {RegData[71:40]};
                                                RegData[95:64]  <= {RegData[71:40]};
                                                RegData[63:32]  <= {RegData[39:32],RegData[31:16],8'hFF};
                                                RegData[63:32]  <= {RegData[39:32],RegData[31:16],8'hFF};
 
                        CheckMode       <= 1'b1;
                                        end else begin
                                        end else begin
                                                RegWidth                <= RegWidth + 32;
                        RegWidth        <= RegWidth + 7'd32;
                                                RegData[95:64]  <= RegData[63:32];
                                                RegData[95:64]  <= RegData[63:32];
                                                RegData[63:32]  <= RegData[31:0];
                                                RegData[63:32]  <= RegData[31:0];
 
                        CheckMode       <= 1'b0;
                                        end
                                        end
                                end else begin
                                end else begin
                                        RegWidth                <= RegWidth + 32;
                    RegWidth        <= RegWidth + 7'd32;
                                        RegData[95:64]  <= RegData[63:32];
                                        RegData[95:64]  <= RegData[63:32];
                                        RegData[63:32]  <= RegData[31:0];
                                        RegData[63:32]  <= RegData[31:0];
 
                    CheckMode       <= 1'b0;
                                end
                                end
                                RegData[31: 0] <= {DataIn[7:0],DataIn[15:8],DataIn[23:16],DataIn[31:24]};
                                RegData[31: 0] <= {DataIn[7:0],DataIn[15:8],DataIn[23:16],DataIn[31:24]};
                        end else if(UseBit == 1'b1) begin
                        end else if(UseBit == 1'b1) begin
                                RegWidth <= RegWidth - UseWidth;
                                RegWidth <= RegWidth - UseWidth;
                        end else if(UseByte == 1'b1) begin
                        end else if(UseByte == 1'b1) begin
                                RegWidth <= RegWidth - 8;
                RegWidth <= RegWidth - 7'd8;
                        end else if(UseWord == 1'b1) begin
                        end else if(UseWord == 1'b1) begin
                                RegWidth <= RegWidth - 16;
                RegWidth <= RegWidth - 7'd16;
                        end
                        end
                end
                end
        end
        end
 
 
 
    // PickUp with End of Jpeg Data
        always @(posedge clk or negedge rst) begin
        always @(posedge clk or negedge rst) begin
                if(!rst) begin
                if(!rst) begin
                        DataEnd <= 1'b0;
                        DataEnd <= 1'b0;
                end else begin
                end else begin
                        if(ProcessIdle) begin
                        if(ProcessIdle) begin
                                DataEnd <= 1'b0;
                                DataEnd <= 1'b0;
                        end else if(ImageEnable == 1'b1 & (RegData[39:24] == 16'hFFD9 | RegData[31:16] == 16'hFFD9 | RegData[23: 8] == 16'hFFD9 | RegData[15: 0] == 16'hFFD9)) begin
            end else if(ImageEnable == 1'b1 & ((RegData[39:24] == 16'hFFD9 & CheckMode != 1'b1) | RegData[31:16] == 16'hFFD9 | RegData[23: 8] == 16'hFFD9 | RegData[15: 0] == 16'hFFD9)) begin
                                DataEnd <= 1'b1;
                                DataEnd <= 1'b1;
                        end
                        end
                end
                end
        end
        end
 
 
        function [31:0] SliceData;
        function [31:0] SliceData;
                input [95:0] RegData;
                input [95:0] RegData;
                input [7:0]  RegWidth;
                input [7:0]  RegWidth;
 
 
                case(RegWidth)
                case(RegWidth)
 
            //8'd33: SliceData = RegData[32: 1];
 
            //8'd34: SliceData = RegData[33: 2];
 
            //8'd35: SliceData = RegData[34: 3];
 
            //8'd36: SliceData = RegData[35: 4];
 
            //8'd37: SliceData = RegData[36: 5];
 
            //8'd38: SliceData = RegData[37: 6];
 
            //8'd39: SliceData = RegData[38: 7];
 
            8'd40: SliceData = RegData[39: 8];
 
            //8'd41: SliceData = RegData[40: 9];
 
            //8'd42: SliceData = RegData[41:10];
 
            //8'd43: SliceData = RegData[42:11];
 
            //8'd44: SliceData = RegData[43:12];
 
            //8'd45: SliceData = RegData[44:13];
 
            //8'd46: SliceData = RegData[45:14];
 
            //8'd47: SliceData = RegData[46:15];
 
            8'd48: SliceData = RegData[47:16];
 
            //8'd49: SliceData = RegData[48:17];
 
            //8'd50: SliceData = RegData[49:18];
 
            //8'd51: SliceData = RegData[50:19];
 
            //8'd52: SliceData = RegData[51:20];
 
            //8'd53: SliceData = RegData[52:21];
 
            //8'd54: SliceData = RegData[53:22];
 
            //8'd55: SliceData = RegData[54:23];
 
            8'd56: SliceData = RegData[55:24];
 
            //8'd57: SliceData = RegData[56:25];
 
            //8'd58: SliceData = RegData[57:26];
 
            //8'd59: SliceData = RegData[58:27];
 
            //8'd60: SliceData = RegData[59:28];
 
            //8'd61: SliceData = RegData[60:29];
 
            //8'd62: SliceData = RegData[61:30];
 
            //8'd63: SliceData = RegData[62:31];
 
            8'd64: SliceData = RegData[63:32];
                        8'd65: SliceData = RegData[64:33];
                        8'd65: SliceData = RegData[64:33];
                        8'd66: SliceData = RegData[65:34];
                        8'd66: SliceData = RegData[65:34];
                        8'd67: SliceData = RegData[66:35];
                        8'd67: SliceData = RegData[66:35];
                        8'd68: SliceData = RegData[67:36];
                        8'd68: SliceData = RegData[67:36];
                        8'd69: SliceData = RegData[68:37];
                        8'd69: SliceData = RegData[68:37];
Line 184... Line 233...
                endcase
                endcase
        endfunction
        endfunction
 
 
        reg                     OutEnable;
        reg                     OutEnable;
        reg                     PreEnable;
        reg                     PreEnable;
 
 
        reg [31:0]              DataOut;
        reg [31:0]              DataOut;
 
 
        always @(posedge clk or negedge rst) begin
        always @(posedge clk or negedge rst) begin
                if(!rst) begin
                if(!rst) begin
                        OutEnable       <= 1'b0;
                        OutEnable       <= 1'b0;
                        PreEnable       <= 1'b0;
                        PreEnable       <= 1'b0;
                        DataOut         <= 32'h00000000;
                        DataOut         <= 32'h00000000;
                end else begin
                end else begin
                        OutEnable       <= RegWidth >64;
            if(DataEnd == 1'b1 & ProcessIdle == 1'b1) begin
 
                OutEnable   <= 1'b0;
 
                PreEnable   <= 1'b0;
 
                DataOut     <= 32'h00000000;
 
            end else begin
 
                OutEnable   <= RegValid;
                        PreEnable       <= (UseBit == 1'b1 | UseByte == 1'b1 | UseWord == 1'b1);
                        PreEnable       <= (UseBit == 1'b1 | UseByte == 1'b1 | UseWord == 1'b1);
                        DataOut         <= SliceData(RegData,RegWidth);
                        DataOut         <= SliceData(RegData,RegWidth);
                end
                end
        end
        end
 
    end
 
 
        assign DataOutEnable = (PreEnable == 1'b0)?OutEnable:1'b0;
        assign DataOutEnable = (PreEnable == 1'b0)?OutEnable:1'b0;
 
 
endmodule
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.