1 |
145 |
lanttu |
-------------------------------------------------
|
2 |
|
|
-- file: ring.vhd
|
3 |
|
|
-- Designer: Jussi Nieminen, 11.02.2009,
|
4 |
|
|
-- modification of Erno Salminen's Octagon
|
5 |
|
|
-- Antti Alhonen, 01.07.2009,
|
6 |
|
|
-- added monitoring
|
7 |
|
|
-- Description: An n-node Ring network
|
8 |
|
|
--
|
9 |
|
|
--
|
10 |
|
|
-- Modified :
|
11 |
|
|
-- 01.07.2009 Added monitoring.
|
12 |
|
|
-- 11.02.2009 Forked from the Octacon ver. 04
|
13 |
|
|
--
|
14 |
|
|
--
|
15 |
|
|
--
|
16 |
|
|
-------------------------------------------------
|
17 |
|
|
library ieee;
|
18 |
|
|
use ieee.std_logic_1164.all;
|
19 |
|
|
use ieee.std_logic_arith.all;
|
20 |
|
|
|
21 |
|
|
use work.mon_pkg.all;
|
22 |
|
|
|
23 |
|
|
entity ring_with_monitor is
|
24 |
|
|
|
25 |
|
|
generic (
|
26 |
|
|
nbr_of_routers_g : integer := 8;
|
27 |
|
|
diag_en_g : integer := 0;
|
28 |
|
|
data_width_g : integer := 32;
|
29 |
|
|
stfwd_en_g : integer;
|
30 |
|
|
pkt_len_g : integer;
|
31 |
|
|
len_flit_en_g : integer := 0;
|
32 |
|
|
oaddr_flit_en_g : integer := 0;
|
33 |
|
|
fifo_depth_g : integer;
|
34 |
|
|
net_freq_g : integer;
|
35 |
|
|
ip_freq_g : integer
|
36 |
|
|
);
|
37 |
|
|
port (
|
38 |
|
|
clk_net : in std_logic;
|
39 |
|
|
clk_ip : in std_logic;
|
40 |
|
|
rst_n : in std_logic;
|
41 |
|
|
tx_data_in : in std_logic_vector( nbr_of_routers_g * data_width_g-1 downto 0 );
|
42 |
|
|
tx_we_in : in std_logic_vector ( nbr_of_routers_g - 1 downto 0 );
|
43 |
|
|
tx_empty_out : out std_logic_vector ( nbr_of_routers_g - 1 downto 0 );
|
44 |
|
|
tx_full_out : out std_logic_vector ( nbr_of_routers_g - 1 downto 0 );
|
45 |
|
|
|
46 |
|
|
rx_data_out : out std_logic_vector( nbr_of_routers_g*data_width_g-1 downto 0 );
|
47 |
|
|
rx_re_in : in std_logic_vector (nbr_of_routers_g-1 downto 0);
|
48 |
|
|
rx_empty_out : out std_logic_vector (nbr_of_routers_g-1 downto 0);
|
49 |
|
|
rx_full_out : out std_logic_vector (nbr_of_routers_g-1 downto 0);
|
50 |
|
|
|
51 |
|
|
-- MONITOR SIGNALS (AA)
|
52 |
|
|
mon_UART_rx_in : in std_logic;
|
53 |
|
|
mon_UART_tx_out : out std_logic;
|
54 |
|
|
mon_command_in : in std_logic_vector(mon_command_width_c-1 downto 0)
|
55 |
|
|
);
|
56 |
|
|
|
57 |
|
|
end ring_with_monitor;
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
architecture structural of ring_with_monitor is
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
type data_arr_type is array (nbr_of_routers_g-1 downto 0) of std_logic_vector (data_width_g-1 downto 0);
|
64 |
|
|
|
65 |
|
|
signal fwd_data : data_arr_type;
|
66 |
|
|
signal fwd_re : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
67 |
|
|
signal fwd_empty : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
68 |
|
|
signal fwd_full : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
69 |
|
|
|
70 |
|
|
signal diag_data : data_arr_type;
|
71 |
|
|
signal diag_re : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
72 |
|
|
signal diag_empty : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
73 |
|
|
signal diag_full : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
74 |
|
|
|
75 |
|
|
signal rev_data : data_arr_type;
|
76 |
|
|
signal rev_re : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
77 |
|
|
signal rev_empty : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
78 |
|
|
signal rev_full : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
79 |
|
|
|
80 |
|
|
signal tx_data_dbg : data_arr_type;
|
81 |
|
|
signal rx_data_arr : data_arr_type;
|
82 |
|
|
|
83 |
|
|
component ring_router
|
84 |
|
|
|
85 |
|
|
generic (
|
86 |
|
|
nbr_of_routers_g : integer := 8;
|
87 |
|
|
data_width_g : integer := 0;
|
88 |
|
|
dateline_en_g : integer := 0;
|
89 |
|
|
stfwd_en_g : integer;
|
90 |
|
|
pkt_len_g : integer;
|
91 |
|
|
len_flit_en_g : integer := 0;
|
92 |
|
|
oaddr_flit_en_g : integer := 0;
|
93 |
|
|
fifo_depth_g : integer;
|
94 |
|
|
router_id_g : integer := 0;
|
95 |
|
|
diag_en_g : integer := 1;
|
96 |
|
|
net_freq_g : integer;
|
97 |
|
|
ip_freq_g : integer
|
98 |
|
|
);
|
99 |
|
|
port (
|
100 |
|
|
clk_net : in std_logic;
|
101 |
|
|
clk_ip : in std_logic;
|
102 |
|
|
rst_n : in std_logic;
|
103 |
|
|
|
104 |
|
|
data_fwd_in : in std_logic_vector ( data_width_g-1 downto 0);
|
105 |
|
|
re_fwd_out : out std_logic;
|
106 |
|
|
empty_fwd_in : in std_logic;
|
107 |
|
|
full_fwd_in : in std_logic;
|
108 |
|
|
|
109 |
|
|
data_rev_in : in std_logic_vector ( data_width_g-1 downto 0);
|
110 |
|
|
re_rev_out : out std_logic;
|
111 |
|
|
empty_rev_in : in std_logic;
|
112 |
|
|
full_rev_in : in std_logic;
|
113 |
|
|
|
114 |
|
|
data_diag_in : in std_logic_vector ( data_width_g-1 downto 0);
|
115 |
|
|
re_diag_out : out std_logic;
|
116 |
|
|
empty_diag_in : in std_logic;
|
117 |
|
|
full_diag_in : in std_logic;
|
118 |
|
|
|
119 |
|
|
data_ip_tx_in : in std_logic_vector ( data_width_g-1 downto 0);
|
120 |
|
|
we_ip_tx_in : in std_logic;
|
121 |
|
|
empty_ip_tx_out : out std_logic;
|
122 |
|
|
full_ip_tx_out : out std_logic;
|
123 |
|
|
|
124 |
|
|
data_fwd_out : out std_logic_vector ( data_width_g-1 downto 0);
|
125 |
|
|
re_fwd_in : in std_logic;
|
126 |
|
|
empty_fwd_out : out std_logic;
|
127 |
|
|
full_fwd_out : out std_logic;
|
128 |
|
|
|
129 |
|
|
data_rev_out : out std_logic_vector ( data_width_g-1 downto 0);
|
130 |
|
|
re_rev_in : in std_logic;
|
131 |
|
|
empty_rev_out : out std_logic;
|
132 |
|
|
full_rev_out : out std_logic;
|
133 |
|
|
|
134 |
|
|
data_diag_out : out std_logic_vector ( data_width_g-1 downto 0);
|
135 |
|
|
re_diag_in : in std_logic;
|
136 |
|
|
empty_diag_out : out std_logic;
|
137 |
|
|
full_diag_out : out std_logic;
|
138 |
|
|
|
139 |
|
|
data_ip_rx_out : out std_logic_vector ( data_width_g-1 downto 0);
|
140 |
|
|
re_ip_rx_in : in std_logic;
|
141 |
|
|
full_ip_rx_out : out std_logic;
|
142 |
|
|
empty_ip_rx_out : out std_logic
|
143 |
|
|
);
|
144 |
|
|
|
145 |
|
|
end component; --ring_router;
|
146 |
|
|
|
147 |
|
|
component monitor_top
|
148 |
|
|
generic (
|
149 |
|
|
num_of_links_g : integer);
|
150 |
|
|
port (
|
151 |
|
|
emptys_in : in std_logic_vector(num_of_links_g-1 downto 0);
|
152 |
|
|
res_in : in std_logic_vector(num_of_links_g-1 downto 0);
|
153 |
|
|
uart_rx_in : in std_logic;
|
154 |
|
|
uart_tx_out : out std_logic;
|
155 |
|
|
clk : in std_logic;
|
156 |
|
|
rst_n : in std_logic;
|
157 |
|
|
mon_command_in : in std_logic_vector(mon_command_width_c-1 downto 0));
|
158 |
|
|
end component;
|
159 |
|
|
|
160 |
|
|
constant num_of_links_c : integer := (diag_en_g + 2) * nbr_of_routers_g;
|
161 |
|
|
|
162 |
|
|
signal emptys_to_mon : std_logic_vector(num_of_links_c-1 downto 0);
|
163 |
|
|
signal res_to_mon : std_logic_vector(num_of_links_c-1 downto 0);
|
164 |
|
|
|
165 |
|
|
begin -- structural
|
166 |
|
|
|
167 |
|
|
map_dbg_arr : for i in 0 to nbr_of_routers_g-1 generate
|
168 |
|
|
tx_data_dbg (i) <= tx_data_in ((i+1)*data_width_g-1 downto i*data_width_g);
|
169 |
|
|
|
170 |
|
|
rx_data_out ((i+1)*data_width_g-1 downto i*data_width_g) <= rx_data_arr (i);
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
end generate map_dbg_arr;
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
-- data defines which index is used
|
177 |
|
|
-- r port signal
|
178 |
|
|
-- ---------------------
|
179 |
|
|
-- 0: data_out => data(0)
|
180 |
|
|
-- 0: re_in => re(0)
|
181 |
|
|
-- 0: empty_out => empty(0)
|
182 |
|
|
-- 1: data_in => data(0)
|
183 |
|
|
-- 1: re_out => re(0)
|
184 |
|
|
-- 1: empty_in => empty(0)
|
185 |
|
|
|
186 |
|
|
map_routers : for r in 1 to nbr_of_routers_g-1 generate
|
187 |
|
|
router : ring_router
|
188 |
|
|
generic map (
|
189 |
|
|
nbr_of_routers_g => nbr_of_routers_g,
|
190 |
|
|
data_width_g => data_width_g,
|
191 |
|
|
dateline_en_g => 0,
|
192 |
|
|
stfwd_en_g => stfwd_en_g,
|
193 |
|
|
pkt_len_g => pkt_len_g,
|
194 |
|
|
len_flit_en_g => len_flit_en_g,
|
195 |
|
|
oaddr_flit_en_g => oaddr_flit_en_g,
|
196 |
|
|
fifo_depth_g => fifo_depth_g,
|
197 |
|
|
router_id_g => r,
|
198 |
|
|
diag_en_g => diag_en_g,
|
199 |
|
|
net_freq_g => net_freq_g,
|
200 |
|
|
ip_freq_g => ip_freq_g
|
201 |
|
|
)
|
202 |
|
|
port map (
|
203 |
|
|
clk_net => clk_net,
|
204 |
|
|
clk_ip => clk_ip,
|
205 |
|
|
rst_n => rst_n,
|
206 |
|
|
|
207 |
|
|
data_ip_tx_in => tx_data_in ( (r+1)*data_width_g-1 downto r*data_width_g ),
|
208 |
|
|
we_ip_tx_in => tx_we_in (r),
|
209 |
|
|
full_ip_tx_out => tx_full_out (r),
|
210 |
|
|
empty_ip_tx_out => tx_empty_out (r),
|
211 |
|
|
|
212 |
|
|
data_fwd_in => fwd_data (r-1),
|
213 |
|
|
re_fwd_out => fwd_re (r-1),
|
214 |
|
|
empty_fwd_in => fwd_empty (r-1),
|
215 |
|
|
full_fwd_in => fwd_full (r-1),
|
216 |
|
|
|
217 |
|
|
data_fwd_out => fwd_data (r),
|
218 |
|
|
re_fwd_in => fwd_re (r),
|
219 |
|
|
empty_fwd_out => fwd_empty (r),
|
220 |
|
|
full_fwd_out => fwd_full (r),
|
221 |
|
|
|
222 |
|
|
data_rev_in => rev_data ( (r+1) mod nbr_of_routers_g ),
|
223 |
|
|
re_rev_out => rev_re ( (r+1) mod nbr_of_routers_g ),
|
224 |
|
|
empty_rev_in => rev_empty ( (r+1) mod nbr_of_routers_g ),
|
225 |
|
|
full_rev_in => rev_full ( (r+1) mod nbr_of_routers_g ),
|
226 |
|
|
|
227 |
|
|
data_rev_out => rev_data (r),
|
228 |
|
|
re_rev_in => rev_re (r),
|
229 |
|
|
empty_rev_out => rev_empty (r),
|
230 |
|
|
full_rev_out => rev_full (r),
|
231 |
|
|
|
232 |
|
|
--FIXME, this only works with rings of size 2*k, k E N
|
233 |
|
|
data_diag_in => diag_data (( r - nbr_of_routers_g / 2 ) mod nbr_of_routers_g),
|
234 |
|
|
re_diag_out => diag_re (( r - nbr_of_routers_g / 2 ) mod nbr_of_routers_g),
|
235 |
|
|
empty_diag_in => diag_empty (( r - nbr_of_routers_g / 2 ) mod nbr_of_routers_g),
|
236 |
|
|
full_diag_in => diag_full (( r - nbr_of_routers_g / 2 ) mod nbr_of_routers_g),
|
237 |
|
|
|
238 |
|
|
data_diag_out => diag_data (r),
|
239 |
|
|
re_diag_in => diag_re (r),
|
240 |
|
|
empty_diag_out => diag_empty (r),
|
241 |
|
|
full_diag_out => diag_full (r),
|
242 |
|
|
|
243 |
|
|
data_ip_rx_out => rx_data_arr (r),
|
244 |
|
|
re_ip_rx_in => rx_re_in (r),
|
245 |
|
|
full_ip_rx_out => rx_full_out (r),
|
246 |
|
|
empty_ip_rx_out => rx_empty_out (r)
|
247 |
|
|
);
|
248 |
|
|
|
249 |
|
|
end generate map_routers;
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
first_router : ring_router
|
253 |
|
|
generic map (
|
254 |
|
|
nbr_of_routers_g => nbr_of_routers_g,
|
255 |
|
|
data_width_g => data_width_g,
|
256 |
|
|
dateline_en_g => 1,
|
257 |
|
|
pkt_len_g => pkt_len_g,
|
258 |
|
|
len_flit_en_g => len_flit_en_g,
|
259 |
|
|
oaddr_flit_en_g => oaddr_flit_en_g,
|
260 |
|
|
stfwd_en_g => stfwd_en_g,
|
261 |
|
|
fifo_depth_g => fifo_depth_g,
|
262 |
|
|
router_id_g => 0,
|
263 |
|
|
diag_en_g => diag_en_g,
|
264 |
|
|
net_freq_g => net_freq_g,
|
265 |
|
|
ip_freq_g => ip_freq_g
|
266 |
|
|
)
|
267 |
|
|
port map (
|
268 |
|
|
clk_net => clk_net,
|
269 |
|
|
clk_ip => clk_ip,
|
270 |
|
|
rst_n => rst_n,
|
271 |
|
|
|
272 |
|
|
data_ip_tx_in => tx_data_in ( data_width_g-1 downto 0 ),
|
273 |
|
|
we_ip_tx_in => tx_we_in (0),
|
274 |
|
|
full_ip_tx_out => tx_full_out (0),
|
275 |
|
|
empty_ip_tx_out => tx_empty_out (0),
|
276 |
|
|
|
277 |
|
|
data_fwd_in => fwd_data ( nbr_of_routers_g - 1 ),
|
278 |
|
|
re_fwd_out => fwd_re ( nbr_of_routers_g - 1 ),
|
279 |
|
|
empty_fwd_in => fwd_empty ( nbr_of_routers_g - 1 ),
|
280 |
|
|
full_fwd_in => fwd_full ( nbr_of_routers_g - 1 ),
|
281 |
|
|
|
282 |
|
|
data_fwd_out => fwd_data (0),
|
283 |
|
|
re_fwd_in => fwd_re (0),
|
284 |
|
|
empty_fwd_out => fwd_empty (0),
|
285 |
|
|
full_fwd_out => fwd_full (0),
|
286 |
|
|
|
287 |
|
|
data_rev_in => rev_data (1),
|
288 |
|
|
re_rev_out => rev_re (1),
|
289 |
|
|
empty_rev_in => rev_empty (1),
|
290 |
|
|
full_rev_in => rev_full (1),
|
291 |
|
|
|
292 |
|
|
data_rev_out => rev_data (0),
|
293 |
|
|
re_rev_in => rev_re (0),
|
294 |
|
|
empty_rev_out => rev_empty (0),
|
295 |
|
|
full_rev_out => rev_full (0),
|
296 |
|
|
|
297 |
|
|
data_diag_in => diag_data ( nbr_of_routers_g / 2 ),
|
298 |
|
|
re_diag_out => diag_re ( nbr_of_routers_g / 2 ),
|
299 |
|
|
empty_diag_in => diag_empty ( nbr_of_routers_g / 2 ),
|
300 |
|
|
full_diag_in => diag_full ( nbr_of_routers_g / 2 ),
|
301 |
|
|
|
302 |
|
|
data_diag_out => diag_data (0),
|
303 |
|
|
re_diag_in => diag_re (0),
|
304 |
|
|
empty_diag_out => diag_empty (0),
|
305 |
|
|
full_diag_out => diag_full (0),
|
306 |
|
|
|
307 |
|
|
|
308 |
|
|
data_ip_rx_out => rx_data_arr (0),
|
309 |
|
|
re_ip_rx_in => rx_re_in (0),
|
310 |
|
|
full_ip_rx_out => rx_full_out (0),
|
311 |
|
|
empty_ip_rx_out => rx_empty_out (0)
|
312 |
|
|
);
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
-- First forwards, then backwards, last diagonals.
|
316 |
|
|
emptys_to_mon(nbr_of_routers_g-1 downto
|
317 |
|
|
0) <= fwd_empty;
|
318 |
|
|
emptys_to_mon(nbr_of_routers_g*2-1 downto
|
319 |
|
|
nbr_of_routers_g) <= rev_empty;
|
320 |
|
|
|
321 |
|
|
res_to_mon(nbr_of_routers_g-1 downto
|
322 |
|
|
0) <= fwd_re;
|
323 |
|
|
res_to_mon(nbr_of_routers_g*2-1 downto
|
324 |
|
|
nbr_of_routers_g) <= rev_re;
|
325 |
|
|
|
326 |
|
|
diagonals: if diag_en_g = 1 generate
|
327 |
|
|
emptys_to_mon(nbr_of_routers_g*3-1 downto nbr_of_routers_g*2) <= diag_empty;
|
328 |
|
|
res_to_mon(nbr_of_routers_g*3-1 downto nbr_of_routers_g*2) <= diag_re;
|
329 |
|
|
end generate diagonals;
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
ring_monitor: monitor_top
|
333 |
|
|
generic map (
|
334 |
|
|
num_of_links_g => num_of_links_c)
|
335 |
|
|
port map (
|
336 |
|
|
emptys_in => emptys_to_mon,
|
337 |
|
|
res_in => res_to_mon,
|
338 |
|
|
uart_rx_in => mon_UART_rx_in,
|
339 |
|
|
uart_tx_out => mon_UART_tx_out,
|
340 |
|
|
clk => clk_net,
|
341 |
|
|
rst_n => rst_n,
|
342 |
|
|
mon_command_in => mon_command_in);
|
343 |
|
|
|
344 |
|
|
end structural;
|