OpenCores
URL https://opencores.org/ocsvn/wb_uart/wb_uart/trunk

Subversion Repositories wb_uart

[/] [wb_uart/] [trunk/] [src/] [slib_clock_div.vhd] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 federico.a
--
2
-- Clock divider (clock enable generator)
3
--
4
-- Author:   Sebastian Witt
5
-- Date:     27.01.2008
6
-- Version:  1.1
7
--
8
-- This code is free software; you can redistribute it and/or
9
-- modify it under the terms of the GNU Lesser General Public
10
-- License as published by the Free Software Foundation; either
11
-- version 2.1 of the License, or (at your option) any later version.
12
--
13
-- This code is distributed in the hope that it will be useful,
14
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
15
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
-- Lesser General Public License for more details.
17
--
18
-- You should have received a copy of the GNU Lesser General Public
19
-- License along with this library; if not, write to the
20
-- Free Software  Foundation, Inc., 59 Temple Place, Suite 330,
21
-- Boston, MA  02111-1307  USA
22
--
23
 
24
LIBRARY IEEE;
25
USE IEEE.std_logic_1164.all;
26
USE IEEE.numeric_std.all;
27
 
28
 
29
entity slib_clock_div is
30
    generic (
31
        RATIO       : integer := 4      -- Clock divider ratio
32
    );
33
    port (
34
        CLK         : in std_logic;     -- Clock
35
        RST         : in std_logic;     -- Reset
36
        CE          : in std_logic;     -- Clock enable input
37
        Q           : out std_logic     -- New clock enable output
38
    );
39
end slib_clock_div;
40
 
41
architecture rtl of slib_clock_div is
42
    -- Signals
43
    signal iQ       : std_logic;                  -- Internal Q
44
    signal iCounter : integer range 0 to RATIO-1; -- Counter
45
 
46
begin
47
    -- Main process
48
    CD_PROC: process (RST, CLK)
49
    begin
50
        if (RST = '1') then
51
            iCounter <= 0;
52
            iQ       <= '0';
53
        elsif (CLK'event and CLK='1') then
54
            iQ <= '0';
55
            if (CE = '1') then
56
                if (iCounter = (RATIO-1)) then
57
                    iQ <= '1';
58
                    iCounter <= 0;
59
                else
60
                    iCounter <= iCounter + 1;
61
                end if;
62
            end if;
63
        end if;
64
    end process;
65
 
66
    -- Output signals
67
    Q <= iQ;
68
 
69
end rtl;
70
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.