summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/clkdiv/clk200ns.vhd
blob: 1b23cbb9f5a30e96569fadddde02da3cc4f497ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-- clk200ns.vhd :
-- Eurobot 2004 : APB Team
-- Auteur : Fid�le GAFAN et Pierre-Andr� Galmes
-- Module g�n�rateur d'horloge 1us-p�riodique
-- 
-- On fera attention que cette horloge repose sur la fq d'horloge du FPGA.
-- Pour changer cette fr�quence, aller voir nono_const : FREQ_CLK.


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

use	work.nono_const.all;

--ENTITY
entity clk200ns is
	port (
                RST		: in std_logic;
                CLK		: in std_logic;  -- 40MHz
                CLK1USOUT      : out std_logic	 -- 
                );
end entity;

--ARCHITECTURE
architecture RTL of clk200ns is 
    signal compt: T_OCTET;
begin
    process(RST,CLK)
    begin
	if (RST = '1') then
            CLK1USOUT <= '0';
            compt <= x"00";
        elsif (CLK'event and CLK = '1') then
          compt <= compt + x"01";
          if (compt = x"00") then -- 30
              CLK1USOUT <= '1';
          else
              CLK1USOUT <= '0';
              if (compt = (CYCLE_CLK200NS - x"01")) then
                  compt <= x"00"; -- 30
              end if;
          end if;
        end if;        
    end process;
end RTL;