00001 --**************************************************************
00002 --* *
00003 --* The source code for the ATLAS BCM "AAA" FPGA is made *
00004 --* available via the GNU General Public License (GPL) *
00005 --* unless otherwise stated below. *
00006 --* *
00007 --* In case of problems/questions/bug reports etc. please *
00008 --* contact michael.niegl@cern.ch *
00009 --* *
00010 --**************************************************************
00011
00012 --**************************************************************
00013 --* *
00014 --* $Source: /local/reps/bcmfpga/bcm_aaa/bcm_aaa/div/EVENT_cnt.vhd,v $
00015 --* $Revision: 1.8.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:45 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023
00024 library ieee;
00025
00026 use ieee.std_logic_1164.all;
00027
00028 use ieee.std_logic_arith.all;
00029
00030 use ieee.std_logic_unsigned.all;
00031
00032
00033
00034
00035
00036
00037
00038 entity EVENT_cnt is
00039 port (
00040 CLK : in ;
00041 RESET : in ;
00042 L1A : in ;
00043 ECR : in ;
00044 ECR_LOAD : in (7 downto 0);
00045 ECR_LOAD_EN : in ;
00046 L1A_LOAD : in (23 downto 0);
00047 L1A_LOAD_EN : in ;
00048 START_RUN : in ;
00049 EXT_EVENT_ID : out (31 downto 0));
00050
00051
00052 attribute use_dsp48 : ;
00053
00054 attribute use_dsp48 of EVENT_cnt : entity is "yes";
00055
00056 end EVENT_cnt;
00057
00058
00059
00060
00061
00062
00063
00064 architecture EVENT_cnt_arc of EVENT_cnt is
00065
00066 signal l1a_i : (23 downto 0) := (others => '1');
00067 signal ecr_i : (7 downto 0) := (others => '0');
00068 signal l1a_edge : := '0';
00069 signal l1a_del : := '0';
00070 signal l1a_del2 : := '0';
00071 signal ecr_edge : := '0';
00072 signal ecr_del : := '0';
00073 signal ecr_inc : := '0';
00074
00075
00076 component edge
00077 port (
00078 CLK : in ;
00079 A : in ;
00080 PULSE : out );
00081 end component;
00082
00083 begin
00084
00085 EXT_EVENT_ID <= ecr_i & l1a_i;
00086 l1a_del <= l1a_edge when rising_edge(CLK);
00087 l1a_del2 <= l1a_del when rising_edge(CLK);
00088 ecr_del <= ecr_edge when rising_edge(CLK);
00089 ecr_inc <= '0' when (ecr_edge and l1a_del) = '1' else
00090 '1' when (l1a_del2 and ecr_del) = '1' else
00091 ecr_edge;
00092
00093
00094 ecr_edge_det : edge
00095 port map (
00096 CLK => CLK ,
00097 A => ECR ,
00098 PULSE => ecr_edge
00099 );
00100
00101
00102 l1a_edge_det : edge
00103 port map (
00104 CLK => CLK ,
00105 A => L1A ,
00106 PULSE => l1a_edge
00107 );
00108
00109
00110 ECR_cnt : process(CLK, RESET)
00111 begin
00112 if CLK'event and CLK = '1' then
00113 if RESET = '1' or START_RUN = '1' then
00114 ecr_i <= (others => '0');
00115 elsif ECR_LOAD_EN = '1' then
00116 ecr_i <= ECR_LOAD;
00117 elsif ecr_inc = '1' then
00118 ecr_i <= ecr_i + 1;
00119 end if;
00120 end if;
00121 end process;
00122
00123
00124 L1A_cnt : process(CLK, RESET)
00125 begin
00126 if CLK'event and CLK = '1' then
00127 if (RESET or START_RUN) = '1' then
00128 l1a_i <= (others => '1');
00129 elsif (l1a_edge and ecr_edge) = '1' then
00130 l1a_i <= (others => '0');
00131 elsif ecr_inc = '1' then
00132 l1a_i <= (others => '1');
00133 elsif L1A_LOAD_EN = '1' then
00134 l1a_i <= L1A_LOAD;
00135 elsif l1a_edge = '1' then
00136 l1a_i <= l1a_i + 1;
00137 end if;
00138 end if;
00139 end process;
00140
00141 end EVENT_cnt_arc;