-
Notifications
You must be signed in to change notification settings - Fork 3
/
uart.vhd
79 lines (77 loc) · 2.06 KB
/
uart.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
-- Universal Asynchronous Receiver / Transmitter
-- TODO(aray): they can probably share clock dividers
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity uart is
generic(
clock_freq_hz : integer;
baud_hz : integer
);
port(
clock : in std_logic;
rx_busy : out std_logic;
rx_enable : in std_logic;
rx_wire : in std_logic;
rx_data : out std_logic_vector( 7 downto 0);
tx_busy : out std_logic;
tx_enable : in std_logic;
tx_wire : out std_logic;
tx_data : in std_logic_vector( 7 downto 0)
);
end uart;
architecture uart_arch of uart is
component uart_rx
generic(
clock_freq_hz : integer;
baud_hz : integer
);
port(
clock : in std_logic;
busy : out std_logic;
enable : in std_logic;
wire : in std_logic;
data : out std_logic_vector( 7 downto 0)
);
end component;
component uart_tx
generic(
clock_freq_hz : integer;
baud_hz : integer
);
port(
clock : in std_logic;
busy : out std_logic;
enable : in std_logic;
wire : out std_logic;
data : in std_logic_vector( 7 downto 0)
);
end component;
begin
uart_rx_u0: uart_rx
generic map (
clock_freq_hz => clock_freq_hz,
baud_hz => baud_hz
)
port map (
clock => clock,
busy => rx_busy,
enable => rx_enable,
wire => rx_wire,
data => rx_data
)
;
uart_tx_u0: uart_tx
generic map (
clock_freq_hz => clock_freq_hz,
baud_hz => baud_hz
)
port map (
clock => clock,
busy => tx_busy,
enable => tx_enable,
wire => tx_wire,
data => tx_data
)
;
end architecture uart_arch;