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

Subversion Repositories nova

[/] [nova/] [tags/] [Start/] [src/] [NumCoeffTrailingOnes_decoding.v] - Diff between revs 3 and 11

Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 11
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Design    : nova
// Design    : nova
// Author(s) : Ke Xu
// Author(s) : Ke Xu
// Email           : eexuke@yahoo.com
// Email           : eexuke@yahoo.com
// File      : NumCoeffTrailingOnes_decoding.v
// File      : NumCoeffTrailingOnes_decoding.v
// Generated : June 8, 2005
// Generated : June 8, 2005
// Copyright (C) 2008 Ke Xu                
// Copyright (C) 2008 Ke Xu                
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// Description 
// Description 
// Decoding for Table 9-5 on Page159 of H.264/AVC standard 2003
// Decoding for Table 9-5 on Page159 of H.264/AVC standard 2003
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
 
 
// synopsys translate_off
// synopsys translate_off
`include "timescale.v"
`include "timescale.v"
// synopsys translate_on
// synopsys translate_on
`include "nova_defines.v"
`include "nova_defines.v"
 
 
module NumCoeffTrailingOnes_decoding (clk,reset_n,cavlc_decoder_state,heading_one_pos,BitStream_buffer_output,
module NumCoeffTrailingOnes_decoding (clk,reset_n,cavlc_decoder_state,heading_one_pos,BitStream_buffer_output,
        nC,TrailingOnes,TotalCoeff,NumCoeffTrailingOnes_len);
        nC,TrailingOnes,TotalCoeff,NumCoeffTrailingOnes_len);
        input clk,reset_n;
        input clk,reset_n;
        input [3:0] cavlc_decoder_state;
        input [3:0] cavlc_decoder_state;
        input [3:0] heading_one_pos;
        input [3:0] heading_one_pos;
        input [15:0] BitStream_buffer_output;
        input [15:0] BitStream_buffer_output;
        input [4:0] nC;
        input [4:0] nC;
        output [1:0] TrailingOnes;
        output [1:0] TrailingOnes;
        output [4:0] TotalCoeff;
        output [4:0] TotalCoeff;
        output [4:0] NumCoeffTrailingOnes_len;
        output [4:0] NumCoeffTrailingOnes_len;
        reg [1:0] TrailingOnes;
        reg [1:0] TrailingOnes;
        reg [4:0] TotalCoeff;
        reg [4:0] TotalCoeff;
        reg [4:0] NumCoeffTrailingOnes_len;
        reg [4:0] NumCoeffTrailingOnes_len;
 
 
        reg [1:0] TrailingOnes_reg;
        reg [1:0] TrailingOnes_reg;
        reg [4:0] TotalCoeff_reg;
        reg [4:0] TotalCoeff_reg;
 
 
        wire nC_0to2,nC_2to4,nC_4to8,nC_n1,nC_GE8;
        wire nC_0to2,nC_2to4,nC_4to8,nC_n1,nC_GE8;
        wire nC_0to2_t0,nC_0to2_t1,nC_0to2_t2,nC_0to2_t3;
        wire nC_0to2_t0,nC_0to2_t1,nC_0to2_t2,nC_0to2_t3;
        wire nC_2to4_t0,nC_2to4_t1,nC_2to4_t2,nC_2to4_t3;
        wire nC_2to4_t0,nC_2to4_t1,nC_2to4_t2,nC_2to4_t3;
        wire nC_4to8_t0,nC_4to8_t1;
        wire nC_4to8_t0,nC_4to8_t1;
        wire nC_n1_t0;
        wire nC_n1_t0;
        //Select nC values to choose table
        //Select nC values to choose table
        assign nC_0to2 = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && (nC == 5'd0 || nC == 5'd1));
        assign nC_0to2 = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && (nC == 5'd0 || nC == 5'd1));
        assign nC_2to4 = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && (nC == 5'd2 || nC == 5'd3));
        assign nC_2to4 = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && (nC == 5'd2 || nC == 5'd3));
        assign nC_4to8 = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && (nC == 5'd4 || nC == 5'd5 || nC == 5'd6 || nC == 5'd7));
        assign nC_4to8 = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && (nC == 5'd4 || nC == 5'd5 || nC == 5'd6 || nC == 5'd7));
        assign nC_n1   = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && (nC == 5'd31));
        assign nC_n1   = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && (nC == 5'd31));
        assign nC_GE8  = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && !nC_0to2 && !nC_2to4 && !nC_4to8 && !nC_n1);
        assign nC_GE8  = (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT && !nC_0to2 && !nC_2to4 && !nC_4to8 && !nC_n1);
 
 
        //1.nC_0to2 t0 ~ t4     sub-table selection
        //1.nC_0to2 t0 ~ t4     sub-table selection
        assign nC_0to2_t0 = (nC_0to2 && (heading_one_pos == 4'd0 || heading_one_pos == 4'd1 || heading_one_pos == 4'd2));
        assign nC_0to2_t0 = (nC_0to2 && (heading_one_pos == 4'd0 || heading_one_pos == 4'd1 || heading_one_pos == 4'd2));
        assign nC_0to2_t1 = (nC_0to2 && (heading_one_pos == 4'd3 || heading_one_pos == 4'd4));
        assign nC_0to2_t1 = (nC_0to2 && (heading_one_pos == 4'd3 || heading_one_pos == 4'd4));
        assign nC_0to2_t2 = (nC_0to2 && (heading_one_pos == 4'd5 || heading_one_pos == 4'd6 || heading_one_pos == 4'd7 || heading_one_pos == 4'd8));
        assign nC_0to2_t2 = (nC_0to2 && (heading_one_pos == 4'd5 || heading_one_pos == 4'd6 || heading_one_pos == 4'd7 || heading_one_pos == 4'd8));
        assign nC_0to2_t3 = (nC_0to2 && (heading_one_pos == 4'd9 || heading_one_pos == 4'd10));
        assign nC_0to2_t3 = (nC_0to2 && (heading_one_pos == 4'd9 || heading_one_pos == 4'd10));
        //2.nC_2to4 t0 ~ t4     sub-table selection
        //2.nC_2to4 t0 ~ t4     sub-table selection
        assign nC_2to4_t0 = (nC_2to4 && (heading_one_pos == 4'd0 || heading_one_pos == 4'd1));
        assign nC_2to4_t0 = (nC_2to4 && (heading_one_pos == 4'd0 || heading_one_pos == 4'd1));
        assign nC_2to4_t1 = (nC_2to4 && (heading_one_pos == 4'd2 || heading_one_pos == 4'd3));
        assign nC_2to4_t1 = (nC_2to4 && (heading_one_pos == 4'd2 || heading_one_pos == 4'd3));
        assign nC_2to4_t2 = (nC_2to4 && (heading_one_pos == 4'd4 || heading_one_pos == 4'd5 || heading_one_pos == 4'd6));
        assign nC_2to4_t2 = (nC_2to4 && (heading_one_pos == 4'd4 || heading_one_pos == 4'd5 || heading_one_pos == 4'd6));
        assign nC_2to4_t3 = (nC_2to4 && (heading_one_pos == 4'd7 || heading_one_pos == 4'd8));
        assign nC_2to4_t3 = (nC_2to4 && (heading_one_pos == 4'd7 || heading_one_pos == 4'd8));
        //3.nC_4to8 t0 ~ t2     sub-table selection 
        //3.nC_4to8 t0 ~ t2     sub-table selection 
        assign nC_4to8_t0 = (nC_4to8 && heading_one_pos == 4'd0);
        assign nC_4to8_t0 = (nC_4to8 && heading_one_pos == 4'd0);
        assign nC_4to8_t1 = (nC_4to8 && (heading_one_pos == 4'd1 || heading_one_pos == 4'd2 || heading_one_pos == 4'd3 || heading_one_pos == 4'd4));
        assign nC_4to8_t1 = (nC_4to8 && (heading_one_pos == 4'd1 || heading_one_pos == 4'd2 || heading_one_pos == 4'd3 || heading_one_pos == 4'd4));
        //4.nC_GE8:single table, NO sub-table selection
        //4.nC_GE8:single table, NO sub-table selection
        //5.nC_n1 t0 ~ t1 sub-table selection
        //5.nC_n1 t0 ~ t1 sub-table selection
        assign nC_n1_t0 = (nC_n1 && (heading_one_pos == 4'd0 || heading_one_pos == 4'd1 || heading_one_pos == 4'd2));
        assign nC_n1_t0 = (nC_n1 && (heading_one_pos == 4'd0 || heading_one_pos == 4'd1 || heading_one_pos == 4'd2));
 
 
        //NumCoeffTrailingOnes_len
        //NumCoeffTrailingOnes_len
        always @ (nC_0to2 or nC_2to4 or nC_4to8 or nC_GE8 or nC_n1 or heading_one_pos or BitStream_buffer_output)
        always @ (nC_0to2 or nC_2to4 or nC_4to8 or nC_GE8 or nC_n1 or heading_one_pos or BitStream_buffer_output)
                if (nC_0to2)
                if (nC_0to2)
                        case (heading_one_pos)
                        case (heading_one_pos)
                                0 :NumCoeffTrailingOnes_len <= 5'd1;
                                0 :NumCoeffTrailingOnes_len <= 5'd1;
                                1 :NumCoeffTrailingOnes_len <= 5'd2;
                                1 :NumCoeffTrailingOnes_len <= 5'd2;
                                2 :NumCoeffTrailingOnes_len <= 5'd3;
                                2 :NumCoeffTrailingOnes_len <= 5'd3;
                                3 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[11] == 1)? 5'd5:5'd6;
                                3 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[11] == 1)? 5'd5:5'd6;
                                4 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[10] == 1)? 5'd6:5'd7;
                                4 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[10] == 1)? 5'd6:5'd7;
                                5 :NumCoeffTrailingOnes_len <= 5'd8;
                                5 :NumCoeffTrailingOnes_len <= 5'd8;
                                6 :NumCoeffTrailingOnes_len <= 5'd9;
                                6 :NumCoeffTrailingOnes_len <= 5'd9;
                                7 :NumCoeffTrailingOnes_len <= 5'd10;
                                7 :NumCoeffTrailingOnes_len <= 5'd10;
                                8 :NumCoeffTrailingOnes_len <= 5'd11;
                                8 :NumCoeffTrailingOnes_len <= 5'd11;
                                9 :NumCoeffTrailingOnes_len <= 5'd13;
                                9 :NumCoeffTrailingOnes_len <= 5'd13;
                                10:NumCoeffTrailingOnes_len <= 5'd14;
                                10:NumCoeffTrailingOnes_len <= 5'd14;
                                11:NumCoeffTrailingOnes_len <= 5'd15;
                                11:NumCoeffTrailingOnes_len <= 5'd15;
                                12:NumCoeffTrailingOnes_len <= 5'd16;
                                12:NumCoeffTrailingOnes_len <= 5'd16;
                                13:NumCoeffTrailingOnes_len <= 5'd16;
                                13:NumCoeffTrailingOnes_len <= 5'd16;
                                14:NumCoeffTrailingOnes_len <= 5'd15;
                                14:NumCoeffTrailingOnes_len <= 5'd15;
                                default:NumCoeffTrailingOnes_len <= 5'd0;
                                default:NumCoeffTrailingOnes_len <= 5'd0;
                        endcase
                        endcase
                else if (nC_2to4)
                else if (nC_2to4)
                        case (heading_one_pos)
                        case (heading_one_pos)
                                0 :NumCoeffTrailingOnes_len <= 5'd2;
                                0 :NumCoeffTrailingOnes_len <= 5'd2;
                                1 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[13] == 1)? 5'd3:5'd4;
                                1 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[13] == 1)? 5'd3:5'd4;
                                2 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[12] == 1)? 5'd5:5'd6;
                                2 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[12] == 1)? 5'd5:5'd6;
                                3 :NumCoeffTrailingOnes_len <= 5'd6;
                                3 :NumCoeffTrailingOnes_len <= 5'd6;
                                4 :NumCoeffTrailingOnes_len <= 5'd7;
                                4 :NumCoeffTrailingOnes_len <= 5'd7;
                                5 :NumCoeffTrailingOnes_len <= 5'd8;
                                5 :NumCoeffTrailingOnes_len <= 5'd8;
                                6 :NumCoeffTrailingOnes_len <= 5'd9;
                                6 :NumCoeffTrailingOnes_len <= 5'd9;
                                7 :NumCoeffTrailingOnes_len <= 5'd11;
                                7 :NumCoeffTrailingOnes_len <= 5'd11;
                                8 :NumCoeffTrailingOnes_len <= 5'd12;
                                8 :NumCoeffTrailingOnes_len <= 5'd12;
                                9 :NumCoeffTrailingOnes_len <= 5'd13;
                                9 :NumCoeffTrailingOnes_len <= 5'd13;
                                10:NumCoeffTrailingOnes_len <= (BitStream_buffer_output[4] == 1)? 5'd13:5'd14;
                                10:NumCoeffTrailingOnes_len <= (BitStream_buffer_output[4] == 1)? 5'd13:5'd14;
                                11:NumCoeffTrailingOnes_len <= 5'd14;
                                11:NumCoeffTrailingOnes_len <= 5'd14;
                                12:NumCoeffTrailingOnes_len <= 5'd13;
                                12:NumCoeffTrailingOnes_len <= 5'd13;
                                default:NumCoeffTrailingOnes_len <= 5'd0;
                                default:NumCoeffTrailingOnes_len <= 5'd0;
                        endcase
                        endcase
                else if (nC_n1)
                else if (nC_n1)
                        case (heading_one_pos)
                        case (heading_one_pos)
                                0:NumCoeffTrailingOnes_len <= 5'd1;
                                0:NumCoeffTrailingOnes_len <= 5'd1;
                                1:NumCoeffTrailingOnes_len <= 5'd2;
                                1:NumCoeffTrailingOnes_len <= 5'd2;
                                2:NumCoeffTrailingOnes_len <= 5'd3;
                                2:NumCoeffTrailingOnes_len <= 5'd3;
                                3:NumCoeffTrailingOnes_len <= 5'd6;
                                3:NumCoeffTrailingOnes_len <= 5'd6;
                                4:NumCoeffTrailingOnes_len <= 5'd6;
                                4:NumCoeffTrailingOnes_len <= 5'd6;
                                5:NumCoeffTrailingOnes_len <= 5'd7;
                                5:NumCoeffTrailingOnes_len <= 5'd7;
                                6:NumCoeffTrailingOnes_len <= 5'd8;
                                6:NumCoeffTrailingOnes_len <= 5'd8;
                                default:NumCoeffTrailingOnes_len <= 5'd7;
                                default:NumCoeffTrailingOnes_len <= 5'd7;
                        endcase
                        endcase
                else if (nC_4to8)
                else if (nC_4to8)
                        case (heading_one_pos)
                        case (heading_one_pos)
                                0 :NumCoeffTrailingOnes_len <= 5'd4;
                                0 :NumCoeffTrailingOnes_len <= 5'd4;
                                1 :NumCoeffTrailingOnes_len <= 5'd5;
                                1 :NumCoeffTrailingOnes_len <= 5'd5;
                                2 :NumCoeffTrailingOnes_len <= 5'd6;
                                2 :NumCoeffTrailingOnes_len <= 5'd6;
                                3 :NumCoeffTrailingOnes_len <= 5'd7;
                                3 :NumCoeffTrailingOnes_len <= 5'd7;
                                4 :NumCoeffTrailingOnes_len <= 5'd8;
                                4 :NumCoeffTrailingOnes_len <= 5'd8;
                                5 :NumCoeffTrailingOnes_len <= 5'd9;
                                5 :NumCoeffTrailingOnes_len <= 5'd9;
                                6 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[8:7] == 2'b11)? 5'd9:5'd10;
                                6 :NumCoeffTrailingOnes_len <= (BitStream_buffer_output[8:7] == 2'b11)? 5'd9:5'd10;
                                7 :NumCoeffTrailingOnes_len <= 5'd10;
                                7 :NumCoeffTrailingOnes_len <= 5'd10;
                                8 :NumCoeffTrailingOnes_len <= 5'd10;
                                8 :NumCoeffTrailingOnes_len <= 5'd10;
                                9 :NumCoeffTrailingOnes_len <= 5'd10;
                                9 :NumCoeffTrailingOnes_len <= 5'd10;
                                10:NumCoeffTrailingOnes_len <= 5'd10;
                                10:NumCoeffTrailingOnes_len <= 5'd10;
                                default:NumCoeffTrailingOnes_len <= 5'd0;
                                default:NumCoeffTrailingOnes_len <= 5'd0;
                        endcase
                        endcase
                else if (nC_GE8)
                else if (nC_GE8)
                        NumCoeffTrailingOnes_len <= 5'd6;
                        NumCoeffTrailingOnes_len <= 5'd6;
                else
                else
                        NumCoeffTrailingOnes_len <= 0;
                        NumCoeffTrailingOnes_len <= 0;
 
 
 
 
        //TrailingOnes
        //TrailingOnes
        always @ (posedge clk)
        always @ (posedge clk)
                if (reset_n == 0)
                if (reset_n == 0)
                        TrailingOnes_reg <= 0;
                        TrailingOnes_reg <= 0;
                else if (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT)
                else if (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT)
                        TrailingOnes_reg <= TrailingOnes;
                        TrailingOnes_reg <= TrailingOnes;
 
 
        always @ (nC_0to2 or nC_2to4 or nC_4to8 or nC_n1 or nC_GE8
        always @ (nC_0to2 or nC_2to4 or nC_4to8 or nC_n1 or nC_GE8
        or nC_0to2_t0 or nC_0to2_t1 or nC_0to2_t2 or nC_0to2_t3
        or nC_0to2_t0 or nC_0to2_t1 or nC_0to2_t2 or nC_0to2_t3
        or nC_2to4_t0 or nC_2to4_t1 or nC_2to4_t2 or nC_2to4_t3
        or nC_2to4_t0 or nC_2to4_t1 or nC_2to4_t2 or nC_2to4_t3
        or nC_4to8_t0 or nC_4to8_t1 or nC_n1_t0
        or nC_4to8_t0 or nC_4to8_t1 or nC_n1_t0
        or TrailingOnes_reg or heading_one_pos or BitStream_buffer_output)
        or TrailingOnes_reg or heading_one_pos or BitStream_buffer_output)
                if (nC_0to2)
                if (nC_0to2)
                        begin
                        begin
                                if (nC_0to2_t0)
                                if (nC_0to2_t0)
                                        TrailingOnes <= heading_one_pos[1:0];
                                        TrailingOnes <= heading_one_pos[1:0];
                                else if (nC_0to2_t1)
                                else if (nC_0to2_t1)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd3 && !BitStream_buffer_output[11])
                                                if (heading_one_pos == 4'd3 && !BitStream_buffer_output[11])
                                                        TrailingOnes <= (BitStream_buffer_output[10])? 2'd0:2'd1;
                                                        TrailingOnes <= (BitStream_buffer_output[10])? 2'd0:2'd1;
                                                else if (heading_one_pos == 4'd4 && BitStream_buffer_output[10:9] == 2'b01)
                                                else if (heading_one_pos == 4'd4 && BitStream_buffer_output[10:9] == 2'b01)
                                                        TrailingOnes <= 2'd2;
                                                        TrailingOnes <= 2'd2;
                                                else
                                                else
                                                        TrailingOnes <= 2'd3;
                                                        TrailingOnes <= 2'd3;
                                        end
                                        end
                                else if (nC_0to2_t2)
                                else if (nC_0to2_t2)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd5)
                                                if (heading_one_pos == 4'd5)
                                                        case (BitStream_buffer_output[9:8])
                                                        case (BitStream_buffer_output[9:8])
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd6)
                                                else if (heading_one_pos == 4'd6)
                                                        case (BitStream_buffer_output[8:7])
                                                        case (BitStream_buffer_output[8:7])
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd7)
                                                else if (heading_one_pos == 4'd7)
                                                        case (BitStream_buffer_output[7:6])
                                                        case (BitStream_buffer_output[7:6])
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[6:5])
                                                        case (BitStream_buffer_output[6:5])
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else if (nC_0to2_t3)
                                else if (nC_0to2_t3)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd9)
                                                if (heading_one_pos == 4'd9)
                                                        case (BitStream_buffer_output[4:3])
                                                        case (BitStream_buffer_output[4:3])
                                                                2'b00:TrailingOnes <= (BitStream_buffer_output[5])? 2'd3:2'd0;
                                                                2'b00:TrailingOnes <= (BitStream_buffer_output[5])? 2'd3:2'd0;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[3:2])
                                                        case (BitStream_buffer_output[3:2])
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else
                                else
                                        begin
                                        begin
                                                if ((heading_one_pos == 4'd11 &&  BitStream_buffer_output[2:1] == 2'b11) ||
                                                if ((heading_one_pos == 4'd11 &&  BitStream_buffer_output[2:1] == 2'b11) ||
                (heading_one_pos == 4'd12 &&  BitStream_buffer_output[1:0] == 2'b11) ||
                (heading_one_pos == 4'd12 &&  BitStream_buffer_output[1:0] == 2'b11) ||
                (heading_one_pos == 4'd13 && (BitStream_buffer_output[1:0] == 2'b00  || BitStream_buffer_output[1:0] == 2'b11)))
                (heading_one_pos == 4'd13 && (BitStream_buffer_output[1:0] == 2'b00  || BitStream_buffer_output[1:0] == 2'b11)))
                                                        TrailingOnes <= 2'd0;
                                                        TrailingOnes <= 2'd0;
                                                else if ((heading_one_pos == 4'd11 && BitStream_buffer_output[2:1] == 2'b10) ||
                                                else if ((heading_one_pos == 4'd11 && BitStream_buffer_output[2:1] == 2'b10) ||
                     (heading_one_pos == 4'd12 && BitStream_buffer_output[1:0] == 2'b10) ||
                     (heading_one_pos == 4'd12 && BitStream_buffer_output[1:0] == 2'b10) ||
                     (heading_one_pos == 4'd13 && BitStream_buffer_output[1:0] == 2'b10) ||
                     (heading_one_pos == 4'd13 && BitStream_buffer_output[1:0] == 2'b10) ||
                      heading_one_pos == 4'd14)
                      heading_one_pos == 4'd14)
                                                        TrailingOnes <= 2'd1;
                                                        TrailingOnes <= 2'd1;
                                                else if ((heading_one_pos == 4'd11 && BitStream_buffer_output[2:1] == 2'b01) ||
                                                else if ((heading_one_pos == 4'd11 && BitStream_buffer_output[2:1] == 2'b01) ||
                     (heading_one_pos == 4'd12 && BitStream_buffer_output[1:0] == 2'b01) ||
                     (heading_one_pos == 4'd12 && BitStream_buffer_output[1:0] == 2'b01) ||
                     (heading_one_pos == 4'd13 && BitStream_buffer_output[1:0] == 2'b01))
                     (heading_one_pos == 4'd13 && BitStream_buffer_output[1:0] == 2'b01))
                                                        TrailingOnes <= 2'd2;
                                                        TrailingOnes <= 2'd2;
                                                else
                                                else
                                                        TrailingOnes <= 2'd3;
                                                        TrailingOnes <= 2'd3;
                                        end
                                        end
                        end
                        end
                else if (nC_2to4)
                else if (nC_2to4)
                        begin
                        begin
                                if (nC_2to4_t0)
                                if (nC_2to4_t0)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd0)
                                                if (heading_one_pos == 4'd0)
                                                        TrailingOnes <= {1'b0,~BitStream_buffer_output[14]};
                                                        TrailingOnes <= {1'b0,~BitStream_buffer_output[14]};
                                                else
                                                else
                                                        TrailingOnes <= (BitStream_buffer_output[13])? 2'd2:2'd3;
                                                        TrailingOnes <= (BitStream_buffer_output[13])? 2'd2:2'd3;
                                        end
                                        end
                                else if (nC_2to4_t1)
                                else if (nC_2to4_t1)
                                        begin
                                        begin
                                                if ((heading_one_pos == 4'd2 && BitStream_buffer_output[12:10] == 3'b011) ||
                                                if ((heading_one_pos == 4'd2 && BitStream_buffer_output[12:10] == 3'b011) ||
                (heading_one_pos == 4'd3 && BitStream_buffer_output[11:10] == 2'b11))
                (heading_one_pos == 4'd3 && BitStream_buffer_output[11:10] == 2'b11))
                                                        TrailingOnes <= 2'd0;
                                                        TrailingOnes <= 2'd0;
                                                else if ((heading_one_pos == 4'd2 && (BitStream_buffer_output[12:11] == 2'b11 || BitStream_buffer_output[12:10] == 3'b010)) ||
                                                else if ((heading_one_pos == 4'd2 && (BitStream_buffer_output[12:11] == 2'b11 || BitStream_buffer_output[12:10] == 3'b010)) ||
                     (heading_one_pos == 4'd3 &&  BitStream_buffer_output[11:10] == 2'b10))
                     (heading_one_pos == 4'd3 &&  BitStream_buffer_output[11:10] == 2'b10))
                                                        TrailingOnes <= 2'd1;
                                                        TrailingOnes <= 2'd1;
                                                else if ((heading_one_pos == 4'd2 && BitStream_buffer_output[12:10] == 3'b001) ||
                                                else if ((heading_one_pos == 4'd2 && BitStream_buffer_output[12:10] == 3'b001) ||
                     (heading_one_pos == 4'd3 && BitStream_buffer_output[11:10] == 2'b01))
                     (heading_one_pos == 4'd3 && BitStream_buffer_output[11:10] == 2'b01))
                                                        TrailingOnes <= 2'd2;
                                                        TrailingOnes <= 2'd2;
                                                else
                                                else
                                                        TrailingOnes <= 2'd3;
                                                        TrailingOnes <= 2'd3;
                                        end
                                        end
                                else if (nC_2to4_t2)
                                else if (nC_2to4_t2)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd4)
                                                if (heading_one_pos == 4'd4)
                                                        case (BitStream_buffer_output[10:9])
                                                        case (BitStream_buffer_output[10:9])
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd5)
                                                else if (heading_one_pos == 4'd5)
                                                        case (BitStream_buffer_output[9:8])
                                                        case (BitStream_buffer_output[9:8])
                                                                2'b00:TrailingOnes <= 2'd0;
                                                                2'b00:TrailingOnes <= 2'd0;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[8:7])
                                                        case (BitStream_buffer_output[8:7])
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b00:TrailingOnes <= 2'd3;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b01:TrailingOnes <= 2'd2;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b10:TrailingOnes <= 2'd1;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                                2'b11:TrailingOnes <= 2'd0;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else if (nC_2to4_t3)
                                else if (nC_2to4_t3)
                                        begin
                                        begin
                                                if ((heading_one_pos == 4'd7 && BitStream_buffer_output[6:5] == 2'b11) ||
                                                if ((heading_one_pos == 4'd7 && BitStream_buffer_output[6:5] == 2'b11) ||
                (heading_one_pos == 4'd8 && (BitStream_buffer_output[5:4] == 2'b11 || BitStream_buffer_output[6:4] == 3'b000)))
                (heading_one_pos == 4'd8 && (BitStream_buffer_output[5:4] == 2'b11 || BitStream_buffer_output[6:4] == 3'b000)))
                                                        TrailingOnes <= 2'd0;
                                                        TrailingOnes <= 2'd0;
                                                else if ((heading_one_pos == 4'd7 && BitStream_buffer_output[6:5] == 2'b10) ||
                                                else if ((heading_one_pos == 4'd7 && BitStream_buffer_output[6:5] == 2'b10) ||
                     (heading_one_pos == 4'd8 && BitStream_buffer_output[5:4] == 2'b10))
                     (heading_one_pos == 4'd8 && BitStream_buffer_output[5:4] == 2'b10))
                                                        TrailingOnes <= 2'd1;
                                                        TrailingOnes <= 2'd1;
                                                else if ((heading_one_pos == 4'd7 && BitStream_buffer_output[6:5] == 2'b01) ||
                                                else if ((heading_one_pos == 4'd7 && BitStream_buffer_output[6:5] == 2'b01) ||
                     (heading_one_pos == 4'd8 && BitStream_buffer_output[5:4] == 2'b01))
                     (heading_one_pos == 4'd8 && BitStream_buffer_output[5:4] == 2'b01))
                                                        TrailingOnes <= 2'd2;
                                                        TrailingOnes <= 2'd2;
                                                else
                                                else
                                                        TrailingOnes <= 2'd3;
                                                        TrailingOnes <= 2'd3;
                                        end
                                        end
                                else
                                else
                                        begin
                                        begin
                                                if ((heading_one_pos == 4'd9  &&  BitStream_buffer_output[4:3] == 2'b11) ||
                                                if ((heading_one_pos == 4'd9  &&  BitStream_buffer_output[4:3] == 2'b11) ||
                (heading_one_pos == 4'd10 && (BitStream_buffer_output[4:3] == 2'b11  || BitStream_buffer_output[4:2] == 3'b001)) ||
                (heading_one_pos == 4'd10 && (BitStream_buffer_output[4:3] == 2'b11  || BitStream_buffer_output[4:2] == 3'b001)) ||
                (heading_one_pos == 4'd11 &&  BitStream_buffer_output[3:2] == 2'b11))
                (heading_one_pos == 4'd11 &&  BitStream_buffer_output[3:2] == 2'b11))
                                                        TrailingOnes <= 2'd0;
                                                        TrailingOnes <= 2'd0;
                                                else if ((heading_one_pos == 4'd9  &&  BitStream_buffer_output[4:3] == 2'b10) ||
                                                else if ((heading_one_pos == 4'd9  &&  BitStream_buffer_output[4:3] == 2'b10) ||
                     (heading_one_pos == 4'd10 && (BitStream_buffer_output[4:2] == 3'b000 || BitStream_buffer_output[4:2] == 3'b011)) ||
                     (heading_one_pos == 4'd10 && (BitStream_buffer_output[4:2] == 3'b000 || BitStream_buffer_output[4:2] == 3'b011)) ||
                     (heading_one_pos == 4'd11 &&  BitStream_buffer_output[3:2] == 2'b10))
                     (heading_one_pos == 4'd11 &&  BitStream_buffer_output[3:2] == 2'b10))
                                                        TrailingOnes <= 2'd1;
                                                        TrailingOnes <= 2'd1;
                                                else if ((heading_one_pos == 4'd9  &&  BitStream_buffer_output[4:3] == 2'b01) ||
                                                else if ((heading_one_pos == 4'd9  &&  BitStream_buffer_output[4:3] == 2'b01) ||
                     (heading_one_pos == 4'd10 && (BitStream_buffer_output[4:3] == 2'b10  || BitStream_buffer_output[4:2] == 3'b010)) ||
                     (heading_one_pos == 4'd10 && (BitStream_buffer_output[4:3] == 2'b10  || BitStream_buffer_output[4:2] == 3'b010)) ||
                     (heading_one_pos == 4'd11 &&  BitStream_buffer_output[3:2] == 2'b01))
                     (heading_one_pos == 4'd11 &&  BitStream_buffer_output[3:2] == 2'b01))
                                                        TrailingOnes <= 2'd2;
                                                        TrailingOnes <= 2'd2;
                                                else
                                                else
                                                        TrailingOnes <= 2'd3;
                                                        TrailingOnes <= 2'd3;
                                        end
                                        end
                        end
                        end
                else if (nC_n1)
                else if (nC_n1)
                        begin
                        begin
                                if (nC_n1_t0)
                                if (nC_n1_t0)
                                        begin
                                        begin
                                                if      (BitStream_buffer_output[15])   TrailingOnes <= 2'd1;
                                                if      (BitStream_buffer_output[15])   TrailingOnes <= 2'd1;
                                                else if (BitStream_buffer_output[14])   TrailingOnes <= 2'd0;
                                                else if (BitStream_buffer_output[14])   TrailingOnes <= 2'd0;
                                                else                                  TrailingOnes <= 2'd2;
                                                else                                  TrailingOnes <= 2'd2;
                                        end
                                        end
                                else
                                else
                                        begin
                                        begin
                                                if ((heading_one_pos == 4'd3 && (BitStream_buffer_output[11:10] == 2'b00 || BitStream_buffer_output[11:10] == 2'b11)) ||
                                                if ((heading_one_pos == 4'd3 && (BitStream_buffer_output[11:10] == 2'b00 || BitStream_buffer_output[11:10] == 2'b11)) ||
                 heading_one_pos == 4'd4)
                 heading_one_pos == 4'd4)
                                                        TrailingOnes <= 2'd0;
                                                        TrailingOnes <= 2'd0;
                                                else if ((heading_one_pos == 4'd3 && BitStream_buffer_output[11:10] == 2'b10) ||
                                                else if ((heading_one_pos == 4'd3 && BitStream_buffer_output[11:10] == 2'b10) ||
                     (heading_one_pos == 4'd5 && BitStream_buffer_output[9]) ||
                     (heading_one_pos == 4'd5 && BitStream_buffer_output[9]) ||
                     (heading_one_pos == 4'd6 && BitStream_buffer_output[8]))
                     (heading_one_pos == 4'd6 && BitStream_buffer_output[8]))
                                                        TrailingOnes <= 2'd1;
                                                        TrailingOnes <= 2'd1;
                                                else if ((heading_one_pos == 4'd5 && !BitStream_buffer_output[9]) ||
                                                else if ((heading_one_pos == 4'd5 && !BitStream_buffer_output[9]) ||
                     (heading_one_pos == 4'd6 && !BitStream_buffer_output[8]))
                     (heading_one_pos == 4'd6 && !BitStream_buffer_output[8]))
                                                        TrailingOnes <= 2'd2;
                                                        TrailingOnes <= 2'd2;
                                                else
                                                else
                                                        TrailingOnes <= 2'd3;
                                                        TrailingOnes <= 2'd3;
                                        end
                                        end
                        end
                        end
                else if (nC_4to8)
                else if (nC_4to8)
                        begin
                        begin
                                if (nC_4to8_t0)
                                if (nC_4to8_t0)
                                        begin
                                        begin
                                                if      (BitStream_buffer_output[14:12] == 3'b111)      TrailingOnes <= 2'd0;
                                                if      (BitStream_buffer_output[14:12] == 3'b111)      TrailingOnes <= 2'd0;
                                                else if (BitStream_buffer_output[14:12] == 3'b110)      TrailingOnes <= 2'd1;
                                                else if (BitStream_buffer_output[14:12] == 3'b110)      TrailingOnes <= 2'd1;
                                                else if (BitStream_buffer_output[14:12] == 3'b101)      TrailingOnes <= 2'd2;
                                                else if (BitStream_buffer_output[14:12] == 3'b101)      TrailingOnes <= 2'd2;
                                                else                                                TrailingOnes <= 2'd3;
                                                else                                                TrailingOnes <= 2'd3;
                                        end
                                        end
                                else if (nC_4to8_t1)
                                else if (nC_4to8_t1)
                                        begin
                                        begin
                                                if ((heading_one_pos == 4'd1 &&
                                                if ((heading_one_pos == 4'd1 &&
                                                        (BitStream_buffer_output[13:11] == 3'b000 || BitStream_buffer_output[13:11] == 3'b010 ||
                                                        (BitStream_buffer_output[13:11] == 3'b000 || BitStream_buffer_output[13:11] == 3'b010 ||
                                                         BitStream_buffer_output[13:11] == 3'b100 || BitStream_buffer_output[13:11] == 3'b111)) ||
                                                         BitStream_buffer_output[13:11] == 3'b100 || BitStream_buffer_output[13:11] == 3'b111)) ||
                                                        (heading_one_pos == 4'd2 && BitStream_buffer_output[11:10] == 2'b10 ) ||
                                                        (heading_one_pos == 4'd2 && BitStream_buffer_output[11:10] == 2'b10 ) ||
                                                        (heading_one_pos == 4'd3 && BitStream_buffer_output[11:9]  == 3'b110) ||
                                                        (heading_one_pos == 4'd3 && BitStream_buffer_output[11:9]  == 3'b110) ||
                                                        (heading_one_pos == 4'd4 && BitStream_buffer_output[9:8]   == 2'b10 ))
                                                        (heading_one_pos == 4'd4 && BitStream_buffer_output[9:8]   == 2'b10 ))
                                                        TrailingOnes <= 2'd1;
                                                        TrailingOnes <= 2'd1;
                                                else if (
                                                else if (
                                                        (heading_one_pos == 4'd1 && (BitStream_buffer_output[13:11] == 3'b001 || BitStream_buffer_output[13:11] == 3'b011 || BitStream_buffer_output[13:11] == 3'b110))||
                                                        (heading_one_pos == 4'd1 && (BitStream_buffer_output[13:11] == 3'b001 || BitStream_buffer_output[13:11] == 3'b011 || BitStream_buffer_output[13:11] == 3'b110))||
                                                        (heading_one_pos == 4'd2 &&  BitStream_buffer_output[11:10] == 2'b01) ||
                                                        (heading_one_pos == 4'd2 &&  BitStream_buffer_output[11:10] == 2'b01) ||
                                                        (heading_one_pos == 4'd3 && (BitStream_buffer_output[11:9]  == 3'b010 || BitStream_buffer_output[11:9]  == 3'b101))||
                                                        (heading_one_pos == 4'd3 && (BitStream_buffer_output[11:9]  == 3'b010 || BitStream_buffer_output[11:9]  == 3'b101))||
                                                        (heading_one_pos == 4'd4 &&  BitStream_buffer_output[9:8]   == 2'b01))
                                                        (heading_one_pos == 4'd4 &&  BitStream_buffer_output[9:8]   == 2'b01))
                                                        TrailingOnes <= 2'd2;
                                                        TrailingOnes <= 2'd2;
                                                else if (
                                                else if (
                                                        (heading_one_pos == 4'd1 && BitStream_buffer_output[13:11] == 3'b101) ||
                                                        (heading_one_pos == 4'd1 && BitStream_buffer_output[13:11] == 3'b101) ||
                                                        (heading_one_pos == 4'd2 && BitStream_buffer_output[12:10] == 3'b100) ||
                                                        (heading_one_pos == 4'd2 && BitStream_buffer_output[12:10] == 3'b100) ||
                                                        (heading_one_pos == 4'd3 && BitStream_buffer_output[11:9]  == 3'b100) ||
                                                        (heading_one_pos == 4'd3 && BitStream_buffer_output[11:9]  == 3'b100) ||
                                                        (heading_one_pos == 4'd4 && BitStream_buffer_output[9:8]   == 2'b00))
                                                        (heading_one_pos == 4'd4 && BitStream_buffer_output[9:8]   == 2'b00))
                                                        TrailingOnes <= 2'd3;
                                                        TrailingOnes <= 2'd3;
                                                else
                                                else
                                                        TrailingOnes <= 2'd0;
                                                        TrailingOnes <= 2'd0;
                                        end
                                        end
                                else
                                else
                                        begin
                                        begin
                                                if ((heading_one_pos == 4'd5 && BitStream_buffer_output[8:7] == 2'b10) ||
                                                if ((heading_one_pos == 4'd5 && BitStream_buffer_output[8:7] == 2'b10) ||
                (heading_one_pos == 4'd6 && (BitStream_buffer_output[8:7] == 2'b11 || BitStream_buffer_output[7:6] == 2'b00)) ||
                (heading_one_pos == 4'd6 && (BitStream_buffer_output[8:7] == 2'b11 || BitStream_buffer_output[7:6] == 2'b00)) ||
                (heading_one_pos == 4'd7 && BitStream_buffer_output[7:6] == 2'b00))
                (heading_one_pos == 4'd7 && BitStream_buffer_output[7:6] == 2'b00))
                                                        TrailingOnes <= 2'd1;
                                                        TrailingOnes <= 2'd1;
                                                else if (
                                                else if (
                                                        (heading_one_pos == 4'd5 && BitStream_buffer_output[8:7] == 2'b01)  ||
                                                        (heading_one_pos == 4'd5 && BitStream_buffer_output[8:7] == 2'b01)  ||
                                                        (heading_one_pos == 4'd6 && BitStream_buffer_output[8:6] == 3'b011) ||
                                                        (heading_one_pos == 4'd6 && BitStream_buffer_output[8:6] == 3'b011) ||
                                                        (heading_one_pos == 4'd7 && BitStream_buffer_output[7:6] == 2'b11)  ||
                                                        (heading_one_pos == 4'd7 && BitStream_buffer_output[7:6] == 2'b11)  ||
                                                        (heading_one_pos == 4'd8 && BitStream_buffer_output[6]))
                                                        (heading_one_pos == 4'd8 && BitStream_buffer_output[6]))
                                                        TrailingOnes <= 2'd2;
                                                        TrailingOnes <= 2'd2;
                                                else if (
                                                else if (
                                                        (heading_one_pos == 4'd5 &&  BitStream_buffer_output[9:7] == 3'b100)  ||
                                                        (heading_one_pos == 4'd5 &&  BitStream_buffer_output[9:7] == 3'b100)  ||
                                                        (heading_one_pos == 4'd6 &&  BitStream_buffer_output[8:6] == 3'b010) ||
                                                        (heading_one_pos == 4'd6 &&  BitStream_buffer_output[8:6] == 3'b010) ||
                                                        (heading_one_pos == 4'd7 &&  BitStream_buffer_output[7:6] == 2'b10)  ||
                                                        (heading_one_pos == 4'd7 &&  BitStream_buffer_output[7:6] == 2'b10)  ||
                                                        (heading_one_pos == 4'd8 && !BitStream_buffer_output[6]))
                                                        (heading_one_pos == 4'd8 && !BitStream_buffer_output[6]))
                                                        TrailingOnes <= 2'd3;
                                                        TrailingOnes <= 2'd3;
                                                else
                                                else
                                                        TrailingOnes <= 2'd0;
                                                        TrailingOnes <= 2'd0;
                                        end
                                        end
                        end
                        end
                else if (nC_GE8)
                else if (nC_GE8)
                        begin
                        begin
                                if (BitStream_buffer_output[15:10] == 6'b0 || heading_one_pos == 4'd4)
                                if (BitStream_buffer_output[15:10] == 6'b0 || heading_one_pos == 4'd4)
                                        TrailingOnes <= 2'd0;
                                        TrailingOnes <= 2'd0;
                                else if (heading_one_pos == 4'd5)
                                else if (heading_one_pos == 4'd5)
                                        TrailingOnes <= 2'd1;
                                        TrailingOnes <= 2'd1;
                                else
                                else
                                        TrailingOnes <= BitStream_buffer_output[11:10];
                                        TrailingOnes <= BitStream_buffer_output[11:10];
                        end
                        end
                else
                else
                        TrailingOnes <= TrailingOnes_reg;
                        TrailingOnes <= TrailingOnes_reg;
 
 
        //TotalCoeff
        //TotalCoeff
        always @ (posedge clk)
        always @ (posedge clk)
                if (reset_n == 0)
                if (reset_n == 0)
                        TotalCoeff_reg <= 0;
                        TotalCoeff_reg <= 0;
                else if (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT)
                else if (cavlc_decoder_state == `NumCoeffTrailingOnes_LUT)
                        TotalCoeff_reg <= TotalCoeff;
                        TotalCoeff_reg <= TotalCoeff;
 
 
        always @ (nC_0to2 or nC_2to4 or nC_4to8 or nC_n1 or nC_GE8
        always @ (nC_0to2 or nC_2to4 or nC_4to8 or nC_n1 or nC_GE8
        or nC_0to2_t0 or nC_0to2_t1 or nC_0to2_t2 or nC_0to2_t3
        or nC_0to2_t0 or nC_0to2_t1 or nC_0to2_t2 or nC_0to2_t3
        or nC_2to4_t0 or nC_2to4_t1 or nC_2to4_t2 or nC_2to4_t3
        or nC_2to4_t0 or nC_2to4_t1 or nC_2to4_t2 or nC_2to4_t3
        or nC_4to8_t0 or nC_4to8_t1 or nC_n1_t0
        or nC_4to8_t0 or nC_4to8_t1 or nC_n1_t0
        or TotalCoeff_reg or heading_one_pos or BitStream_buffer_output)
        or TotalCoeff_reg or heading_one_pos or BitStream_buffer_output)
                if (nC_0to2)
                if (nC_0to2)
                        begin
                        begin
                                if (nC_0to2_t0)
                                if (nC_0to2_t0)
                                        TotalCoeff <= {3'b0,heading_one_pos[1:0]};
                                        TotalCoeff <= {3'b0,heading_one_pos[1:0]};
                                else if (nC_0to2_t1)
                                else if (nC_0to2_t1)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd3)
                                                if (heading_one_pos == 4'd3)
                                                        case (BitStream_buffer_output[11:10])
                                                        case (BitStream_buffer_output[11:10])
                                                                2'b00  :TotalCoeff <= 5'd2;
                                                                2'b00  :TotalCoeff <= 5'd2;
                                                                2'b01  :TotalCoeff <= 5'd1;
                                                                2'b01  :TotalCoeff <= 5'd1;
                                                                default:TotalCoeff <= 5'd3;
                                                                default:TotalCoeff <= 5'd3;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[10:9])
                                                        case (BitStream_buffer_output[10:9])
                                                                2'b00  :TotalCoeff <= 5'd5;
                                                                2'b00  :TotalCoeff <= 5'd5;
                                                                2'b01  :TotalCoeff <= 5'd3;
                                                                2'b01  :TotalCoeff <= 5'd3;
                                                                default:TotalCoeff <= 5'd4;
                                                                default:TotalCoeff <= 5'd4;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else if (nC_0to2_t2)
                                else if (nC_0to2_t2)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd5)
                                                if (heading_one_pos == 4'd5)
                                                        case (BitStream_buffer_output[9:8])
                                                        case (BitStream_buffer_output[9:8])
                                                                2'b00:TotalCoeff <= 5'd6;
                                                                2'b00:TotalCoeff <= 5'd6;
                                                                2'b01:TotalCoeff <= 5'd4;
                                                                2'b01:TotalCoeff <= 5'd4;
                                                                2'b10:TotalCoeff <= 5'd3;
                                                                2'b10:TotalCoeff <= 5'd3;
                                                                2'b11:TotalCoeff <= 5'd2;
                                                                2'b11:TotalCoeff <= 5'd2;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd6)
                                                else if (heading_one_pos == 4'd6)
                                                        case (BitStream_buffer_output[8:7])
                                                        case (BitStream_buffer_output[8:7])
                                                                2'b00:TotalCoeff <= 5'd7;
                                                                2'b00:TotalCoeff <= 5'd7;
                                                                2'b01:TotalCoeff <= 5'd5;
                                                                2'b01:TotalCoeff <= 5'd5;
                                                                2'b10:TotalCoeff <= 5'd4;
                                                                2'b10:TotalCoeff <= 5'd4;
                                                                2'b11:TotalCoeff <= 5'd3;
                                                                2'b11:TotalCoeff <= 5'd3;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd7)
                                                else if (heading_one_pos == 4'd7)
                                                        case (BitStream_buffer_output[7:6])
                                                        case (BitStream_buffer_output[7:6])
                                                                2'b00:TotalCoeff <= 5'd8;
                                                                2'b00:TotalCoeff <= 5'd8;
                                                                2'b01:TotalCoeff <= 5'd6;
                                                                2'b01:TotalCoeff <= 5'd6;
                                                                2'b10:TotalCoeff <= 5'd5;
                                                                2'b10:TotalCoeff <= 5'd5;
                                                                2'b11:TotalCoeff <= 5'd4;
                                                                2'b11:TotalCoeff <= 5'd4;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[6:5])
                                                        case (BitStream_buffer_output[6:5])
                                                                2'b00:TotalCoeff <= 5'd9;
                                                                2'b00:TotalCoeff <= 5'd9;
                                                                2'b01:TotalCoeff <= 5'd7;
                                                                2'b01:TotalCoeff <= 5'd7;
                                                                2'b10:TotalCoeff <= 5'd6;
                                                                2'b10:TotalCoeff <= 5'd6;
                                                                2'b11:TotalCoeff <= 5'd5;
                                                                2'b11:TotalCoeff <= 5'd5;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else if (nC_0to2_t3)
                                else if (nC_0to2_t3)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd9)
                                                if (heading_one_pos == 4'd9)
                                                        case (BitStream_buffer_output[5:3])
                                                        case (BitStream_buffer_output[5:3])
                                                                3'b001             :TotalCoeff <= 5'd9;
                                                                3'b001             :TotalCoeff <= 5'd9;
                                                                3'b011,3'b110:TotalCoeff <= 5'd7;
                                                                3'b011,3'b110:TotalCoeff <= 5'd7;
                                                                3'b100             :TotalCoeff <= 5'd10;
                                                                3'b100             :TotalCoeff <= 5'd10;
                                                                3'b111             :TotalCoeff <= 5'd6;
                                                                3'b111             :TotalCoeff <= 5'd6;
                                                                default            :TotalCoeff <= 5'd8;
                                                                default            :TotalCoeff <= 5'd8;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[4:2])
                                                        case (BitStream_buffer_output[4:2])
                                                                3'b000             :TotalCoeff <= 5'd12;
                                                                3'b000             :TotalCoeff <= 5'd12;
                                                                3'b001,3'b100:TotalCoeff <= 5'd11;
                                                                3'b001,3'b100:TotalCoeff <= 5'd11;
                                                                3'b110,3'b111:TotalCoeff <= 5'd9;
                                                                3'b110,3'b111:TotalCoeff <= 5'd9;
                                                                default      :TotalCoeff <= 5'd10;
                                                                default      :TotalCoeff <= 5'd10;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else
                                else
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd11)
                                                if (heading_one_pos == 4'd11)
                                                        case (BitStream_buffer_output[3:1])
                                                        case (BitStream_buffer_output[3:1])
                                                                3'b000       :TotalCoeff <= 5'd14;
                                                                3'b000       :TotalCoeff <= 5'd14;
                                                                3'b001,3'b100:TotalCoeff <= 5'd13;
                                                                3'b001,3'b100:TotalCoeff <= 5'd13;
                                                                3'b110,3'b111:TotalCoeff <= 5'd11;
                                                                3'b110,3'b111:TotalCoeff <= 5'd11;
                                                                default      :TotalCoeff <= 5'd12;
                                                                default      :TotalCoeff <= 5'd12;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd12)
                                                else if (heading_one_pos == 4'd12)
                                                        case (BitStream_buffer_output[2:0])
                                                        case (BitStream_buffer_output[2:0])
                                                                3'b000              :TotalCoeff <= 5'd16;
                                                                3'b000              :TotalCoeff <= 5'd16;
                                                                3'b011,3'b101,3'b110:TotalCoeff <= 5'd14;
                                                                3'b011,3'b101,3'b110:TotalCoeff <= 5'd14;
                                                                3'b111              :TotalCoeff <= 5'd13;
                                                                3'b111              :TotalCoeff <= 5'd13;
                                                                default             :TotalCoeff <= 5'd15;
                                                                default             :TotalCoeff <= 5'd15;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd13)
                                                else if (heading_one_pos == 4'd13)
                                                        TotalCoeff <= (BitStream_buffer_output[1:0] == 2'b11)? 5'd15:5'd16;
                                                        TotalCoeff <= (BitStream_buffer_output[1:0] == 2'b11)? 5'd15:5'd16;
                                                else
                                                else
                                                        TotalCoeff <= 5'd13;
                                                        TotalCoeff <= 5'd13;
                                        end
                                        end
                        end
                        end
                else if (nC_2to4)
                else if (nC_2to4)
                        begin
                        begin
                                if (nC_2to4_t0)
                                if (nC_2to4_t0)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd0)
                                                if (heading_one_pos == 4'd0)
                                                        TotalCoeff <= {4'b0,~BitStream_buffer_output[14]};
                                                        TotalCoeff <= {4'b0,~BitStream_buffer_output[14]};
                                                else
                                                else
                                                        case (BitStream_buffer_output[13:12])
                                                        case (BitStream_buffer_output[13:12])
                                                                2'b00  :TotalCoeff <= 5'd4;
                                                                2'b00  :TotalCoeff <= 5'd4;
                                                                2'b01  :TotalCoeff <= 5'd3;
                                                                2'b01  :TotalCoeff <= 5'd3;
                                                                default:TotalCoeff <= 5'd2;
                                                                default:TotalCoeff <= 5'd2;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else if (nC_2to4_t1)
                                else if (nC_2to4_t1)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd2)
                                                if (heading_one_pos == 4'd2)
                                                        case (BitStream_buffer_output[12:11])
                                                        case (BitStream_buffer_output[12:11])
                                                                2'b00:TotalCoeff <= (BitStream_buffer_output[10])? 5'd3:5'd6;
                                                                2'b00:TotalCoeff <= (BitStream_buffer_output[10])? 5'd3:5'd6;
                                                                2'b01:TotalCoeff <= (BitStream_buffer_output[10])? 5'd1:5'd3;
                                                                2'b01:TotalCoeff <= (BitStream_buffer_output[10])? 5'd1:5'd3;
                                                                2'b10:TotalCoeff <= 5'd5;
                                                                2'b10:TotalCoeff <= 5'd5;
                                                                2'b11:TotalCoeff <= 5'd2;
                                                                2'b11:TotalCoeff <= 5'd2;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[11:10])
                                                        case (BitStream_buffer_output[11:10])
                                                                2'b00  :TotalCoeff <= 5'd7;
                                                                2'b00  :TotalCoeff <= 5'd7;
                                                                2'b11  :TotalCoeff <= 5'd2;
                                                                2'b11  :TotalCoeff <= 5'd2;
                                                                default:TotalCoeff <= 5'd4;
                                                                default:TotalCoeff <= 5'd4;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else if (nC_2to4_t2)
                                else if (nC_2to4_t2)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd4)
                                                if (heading_one_pos == 4'd4)
                                                        case (BitStream_buffer_output[10:9])
                                                        case (BitStream_buffer_output[10:9])
                                                                2'b00  :TotalCoeff <= 5'd8;
                                                                2'b00  :TotalCoeff <= 5'd8;
                                                                2'b11  :TotalCoeff <= 5'd3;
                                                                2'b11  :TotalCoeff <= 5'd3;
                                                                default:TotalCoeff <= 5'd5;
                                                                default:TotalCoeff <= 5'd5;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd5)
                                                else if (heading_one_pos == 4'd5)
                                                        case (BitStream_buffer_output[9:8])
                                                        case (BitStream_buffer_output[9:8])
                                                                2'b00  :TotalCoeff <= 5'd5;
                                                                2'b00  :TotalCoeff <= 5'd5;
                                                                2'b11  :TotalCoeff <= 5'd4;
                                                                2'b11  :TotalCoeff <= 5'd4;
                                                                default:TotalCoeff <= 5'd6;
                                                                default:TotalCoeff <= 5'd6;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[8:7])
                                                        case (BitStream_buffer_output[8:7])
                                                                2'b00  :TotalCoeff <= 5'd9;
                                                                2'b00  :TotalCoeff <= 5'd9;
                                                                2'b11  :TotalCoeff <= 5'd6;
                                                                2'b11  :TotalCoeff <= 5'd6;
                                                                default:TotalCoeff <= 5'd7;
                                                                default:TotalCoeff <= 5'd7;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else if (nC_2to4_t3)
                                else if (nC_2to4_t3)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd7)
                                                if (heading_one_pos == 4'd7)
                                                        case (BitStream_buffer_output[7:5])
                                                        case (BitStream_buffer_output[7:5])
                                                                3'b000       :TotalCoeff <= 5'd11;
                                                                3'b000       :TotalCoeff <= 5'd11;
                                                                3'b001,3'b010:TotalCoeff <= 5'd9;
                                                                3'b001,3'b010:TotalCoeff <= 5'd9;
                                                                3'b100       :TotalCoeff <= 5'd10;
                                                                3'b100       :TotalCoeff <= 5'd10;
                                                                3'b111       :TotalCoeff <= 5'd7;
                                                                3'b111       :TotalCoeff <= 5'd7;
                                                                default      :TotalCoeff <= 5'd8;
                                                                default      :TotalCoeff <= 5'd8;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[6:4])
                                                        case (BitStream_buffer_output[6:4])
                                                                3'b000,3'b001,3'b010:TotalCoeff <= 5'd11;
                                                                3'b000,3'b001,3'b010:TotalCoeff <= 5'd11;
                                                                3'b100              :TotalCoeff <= 5'd12;
                                                                3'b100              :TotalCoeff <= 5'd12;
                                                                3'b111              :TotalCoeff <= 5'd9;
                                                                3'b111              :TotalCoeff <= 5'd9;
                                                                default             :TotalCoeff <= 5'd10;
                                                                default             :TotalCoeff <= 5'd10;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else
                                else
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd9)
                                                if (heading_one_pos == 4'd9)
                                                        case (BitStream_buffer_output[5:3])
                                                        case (BitStream_buffer_output[5:3])
                                                                3'b000              :TotalCoeff <= 5'd14;
                                                                3'b000              :TotalCoeff <= 5'd14;
                                                                3'b101,3'b110,3'b111:TotalCoeff <= 5'd12;
                                                                3'b101,3'b110,3'b111:TotalCoeff <= 5'd12;
                                                                default             :TotalCoeff <= 5'd13;
                                                                default             :TotalCoeff <= 5'd13;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd10)
                                                else if (heading_one_pos == 4'd10)
                                                        TotalCoeff <= (BitStream_buffer_output[4:2] == 3'b0 || BitStream_buffer_output[4:2] == 3'b001 || BitStream_buffer_output[4:2] == 3'b010)? 5'd15:5'd14;
                                                        TotalCoeff <= (BitStream_buffer_output[4:2] == 3'b0 || BitStream_buffer_output[4:2] == 3'b001 || BitStream_buffer_output[4:2] == 3'b010)? 5'd15:5'd14;
                                                else if (heading_one_pos == 4'd11)
                                                else if (heading_one_pos == 4'd11)
                                                        TotalCoeff <= 5'd16;
                                                        TotalCoeff <= 5'd16;
                                                else
                                                else
                                                        TotalCoeff <= 5'd15;
                                                        TotalCoeff <= 5'd15;
                                        end
                                        end
                        end
                        end
                else if (nC_n1)
                else if (nC_n1)
                        begin
                        begin
                                if (nC_n1_t0)
                                if (nC_n1_t0)
                                        begin
                                        begin
                                                if      (BitStream_buffer_output[15])   TotalCoeff <= 5'd1;
                                                if      (BitStream_buffer_output[15])   TotalCoeff <= 5'd1;
                                                else if (BitStream_buffer_output[14])   TotalCoeff <= 5'd0;
                                                else if (BitStream_buffer_output[14])   TotalCoeff <= 5'd0;
                                                else                                  TotalCoeff <= 5'd2;
                                                else                                  TotalCoeff <= 5'd2;
                                        end
                                        end
                                else
                                else
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd3)
                                                if (heading_one_pos == 4'd3)
                                                        case (BitStream_buffer_output[11:10])
                                                        case (BitStream_buffer_output[11:10])
                                                                2'b01  :TotalCoeff <= 5'd3;
                                                                2'b01  :TotalCoeff <= 5'd3;
                                                                2'b11  :TotalCoeff <= 5'd1;
                                                                2'b11  :TotalCoeff <= 5'd1;
                                                                default:TotalCoeff <= 5'd2;
                                                                default:TotalCoeff <= 5'd2;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd4)
                                                else if (heading_one_pos == 4'd4)
                                                        TotalCoeff <= (BitStream_buffer_output[10])? 5'd3:5'd4;
                                                        TotalCoeff <= (BitStream_buffer_output[10])? 5'd3:5'd4;
                                                else if (heading_one_pos == 4'd5)
                                                else if (heading_one_pos == 4'd5)
                                                        TotalCoeff <= 5'd3;
                                                        TotalCoeff <= 5'd3;
                                                else
                                                else
                                                        TotalCoeff <= 5'd4;
                                                        TotalCoeff <= 5'd4;
                                        end
                                        end
                        end
                        end
                else if (nC_4to8)
                else if (nC_4to8)
                        begin
                        begin
                                if (nC_4to8_t0)
                                if (nC_4to8_t0)
                                        TotalCoeff <= {2'b0,~BitStream_buffer_output[14:12]};
                                        TotalCoeff <= {2'b0,~BitStream_buffer_output[14:12]};
                                else if (nC_4to8_t1)
                                else if (nC_4to8_t1)
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd1)
                                                if (heading_one_pos == 4'd1)
                                                        case (BitStream_buffer_output[13:11])
                                                        case (BitStream_buffer_output[13:11])
                                                                3'b000,3'b001:TotalCoeff <= 5'd5;
                                                                3'b000,3'b001:TotalCoeff <= 5'd5;
                                                                3'b010,3'b011:TotalCoeff <= 5'd4;
                                                                3'b010,3'b011:TotalCoeff <= 5'd4;
                                                                3'b101       :TotalCoeff <= 5'd8;
                                                                3'b101       :TotalCoeff <= 5'd8;
                                                                3'b111       :TotalCoeff <= 5'd2;
                                                                3'b111       :TotalCoeff <= 5'd2;
                                                                default      :TotalCoeff <= 5'd3;
                                                                default      :TotalCoeff <= 5'd3;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd2)
                                                else if (heading_one_pos == 4'd2)
                                                        case (BitStream_buffer_output[12:10])
                                                        case (BitStream_buffer_output[12:10])
                                                                3'b000       :TotalCoeff <= 5'd3;
                                                                3'b000       :TotalCoeff <= 5'd3;
                                                                3'b001,3'b010:TotalCoeff <= 5'd7;
                                                                3'b001,3'b010:TotalCoeff <= 5'd7;
                                                                3'b011       :TotalCoeff <= 5'd2;
                                                                3'b011       :TotalCoeff <= 5'd2;
                                                                3'b100       :TotalCoeff <= 5'd9;
                                                                3'b100       :TotalCoeff <= 5'd9;
                                                                3'b111       :TotalCoeff <= 5'd1;
                                                                3'b111       :TotalCoeff <= 5'd1;
                                                                default      :TotalCoeff <= 5'd6;
                                                                default      :TotalCoeff <= 5'd6;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd3)
                                                else if (heading_one_pos == 4'd3)
                                                        case (BitStream_buffer_output[11:9])
                                                        case (BitStream_buffer_output[11:9])
                                                                3'b000 :TotalCoeff <= 5'd7;
                                                                3'b000 :TotalCoeff <= 5'd7;
                                                                3'b001 :TotalCoeff <= 5'd6;
                                                                3'b001 :TotalCoeff <= 5'd6;
                                                                3'b010 :TotalCoeff <= 5'd9;
                                                                3'b010 :TotalCoeff <= 5'd9;
                                                                3'b011 :TotalCoeff <= 5'd5;
                                                                3'b011 :TotalCoeff <= 5'd5;
                                                                3'b100 :TotalCoeff <= 5'd10;
                                                                3'b100 :TotalCoeff <= 5'd10;
                                                                3'b111 :TotalCoeff <= 5'd4;
                                                                3'b111 :TotalCoeff <= 5'd4;
                                                                default:TotalCoeff <= 5'd8;
                                                                default:TotalCoeff <= 5'd8;
                                                        endcase
                                                        endcase
                                                else
                                                else
                                                        case (BitStream_buffer_output[10:8])
                                                        case (BitStream_buffer_output[10:8])
                                                                3'b000       :TotalCoeff <= 5'd12;
                                                                3'b000       :TotalCoeff <= 5'd12;
                                                                3'b001,3'b100:TotalCoeff <= 5'd11;
                                                                3'b001,3'b100:TotalCoeff <= 5'd11;
                                                                3'b010,3'b101:TotalCoeff <= 5'd10;
                                                                3'b010,3'b101:TotalCoeff <= 5'd10;
                                                                3'b111       :TotalCoeff <= 5'd8;
                                                                3'b111       :TotalCoeff <= 5'd8;
                                                                default      :TotalCoeff <= 5'd9;
                                                                default      :TotalCoeff <= 5'd9;
                                                        endcase
                                                        endcase
                                        end
                                        end
                                else
                                else
                                        begin
                                        begin
                                                if (heading_one_pos == 4'd5)
                                                if (heading_one_pos == 4'd5)
                                                        case (BitStream_buffer_output[9:7])
                                                        case (BitStream_buffer_output[9:7])
                                                                3'b001,3'b100   :TotalCoeff <= 5'd13;
                                                                3'b001,3'b100   :TotalCoeff <= 5'd13;
                                                                3'b011,3'b110   :TotalCoeff <= 5'd11;
                                                                3'b011,3'b110   :TotalCoeff <= 5'd11;
                                                                3'b111        :TotalCoeff <= 5'd10;
                                                                3'b111        :TotalCoeff <= 5'd10;
                                                                default       :TotalCoeff <= 5'd12;
                                                                default       :TotalCoeff <= 5'd12;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd6)
                                                else if (heading_one_pos == 4'd6)
                                                        case (BitStream_buffer_output[8:6])
                                                        case (BitStream_buffer_output[8:6])
                                                                3'b000              :TotalCoeff <= 5'd15;
                                                                3'b000              :TotalCoeff <= 5'd15;
                                                                3'b101,3'b110,3'b111:TotalCoeff <= 5'd13;
                                                                3'b101,3'b110,3'b111:TotalCoeff <= 5'd13;
                                                                default             :TotalCoeff <= 5'd14;
                                                                default             :TotalCoeff <= 5'd14;
                                                        endcase
                                                        endcase
                                                else if (heading_one_pos == 4'd7)
                                                else if (heading_one_pos == 4'd7)
                                                        TotalCoeff <= (BitStream_buffer_output[7:6] == 2'b00)? 5'd16:5'd15;
                                                        TotalCoeff <= (BitStream_buffer_output[7:6] == 2'b00)? 5'd16:5'd15;
                                                else
                                                else
                                                        TotalCoeff <= 5'd16;
                                                        TotalCoeff <= 5'd16;
                                        end
                                        end
                        end
                        end
                else if (nC_GE8)
                else if (nC_GE8)
                        begin
                        begin
                                if (heading_one_pos == 4'd4)
                                if (heading_one_pos == 4'd4)
                                        TotalCoeff <= 5'd0;
                                        TotalCoeff <= 5'd0;
                                else
                                else
                                        TotalCoeff <= BitStream_buffer_output[15:12] + 1;
                                        TotalCoeff <= BitStream_buffer_output[15:12] + 1;
                        end
                        end
                else
                else
                        TotalCoeff <= TotalCoeff_reg;
                        TotalCoeff <= TotalCoeff_reg;
 
 

powered by: WebSVN 2.1.0

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