NVC code coverage report

File:  ../../Sources/A11_1_golomb_encoder.vhd

     0:   ---------------------------------------------------------------------------------- 
     1:   -- Engineer:    Vitor Mendes Camilo 
     2:   -- 
     3:   -- Module Name: A11_1_golomb_encoder - Behavioral 
     4:   -- 
     5:   -- Description:                     Code segment A11.1 
     6:   --                                  Not actual segment, described in text 
     7:   --                                  on A.5.3 
     8:   -- 
     9:   -- Assumptions: 
    10:   --              (1) k <= SUFFIX_WIDTH       and     k   <= MAPPED_ERROR_VAL_WIDTH 
    11:   --              (2) QBPP <= SUFFIX_WIDTH    and     QBPP <= MAPPED_ERROR_VAL_WIDTH 
    12:   -- 
    13:   ---------------------------------------------------------------------------------- 
    14:    
    15:   library ieee; 
    16:     use ieee.std_logic_1164.all; 
    17:     use ieee.numeric_std.all; 
    18:     use work.openjls_pkg.all; 
    19:    
    20:   entity a11_1_golomb_encoder is 
    21:     generic ( 
    22:       K_WIDTH                : natural := CO_K_WIDTH_STD; 
    23:       QBPP                   : natural := CO_QBPP_STD; 
    24:       LIMIT                  : natural := CO_LIMIT_STD; 
    25:       UNARY_WIDTH            : natural := CO_UNARY_WIDTH_STD; 
    26:       SUFFIX_WIDTH           : natural := CO_SUFFIX_WIDTH_STD; 
    27:       SUFFIXLEN_WIDTH        : natural := CO_SUFFIXLEN_WIDTH_STD; 
    28:       MAPPED_ERROR_VAL_WIDTH : natural := CO_MAPPED_ERROR_VAL_WIDTH_STD 
    29:     ); 
    30:     port ( 
    31:       iK                     : in    unsigned (K_WIDTH - 1 downto 0); 
    32:       iMappedErrorVal        : in    unsigned (MAPPED_ERROR_VAL_WIDTH - 1 downto 0); 
    33:       -- iRiMode selects T.87 A.22.1 LG(k, glimit) with glimit = LIMIT - J[iRunIndex] - 1. 
    34:       -- iRunIndex is the RUNindex value before the A.16 decrement. Ignored when iRiMode='0'. 
    35:       iRiMode                : in    std_logic; 
    36:       iRunIndex              : in    unsigned (4 downto 0); 
    37:       oUnaryZeros            : out   unsigned (UNARY_WIDTH - 1 downto 0); 
    38:       oSuffixLen             : out   unsigned (SUFFIXLEN_WIDTH - 1 downto 0); 
    39:       oSuffixVal             : out   unsigned (SUFFIX_WIDTH - 1 downto 0) 
    40:     ); 
    41:   end entity a11_1_golomb_encoder; 
    42:    
    43:   architecture behavioral of a11_1_golomb_encoder is 
    44:    
    45:     constant REG_THRESHOLD : natural := LIMIT - QBPP - 1; 
    46:    
    47:   begin 
    48:    
    49:     -- Limited-Length Golomb LG(k, L). L=LIMIT in regular mode (A.5.3) and 
    50:     -- L=glimit=LIMIT-J[iRunIndex]-1 in RI mode (A.22.1). Non-escape if 
    51:     -- high_order < L - QBPP - 1. Escape emits (L - QBPP - 1) zeros + '1' + QBPP 
    52:     -- bits of (MErrval - 1); total escape length = L, so RI prefix + code = LIMIT. 
    53:     p_golomb_encode : process (iK, iMappedErrorVal, iRiMode, iRunIndex) is 
    54:    
    55:       variable vKInt           : integer; 
    56:       variable vHighOrder      : unsigned(iMappedErrorVal'range); 
    57:       variable vLowOrder       : unsigned(iMappedErrorVal'range); 
    58:       variable vMappedErrorDec : unsigned(iMappedErrorVal'range); 
    59:       variable vUnaryZeros     : unsigned(oUnaryZeros'range); 
    60:       variable vSuffixLen      : unsigned(oSuffixLen'range); 
    61:       variable vIsEscape       : boolean; 
    62:       variable vSuffixVal      : unsigned(oSuffixVal'range); 
    63:       variable vJ              : natural; 
    64:       variable vThreshold      : natural; 
    65:    
    66:     begin 
    67:    
    68:       if (iRiMode = '1') then 
    69:         vJ         := CO_J_TABLE(to_integer(iRunIndex)); 
    70:         vThreshold := LIMIT - vJ - QBPP - 2; 
    71:       else 
    72:         vThreshold := REG_THRESHOLD; 
    73:       end if; 
    74:    
    75:       vKInt := to_integer(iK); 
    76:       -- q = high-order bits of MErrval = floor(MErrval / 2^k) 
    77:       vHighOrder := shift_right(iMappedErrorVal, vKInt); 
    78:       -- r = low k bits of MErrval = MErrval - (q << k) 
    79:       vLowOrder := iMappedErrorVal - shift_left(vHighOrder, vKInt); 
    80:    
    81:       vIsEscape := (vHighOrder >= vThreshold); 
    82:    
    83:       if (not vIsEscape) then 
    84:         vUnaryZeros := resize(vHighOrder, vUnaryZeros'length); 
    85:         vSuffixLen  := resize(iK, vSuffixLen'length); 
    86:    
    87:         vSuffixVal := resize(vLowOrder, vSuffixVal'length); 
    88:       else 
    89:         -- Assertions ---------------------------------------------------------------- 
    90:         assert (iMappedErrorVal /= 0)                                               -- Catch impossible case on simulation set 
    91:           report "LG(k,LIMIT) escape with MErrval=0 is impossible per T.87/14495-1" 
    92:           severity failure; 
    93:         ------------------------------------------------------------------------------ 
    94:    
    95:         vUnaryZeros := to_unsigned(vThreshold, vUnaryZeros'length); 
    96:         vSuffixLen  := to_unsigned(QBPP, vSuffixLen'length); 
    97:    
    98:         vMappedErrorDec := iMappedErrorVal - 1;                                     -- MErrval is guaranteed to be greater than 1 when escape 
    99:    
   100:         vSuffixVal                    := (others => '0'); 
   101:         vSuffixVal(QBPP - 1 downto 0) := vMappedErrorDec(QBPP - 1 downto 0); 
   102:       end if; 
   103:    
   104:       oUnaryZeros <= vUnaryZeros; 
   105:       oSuffixLen  <= vSuffixLen; 
   106:       oSuffixVal  <= vSuffixVal; 
   107:    
   108:     end process p_golomb_encode; 
   109:    
   110:   end architecture behavioral;