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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [rtl/] [vhdl/] [ip/] [wb_uart/] [uart_tx.vhd] - Blame information for rev 69

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

Line No. Rev Author Line
1 16 ameziti
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
 
5
-----------------------------------------------------------------------------
6
-- UART Transmitter ---------------------------------------------------------
7
entity uart_tx is
8
        port (
9 41 ameziti
                clk      : in  std_ulogic;
10
                reset    : in  std_ulogic;
11 16 ameziti
                --
12 41 ameziti
                divisor  : in  std_ulogic_vector(15 downto 0);
13
                din      : in  std_ulogic_vector( 7 downto 0);
14
                wr       : in  std_ulogic;
15
                busy     : out std_ulogic;
16 16 ameziti
                --
17 41 ameziti
                txd      : out std_ulogic );
18 16 ameziti
end uart_tx;
19
 
20
 
21
-----------------------------------------------------------------------------
22
-- Implemenattion -----------------------------------------------------------
23
architecture rtl of uart_tx is
24
 
25
-- Signals
26
signal bitcount  : integer range 0 to 10;
27
signal count     : unsigned(15 downto 0);
28 41 ameziti
signal shiftreg  : std_ulogic_vector(7 downto 0);
29 16 ameziti
 
30
begin
31
 
32
proc: process(clk)
33
begin
34
        if clk'event and clk='1' then
35
                if reset='1' then
36
                        count    <= (others => '0');
37
                        bitcount <= 0;
38
                        busy     <= '0';
39
                        txd      <= '1';
40
                else
41
                        if count/=0 then
42
                                count <= count - 1;
43
                        else
44
                                if bitcount=0 then
45
                                        if wr='1' then          -- START BIT
46
                                                shiftreg <= din;
47
                                                busy     <= '1';
48
                                                txd      <= '0';
49
                                                bitcount <= bitcount + 1;
50
                                                count    <= unsigned(divisor);
51
                                        else
52
                                                busy <= '0';
53
                                        end if;
54
                                elsif bitcount=9 then      -- STOP BIT
55
                                        txd         <= '1';
56
                                        bitcount    <= 0;
57
                                        count       <= unsigned(divisor);
58
                                else                       -- DATA BIT
59
                                        shiftreg(6 downto 0) <= shiftreg(7 downto 1);
60
                                        txd         <= shiftreg(0);
61
                                        bitcount    <= bitcount + 1;
62
                                        count       <= unsigned(divisor);
63
                                end if;
64
                        end if;
65
                end if;
66
        end if;
67
end process;
68
 
69
end rtl;
70
 

powered by: WebSVN 2.1.0

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