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/rio/cal.vhd,v $ *
00015 --* $Revision: 1.6.2.5 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:47 $ *
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 entity cal is
00034 generic
00035 (
00036 ADJUST : := 0
00037 );
00038 port (
00039 CLK : in ;
00040 STAT_R1 : in ;
00041 STAT_R2 : in ;
00042 STAT_R3 : in ;
00043 STAT_F1 : in ;
00044 STAT_F2 : in ;
00045 STAT_F3 : in ;
00046 RIS1 : in (5 downto 0);
00047 RIS2 : in (5 downto 0);
00048 RIS3 : in (5 downto 0);
00049 FAL1 : in (5 downto 0);
00050 FAL2 : in (5 downto 0);
00051 FAL3 : in (5 downto 0);
00052 S_T1 : out ;
00053 S_T2 : out ;
00054 S_T3 : out ;
00055 S_W1 : out ;
00056 S_W2 : out ;
00057 S_W3 : out ;
00058 TIME1 : out (7 downto 0);
00059 TIME2 : out (7 downto 0);
00060 TIME3 : out (7 downto 0);
00061 WIDTH1 : out (7 downto 0);
00062 WIDTH2 : out (7 downto 0);
00063 WIDTH3 : out (7 downto 0);
00064 SUM_RIN : in (7 downto 0);
00065 SUM_FIN : in (7 downto 0);
00066 SUM_ROUT : out (7 downto 0);
00067 SUM_FOUT : out (7 downto 0);
00068 OVER : out
00069 );
00070 end cal;
00071
00072
00073 architecture cal_arc of cal is
00074
00075 -------------------------------- signals --------------------------------------
00076 signal time1_i : (5 downto 0) := (others => '0');
00077 signal time2_i : (5 downto 0) := (others => '0');
00078 -- signal time3_i : std_logic_vector (7 downto 0) := (others => '0');
00079 signal width1_i : (7 downto 0) := (others => '0');
00080 signal width2_i : (7 downto 0) := (others => '0');
00081 -- signal width3_i : std_logic_vector (7 downto 0) := (others => '0');
00082 signal S_T1_i : := '0';
00083 signal S_T2_i : := '0';
00084 -- signal S_T3_i : std_logic := '0';
00085 signal S_W1_i : := '0';
00086 signal S_W2_i : := '0';
00087 -- signal S_W3_i : std_logic := '0';
00088 signal over_i : := '0';
00089
00090 begin
00091
00092 TIME1 <= "00" & time1_i;
00093 TIME2 <= "00" & time2_i;
00094 TIME3 <= (others => '0'); --time3_i;
00095 WIDTH1 <= width1_i;
00096 WIDTH2 <= width2_i;
00097 WIDTH3 <= (others => '0'); --width3_i;
00098 S_T1 <= S_T1_i;
00099 S_T2 <= S_T2_i;
00100 S_T3 <= '0'; --S_T3_i;
00101 S_W1 <= S_W1_i;
00102 S_W2 <= S_W2_i;
00103 S_W3 <= '0'; --S_W3_i;
00104 OVER <= over_i;
00105
00106
00107 process (CLK)
00108 begin
00109
00110 if CLK'event and CLK = '1' then
00111
00112 SUM_ROUT <= SUM_RIN;
00113 SUM_FOUT <= SUM_FIN;
00114
00115 over_i <= '0';
00116
00117 if STAT_R1 = '1' then
00118 time1_i <= RIS1;
00119 S_T1_i <= '1';
00120 else
00121 time1_i <= (others => '0');
00122 S_T1_i <= '0';
00123 end if;
00124 if (STAT_F1 and STAT_R1) = '1' then
00125 if FAL1 < RIS1 then
00126 if RIS1 <= 32 then
00127 width1_i <= "00" & (32 - RIS1 + FAL1);
00128 else
00129 width1_i <= "00" & (64 - RIS1 + FAL1);
00130 end if;
00131 else
00132 width1_i <= "00" & FAL1 - RIS1;
00133 end if;
00134 S_W1_i <= '1';
00135 else
00136 if STAT_R1 = '1' then
00137 width1_i <= "00" & (64 - RIS1);
00138 S_W1_i <= '1';
00139 over_i <= '1';
00140 else
00141 width1_i <= (others => '0');
00142 S_W1_i <= '0';
00143 end if;
00144 end if;
00145
00146 if STAT_R2 = '1' then
00147 time2_i <= RIS2;
00148 S_T2_i <= '1';
00149 else
00150 time2_i <= (others => '0');
00151 S_T2_i <= '0';
00152 end if;
00153 if (STAT_F2 and STAT_R2) = '1' then
00154 if FAL2 < RIS2 then
00155 if RIS2 <= 32 then
00156 width2_i <= "00" & (32 - RIS2 + FAL2);
00157 else
00158 width2_i <= "00" & (64 - RIS2 + FAL2);
00159 end if;
00160 else
00161 width2_i <= "00" & FAL2 - RIS2;
00162 end if;
00163 S_W2_i <= '1';
00164 else
00165 if STAT_R2 = '1' then
00166 width2_i <= "00" & (64 - RIS2);
00167 S_W2_i <= '1';
00168 over_i <= '1';
00169 else
00170 width2_i <= (others => '0');
00171 S_W2_i <= '0';
00172 end if;
00173 end if;
00174
00175 -- if STAT_R3 = '1' then
00176 -- time3_i <= ("00" & RIS3);
00177 -- S_T3_i <= '1';
00178 -- else
00179 -- time3_i <= (others => '0');
00180 -- S_T3_i <= '0';
00181 -- end if;
00182 -- if STAT_F3 = '1' then
00183 -- if FAL3 < RIS3 then
00184 -- width3_i <= "00" & (32 - RIS3 + FAL3);
00185 -- else
00186 -- width3_i <= "00" & FAL3 - RIS3;
00187 -- end if;
00188 -- S_W3_i <= '1';
00189 -- else
00190 -- if STAT_R3 = '1' then
00191 -- width3_i <= "00" & (64 - RIS3);
00192 -- S_W3_i <= '1';
00193 -- over_i <= '1';
00194 -- else
00195 -- width3_i <= (others => '0');
00196 -- S_W3_i <= '0';
00197 -- end if;
00198 -- end if;
00199
00200 end if;
00201 end process;
00202
00203 end cal_arc;