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/div/prescaler.vhd,v $
00015 --* $Revision: 1.7.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:45 $ *
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 entity prescaler is
00035 generic (divider : range 0 to 127 := 10);
00036 port (CLK : in ;
00037 CE : in ;
00038 R : in ;
00039 TC : out
00040 );
00041 end prescaler;
00042
00043
00044 architecture prescaler_arc of prescaler is
00045
00046 signal cnt : range 0 to 127;
00047 signal clk_out : := '0';
00048
00049 begin
00050
00051 TC <= clk_out;
00052
00053 process (CLK)
00054 begin
00055 if clk'event and clk = '1' then
00056 if R = '1' then
00057 cnt <= 0;
00058 clk_out <= '0';
00059 elsif CE = '1' then
00060 cnt <= cnt+1;
00061 if cnt = (divider-1)/2 then
00062 cnt <= 0;
00063 clk_out <= not clk_out;
00064 end if;
00065 end if;
00066 end if;
00067 end process;
00068
00069 end prescaler_arc;
00070