--
-- TLU_address_map.vhdl
--
-- package containg address map and type definitions for JRA1 TLU
--
-- Generated by script make_tlu_address_map.pl
--
-- Do not edit by hand! 
-- Edit TLU_address_map.dat instead                                
--
-- Generated on Sun Aug 31 21:05:20 2008
--
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

package TLU_Address_Map is

  constant FIRMWARE_ID : std_logic_vector(7 downto 0) := "11111010" ; 
  constant NUMBER_OF_DUT : integer := 6; -- how many devices
                                  -- (including telescope devices)
                                  -- in system
											 
  constant BEAM_TRIGGER_MASK_WIDTH : integer := 12; -- should be three times the # trigger
  constant NUMBER_OF_BEAM_TRIGGERS : integer := 4;
  
  constant TIMESTAMP_WIDTH : integer := 64;
  constant NUMBER_WORDS_IN_TIMESTAMP : integer := 4;
  constant TRIGGER_COUNTER_WIDTH : integer := 32;
  constant TRIGGER_DATA_WIDTH : integer := 32;
  constant BUFFER_POINTER_WIDTH : integer := 16;    --  width of pointer
  constant BUFFER_COUNTER_WIDTH : integer := 12;  -- this is the width of
                                                    -- the counter,
                                                    -- *NOT* the pointer
                                                    -- ( which has to be
                                                    -- an integer number
                                                    -- of bytes )
  constant BUFFER_DEPTH : integer := 4096;          -- 2^BUFFER_COUNTER_WIDTH
  constant BUFFER_HEADROOM : integer := 8; -- leave this many entries in 
                                           -- buffer when siganlling full
  -----------------------------------------------------------------------------
  -- define which bits in RESET_REGISTER reset which counters/pointers...
  constant TIMESTAMP_RESET_BIT : integer := 0;
  constant TRIGGER_COUNTER_RESET_BIT : integer := 1;
  constant BUFFER_POINTER_RESET_BIT : integer := 2;
  constant TRIGGER_FSM_RESET_BIT : integer := 3;
  constant BEAM_TRIGGER_FSM_RESET_BIT : integer := 4;
  constant DMA_CONTROLLER_RESET_BIT : integer := 5;
  constant TRIGGER_SCALERS_RESET_BIT : integer := 6;

 -----------------------------------------------------------------------------
  -- Constants for internal trigger generation
  constant CALIBRATION_TRIGGER_COUNTER_WIDTH : integer := 8;
  constant SLOW_CLOCK_COUNTER_WIDTH : integer := 16;  -- needs to store 48000
  constant SLOW_CLOCK_RATIO : std_logic_vector (SLOW_CLOCK_COUNTER_WIDTH-1 downto 0) := "1011101110000000";  -- ratio between 48MHz and 1kHz

  -----------------------------------------------------------------------------
  constant SCALER_NUMBER_OF_BYTES : integer := 2;
  subtype TRIGGER_SCALER is std_logic_vector(8*SCALER_NUMBER_OF_BYTES - 1 downto 0);
  type TRIGGER_SCALER_ARRAY is array ( NUMBER_OF_BEAM_TRIGGERS-1 downto 0) of TRIGGER_SCALER;
  
  -----------------------------------------------------------------------------
    -- mapping of IO pins onto signals in design.
  -----------------------------------------------------------------------------
  type beam_trigger_inputs is array ( 0 to 3 ) of integer; 
  -- this beam trigger mapping assumes use of Bonn discriminator board.
  -- i.e. 1,0,3,2
  constant BEAM_TRIG_IN_BIT : beam_trigger_inputs := (9,6,11,8);
  
  type dut_io is array ( 0 to NUMBER_OF_DUT-1 ) of integer;
  constant TRIGGER_OUTPUT_BIT : dut_io := (1,0,3,2,5,4);
  constant DUT_RESET_BIT : dut_io := (13,12,15,14,17,16);
  constant DUT_BUSY_BIT : dut_io := (27,26,29,28,31,30);
  constant DUT_CLOCK_BIT : dut_io := (38,41,43,42,44,46);
  constant DUT_LED_BIT : dut_io := (18,21,20,23,22,25);

  type gpio is array (0 to 4) of integer;  -- mapping for gpio bits
  constant GPIO_BIT : gpio := (37,36,35,34,32);
  -----------------------------------------------------------------------------

  constant BASE_ADDRESS : std_logic_vector(15 downto 0) := "0010000000000000" ;

  constant FIRMWARE_ID_ADDRESS : std_logic_vector(5 downto 0) := "000001" ;
  constant DUT_BUSY_ADDRESS : std_logic_vector(5 downto 0) := "000010" ;
  constant DUT_RESET_ADDRESS : std_logic_vector(5 downto 0) := "000011" ;
  constant DUT_TRIGGER_ADDRESS : std_logic_vector(5 downto 0) := "000100" ;
  constant DUT_MASK_ADDRESS : std_logic_vector(5 downto 0) := "000101" ;
  constant TRIG_INHIBIT_ADDRESS : std_logic_vector(5 downto 0) := "000110" ;
  constant RESET_REGISTER_ADDRESS : std_logic_vector(5 downto 0) := "000111" ;
  constant INITIATE_READOUT_ADDRESS : std_logic_vector(5 downto 0) := "001000" ;
  constant STATE_CAPTURE_ADDRESS : std_logic_vector(5 downto 0) := "001001" ;
  constant TRIGGER_FSM_STATUS_ADDRESS : std_logic_vector(5 downto 0) := "001010" ;
  constant BEAM_TRIGGER_FSM_STATUS_ADDRESS : std_logic_vector(5 downto 0) := "001011" ;
  constant DMA_STATUS_ADDRESS : std_logic_vector(5 downto 0) := "001100" ;
  constant REGISTERED_BUFFER_POINTER_ADDRESS_0 : std_logic_vector(5 downto 0) := "001101" ;
  constant REGISTERED_BUFFER_POINTER_ADDRESS_1 : std_logic_vector(5 downto 0) := "001110" ;
  constant REGISTERED_TIMESTAMP_ADDRESS_0 : std_logic_vector(5 downto 0) := "001111" ;
  constant REGISTERED_TIMESTAMP_ADDRESS_1 : std_logic_vector(5 downto 0) := "010000" ;
  constant REGISTERED_TIMESTAMP_ADDRESS_2 : std_logic_vector(5 downto 0) := "010001" ;
  constant REGISTERED_TIMESTAMP_ADDRESS_3 : std_logic_vector(5 downto 0) := "010010" ;
  constant REGISTERED_TIMESTAMP_ADDRESS_4 : std_logic_vector(5 downto 0) := "010011" ;
  constant REGISTERED_TIMESTAMP_ADDRESS_5 : std_logic_vector(5 downto 0) := "010100" ;
  constant REGISTERED_TIMESTAMP_ADDRESS_6 : std_logic_vector(5 downto 0) := "010101" ;
  constant REGISTERED_TIMESTAMP_ADDRESS_7 : std_logic_vector(5 downto 0) := "010110" ;
  constant REGISTERED_TRIGGER_COUNTER_ADDRESS_0 : std_logic_vector(5 downto 0) := "010111" ;
  constant REGISTERED_TRIGGER_COUNTER_ADDRESS_1 : std_logic_vector(5 downto 0) := "011000" ;
  constant REGISTERED_TRIGGER_COUNTER_ADDRESS_2 : std_logic_vector(5 downto 0) := "011001" ;
  constant REGISTERED_TRIGGER_COUNTER_ADDRESS_3 : std_logic_vector(5 downto 0) := "011010" ;
  constant BUFFER_POINTER_ADDRESS_0 : std_logic_vector(5 downto 0) := "011011" ;
  constant BUFFER_POINTER_ADDRESS_1 : std_logic_vector(5 downto 0) := "011100" ;
  constant TIMESTAMP_ADDRESS_0 : std_logic_vector(5 downto 0) := "011101" ;
  constant TIMESTAMP_ADDRESS_1 : std_logic_vector(5 downto 0) := "011110" ;
  constant TIMESTAMP_ADDRESS_2 : std_logic_vector(5 downto 0) := "011111" ;
  constant TIMESTAMP_ADDRESS_3 : std_logic_vector(5 downto 0) := "100000" ;
  constant TIMESTAMP_ADDRESS_4 : std_logic_vector(5 downto 0) := "100001" ;
  constant TIMESTAMP_ADDRESS_5 : std_logic_vector(5 downto 0) := "100010" ;
  constant TIMESTAMP_ADDRESS_6 : std_logic_vector(5 downto 0) := "100011" ;
  constant TIMESTAMP_ADDRESS_7 : std_logic_vector(5 downto 0) := "100100" ;
  constant TRIGGER_COUNTER_ADDRESS_0 : std_logic_vector(5 downto 0) := "100101" ;
  constant TRIGGER_COUNTER_ADDRESS_1 : std_logic_vector(5 downto 0) := "100110" ;
  constant TRIGGER_COUNTER_ADDRESS_2 : std_logic_vector(5 downto 0) := "100111" ;
  constant TRIGGER_COUNTER_ADDRESS_3 : std_logic_vector(5 downto 0) := "101000" ;
  constant BEAM_TRIGGER_AMASK_ADDRESS : std_logic_vector(5 downto 0) := "101001" ;
  constant BEAM_TRIGGER_OMASK_ADDRESS : std_logic_vector(5 downto 0) := "101010" ;
  constant BEAM_TRIGGER_VMASK_ADDRESS : std_logic_vector(5 downto 0) := "101011" ;
  constant INTERNAL_TRIGGER_INTERVAL : std_logic_vector(5 downto 0) := "101100" ;
  constant BEAM_TRIGGER_IN_ADDRESS : std_logic_vector(5 downto 0) := "101101" ;
  constant DUT_RESET_DEBUG_ADDRESS : std_logic_vector(5 downto 0) := "101110" ;
  constant DUT_DEBUG_TRIGGER_ADDRESS : std_logic_vector(5 downto 0) := "101111" ;
  constant DUT_CLOCK_DEBUG_ADDRESS : std_logic_vector(5 downto 0) := "110000" ;
  constant DUT_LED_ADDRESS : std_logic_vector(5 downto 0) := "110001" ;
  constant CLOCK_SOURCE_SELECT_ADDRESS : std_logic_vector(5 downto 0) := "110010" ;
  constant TRIGGER_IN0_COUNTER_0 : std_logic_vector(5 downto 0) := "110011" ;
  constant TRIGGER_IN0_COUNTER_1 : std_logic_vector(5 downto 0) := "110100" ;
  constant TRIGGER_IN1_COUNTER_0 : std_logic_vector(5 downto 0) := "110101" ;
  constant TRIGGER_IN1_COUNTER_1 : std_logic_vector(5 downto 0) := "110110" ;
  constant TRIGGER_IN2_COUNTER_0 : std_logic_vector(5 downto 0) := "110111" ;
  constant TRIGGER_IN2_COUNTER_1 : std_logic_vector(5 downto 0) := "111000" ;
  constant TRIGGER_IN3_COUNTER_0 : std_logic_vector(5 downto 0) := "111001" ;
  constant TRIGGER_IN3_COUNTER_1 : std_logic_vector(5 downto 0) := "111010" ;
  constant REGISTERED_PARTICLE_COUNTER_ADDRESS_0 : std_logic_vector(5 downto 0) := "111011" ;
  constant REGISTERED_PARTICLE_COUNTER_ADDRESS_1 : std_logic_vector(5 downto 0) := "111100" ;
  constant REGISTERED_PARTICLE_COUNTER_ADDRESS_2 : std_logic_vector(5 downto 0) := "111101" ;
  constant REGISTERED_PARTICLE_COUNTER_ADDRESS_3 : std_logic_vector(5 downto 0) := "111110" ;
end package TLU_Address_Map;
