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/riocheck.vhd,v $
00015 --* $Revision: 1.7.2.5 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 19:00:05 $ *
00019
00020
00021
00022 --* *
00023 --**************************************************************
00024
00025
00026 library ieee;
00027
00028 use ieee.std_logic_1164.all;
00029
00030 use ieee.numeric_std.all;
00031
00032 use ieee.std_logic_arith.all;
00033
00034 use ieee.std_logic_unsigned.all;
00035 library work;
00036 use work.build_parameters.all;
00037 use work.daq_header.all;
00038
00039
00040 entity riocheck is
00041
00042 port (
00043 CLK : in ;
00044 RES : in ;
00045 EN : in ;
00046 DATA_IN : in (255 downto 0);
00047 MASK_N : in (7 downto 0) := (others => '1');
00048 ERR : out ;
00049 ERR_TYPE : out (7 downto 0)
00050 );
00051
00052 end riocheck;
00053
00054
00055 architecture riocheck_arc of riocheck is
00056
00057 signal err0_i, err1_i, err2_i, err3_i, err4_i, err5_i, err6_i, err7_i : := 0;
00058 signal err_i : (7 downto 0) := (others => '0');
00059 signal err_bit : := '0';
00060 signal err_cnt : (8 downto 0) := (others => '0');
00061
00062 begin -- riocheck_arc
00063
00064 get_error : process (CLK, RES)
00065 begin -- process get_error
00066 if RES = '1' then -- asynchronous reset (active low)
00067 ERR <= '0';
00068 ERR_TYPE <= (others => '0');
00069 err_i <= (others => '0');
00070 err0_i <= 0;
00071 err1_i <= 0;
00072 err2_i <= 0;
00073 err3_i <= 0;
00074 err4_i <= 0;
00075 err5_i <= 0;
00076 err6_i <= 0;
00077 err7_i <= 0;
00078 err_bit <= '0';
00079 err_cnt <= (others => '0');
00080 elsif CLK'event and CLK = '1' then -- rising clock edge
00081 if EN = '1' then
00082 if err0_i >= kErr_Cnt then
00083 err_i(0) <= MASK_N(0);
00084 else
00085 err_i(0) <= '0';
00086 end if;
00087 err0_i <= cnt_ones(DATA_IN(255 downto 224));
00088 if err1_i >= kErr_Cnt then
00089 err_i(1) <= MASK_N(1);
00090 else
00091 err_i(1) <= '0';
00092 end if;
00093 err1_i <= cnt_ones(DATA_IN(223 downto 192));
00094 if err2_i >= kErr_Cnt then
00095 err_i(2) <= MASK_N(2);
00096 else
00097 err_i(2) <= '0';
00098 end if;
00099 err2_i <= cnt_ones(DATA_IN(191 downto 160));
00100 if err3_i >= kErr_Cnt then
00101 err_i(3) <= MASK_N(3);
00102 else
00103 err_i(3) <= '0';
00104 end if;
00105 err3_i <= cnt_ones(DATA_IN(159 downto 128));
00106 if err4_i >= kErr_Cnt then
00107 err_i(4) <= MASK_N(4);
00108 else
00109 err_i(4) <= '0';
00110 end if;
00111 err4_i <= cnt_ones(DATA_IN(127 downto 96));
00112 if err5_i >= kErr_Cnt then
00113 err_i(5) <= MASK_N(5);
00114 else
00115 err_i(5) <= '0';
00116 end if;
00117 err5_i <= cnt_ones(DATA_IN(95 downto 64));
00118 if err6_i >= kErr_Cnt then
00119 err_i(6) <= MASK_N(6);
00120 else
00121 err_i(6) <= '0';
00122 end if;
00123 err6_i <= cnt_ones(DATA_IN(63 downto 32));
00124 if err7_i >= kErr_Cnt then
00125 err_i(7) <= MASK_N(7);
00126 else
00127 err_i(7) <= '0';
00128 end if;
00129 err7_i <= cnt_ones(DATA_IN(31 downto 0));
00130 end if;
00131
00132 err_bit <= err_i(7) or err_i(6) or err_i(5) or err_i(4) or err_i(3) or err_i(2) or err_i(1) or err_i(0);
00133
00134 if err_bit = '1' then
00135 err_cnt <= err_cnt + 1;
00136 else
00137 err_cnt <= (others => '0');
00138 end if;
00139
00140 if err_cnt >= kTime_Cnt then
00141 ERR <= '1';
00142 ERR_TYPE <= err_i;
00143 end if;
00144
00145 end if;
00146 end process get_error;
00147
00148
00149 end riocheck_arc;