1 |
145 |
lanttu |
-------------------------------------------------
|
2 |
|
|
-- file: ring.vhd
|
3 |
|
|
-- Designer: Jussi Nieminen, 11.02.2009,
|
4 |
|
|
-- modification of Erno Salminen's Octagon
|
5 |
|
|
-- Description: An n-node Ring network
|
6 |
|
|
--
|
7 |
|
|
--
|
8 |
|
|
-- Modified :
|
9 |
|
|
-- 11.02.2009 Forked from the Octacon ver. 04
|
10 |
|
|
--
|
11 |
|
|
--
|
12 |
|
|
--
|
13 |
|
|
-------------------------------------------------
|
14 |
|
|
|
15 |
|
|
-------------------------------------------------------------------------------
|
16 |
|
|
-- Copyright (c) 2011 Tampere University of Technology
|
17 |
|
|
-------------------------------------------------------------------------------
|
18 |
|
|
-- This file is part of Transaction Generator.
|
19 |
|
|
--
|
20 |
|
|
-- Transaction Generator is free software: you can redistribute it and/or
|
21 |
|
|
-- modify it under the terms of the Lesser GNU General Public License as
|
22 |
|
|
-- published by the Free Software Foundation, either version 3 of the License,
|
23 |
|
|
-- or (at your option) any later version.
|
24 |
|
|
--
|
25 |
|
|
-- Transaction Generator is distributed in the hope that it will be useful,
|
26 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
27 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
28 |
|
|
-- Lesser GNU General Public License for more details.
|
29 |
|
|
--
|
30 |
|
|
-- You should have received a copy of the Lesser GNU General Public License
|
31 |
|
|
-- along with Transaction Generator. If not, see
|
32 |
|
|
-- <http://www.gnu.org/licenses/>.
|
33 |
|
|
-------------------------------------------------------------------------------
|
34 |
|
|
|
35 |
|
|
library ieee;
|
36 |
|
|
use ieee.std_logic_1164.all;
|
37 |
|
|
use ieee.std_logic_arith.all;
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
entity ring is
|
41 |
|
|
|
42 |
|
|
generic (
|
43 |
|
|
nbr_of_routers_g : integer := 8;
|
44 |
|
|
diag_en_g : integer := 0;
|
45 |
|
|
data_width_g : integer := 32;
|
46 |
|
|
stfwd_en_g : integer;
|
47 |
|
|
pkt_len_g : integer;
|
48 |
|
|
len_flit_en_g : integer := 0;
|
49 |
|
|
oaddr_flit_en_g : integer := 0;
|
50 |
|
|
fifo_depth_g : integer;
|
51 |
|
|
net_freq_g : integer;
|
52 |
|
|
ip_freq_g : integer
|
53 |
|
|
);
|
54 |
|
|
port (
|
55 |
|
|
clk_net : in std_logic;
|
56 |
|
|
clk_ip : in std_logic;
|
57 |
|
|
rst_n : in std_logic;
|
58 |
|
|
tx_data_in : in std_logic_vector( nbr_of_routers_g * data_width_g-1 downto 0 );
|
59 |
|
|
tx_we_in : in std_logic_vector ( nbr_of_routers_g - 1 downto 0 );
|
60 |
|
|
tx_empty_out : out std_logic_vector ( nbr_of_routers_g - 1 downto 0 );
|
61 |
|
|
tx_full_out : out std_logic_vector ( nbr_of_routers_g - 1 downto 0 );
|
62 |
|
|
|
63 |
|
|
rx_data_out : out std_logic_vector( nbr_of_routers_g*data_width_g-1 downto 0 );
|
64 |
|
|
rx_re_in : in std_logic_vector (nbr_of_routers_g-1 downto 0);
|
65 |
|
|
rx_empty_out : out std_logic_vector (nbr_of_routers_g-1 downto 0);
|
66 |
|
|
rx_full_out : out std_logic_vector (nbr_of_routers_g-1 downto 0)
|
67 |
|
|
);
|
68 |
|
|
|
69 |
|
|
end ring;
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
architecture structural of ring is
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
type data_arr_type is array (nbr_of_routers_g-1 downto 0) of std_logic_vector (data_width_g-1 downto 0);
|
76 |
|
|
|
77 |
|
|
signal fwd_data : data_arr_type;
|
78 |
|
|
signal fwd_re : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
79 |
|
|
signal fwd_empty : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
80 |
|
|
signal fwd_full : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
81 |
|
|
|
82 |
|
|
signal diag_data : data_arr_type;
|
83 |
|
|
signal diag_re : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
84 |
|
|
signal diag_empty : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
85 |
|
|
signal diag_full : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
86 |
|
|
|
87 |
|
|
signal rev_data : data_arr_type;
|
88 |
|
|
signal rev_re : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
89 |
|
|
signal rev_empty : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
90 |
|
|
signal rev_full : std_logic_vector (nbr_of_routers_g-1 downto 0);
|
91 |
|
|
|
92 |
|
|
signal tx_data_dbg : data_arr_type;
|
93 |
|
|
signal rx_data_arr : data_arr_type;
|
94 |
|
|
|
95 |
|
|
component ring_router
|
96 |
|
|
|
97 |
|
|
generic (
|
98 |
|
|
nbr_of_routers_g : integer := 8;
|
99 |
|
|
data_width_g : integer := 0;
|
100 |
|
|
dateline_en_g : integer := 0;
|
101 |
|
|
stfwd_en_g : integer;
|
102 |
|
|
pkt_len_g : integer;
|
103 |
|
|
len_flit_en_g : integer := 0;
|
104 |
|
|
oaddr_flit_en_g : integer := 0;
|
105 |
|
|
fifo_depth_g : integer;
|
106 |
|
|
router_id_g : integer := 0;
|
107 |
|
|
diag_en_g : integer := 1;
|
108 |
|
|
net_freq_g : integer;
|
109 |
|
|
ip_freq_g : integer
|
110 |
|
|
);
|
111 |
|
|
port (
|
112 |
|
|
clk_net : in std_logic;
|
113 |
|
|
clk_ip : in std_logic;
|
114 |
|
|
rst_n : in std_logic;
|
115 |
|
|
|
116 |
|
|
data_fwd_in : in std_logic_vector ( data_width_g-1 downto 0);
|
117 |
|
|
re_fwd_out : out std_logic;
|
118 |
|
|
empty_fwd_in : in std_logic;
|
119 |
|
|
full_fwd_in : in std_logic;
|
120 |
|
|
|
121 |
|
|
data_rev_in : in std_logic_vector ( data_width_g-1 downto 0);
|
122 |
|
|
re_rev_out : out std_logic;
|
123 |
|
|
empty_rev_in : in std_logic;
|
124 |
|
|
full_rev_in : in std_logic;
|
125 |
|
|
|
126 |
|
|
data_diag_in : in std_logic_vector ( data_width_g-1 downto 0);
|
127 |
|
|
re_diag_out : out std_logic;
|
128 |
|
|
empty_diag_in : in std_logic;
|
129 |
|
|
full_diag_in : in std_logic;
|
130 |
|
|
|
131 |
|
|
data_ip_tx_in : in std_logic_vector ( data_width_g-1 downto 0);
|
132 |
|
|
we_ip_tx_in : in std_logic;
|
133 |
|
|
empty_ip_tx_out : out std_logic;
|
134 |
|
|
full_ip_tx_out : out std_logic;
|
135 |
|
|
|
136 |
|
|
data_fwd_out : out std_logic_vector ( data_width_g-1 downto 0);
|
137 |
|
|
re_fwd_in : in std_logic;
|
138 |
|
|
empty_fwd_out : out std_logic;
|
139 |
|
|
full_fwd_out : out std_logic;
|
140 |
|
|
|
141 |
|
|
data_rev_out : out std_logic_vector ( data_width_g-1 downto 0);
|
142 |
|
|
re_rev_in : in std_logic;
|
143 |
|
|
empty_rev_out : out std_logic;
|
144 |
|
|
full_rev_out : out std_logic;
|
145 |
|
|
|
146 |
|
|
data_diag_out : out std_logic_vector ( data_width_g-1 downto 0);
|
147 |
|
|
re_diag_in : in std_logic;
|
148 |
|
|
empty_diag_out : out std_logic;
|
149 |
|
|
full_diag_out : out std_logic;
|
150 |
|
|
|
151 |
|
|
data_ip_rx_out : out std_logic_vector ( data_width_g-1 downto 0);
|
152 |
|
|
re_ip_rx_in : in std_logic;
|
153 |
|
|
full_ip_rx_out : out std_logic;
|
154 |
|
|
empty_ip_rx_out : out std_logic
|
155 |
|
|
);
|
156 |
|
|
|
157 |
|
|
end component; --ring_router;
|
158 |
|
|
|
159 |
|
|
begin -- structural
|
160 |
|
|
|
161 |
|
|
map_dbg_arr : for i in 0 to nbr_of_routers_g-1 generate
|
162 |
|
|
tx_data_dbg (i) <= tx_data_in ((i+1)*data_width_g-1 downto i*data_width_g);
|
163 |
|
|
|
164 |
|
|
rx_data_out ((i+1)*data_width_g-1 downto i*data_width_g) <= rx_data_arr (i);
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
end generate map_dbg_arr;
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
-- data defines which index is used
|
171 |
|
|
-- r port signal
|
172 |
|
|
-- ---------------------
|
173 |
|
|
-- 0: data_out => data(0)
|
174 |
|
|
-- 0: re_in => re(0)
|
175 |
|
|
-- 0: empty_out => empty(0)
|
176 |
|
|
-- 1: data_in => data(0)
|
177 |
|
|
-- 1: re_out => re(0)
|
178 |
|
|
-- 1: empty_in => empty(0)
|
179 |
|
|
|
180 |
|
|
map_routers : for r in 1 to nbr_of_routers_g-1 generate
|
181 |
|
|
router : ring_router
|
182 |
|
|
generic map (
|
183 |
|
|
nbr_of_routers_g => nbr_of_routers_g,
|
184 |
|
|
data_width_g => data_width_g,
|
185 |
|
|
dateline_en_g => 0,
|
186 |
|
|
stfwd_en_g => stfwd_en_g,
|
187 |
|
|
pkt_len_g => pkt_len_g,
|
188 |
|
|
len_flit_en_g => len_flit_en_g,
|
189 |
|
|
oaddr_flit_en_g => oaddr_flit_en_g,
|
190 |
|
|
fifo_depth_g => fifo_depth_g,
|
191 |
|
|
router_id_g => r,
|
192 |
|
|
diag_en_g => diag_en_g,
|
193 |
|
|
net_freq_g => net_freq_g,
|
194 |
|
|
ip_freq_g => ip_freq_g
|
195 |
|
|
)
|
196 |
|
|
port map (
|
197 |
|
|
clk_net => clk_net,
|
198 |
|
|
clk_ip => clk_ip,
|
199 |
|
|
rst_n => rst_n,
|
200 |
|
|
|
201 |
|
|
data_ip_tx_in => tx_data_in ( (r+1)*data_width_g-1 downto r*data_width_g ),
|
202 |
|
|
we_ip_tx_in => tx_we_in (r),
|
203 |
|
|
full_ip_tx_out => tx_full_out (r),
|
204 |
|
|
empty_ip_tx_out => tx_empty_out (r),
|
205 |
|
|
|
206 |
|
|
data_fwd_in => fwd_data (r-1),
|
207 |
|
|
re_fwd_out => fwd_re (r-1),
|
208 |
|
|
empty_fwd_in => fwd_empty (r-1),
|
209 |
|
|
full_fwd_in => fwd_full (r-1),
|
210 |
|
|
|
211 |
|
|
data_fwd_out => fwd_data (r),
|
212 |
|
|
re_fwd_in => fwd_re (r),
|
213 |
|
|
empty_fwd_out => fwd_empty (r),
|
214 |
|
|
full_fwd_out => fwd_full (r),
|
215 |
|
|
|
216 |
|
|
data_rev_in => rev_data ( (r+1) mod nbr_of_routers_g ),
|
217 |
|
|
re_rev_out => rev_re ( (r+1) mod nbr_of_routers_g ),
|
218 |
|
|
empty_rev_in => rev_empty ( (r+1) mod nbr_of_routers_g ),
|
219 |
|
|
full_rev_in => rev_full ( (r+1) mod nbr_of_routers_g ),
|
220 |
|
|
|
221 |
|
|
data_rev_out => rev_data (r),
|
222 |
|
|
re_rev_in => rev_re (r),
|
223 |
|
|
empty_rev_out => rev_empty (r),
|
224 |
|
|
full_rev_out => rev_full (r),
|
225 |
|
|
|
226 |
|
|
--FIXME, this only works with rings of size 2*k, k E N
|
227 |
|
|
data_diag_in => diag_data (( r - nbr_of_routers_g / 2 ) mod nbr_of_routers_g),
|
228 |
|
|
re_diag_out => diag_re (( r - nbr_of_routers_g / 2 ) mod nbr_of_routers_g),
|
229 |
|
|
empty_diag_in => diag_empty (( r - nbr_of_routers_g / 2 ) mod nbr_of_routers_g),
|
230 |
|
|
full_diag_in => diag_full (( r - nbr_of_routers_g / 2 ) mod nbr_of_routers_g),
|
231 |
|
|
|
232 |
|
|
data_diag_out => diag_data (r),
|
233 |
|
|
re_diag_in => diag_re (r),
|
234 |
|
|
empty_diag_out => diag_empty (r),
|
235 |
|
|
full_diag_out => diag_full (r),
|
236 |
|
|
|
237 |
|
|
data_ip_rx_out => rx_data_arr (r),
|
238 |
|
|
re_ip_rx_in => rx_re_in (r),
|
239 |
|
|
full_ip_rx_out => rx_full_out (r),
|
240 |
|
|
empty_ip_rx_out => rx_empty_out (r)
|
241 |
|
|
);
|
242 |
|
|
|
243 |
|
|
end generate map_routers;
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
first_router : ring_router
|
247 |
|
|
generic map (
|
248 |
|
|
nbr_of_routers_g => nbr_of_routers_g,
|
249 |
|
|
data_width_g => data_width_g,
|
250 |
|
|
dateline_en_g => 1,
|
251 |
|
|
pkt_len_g => pkt_len_g,
|
252 |
|
|
len_flit_en_g => len_flit_en_g,
|
253 |
|
|
oaddr_flit_en_g => oaddr_flit_en_g,
|
254 |
|
|
stfwd_en_g => stfwd_en_g,
|
255 |
|
|
fifo_depth_g => fifo_depth_g,
|
256 |
|
|
router_id_g => 0,
|
257 |
|
|
diag_en_g => diag_en_g,
|
258 |
|
|
net_freq_g => net_freq_g,
|
259 |
|
|
ip_freq_g => ip_freq_g
|
260 |
|
|
)
|
261 |
|
|
port map (
|
262 |
|
|
clk_net => clk_net,
|
263 |
|
|
clk_ip => clk_ip,
|
264 |
|
|
rst_n => rst_n,
|
265 |
|
|
|
266 |
|
|
data_ip_tx_in => tx_data_in ( data_width_g-1 downto 0 ),
|
267 |
|
|
we_ip_tx_in => tx_we_in (0),
|
268 |
|
|
full_ip_tx_out => tx_full_out (0),
|
269 |
|
|
empty_ip_tx_out => tx_empty_out (0),
|
270 |
|
|
|
271 |
|
|
data_fwd_in => fwd_data ( nbr_of_routers_g - 1 ),
|
272 |
|
|
re_fwd_out => fwd_re ( nbr_of_routers_g - 1 ),
|
273 |
|
|
empty_fwd_in => fwd_empty ( nbr_of_routers_g - 1 ),
|
274 |
|
|
full_fwd_in => fwd_full ( nbr_of_routers_g - 1 ),
|
275 |
|
|
|
276 |
|
|
data_fwd_out => fwd_data (0),
|
277 |
|
|
re_fwd_in => fwd_re (0),
|
278 |
|
|
empty_fwd_out => fwd_empty (0),
|
279 |
|
|
full_fwd_out => fwd_full (0),
|
280 |
|
|
|
281 |
|
|
data_rev_in => rev_data (1),
|
282 |
|
|
re_rev_out => rev_re (1),
|
283 |
|
|
empty_rev_in => rev_empty (1),
|
284 |
|
|
full_rev_in => rev_full (1),
|
285 |
|
|
|
286 |
|
|
data_rev_out => rev_data (0),
|
287 |
|
|
re_rev_in => rev_re (0),
|
288 |
|
|
empty_rev_out => rev_empty (0),
|
289 |
|
|
full_rev_out => rev_full (0),
|
290 |
|
|
|
291 |
|
|
data_diag_in => diag_data ( nbr_of_routers_g / 2 ),
|
292 |
|
|
re_diag_out => diag_re ( nbr_of_routers_g / 2 ),
|
293 |
|
|
empty_diag_in => diag_empty ( nbr_of_routers_g / 2 ),
|
294 |
|
|
full_diag_in => diag_full ( nbr_of_routers_g / 2 ),
|
295 |
|
|
|
296 |
|
|
data_diag_out => diag_data (0),
|
297 |
|
|
re_diag_in => diag_re (0),
|
298 |
|
|
empty_diag_out => diag_empty (0),
|
299 |
|
|
full_diag_out => diag_full (0),
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
data_ip_rx_out => rx_data_arr (0),
|
303 |
|
|
re_ip_rx_in => rx_re_in (0),
|
304 |
|
|
full_ip_rx_out => rx_full_out (0),
|
305 |
|
|
empty_ip_rx_out => rx_empty_out (0)
|
306 |
|
|
);
|
307 |
|
|
|
308 |
|
|
|
309 |
|
|
end structural;
|