summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/pwm/clk1us.vhd
blob: 082e4ecc80a2a6c8e3cd94a51a9374a344eb7116 (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
-------------------------------------------------------------------------------
--clk1us.vhd 
--Eurobot 2004 : APB Team
--Auteur : Fid�le GAFAN
--Module g�n�rateur d'horloge 1us-p�riodique(0,992us en r�alit�)
--
--REMARQUE(S):changer inc si CLK#32MHz
--Les calculs ont �t� faits avec CLK=32MHz
--donc 31*(1/CLK)=1us
--d'o� inc=31
-------------------------------------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
--ENTITY
entity clk1us is
	port (
                RST		: in std_logic;
                CLK		: in std_logic;  --32MHz
                CLK1USOUT      : out std_logic
                );
end entity;
--ARCHITECTURE
architecture clk1usbehav of clk1us is 
signal inc	: integer range 0 to 31;-- nombres de cycles de clk necessaires
                                        --pour 1us decremente
begin
	process(RST,CLK)
	begin
	if (RST = '1') then
            CLK1USOUT<='0';
           inc<=31;                    --31,25 normalement
        elsif (CLK'event and CLK = '1') then
          inc<=((inc)-1);
          if (inc=30) then
             CLK1USOUT<='1';
          else
            CLK1USOUT<='0';
            if (inc=0) then
              inc<=30;
            end if;
          end if;
        end if;        
	end process;
end clk1usbehav;