1bbe2b892096fd4404a5bafa13dec520f989e659
[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 -- constant CLK_PER_BAUD : integer := 50; -- @modelsim
28
29  component extension_uart is
30         --some modules won't need all inputs/outputs
31         generic (
32                         -- active reset value
33                         RESET_VALUE : std_logic;
34                         CLK_PER_BAUD : integer
35                         );
36         port(
37                 --System inputs
38                         clk :   in std_logic;
39                         reset : in std_logic;
40                 -- general extension interface                  
41                         ext_reg  : in extmod_rec;
42                         data_out : out gp_register_t;
43
44                         uart_int : out std_logic;
45                 -- Input
46                         bus_rx : in std_logic;
47                 -- Ouput
48                         bus_tx : out std_logic
49                 );
50  end component extension_uart;
51
52 component rs232_tx is
53         generic (
54                 -- active reset value
55                 RESET_VALUE : std_logic
56                 );
57
58         port(
59                 --System inputs
60                 sys_clk : in std_logic;
61                 sys_res_n : in std_logic;
62
63                 --Bus
64                 bus_tx : out std_logic;
65
66                 --From/to sendlogic
67                 new_tx_data : in std_logic;
68                 tx_data : in uart_data;
69                 tx_rdy : out std_logic;
70                 bd_rate : in baud_rate_l;
71                 stop_bit : in std_logic 
72 );
73 end component rs232_tx;
74
75 component rs232_rx is
76         generic (
77                 -- active reset value
78                 RESET_VALUE : std_logic;
79                 SYNC_STAGES : integer range 2 to integer'high
80                 );
81
82         port(
83                 --System inputs
84                 sys_clk : in std_logic;
85                 sys_res_n : in std_logic;
86
87                 --Bus
88                 bus_rx_unsync : in std_logic;
89
90                 --To sendlogic
91                 new_rx_data : out std_logic;
92                 rx_data : out uart_data;
93                 bd_rate : in baud_rate_l
94         );
95 end component rs232_rx;
96
97
98
99 end package extension_uart_pkg;