From 12bbdb42cdcf5e6e39832d75fbbd31e3781d550a Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Fri, 11 Apr 2014 19:29:53 +0200 Subject: Import fichiers projet Quartus --- FPGA/vhdl/clock_divider.vhd | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 FPGA/vhdl/clock_divider.vhd (limited to 'FPGA/vhdl/clock_divider.vhd') diff --git a/FPGA/vhdl/clock_divider.vhd b/FPGA/vhdl/clock_divider.vhd new file mode 100644 index 0000000..3a061bb --- /dev/null +++ b/FPGA/vhdl/clock_divider.vhd @@ -0,0 +1,57 @@ +------------------------------------------------------ +-- Clock Divider +------------------------------------------------------ +-- Creation : A. Exertier, 2005 +------------------------------------------------------ + +library ieee; +use ieee.std_logic_1164.all; + +------------------------------------------------------ +-- PARAMETRES GENERIQUES +------------------------------------------------------ +-- board_frequency : frequency of the FPGA +-- user_frequency : desired frequency +------------------------------------------------------ +-- INPUTS +------------------------------------------------------ +-- clk : main clock +-- resetn : asynchronous active low reset +------------------------------------------------------ +-- OUTPUT +------------------------------------------------------ +-- en_user : signal at user_frequency +-- set to 1 only 1 main clock cycle +------------------------------------------------------ + + +entity clock_divider is + generic( + board_frequency : real :=50_000_000.0; -- 50 MHz + user_frequency : real :=4.0); -- 4 Hz + Port ( + clk : in std_logic; + resetn : in std_logic; -- active low + en_user : out std_logic); +end clock_divider; + +architecture RTL of clock_divider is + constant max : natural := integer(board_frequency/user_frequency); +begin + process(clk,resetn) + variable counter : natural range 0 to max-1; + begin + if resetn='0' then + counter := 0; + en_user <= '0'; + elsif rising_edge(clk) then + if counter = max-1 then + counter := 0; + en_user <= '1'; + else + counter := counter+1; + en_user <= '0'; + end if; + end if; + end process; +end RTL; -- cgit v1.2.3