00001
00002 --**************************************************************
00003 --* *
00004 --* The source code for the ATLAS BCM "AAA" FPGA is made *
00005 --* available via the GNU General Public License (GPL) *
00006 --* unless otherwise stated below. *
00007 --* *
00008 --* In case of problems/questions/bug reports etc. please *
00009 --* contact michael.niegl@cern.ch *
00010 --* *
00011 --**************************************************************
00012
00013 --**************************************************************
00014 --* *
00015 --* $Source: /local/reps/bcmfpga/bcm_aaa/bcm_aaa/div/loop_cnt_sh.vhd,v $
00016 --* $Revision: 1.3.2.3 $ *
00017 --* $Name: dev $ *
00018 --* $Author: mniegl $ *
00019 --* $Date: 2008/11/03 17:57:45 $ *
00020
00021
00022 --* *
00023 --**************************************************************
00024
00025
00026 library ieee;
00027
00028 use ieee.std_logic_1164.all;
00029
00030 use ieee.std_logic_arith.all;
00031
00032 use ieee.std_logic_unsigned.all;
00033
00034 use ieee.numeric_std.all;
00035
00036
00037 entity loop_cnt_sh is
00038 port (
00039 CLK : in ;
00040 EN : in ;
00041 RESET : in ;
00042 Y : out (5 downto 0)
00043 );
00044
00045 end loop_cnt_sh;
00046
00047
00048 architecture loop_cnt_sh_arc of loop_cnt_sh is
00049
00050 signal cnt_i : (5 downto 0) := (others => '0');
00051 signal up : := '0';
00052
00053 begin -- loop_cnt_arc
00054
00055 Y <= cnt_i;
00056
00057 counter : process(CLK)
00058 begin
00059 if CLK'event and CLK = '1' then
00060 if RESET = '1' then
00061 cnt_i <= (others => '0');
00062 up <= '1';
00063 else
00064 if EN = '1' then
00065
00066 if up = '1' then
00067 if cnt_i = "111111" then
00068 up <= '0';
00069 cnt_i <= cnt_i - 1;
00070 else
00071 cnt_i <= cnt_i + 1;
00072 end if;
00073
00074 else
00075 if cnt_i = "000000" then
00076 up <= '1';
00077 cnt_i <= cnt_i + 1;
00078 else
00079 cnt_i <= cnt_i - 1;
00080 end if;
00081 end if;
00082
00083 else
00084 cnt_i <= cnt_i;
00085 end if;
00086 end if;
00087 end if;
00088 end process counter;
00089
00090 end loop_cnt_sh_arc;