cmprs_tile_mode_decode.v 7.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*!
 * <b>Module:</b>cmprs_tile_mode_decode
 * @file cmprs_tile_mode_decode.v
 * @date 2015-06-14  
 * @author Andrey Filippov     
 *
 * @brief Decode tile/macroblocks parameters from compressor type
 *
 * @copyright Copyright (c) 2015 Elphel, Inc.
 *
 * <b>License:</b>
12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * cmprs_tile_mode_decode.v is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  cmprs_tile_mode_decode.v is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/> .
25 26 27 28 29 30
 *
 * Additional permission under GNU GPL version 3 section 7:
 * If you modify this Program, or any covered work, by linking or combining it
 * with independent modules provided by the FPGA vendor only (this permission
 * does not extend to any 3-rd party modules, "soft cores" or macros) under
 * different license terms solely for the purpose of generating binary "bitstream"
31
 * files and/or simulating the code, the copyright holders of this Program give
32 33
 * you the right to distribute the covered work without those independent modules
 * as long as the source code for them is available from the FPGA vendor free of
Andrey Filippov's avatar
Andrey Filippov committed
34
 * charge, and there is no dependence on any encrypted modules for simulating of
35 36 37
 * the combined code. This permission applies to you if the distributed code
 * contains all the components and scripts required to completely simulate it
 * with at least one of the Free Software programs.
38
 */
39 40 41 42 43 44 45 46 47 48 49
`timescale 1ns/1ps

module  cmprs_tile_mode_decode #(
        parameter CMPRS_COLOR18 =           0, // JPEG 4:2:0 with 18x18 overlapping tiles for de-bayer
        parameter CMPRS_COLOR20 =           1, // JPEG 4:2:0 with 18x18 overlapping tiles for de-bayer (not implemented)
        parameter CMPRS_MONO16 =            2, // JPEG 4:2:0 with 16x16 non-overlapping tiles, color components zeroed
        parameter CMPRS_JP4 =               3, // JP4 mode with 16x16 macroblocks
        parameter CMPRS_JP4DIFF =           4, // JP4DIFF mode TODO: see if correct
        parameter CMPRS_MONO8 =             7  // Regular JPEG monochrome with 8x8 macroblocks (not yet implemented)
)(
    input          [2:0] converter_type,
50 51 52
    output reg    [ 5:0] mb_w_m1,            // macroblock width minus 1
    output reg    [ 5:0] mb_h_m1,            // macroblock height minus 1
    output reg    [ 4:0] mb_hper,            // macroblock horizontal period (8/16) // 3 LSB not used
53 54 55 56 57 58 59 60
    output reg    [ 1:0] tile_width,         // memory tile width (can be 128 for monochrome JPEG)   Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
    output reg           tile_col_width      // 0 - 16 pixels,  1 -32 pixels
);

//    wire   [ 2:0] converter_type;    // 0 - color18, 1 - color20, 2 - mono, 3 - jp4, 4 - jp4-diff, 7 - mono8 (not yet implemented)
    always @(converter_type) begin
        case (converter_type)
            CMPRS_COLOR18:    begin
61 62 63
                        mb_w_m1 <=        17;            // macroblock width minus 1 
                        mb_h_m1 <=        17;            // macroblock height minus 1
                        mb_hper <=        16;            // macroblock horizontal period (8/16) // 3 LSB not used
64 65 66 67
                        tile_width <=      1;            // memory tile width (can be 128 for monochrome JPEG)   Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
                        tile_col_width <=  1;            // 0 - 16 pixels,  1 -32 pixels
                     end
            CMPRS_COLOR20:    begin
68 69 70
                        mb_w_m1 <=        19;            // macroblock width minus 1
                        mb_h_m1 <=        19;            // macroblock height minus 1
                        mb_hper <=        16;            // macroblock horizontal period (8/16) // 3 LSB not used
71 72 73 74
                        tile_width <=      1;            // memory tile width (can be 128 for monochrome JPEG)   Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
                        tile_col_width <=  1;            // 0 - 16 pixels,  1 -32 pixels
                     end
            CMPRS_MONO16:    begin
75 76 77
                        mb_w_m1 <=        15;            // macroblock width minus 1
                        mb_h_m1 <=        15;            // macroblock height minus 1
                        mb_hper <=        16;            // macroblock horizontal period (8/16) // 3 LSB not used
78 79 80 81
                        tile_width <=      2;            // memory tile width (can be 128 for monochrome JPEG)   Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
                        tile_col_width <=  1;            // 0 - 16 pixels,  1 -32 pixels
                     end
            CMPRS_JP4:    begin
82 83 84
                        mb_w_m1 <=        15;            // macroblock width minus 1
                        mb_h_m1 <=        15;            // macroblock height minus 1
                        mb_hper <=        16;            // macroblock horizontal period (8/16) // 3 LSB not used
85 86 87 88
                        tile_width <=      2;            // memory tile width (can be 128 for monochrome JPEG)   Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
                        tile_col_width <=  1;            // 0 - 16 pixels,  1 -32 pixels
                     end
            CMPRS_JP4DIFF:    begin
89 90 91
                        mb_w_m1 <=        15;            // macroblock width minus 1
                        mb_h_m1 <=        15;            // macroblock height minus 1
                        mb_hper <=        16;            // macroblock horizontal period (8/16) // 3 LSB not used
92 93 94 95
                        tile_width <=      2;            // memory tile width (can be 128 for monochrome JPEG)   Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
                        tile_col_width <=  1;            // 0 - 16 pixels,  1 -32 pixels
                     end
            CMPRS_MONO8:    begin
96 97 98
                        mb_w_m1 <=         7;            // macroblock width minus 1
                        mb_h_m1 <=         7;            // macroblock height minus 1
                        mb_hper <=         8;            // macroblock horizontal period (8/16) // 3 LSB not used
99 100 101 102
                        tile_width <=      3;            // memory tile width (can be 128 for monochrome JPEG)   Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
                        tile_col_width <=  1;            // 0 - 16 pixels,  1 -32 pixels
                     end
            default: begin
103 104 105
                        mb_w_m1 <=        'bx;            // macroblock width minus 1
                        mb_h_m1 <=        'bx;            // macroblock height minus 1
                        mb_hper <=        'bx;            // macroblock horizontal period (8/16) // 3 LSB not used
106 107 108 109 110 111 112 113
                        tile_width <=     'bx;            // memory tile width (can be 128 for monochrome JPEG)   Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
                        tile_col_width <= 'bx;            // 0 - 16 pixels,  1 -32 pixels
                     end
        endcase
    end

endmodule