9a2a52f3dd4a4aac5b3a8f12c0e4235014b876d9
[calu.git] / cpu / src / extension_uart_pkg.vhd
1 library IEEE;
2
3 use IEEE.std_logic_1164.all;
4 use IEEE.numeric_std.all;
5
6 use work.common_pkg.all;
7 use work.extension_pkg.all;
8
9 package extension_uart_pkg is
10
11
12
13
14
15
16 --RS232
17 constant UART_WIDTH : integer := 8;
18 subtype uart_data is std_logic_vector(UART_WIDTH-1 downto 0);
19 constant BAUD_RATE_WIDTH : integer := 16;
20 subtype baud_rate_l is std_logic_vector(BAUD_RATE_WIDTH-1 downto 0);
21 --CLKs
22 --constant CLK_FREQ_MHZ : real := 33.33;
23 --constant BAUD_RATE : integer := 115200;
24 --constant CLK_PER_BAUD : integer := integer((CLK_FREQ_MHZ * 1000000.0) / real(BAUD_RATE) - 0.5);
25 -- constant CLK_PER_BAUD : integer := 434;
26 constant CLK_PER_BAUD : integer := 2083; -- @uni, bei 20MHz und 9600 Baud
27
28  component extension_uart is
29         --some modules won't need all inputs/outputs
30         generic (
31                         -- active reset value
32                         RESET_VALUE : std_logic
33                         );
34         port(
35                 --System inputs
36                         clk :   in std_logic;
37                         reset : in std_logic;
38                 -- general extension interface                  
39                         ext_reg  : in extmod_rec;
40                         data_out : out gp_register_t;
41
42                         uart_int : out std_logic;
43                 -- Input
44                         bus_rx : in std_logic;
45                 -- Ouput
46                         bus_tx : out std_logic
47                 );
48  end component extension_uart;
49
50 component rs232_tx is
51         generic (
52                 -- active reset value
53                 RESET_VALUE : std_logic
54                 );
55
56         port(
57                 --System inputs
58                 sys_clk : in std_logic;
59                 sys_res_n : in std_logic;
60
61                 --Bus
62                 bus_tx : out std_logic;
63
64                 --From/to sendlogic
65                 new_tx_data : in std_logic;
66                 tx_data : in uart_data;
67                 tx_rdy : out std_logic;
68                 bd_rate : in baud_rate_l;
69                 stop_bit : in std_logic 
70 );
71 end component rs232_tx;
72
73 component rs232_rx is
74         generic (
75                 -- active reset value
76                 RESET_VALUE : std_logic;
77                 SYNC_STAGES : integer range 2 to integer'high
78                 );
79
80         port(
81                 --System inputs
82                 sys_clk : in std_logic;
83                 sys_res_n : in std_logic;
84
85                 --Bus
86                 bus_rx_unsync : in std_logic;
87
88                 --To sendlogic
89                 new_rx_data : out std_logic;
90                 rx_data : out uart_data;
91                 bd_rate : in baud_rate_l
92         );
93 end component rs232_rx;
94
95
96
97 end package extension_uart_pkg;