-
Notifications
You must be signed in to change notification settings - Fork 3
/
top.vhd
189 lines (185 loc) · 5.4 KB
/
top.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
-- hello_de0-nano - top entity, contains hello
library ieee;
use ieee.std_logic_1164.all;
entity top is
port(
CLOCK_50 : in std_logic;
LED : out std_logic_vector( 7 downto 0 );
GPIO_0 : inout std_logic_vector( 33 downto 0 ) := (others => 'Z')
);
end top;
architecture arch of top is
signal tx_busy : std_logic;
signal tx_enable : std_logic;
signal tx_wire : std_logic;
signal tx_data : std_logic_vector(7 downto 0);
signal rx_reset : std_logic;
signal rx_wire : std_logic;
signal rx_busy : std_logic;
signal rx_valid : std_logic;
signal rx_data : std_logic_vector(7 downto 0);
signal spi_enable : std_logic;
signal spi_reset : std_logic;
signal spi_busy : std_logic;
signal spi_done : std_logic;
signal spi_master_tx : std_logic_vector(7 downto 0);
signal spi_master_rx : std_logic_vector(7 downto 0);
signal spi_slave_tx : std_logic_vector(7 downto 0);
signal spi_slave_rx : std_logic_vector(7 downto 0);
signal spi_sclk : std_logic;
signal spi_mosi : std_logic;
signal spi_miso : std_logic;
signal spi_ss_l : std_logic;
component hello
generic(
clock_freq_hz : integer;
tick_freq_hz : integer
);
port(
clock : in std_logic;
led : out std_logic_vector( 7 downto 0 );
tick : out std_logic
);
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;
component uart_rx
generic(
clock_freq_hz : integer;
baud_hz : integer
);
port(
clock : in std_logic;
reset : in std_logic;
wire : in std_logic;
busy : out std_logic;
valid : out std_logic;
data : out std_logic_vector(7 downto 0)
);
end component;
component spi_master
generic(
fpga_clk_freq_hz : integer;
sclk_freq_hz : integer;
cpol : std_logic;
cpha : std_logic
);
port(
fpga_clock : in std_logic;
enable : in std_logic;
reset : in std_logic;
busy : out std_logic;
done : out std_logic;
data_tx : in std_logic_vector(7 downto 0);
data_rx : out std_logic_vector(7 downto 0);
sclk : out std_logic;
mosi : out std_logic;
miso : in std_logic;
ss_l : out std_logic
);
end component;
component spi_slave
generic(
cpol : std_logic;
cpha : std_logic
);
port(
done : out std_logic;
data_tx : in std_logic_vector(7 downto 0);
data_rx : out std_logic_vector(7 downto 0);
sclk : in std_logic;
mosi : in std_logic;
miso : out std_logic;
ss_l : in std_logic
);
end component;
begin
GPIO_0(0) <= tx_wire;
GPIO_0(1) <= rx_wire;
LED <= tx_data;
hello_u0: hello
generic map (
clock_freq_hz => 50000000,
tick_freq_hz => 10
)
port map (
clock => CLOCK_50,
led => tx_data,
tick => tx_enable
)
;
uart_tx_u0: uart_tx
generic map (
clock_freq_hz => 50000000,
baud_hz => 9600
)
port map (
clock => CLOCK_50,
busy => tx_busy,
enable => tx_enable,
wire => tx_wire,
data => tx_data
)
;
uart_rx_u0: uart_rx
generic map (
clock_freq_hz => 50000000,
baud_hz => 9600
)
port map (
clock => CLOCK_50,
reset => rx_reset,
wire => rx_wire,
busy => rx_busy,
valid => rx_valid,
data => rx_data
)
;
spi_master_u0: spi_master
generic map (
fpga_clk_freq_hz => 50000000,
sclk_freq_hz => 1000000,
cpol => '0',
cpha => '0'
)
port map (
fpga_clock => CLOCK_50,
enable => spi_enable,
reset => spi_reset,
busy => spi_busy,
done => spi_done,
data_tx => spi_master_tx,
data_rx => spi_master_rx,
sclk => spi_sclk,
mosi => spi_mosi,
miso => spi_miso,
ss_l => spi_ss_l
)
;
spi_slave_u0: spi_slave
generic map (
cpol => '0',
cpha => '0'
)
port map (
done => spi_done,
data_tx => spi_slave_tx,
data_rx => spi_slave_rx,
sclk => spi_sclk,
mosi => spi_mosi,
miso => spi_miso,
ss_l => spi_ss_l
)
;
end architecture;