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/coin/incrementer.vhd,v $
00015 --* $Revision: 1.3.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:42 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023
00024 library ieee;
00025
00026 use ieee.std_logic_1164.all;
00027
00028 use ieee.numeric_std.all;
00029
00030
00031
00032
00033 entity incrementer is
00034
00035 port (
00036 CLK : in ;
00037 RES : in ;
00038 INC_1 : in ;
00039 INC_2 : in ;
00040 READ_OUT : in ;
00041 VALUE : out (31 downto 0)
00042 );
00043
00044 end incrementer;
00045
00046
00047
00048
00049
00050 architecture incrementer_arc of incrementer is
00051
00052 signal val_i : (31 downto 0) := (others => '0');
00053
00054 begin -- incrementer_arc
00055
00056 VALUE <= val_i;
00057
00058
00059 counter : process (CLK)
00060 variable cnt : := 0;
00061 begin -- process counter
00062 if CLK'event and CLK = '1' then -- rising clock edge
00063 if RES = '1' then
00064 cnt := 0;
00065 val_i <= (others => '0');
00066 else
00067
00068 if (INC_1 and INC_2) = '1' then
00069 cnt := cnt + 3;
00070 elsif INC_2 = '1' then
00071 cnt := cnt + 2;
00072 elsif INC_1 = '1' then
00073 cnt := cnt + 1;
00074 else
00075 cnt := cnt;
00076 end if;
00077
00078 if READ_OUT = '1' then
00079 val_i <= (to_unsigned(cnt,32));
00080 cnt := 0;
00081 else
00082 val_i <= val_i;
00083 end if;
00084
00085 end if;
00086 end if;
00087 end process counter;
00088
00089 end incrementer_arc;