--/******************************************************************************
--    Company      		: MICROSEMI

--    File Name    		: ddc_hb2_dec_coeffpack.vhd 
                   		
--    Description  		: This module is a package for user defined parameters

--    Targeted device 	: Family           Die          Package
--                   	  PolarFire     MPF300T_ES      MPF300T_ES

--    Author          	: India Solutions Team

--
-- SVN Revision Information:
-- SVN $Revision: 
-- SVN $Date:  $  
-- COPYRIGHT 2018 BY MICROSEMI 
-- THE INFORMATION CONTAINED IN THIS DOCUMENT IS SUBJECT TO LICENSING RESTRICTIONS 
-- FROM MICROSEMI CORP.  IF YOU ARE NOT IN POSSESSION OF WRITTEN AUTHORIZATION FROM 
-- MICROSEMI FOR USE OF THIS FILE, THEN THE FILE SHOULD BE IMMEDIATELY DESTROYED AND 
-- NO BACK-UP OF THE FILE SHOULD BE MADE. 
-- 

--******************************************************************************/
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_unsigned.all;
use ieee.math_real.all;
use work.System_pack.all;

package ddc_hb2_dec_coeffpack is
--------------------------------------------
-- USER provided Configuration
--------------------------------------------
    constant g_CLKFREQ             : integer := g_CLKFREQ;   		  			-- Clock frequency in Hz
    constant g_SAMPLEFREQ          : integer := (g_DDC_INPUT_RATE/4);		    -- Sample input frequency

--  Coefficient parameters
    constant g_COEFF_WIDTH        : integer := 16;								-- coefficients -fixed point format
    constant g_COEFF_FRACWIDTH    : integer := 15;
    constant g_COEFF_NUM          : integer := 23;      						-- number of coefficients
--   Mode of Delay input  
    constant g_HAS_SYMM           : integer := 1;         						-- 0-No symmetry , 1-symmetry    (Type of coefficient structure )
    constant g_SYMM				  : integer := 1;         						-- 0-Odd, 1-Even (Type of symmetry for the filter phase 0) 
   
--------------------------------------------
-- Calculated constant declarations
--------------------------------------------    
 FUNCTION DSPCount    (x : integer;
                       y : boolean)
         RETURN integer;
    constant g_CHANCOUNT          : integer:= (g_CLKFREQ/g_SAMPLEFREQ); 
    constant g_NUMCHANNELS        : integer := integer(g_CHANCOUNT/2); 		           -- Number of channels that can be processed out        
    constant g_CHAN_WIDTH         : integer := integer(ceil(log2(real(g_CHANCOUNT))));  
    constant g_EFF_COEFF_NUM      : integer := (g_COEFF_NUM+1)/ 4;                     --odd symmetry ,  (COEFF_NUM)/ 4 - even symm (Based on alternate zeros and symmetry) 
    constant g_DSPCOUNT           : integer := g_EFF_COEFF_NUM; 
    constant g_DSPCOUNT_WIDTH     : integer := integer(ceil(log2(real(g_DSPCOUNT))));     
    constant g_UNRND_FRACWIDTH    : integer :=  g_COEFF_FRACWIDTH + g_DATAIN_FRACWIDTH;    
    constant g_ADDERWIDTH         : integer := g_DATAIN_WIDTH+1; 
    constant g_MULTWIDTH          : integer := g_ADDERWIDTH+g_COEFF_WIDTH;
    constant g_ACCWIDTH           : integer := 48;      
    constant g_FINALADDWIDTH      : integer := g_MULTWIDTH+g_DSPCOUNT_WIDTH+1 ; 
    constant g_CHANDELAY          : integer := g_NUMCHANNELS+g_DSPCOUNT+4;   
    constant g_EVENODDDELAY       : integer := g_DSPCOUNT+4;          
    constant g_CENTER_TAP         : std_logic_vector(g_COEFF_WIDTH-1 DOWNTO 0) := x"4000";
    CONSTANT g_INIT               : std_logic_vector(287 downto 0) := x"FFF5800B3FF7E804DCFD2B027F1000000000000000000000000000000000000000000000"  ;  
end ddc_hb2_dec_coeffpack;
package body ddc_hb2_dec_coeffpack is


FUNCTION DSPCount    (x : integer;
                       y : boolean)
         RETURN integer IS
         BEGIN
             IF y THEN
                RETURN x;
             ELSE
                RETURN (x+1);
             END IF;
  END FUNCTION DSPCount;


end ddc_hb2_dec_coeffpack;
