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

Subversion Repositories cpu_lecture

[/] [cpu_lecture/] [trunk/] [src/] [uart_tx.vhd] - Blame information for rev 25

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jsauermann
-------------------------------------------------------------------------------
2
-- 
3
-- Copyright (C) 2009, 2010 Dr. Juergen Sauermann
4
-- 
5
--  This code is free software: you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation, either version 3 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This code is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this code (see the file named COPYING).
17
--  If not, see http://www.gnu.org/licenses/.
18
--
19
-------------------------------------------------------------------------------
20
-------------------------------------------------------------------------------
21
--
22
-- Module Name:    uart_tx - Behavioral 
23
-- Create Date:    14:21:59 11/07/2009 
24
-- Description:    a UART receiver.
25
--
26
-------------------------------------------------------------------------------
27
--
28
library IEEE;
29
use IEEE.STD_LOGIC_1164.ALL;
30
use IEEE.STD_LOGIC_ARITH.ALL;
31
use IEEE.STD_LOGIC_UNSIGNED.ALL;
32
 
33
entity uart_tx is
34
    port(   I_CLK       : in  std_logic;
35
            I_CLR       : in  std_logic;            -- RESET
36
            I_CE_1      : in  std_logic;            -- BAUD rate clock enable
37 25 jsauermann
            I_DATA      : in  std_logic_vector(7 downto 0);   -- DATA to send
38 2 jsauermann
            I_FLAG      : in  std_logic;            -- toggle to send data
39 25 jsauermann
            Q_TX_N      : out std_logic;            -- Serial output, active low
40
            Q_BUSY      : out std_logic);           -- Transmitter busy
41 2 jsauermann
end uart_tx;
42
 
43
architecture Behavioral of uart_tx is
44
 
45 25 jsauermann
signal L_BUF            : std_logic_vector(8 downto 0);
46
signal L_FLAG           : std_logic;
47 2 jsauermann
signal L_TODO           : std_logic_vector(3 downto 0);     -- bits to send
48
 
49
begin
50
 
51
    process(I_CLK)
52
    begin
53
        if (rising_edge(I_CLK)) then
54 25 jsauermann
            if (I_CLR = '1') then               -- reset
55
                Q_TX_N <= '1';
56
                L_BUF  <= "111111111";
57 2 jsauermann
                L_TODO <= "0000";
58 25 jsauermann
                L_FLAG <= I_FLAG;
59
            elsif (L_TODO = "0000") then        -- idle
60
                if (L_FLAG /= I_FLAG) then      -- new byte
61
                    L_BUF <= I_DATA & '0';      -- 8 data / 1 start
62
                    L_TODO <= "1100";           -- 11 bits to send
63
                    L_FLAG <= I_FLAG;
64
                end if;
65
            else                                -- shifting
66
                if (I_CE_1 = '1') then
67
                    Q_TX_N <= L_BUF(0);
68
                    L_BUF <= '1' & L_BUF(8 downto 1);
69 2 jsauermann
                    L_TODO <= L_TODO - "0001";
70
                end if;
71
            end if;
72
        end if;
73
    end process;
74
 
75 25 jsauermann
    Q_BUSY <= '0' when (L_TODO = "0000") else '1';
76 2 jsauermann
 
77
end Behavioral;
78 25 jsauermann
 

powered by: WebSVN 2.1.0

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