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

Subversion Repositories cpu_lecture

[/] [cpu_lecture/] [trunk/] [html/] [27_Listing_of_uart_tx.vhd.html] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jsauermann
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
3
<HTML>
4
<HEAD>
5
<TITLE>html/Listing_of_uart_tx.vhd</TITLE>
6
<META NAME="generator" CONTENT="HTML::TextToHTML v2.46">
7
<LINK REL="stylesheet" TYPE="text/css" HREF="lecture.css">
8
</HEAD>
9
<BODY>
10
<P><table class="ttop"><th class="tpre"><a href="26_Listing_of_uart_rx.vhd.html">Previous Lesson</a></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="28_Listing_of_RAMB4_S4_S4.vhd.html">Next Lesson</a></th></table>
11
<hr>
12
 
13
<H1><A NAME="section_1">27 LISTING OF uart_tx.vhd</A></H1>
14
 
15
<pre class="vhdl">
16
 
17
  1     -------------------------------------------------------------------------------
18
  2     --
19
  3     -- Copyright (C) 2009, 2010 Dr. Juergen Sauermann
20
  4     --
21
  5     --  This code is free software: you can redistribute it and/or modify
22
  6     --  it under the terms of the GNU General Public License as published by
23
  7     --  the Free Software Foundation, either version 3 of the License, or
24
  8     --  (at your option) any later version.
25
  9     --
26
 10     --  This code is distributed in the hope that it will be useful,
27
 11     --  but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 12     --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 13     --  GNU General Public License for more details.
30
 14     --
31
 15     --  You should have received a copy of the GNU General Public License
32
 16     --  along with this code (see the file named COPYING).
33
 17     --  If not, see http://www.gnu.org/licenses/.
34
 18     --
35
 19     -------------------------------------------------------------------------------
36
 20     -------------------------------------------------------------------------------
37
 21     --
38
 22     -- Module Name:    uart_tx - Behavioral
39
 23     -- Create Date:    14:21:59 11/07/2009
40
 24     -- Description:    a UART receiver.
41
 25     --
42
 26     -------------------------------------------------------------------------------
43
 27     --
44
 28     library IEEE;
45
 29     use IEEE.STD_LOGIC_1164.ALL;
46
 30     use IEEE.STD_LOGIC_ARITH.ALL;
47
 31     use IEEE.STD_LOGIC_UNSIGNED.ALL;
48
 32
49
 33     entity uart_tx is
50
 34         port(   I_CLK       : in  std_logic;
51
 35                 I_CLR       : in  std_logic;            -- RESET
52
 36                 I_CE_1      : in  std_logic;            -- BAUD rate clock enable
53
 37                 I_DATA      : in  std_logic_vector(7 downto 0);   -- DATA to be sent
54
 38                 I_FLAG      : in  std_logic;            -- toggle to send data
55
 39                 Q_TX        : out std_logic;            -- Serial output line
56
 40                 Q_FLAG      : out std_logic);           -- Transmitting Flag
57
 41     end uart_tx;
58
 42
59
 43     architecture Behavioral of uart_tx is
60
 44
61
 45     signal L_BUF            : std_logic_vector(7 downto 0);
62
 46     signal L_TODO           : std_logic_vector(3 downto 0);     -- bits to send
63
 47     signal L_FLAG           : std_logic;
64
 48
65
 49     begin
66
 50
67
 51         process(I_CLK)
68
 52         begin
69
 53             if (rising_edge(I_CLK)) then
70
 54                 if (I_CLR = '1') then
71
 55                     Q_TX   <= '1';
72
 56                     L_BUF  <= "11111111";
73
 57                     L_TODO <= "0000";
74
 58                     L_FLAG <= I_FLAG;                   -- idle
75
 59                 elsif (I_CE_1 = '1') then
76
 60                     if (L_TODO /= "0000") then          -- transmitting
77
 61                         Q_TX <= L_BUF(0);               -- next bit
78
 62                         L_BUF     <= '1' & L_BUF(7 downto 1);
79
 63                         if (L_TODO = "0001") then
80
 64                             L_FLAG <= I_FLAG;
81
 65                         end if;
82
 66                         L_TODO <= L_TODO - "0001";
83
 67                     elsif (L_FLAG /= I_FLAG) then       -- new byte
84
 68                         Q_TX <= '0';                    -- start bit
85
 69                         L_BUF <= I_DATA;                -- data bits
86
 70                         L_TODO <= "1001";
87
 71                     end if;
88
 72                 end if;
89
 73             end if;
90
 74         end process;
91
 75
92
 76         Q_FLAG <= L_FLAG;
93
 77
94
 78     end Behavioral;
95
 79
96
<pre class="filename">
97
src/uart_tx.vhd
98
</pre></pre>
99
<P>
100
 
101
<P><hr><BR>
102
<table class="ttop"><th class="tpre"><a href="26_Listing_of_uart_rx.vhd.html">Previous Lesson</a></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="28_Listing_of_RAMB4_S4_S4.vhd.html">Next Lesson</a></th></table>
103
</BODY>
104
</HTML>

powered by: WebSVN 2.1.0

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