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

Subversion Repositories wb_uart

[/] [wb_uart/] [trunk/] [src/] [uart_baudgen.vhd] - Blame information for rev 14

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 federico.a
--
2
-- UART Baudrate 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
-- Serial UART baudrate generator
29
entity uart_baudgen is
30
    port (
31
        CLK         : in std_logic;                                 -- Clock
32
        RST         : in std_logic;                                 -- Reset
33
        CE          : in std_logic;                                 -- Clock enable
34
        CLEAR       : in std_logic;                                 -- Reset generator (synchronization)
35
        DIVIDER     : in std_logic_vector(15 downto 0);             -- Clock divider
36
        BAUDTICK    : out std_logic                                 -- 16xBaudrate tick
37
    );
38
end uart_baudgen;
39
 
40
architecture rtl of uart_baudgen is
41
    -- Signals
42
    signal iCounter : unsigned(15 downto 0);
43
begin
44
    -- Baudrate counter
45
    BG_COUNT: process (CLK, RST)
46
    begin
47
        if (RST = '1') then
48
            iCounter <= (others => '0');
49
            BAUDTICK <= '0';
50
        elsif (CLK'event and CLK = '1') then
51
            if (CLEAR = '1') then
52
                iCounter <= (others => '0');
53
            elsif (CE = '1') then
54
                iCounter <= iCounter + 1;
55
            end if;
56
 
57
            BAUDTICK <= '0';
58
            if (iCounter = unsigned(DIVIDER)) then
59
                iCounter <= (others => '0');
60
                BAUDTICK <= '1';
61
            end if;
62
        end if;
63
    end process;
64
 
65
end rtl;
66
 
67
 

powered by: WebSVN 2.1.0

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