00001 ------------------------------------------------------------------------------ 00002 -- This file is a part of the LPP VHDL IP LIBRARY 00003 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS 00004 -- 00005 -- This program is free software; you can redistribute it and/or modify 00006 -- it under the terms of the GNU General Public License as published by 00007 -- the Free Software Foundation; either version 3 of the License, or 00008 -- (at your option) any later version. 00009 -- 00010 -- This program is distributed in the hope that it will be useful, 00011 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 -- GNU General Public License for more details. 00014 -- 00015 -- You should have received a copy of the GNU General Public License 00016 -- along with this program; if not, write to the Free Software 00017 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 ------------------------------------------------------------------------------- 00019 -- Author : Alexis Jeandet 00020 -- Mail : alexis.jeandet@lpp.polytechnique.fr 00021 ---------------------------------------------------------------------------- 00022 library IEEE; 00023 use IEEE.STD_LOGIC_1164.ALL; 00024 00025 00026 entity Clk_divider is 00027 generic(OSC_freqHz : integer := 50000000; 00028 TargetFreq_Hz : integer := 50000); 00029 Port ( clk : in STD_LOGIC; 00030 reset : in STD_LOGIC; 00031 clk_divided : out STD_LOGIC); 00032 end Clk_divider; 00033 00034 architecture ar_Clk_divider of Clk_divider is 00035 00036 Constant clk_TRIGER : integer := (OSC_freqHz/(2*TargetFreq_Hz))+1; 00037 00038 00039 signal cpt1 : integer; 00040 00041 signal clk_int : std_logic := '0'; 00042 00043 00044 begin 00045 00046 clk_divided <= clk_int; 00047 00048 00049 process(reset,clk) 00050 begin 00051 if reset = '0' then 00052 cpt1 <= 0; 00053 clk_int <= '0'; 00054 elsif clk'event and clk = '1' then 00055 if cpt1 = clk_TRIGER then 00056 clk_int <= not clk_int; 00057 cpt1 <= 0; 00058 else 00059 cpt1 <= cpt1 + 1; 00060 end if; 00061 end if; 00062 end process; 00063 00064 00065 end ar_Clk_divider; 00066 00067
© Copyright 2011 LPP-CNRS | Design by Alexis Jeandet