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