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/eth/period_check.vhd,v $
00015 --* $Revision: 2.0.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:46 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023
00024
00025 library ieee;
00026
00027 use ieee.std_logic_1164.all;
00028
00029 use ieee.std_logic_arith.all;
00030
00031 use ieee.std_logic_unsigned.all;
00032
00033
00034
00035
00036 entity period_check is
00037
00038 generic (
00039 PERIOD : range 0 to 255 := 8);
00040 port (
00041 CLK : in ;
00042 RES : in ;
00043 EN : in ;
00044 A : in ;
00045 Y : out
00046 );
00047
00048 end period_check;
00049
00050
00051
00052
00053
00054
00055 architecture period_check_arc of period_check is
00056
00057 signal res_n : := '1';
00058 signal ok : := '0';
00059 signal per_cnt_0 : (3 downto 0) := (others => '0');
00060 signal per_cnt_1 : (3 downto 0) := (others => '0');
00061
00062 begin -- period_check_arc
00063
00064 res_n <= not RES;
00065 Y <= ok when rising_edge(CLK);
00066
00067
00068 onescnt : process (CLK, res_n)
00069 variable cnt : range 0 to 255 := 0;
00070 begin -- process onescnt
00071 if res_n = '0' then -- asynchronous reset (active low)
00072 cnt := 0;
00073 per_cnt_1 <= (others => '0');
00074 elsif CLK'event and CLK = '1' then -- rising clock edge
00075 if EN = '1' and ok = '0' then
00076 if A = '1' then
00077 cnt := cnt + 1;
00078 else
00079 if cnt = PERIOD/2 then
00080 per_cnt_1 <= per_cnt_1 + '1';
00081 elsif cnt /= 0 then
00082 per_cnt_1 <= (others => '0');
00083 else
00084 per_cnt_1 <= per_cnt_1;
00085 end if;
00086 cnt := 0;
00087 end if;
00088 else
00089 cnt := cnt;
00090 per_cnt_1 <= per_cnt_1;
00091 end if;
00092 end if;
00093 end process onescnt;
00094
00095
00096 zeroscnt : process (CLK, res_n)
00097 variable cnt : range 0 to 255 := 0;
00098 begin -- process onescnt
00099 if res_n = '0' then -- asynchronous reset (active low)
00100 cnt := 0;
00101 per_cnt_0 <= (others => '0');
00102 elsif CLK'event and CLK = '1' then -- rising clock edge
00103 if EN = '1' and ok = '0' then
00104 if A = '0' then
00105 cnt := cnt + 1;
00106 else
00107 if cnt = PERIOD/2 then
00108 per_cnt_0 <= per_cnt_0 + '1';
00109 elsif cnt /= 0 then
00110 per_cnt_0 <= (others => '0');
00111 else
00112 per_cnt_0 <= per_cnt_0;
00113 end if;
00114 cnt := 0;
00115 end if;
00116 else
00117 cnt := cnt;
00118 per_cnt_0 <= per_cnt_0;
00119 end if;
00120 end if;
00121 end process zeroscnt;
00122
00123 ok <= '0' when res_n = '0' else
00124 '1' when per_cnt_0 >= 3 and per_cnt_1 >= 3 else
00125 '0';
00126
00127 end period_check_arc;