1 |
145 |
lanttu |
-------------------------------------------------------------------------------
|
2 |
|
|
-- File : packet_encoder_decoder.vhdl
|
3 |
|
|
-- Description : encode and decodes packets
|
4 |
|
|
-- Author : Vesa Lahtinen
|
5 |
|
|
-- Date : 23.10.2003
|
6 |
|
|
-- Modified :
|
7 |
|
|
-- 27.04.2005 ES: New fifo
|
8 |
|
|
-- 23.08.2006 AR: new generics and support for LUT
|
9 |
|
|
-------------------------------------------------------------------------------
|
10 |
|
|
|
11 |
|
|
-------------------------------------------------------------------------------
|
12 |
|
|
-- Funbase IP library Copyright (C) 2011 TUT Department of Computer Systems
|
13 |
|
|
--
|
14 |
|
|
-- This source file may be used and distributed without
|
15 |
|
|
-- restriction provided that this copyright statement is not
|
16 |
|
|
-- removed from the file and that any derivative work contains
|
17 |
|
|
-- the original copyright notice and the associated disclaimer.
|
18 |
|
|
--
|
19 |
|
|
-- This source file is free software; you can redistribute it
|
20 |
|
|
-- and/or modify it under the terms of the GNU Lesser General
|
21 |
|
|
-- Public License as published by the Free Software Foundation;
|
22 |
|
|
-- either version 2.1 of the License, or (at your option) any
|
23 |
|
|
-- later version.
|
24 |
|
|
--
|
25 |
|
|
-- This source is distributed in the hope that it will be
|
26 |
|
|
-- useful, but WITHOUT ANY WARRANTY; without even the implied
|
27 |
|
|
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
28 |
|
|
-- PURPOSE. See the GNU Lesser General Public License for more
|
29 |
|
|
-- details.
|
30 |
|
|
--
|
31 |
|
|
-- You should have received a copy of the GNU Lesser General
|
32 |
|
|
-- Public License along with this source; if not, download it
|
33 |
|
|
-- from http://www.opencores.org/lgpl.shtml
|
34 |
|
|
-------------------------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
library ieee;
|
37 |
|
|
use ieee.std_logic_1164.all;
|
38 |
|
|
use ieee.std_logic_arith.all;
|
39 |
|
|
use ieee.std_logic_unsigned.all;
|
40 |
|
|
|
41 |
|
|
entity packet_encoder_decoder is
|
42 |
|
|
generic (
|
43 |
|
|
wait_empty_fifo_g : integer := 0; -- before writing new pkt to net
|
44 |
|
|
data_width_g : integer := 36; -- in bits
|
45 |
|
|
addr_width_g : integer := 32;
|
46 |
|
|
tx_len_width_g : integer := 8;
|
47 |
|
|
packet_length_g : integer := 3; -- words= payload + hdr
|
48 |
|
|
timeout_g : integer := 0; -- how many cycles wait for pkt completion
|
49 |
|
|
fill_packet_g : integer := 0; -- fill pkt with dummy data
|
50 |
|
|
lut_en_g : integer := 1;
|
51 |
|
|
net_type_g : integer; -- 0 MESH, 1 Octagon
|
52 |
|
|
len_flit_en_g : integer := 1; -- 2007/08/03 where to place a pkt_len
|
53 |
|
|
oaddr_flit_en_g : integer := 1; -- 2007/08/03 whether to send the orig address
|
54 |
|
|
dbg_en_g : integer := 0;
|
55 |
|
|
dbg_width_g : integer := 1;
|
56 |
|
|
status_en_g : integer := 0
|
57 |
|
|
);
|
58 |
|
|
|
59 |
|
|
port (
|
60 |
|
|
clk : in std_logic;
|
61 |
|
|
rst_n : in std_logic;
|
62 |
|
|
|
63 |
|
|
-- Signals between IP block and encoder
|
64 |
|
|
av_ip_enc_in : in std_logic;
|
65 |
|
|
data_ip_enc_in : in std_logic_vector (data_width_g-1 downto 0);
|
66 |
|
|
we_ip_enc_in : in std_logic;
|
67 |
|
|
len_ip_enc_in : in std_logic_vector( tx_len_width_g-1 downto 0 );
|
68 |
|
|
full_enc_ip_out : out std_logic;
|
69 |
|
|
empty_enc_ip_out : out std_logic;
|
70 |
|
|
|
71 |
|
|
-- Signals between network and encoder
|
72 |
|
|
av_enc_net_out : out std_logic;
|
73 |
|
|
data_enc_net_out : out std_logic_vector (data_width_g-1 downto 0);
|
74 |
|
|
we_enc_net_out : out std_logic;
|
75 |
|
|
full_net_enc_in : in std_logic;
|
76 |
|
|
empty_net_enc_in : in std_logic;
|
77 |
|
|
|
78 |
|
|
-- Signals between network and decoder
|
79 |
|
|
data_net_dec_in : in std_logic_vector (data_width_g-1 downto 0);
|
80 |
|
|
empty_net_dec_in : in std_logic;
|
81 |
|
|
re_dec_net_out : out std_logic;
|
82 |
|
|
|
83 |
|
|
-- Signals between IP block and decoder
|
84 |
|
|
av_dec_ip_out : out std_logic;
|
85 |
|
|
data_dec_ip_out : out std_logic_vector (data_width_g-1 downto 0);
|
86 |
|
|
re_ip_dec_in : in std_logic;
|
87 |
|
|
empty_dec_ip_out : out std_logic;
|
88 |
|
|
|
89 |
|
|
dbg_out : out std_logic_vector(dbg_width_g - 1 downto 0)
|
90 |
|
|
);
|
91 |
|
|
|
92 |
|
|
end packet_encoder_decoder;
|
93 |
|
|
|
94 |
|
|
architecture structural of packet_encoder_decoder is
|
95 |
|
|
|
96 |
|
|
constant fifo_width_c : integer := data_width_g +1; -- data + av
|
97 |
|
|
constant fifo_depth_c : integer := packet_length_g; -- payload_words + hdr_words
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
component packet_encoder_ctrl
|
101 |
|
|
generic (
|
102 |
|
|
wait_empty_fifo_g : integer := 0;
|
103 |
|
|
data_width_g : integer := 0;
|
104 |
|
|
addr_width_g : integer := 32; -- lsb part of data_width_g
|
105 |
|
|
tx_len_width_g : integer := 4;
|
106 |
|
|
packet_length_g : integer := 0;
|
107 |
|
|
timeout_g : integer := 0;
|
108 |
|
|
fill_packet_g : integer := 0;
|
109 |
|
|
lut_en_g : integer := 1;
|
110 |
|
|
net_type_g : integer;
|
111 |
|
|
len_flit_en_g : integer := 1; -- 2007/08/03 where to place a pkt_len
|
112 |
|
|
oaddr_flit_en_g : integer := 1; -- 2007/08/03 whether to send the orig address
|
113 |
|
|
dbg_en_g : integer;
|
114 |
|
|
dbg_width_g : integer;
|
115 |
|
|
status_en_g : integer := 0
|
116 |
|
|
);
|
117 |
|
|
port (
|
118 |
|
|
clk : in std_logic;
|
119 |
|
|
rst_n : in std_logic;
|
120 |
|
|
|
121 |
|
|
ip_av_in : in std_logic;
|
122 |
|
|
ip_data_in : in std_logic_vector (data_width_g-1 downto 0);
|
123 |
|
|
ip_we_in : in std_logic;
|
124 |
|
|
ip_tx_len_in : in std_logic_vector (tx_len_width_g-1 downto 0);
|
125 |
|
|
ip_stall_out : out std_logic;
|
126 |
|
|
|
127 |
|
|
fifo_av_in : in std_logic;
|
128 |
|
|
fifo_data_in : in std_logic_vector (data_width_g-1 downto 0);
|
129 |
|
|
fifo_re_out : out std_logic;
|
130 |
|
|
fifo_full_in : in std_logic;
|
131 |
|
|
fifo_empty_in : in std_logic;
|
132 |
|
|
|
133 |
|
|
net_av_out : out std_logic;
|
134 |
|
|
net_data_out : out std_logic_vector (data_width_g-1 downto 0);
|
135 |
|
|
net_we_out : out std_logic;
|
136 |
|
|
net_empty_in : in std_logic;
|
137 |
|
|
net_full_in : in std_logic;
|
138 |
|
|
dbg_out : out std_logic_vector(dbg_width_g - 1 downto 0)
|
139 |
|
|
);
|
140 |
|
|
end component;
|
141 |
|
|
|
142 |
|
|
component packet_decoder_ctrl
|
143 |
|
|
generic (
|
144 |
|
|
data_width_g : integer := 0;
|
145 |
|
|
addr_width_g : integer := 0;
|
146 |
|
|
pkt_len_g : integer := 0;
|
147 |
|
|
fill_packet_g : integer := 0;
|
148 |
|
|
len_flit_en_g : integer := 1; -- 2007/08/03 where to place a pkt_len
|
149 |
|
|
oaddr_flit_en_g : integer := 1; -- 2007/08/03 whether to send the orig address
|
150 |
|
|
dbg_en_g : integer;
|
151 |
|
|
dbg_width_g : integer
|
152 |
|
|
);
|
153 |
|
|
port (
|
154 |
|
|
clk : in std_logic;
|
155 |
|
|
rst_n : in std_logic;
|
156 |
|
|
|
157 |
|
|
net_data_in : in std_logic_vector (data_width_g-1 downto 0);
|
158 |
|
|
net_empty_in : in std_logic;
|
159 |
|
|
net_re_out : out std_logic;
|
160 |
|
|
|
161 |
|
|
fifo_av_out : out std_logic;
|
162 |
|
|
fifo_data_out : out std_logic_vector (data_width_g-1 downto 0);
|
163 |
|
|
fifo_we_out : out std_logic;
|
164 |
|
|
fifo_full_in : in std_logic;
|
165 |
|
|
dbg_out : out std_logic_vector(dbg_width_g - 1 downto 0)
|
166 |
|
|
);
|
167 |
|
|
end component;
|
168 |
|
|
|
169 |
|
|
component fifo
|
170 |
|
|
generic (
|
171 |
|
|
data_width_g : integer := 0;
|
172 |
|
|
depth_g : integer := 0
|
173 |
|
|
);
|
174 |
|
|
port (
|
175 |
|
|
clk : in std_logic;
|
176 |
|
|
rst_n : in std_logic;
|
177 |
|
|
|
178 |
|
|
data_in : in std_logic_vector (data_width_g-1 downto 0);
|
179 |
|
|
we_in : in std_logic;
|
180 |
|
|
full_out : out std_logic;
|
181 |
|
|
one_p_out : out std_logic;
|
182 |
|
|
|
183 |
|
|
data_out : out std_logic_vector (data_width_g-1 downto 0);
|
184 |
|
|
re_in : in std_logic;
|
185 |
|
|
empty_out : out std_logic;
|
186 |
|
|
one_d_out : out std_logic
|
187 |
|
|
);
|
188 |
|
|
|
189 |
|
|
end component;
|
190 |
|
|
|
191 |
|
|
-- dbg signals
|
192 |
|
|
signal enc_dbg : std_logic_vector(dbg_width_g - 1 downto 0);
|
193 |
|
|
signal dec_dbg : std_logic_vector(dbg_width_g - 1 downto 0);
|
194 |
|
|
|
195 |
|
|
-- Signals for enc-fifo
|
196 |
|
|
signal d_av_to_encfifo : std_logic_vector (fifo_width_c-1 downto 0) ;-- (data_width_g+1-1 downto 0);
|
197 |
|
|
signal d_av_from_encfifo : std_logic_vector (fifo_width_c-1 downto 0) ;-- (data_width_g+1-1 downto 0);
|
198 |
|
|
signal full_from_encfifo : std_logic;
|
199 |
|
|
signal empty_from_encfifo : std_logic;
|
200 |
|
|
signal we_to_encfifo : std_logic;
|
201 |
|
|
|
202 |
|
|
-- Signals for encoding
|
203 |
|
|
signal av_fifo_enc : std_logic;
|
204 |
|
|
signal data_fifo_enc : std_logic_vector (data_width_g-1 downto 0);
|
205 |
|
|
signal re_enc_fifo : std_logic;
|
206 |
|
|
signal stall_from_enc : std_logic;
|
207 |
|
|
|
208 |
|
|
-- Signals between the control and the fifo of decoder
|
209 |
|
|
signal d_av_to_decfifo : std_logic_vector (fifo_width_c-1 downto 0) ;-- (data_width_g+1-1 downto 0);
|
210 |
|
|
signal d_av_from_decfifo : std_logic_vector (fifo_width_c-1 downto 0) ;-- (data_width_g+1-1 downto 0);
|
211 |
|
|
|
212 |
|
|
signal av_dec_fifo : std_logic;
|
213 |
|
|
signal data_dec_fifo : std_logic_vector (data_width_g-1 downto 0);
|
214 |
|
|
signal we_dec_fifo : std_logic;
|
215 |
|
|
signal full_fifo_dec : std_logic;
|
216 |
|
|
|
217 |
|
|
begin
|
218 |
|
|
|
219 |
|
|
-- for xbar_util_mon
|
220 |
|
|
gen_dbg: if dbg_en_g = 1 generate
|
221 |
|
|
dbg_out(0) <= we_ip_enc_in and
|
222 |
|
|
not(stall_from_enc or full_from_encfifo) and
|
223 |
|
|
not(av_ip_enc_in);
|
224 |
|
|
end generate gen_dbg;
|
225 |
|
|
|
226 |
|
|
-- Concurrent assignments
|
227 |
|
|
-- 1) outputs
|
228 |
|
|
full_enc_ip_out <= stall_from_enc or full_from_encfifo;
|
229 |
|
|
empty_enc_ip_out <= empty_from_encfifo;
|
230 |
|
|
av_dec_ip_out <= d_av_from_decfifo (0);
|
231 |
|
|
data_dec_ip_out <= d_av_from_decfifo (data_width_g downto 1);
|
232 |
|
|
|
233 |
|
|
-- 2) to enc-fifo
|
234 |
|
|
we_to_encfifo <= we_ip_enc_in and not(stall_from_enc);
|
235 |
|
|
d_av_to_encfifo(data_width_g downto 1) <= data_ip_enc_in;
|
236 |
|
|
d_av_to_encfifo(0) <= av_ip_enc_in;
|
237 |
|
|
|
238 |
|
|
-- 3) to encoder ctrl
|
239 |
|
|
data_fifo_enc <= d_av_from_encfifo (data_width_g downto 1);
|
240 |
|
|
av_fifo_enc <= d_av_from_encfifo (0);
|
241 |
|
|
|
242 |
|
|
-- 4) to dec-fifo
|
243 |
|
|
d_av_to_decfifo (data_width_g downto 1) <= data_dec_fifo;
|
244 |
|
|
d_av_to_decfifo (0) <= av_dec_fifo;
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
encode_control : packet_encoder_ctrl
|
249 |
|
|
generic map (
|
250 |
|
|
wait_empty_fifo_g => wait_empty_fifo_g,
|
251 |
|
|
data_width_g => data_width_g,
|
252 |
|
|
addr_width_g => addr_width_g,
|
253 |
|
|
tx_len_width_g => tx_len_width_g,
|
254 |
|
|
packet_length_g => packet_length_g,
|
255 |
|
|
timeout_g => timeout_g,
|
256 |
|
|
fill_packet_g => fill_packet_g,
|
257 |
|
|
lut_en_g => lut_en_g,
|
258 |
|
|
net_type_g => net_type_g,
|
259 |
|
|
len_flit_en_g => len_flit_en_g, -- 2007/08/03
|
260 |
|
|
oaddr_flit_en_g => oaddr_flit_en_g, -- 2007/08/03
|
261 |
|
|
dbg_en_g => dbg_en_g,
|
262 |
|
|
dbg_width_g => dbg_width_g,
|
263 |
|
|
status_en_g => status_en_g
|
264 |
|
|
)
|
265 |
|
|
port map (
|
266 |
|
|
clk => clk,
|
267 |
|
|
rst_n => rst_n,
|
268 |
|
|
|
269 |
|
|
ip_av_in => av_ip_enc_in,
|
270 |
|
|
ip_data_in => data_ip_enc_in,
|
271 |
|
|
ip_we_in => we_ip_enc_in,
|
272 |
|
|
ip_tx_len_in => len_ip_enc_in,
|
273 |
|
|
ip_stall_out => stall_from_enc,
|
274 |
|
|
|
275 |
|
|
fifo_av_in => av_fifo_enc,
|
276 |
|
|
fifo_data_in => data_fifo_enc,
|
277 |
|
|
fifo_full_in => full_from_encfifo,
|
278 |
|
|
fifo_empty_in => empty_from_encfifo,
|
279 |
|
|
fifo_re_out => re_enc_fifo,
|
280 |
|
|
|
281 |
|
|
net_av_out => av_enc_net_out,
|
282 |
|
|
net_data_out => data_enc_net_out,
|
283 |
|
|
net_we_out => we_enc_net_out,
|
284 |
|
|
net_empty_in => empty_net_enc_in,
|
285 |
|
|
net_full_in => full_net_enc_in,
|
286 |
|
|
dbg_out => enc_dbg
|
287 |
|
|
);
|
288 |
|
|
|
289 |
|
|
|
290 |
|
|
decode_control : packet_decoder_ctrl
|
291 |
|
|
generic map (
|
292 |
|
|
data_width_g => data_width_g,
|
293 |
|
|
addr_width_g => addr_width_g,
|
294 |
|
|
pkt_len_g => packet_length_g,
|
295 |
|
|
fill_packet_g => fill_packet_g,
|
296 |
|
|
len_flit_en_g => len_flit_en_g, -- 2007/08/03
|
297 |
|
|
oaddr_flit_en_g => oaddr_flit_en_g, -- 2007/08/03
|
298 |
|
|
dbg_en_g => dbg_en_g,
|
299 |
|
|
dbg_width_g => dbg_width_g
|
300 |
|
|
)
|
301 |
|
|
port map (
|
302 |
|
|
clk => clk,
|
303 |
|
|
rst_n => rst_n,
|
304 |
|
|
|
305 |
|
|
net_data_in => data_net_dec_in,
|
306 |
|
|
net_empty_in => empty_net_dec_in,
|
307 |
|
|
net_re_out => re_dec_net_out,
|
308 |
|
|
|
309 |
|
|
fifo_av_out => av_dec_fifo,
|
310 |
|
|
fifo_data_out => data_dec_fifo,
|
311 |
|
|
fifo_we_out => we_dec_fifo,
|
312 |
|
|
fifo_full_in => full_fifo_dec,
|
313 |
|
|
dbg_out => dec_dbg
|
314 |
|
|
);
|
315 |
|
|
|
316 |
|
|
encode_fifo : fifo
|
317 |
|
|
generic map (
|
318 |
|
|
data_width_g => fifo_width_c,
|
319 |
|
|
depth_g => fifo_depth_c
|
320 |
|
|
)
|
321 |
|
|
port map (
|
322 |
|
|
clk => clk,
|
323 |
|
|
rst_n => rst_n,
|
324 |
|
|
data_In => d_av_to_encfifo,
|
325 |
|
|
we_in => we_to_encfifo,
|
326 |
|
|
full_out => full_from_encfifo,
|
327 |
|
|
data_out => d_av_from_encfifo,
|
328 |
|
|
re_in => re_enc_fifo,
|
329 |
|
|
empty_out => empty_from_encfifo
|
330 |
|
|
);
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
decode_fifo : fifo
|
334 |
|
|
generic map (
|
335 |
|
|
data_width_g => fifo_width_c,
|
336 |
|
|
depth_g => fifo_depth_c
|
337 |
|
|
)
|
338 |
|
|
port map (
|
339 |
|
|
clk => clk,
|
340 |
|
|
rst_n => rst_n,
|
341 |
|
|
data_In => d_av_to_decfifo,
|
342 |
|
|
we_in => we_dec_fifo,
|
343 |
|
|
full_out => full_fifo_dec,
|
344 |
|
|
data_out => d_av_from_decfifo,
|
345 |
|
|
re_in => re_ip_dec_in,
|
346 |
|
|
empty_out => empty_dec_ip_out
|
347 |
|
|
);
|
348 |
|
|
|
349 |
|
|
end structural;
|