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/sata/clock_divider.vhd,v $
00015 --* $Revision: 1.7.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:49 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023
00024 library ieee;
00025
00026 use ieee.std_logic_1164.all;
00027
00028 use ieee.std_logic_arith.all;
00029
00030 use ieee.std_logic_unsigned.all;
00031
00032
00033 entity clock_divider is
00034 generic(
00035 DIVISION_FACTOR : range 0 to 127 := 2;
00036 INITIAL_VALUE : range 0 to 127 := 2
00037 );
00038 port(
00039 CLK_IN : in ;
00040 CLK_OUT : out
00041 );
00042 end clock_divider;
00043
00044
00045 architecture clock_divider_arc of clock_divider is
00046
00047 signal clock_out_i : := '0';
00048 signal counter_i : range 0 to 127 := INITIAL_VALUE;
00049
00050 begin
00051
00052
00053 process (CLK_IN)
00054 begin
00055 if (CLK_IN'event and CLK_IN = '1') then
00056 if (counter_i = 2) then
00057 clock_out_i <= not clock_out_i;
00058 counter_i <= DIVISION_FACTOR;
00059 else
00060 counter_i <= counter_i - 2;
00061 end if;
00062 end if;
00063 end process;
00064
00065 CLK_OUT <= clock_out_i;
00066
00067 end clock_divider_arc;
00068