--******************************************************************************
--* @short   Input FPGA (CSC version)
--******************************************************************************
--* @author  SAKULIN Hannes  <hsakulin@dsy-srv3.cern.ch>
--* @date    $Date: 2004/12/17 11:24:27 $
--* @version $Revision: 1.10 $
--******************************************************************************
--/
library IEEE;
use IEEE.Std_logic_1164.all;
use WORK.GMTTypes.all;
use WORK.ReadOutBufTypes.all;
use WORK.VMEMux.all;
use WORK.IFVMEAddrMap.all;

-- pragma translate_off
library UNISIM;
use UNISIM.VCOMPONENTS.all;
-- pragma translate_on
use IEEE.NUMERIC_STD.all;

entity InputFPGAcsc is
  port (
    -- CHIP INPUTS    
    CSCMu : in TFourInMuons_flat;

    -- out to Logic FPGA and to MIPISO AU
    CSCMu_LF : out TFourSyncedMu_flat;
    CSCMu_AU : out TFourSyncedMu_flat;

    -- forCOU (DT and CSC chip, only)
    CSCPhiCOU : out TPhi_vec(0 to 3);
    CSCEtaCOU : out TEtaCOU_vec(0 to 3);
    spare_INC_LFB  : out std_logic;

    -- VME port
    vme_addr       : in    std_logic_vector(19 downto 1);
    vme_data       : inout std_logic_vector(15 downto 0);
    vme_en_INC     : in    std_logic;
    vme_wr_INC     : in    std_logic;
    vme_ndtack_INC : out   std_logic;   -- low active 
    vme_nirq_INC   : out   std_logic;   -- low active 

    -- Readout Data Port
    ro_data_INC    : out std_logic_vector(23 downto 0);
    ro_rdfifo_INC  : in std_logic;
    ro_fetch_INC   : in std_logic;
    l1a_INC        : in std_logic;          -- Level-1 accept
    bcreset_INC    : in std_logic;          -- Bunch Counter reset
    l1reset_INC    : in std_logic;          -- Level-1 reset

    -- Clock and control
    clk_INC        : in  std_logic;
    clk_test_INC   : out std_logic;     -- clock1x from DCM
    clk_out_INC    : out std_logic;     -- clock output for feedback (use optional)
                                        -- same as clk_test
    clk_fb_INC     : in  std_logic;     -- clock feedback input (use optional)
    dcm_locked_INC : out std_logic;     -- DCM is locked => goes to VME chip
    reset_dcm      : in  std_logic;     -- resets DCM
    inactive       : in  std_logic;     -- from front panel button (to GTS)

    status_INC     : out std_logic_vector(1 downto 0);
    test_lemo_INC  : out std_logic;
    test_INC       : out std_logic_vector(3 downto 0);
    reset_INC      : in  std_logic;     -- hard reset from trigger control
                                        --
                                        -- register input
                                        -- same function as level-1 reset
                                        -- or hard reset from trigger control
                                        --
                                        -- generated by VME chip
                                        -- resets only state machines, FFs,
                                        -- counters, error flags
                                        -- but not memories and registers

    dummyb_INC : in std_logic);
end;


architecture behavioral of InputFPGAcsc is
  attribute syn_useioff               : boolean;
  attribute syn_useioff of behavioral : architecture is true;
begin
  theChip: entity work.InputFPGA
    generic map (
      input_fpga_idx => 1)                --CSC
    port map (
      iMuons     => CSCMu,
      oMuonsLF   => CSCmu_LF,
      oMuonsAU   => CSCmu_AU,
      oPhi       => CSCPhiCOU,
      oEta       => CSCEtaCOU,
      vme_addr   => vme_addr,
      vme_data   => vme_data,
      vme_en     => vme_en_INC,
      vme_wr     => vme_wr_INC,
      vme_ndtack => vme_ndtack_INC,
      vme_nirq   => vme_nirq_INC,

      ro_data    => ro_data_INC,
      ro_rdfifo  => ro_rdfifo_INC,       
      ro_fetch   => ro_fetch_INC,
      l1a        => l1a_INC,
      bcreset    => bcreset_INC,
      l1reset    => l1reset_INC,   

      clk_input  => clk_INC,
      clk_test   => clk_test_INC,
      clk_out    => clk_out_INC,
      clk_fb     => clk_fb_INC,
      dcm_locked => dcm_locked_INC,
      reset_dcm        => reset_dcm,
      inactive   => inactive,
      status     => status_INC,
      test_lemo  => test_lemo_INC,
      test       => test_INC,
      reset_input=> reset_INC,      
      dummyb     => dummyb_INC);
  spare_INC_LFB <= '0'; 
end architecture behavioral;