copyleft: gplv3 added and set repo to public
[calu.git] / cpu / src / extension_uart_pkg.vhd
1 --   `Deep Thought', a softcore CPU implemented on a FPGA
2 --
3 --  Copyright (C) 2010 Markus Hofstaetter <markus.manrow@gmx.at>
4 --  Copyright (C) 2010 Martin Perner <e0725782@student.tuwien.ac.at>
5 --  Copyright (C) 2010 Stefan Rebernig <stefan.rebernig@gmail.com>
6 --  Copyright (C) 2010 Manfred Schwarz <e0725898@student.tuwien.ac.at>
7 --  Copyright (C) 2010 Bernhard Urban <lewurm@gmail.com>
8 --
9 --  This program is free software: you can redistribute it and/or modify
10 --  it under the terms of the GNU General Public License as published by
11 --  the Free Software Foundation, either version 3 of the License, or
12 --  (at your option) any later version.
13 --
14 --  This program is distributed in the hope that it will be useful,
15 --  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 --  GNU General Public License for more details.
18 --
19 --  You should have received a copy of the GNU General Public License
20 --  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22 library IEEE;
23
24 use IEEE.std_logic_1164.all;
25 use IEEE.numeric_std.all;
26
27 use work.common_pkg.all;
28 use work.extension_pkg.all;
29
30 package extension_uart_pkg is
31
32
33
34
35
36
37 --RS232
38 constant UART_WIDTH : integer := 8;
39 subtype uart_data is std_logic_vector(UART_WIDTH-1 downto 0);
40 constant BAUD_RATE_WIDTH : integer := 16;
41 subtype baud_rate_l is std_logic_vector(BAUD_RATE_WIDTH-1 downto 0);
42 --CLKs
43 --constant CLK_FREQ_MHZ : real := 33.33;
44 --constant BAUD_RATE : integer := 115200;
45 --constant CLK_PER_BAUD : integer := integer((CLK_FREQ_MHZ * 1000000.0) / real(BAUD_RATE) - 0.5);
46 -- constant CLK_PER_BAUD : integer := 434;
47 -- constant CLK_PER_BAUD : integer := 2083; -- @uni, bei 20MHz und 9600 Baud
48 -- constant CLK_PER_BAUD : integer := 50; -- @modelsim
49
50  component extension_uart is
51         --some modules won't need all inputs/outputs
52         generic (
53                         -- active reset value
54                         RESET_VALUE : std_logic;
55                         CLK_PER_BAUD : integer
56                         );
57         port(
58                 --System inputs
59                         clk :   in std_logic;
60                         reset : in std_logic;
61                 -- general extension interface                  
62                         ext_reg  : in extmod_rec;
63                         data_out : out gp_register_t;
64
65                         uart_int : out std_logic;
66                 -- Input
67                         bus_rx : in std_logic;
68                 -- Ouput
69                         bus_tx : out std_logic
70                 );
71  end component extension_uart;
72
73 component rs232_tx is
74         generic (
75                 -- active reset value
76                 RESET_VALUE : std_logic
77                 );
78
79         port(
80                 --System inputs
81                 sys_clk : in std_logic;
82                 sys_res_n : in std_logic;
83
84                 --Bus
85                 bus_tx : out std_logic;
86
87                 --From/to sendlogic
88                 new_tx_data : in std_logic;
89                 tx_data : in uart_data;
90                 tx_rdy : out std_logic;
91                 bd_rate : in baud_rate_l;
92                 stop_bit : in std_logic 
93 );
94 end component rs232_tx;
95
96 component rs232_rx is
97         generic (
98                 -- active reset value
99                 RESET_VALUE : std_logic;
100                 SYNC_STAGES : integer range 2 to integer'high
101                 );
102
103         port(
104                 --System inputs
105                 sys_clk : in std_logic;
106                 sys_res_n : in std_logic;
107
108                 --Bus
109                 bus_rx_unsync : in std_logic;
110
111                 --To sendlogic
112                 new_rx_data : out std_logic;
113                 rx_data : out uart_data;
114                 bd_rate : in baud_rate_l
115         );
116 end component rs232_rx;
117
118
119
120 end package extension_uart_pkg;