OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.communication/] [packet_codec/] [1.0/] [vhd/] [pkt_enc_dec_for_monitor.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
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
 
37
library ieee;
38
use ieee.std_logic_1164.all;
39
use ieee.std_logic_arith.all;
40
use ieee.std_logic_unsigned.all;
41
 
42
entity packet_encoder_decoder_for_monitor is
43
  generic (
44
    wait_empty_fifo_g   : integer := 0;  -- before writing new pkt to net
45
    data_width_g        : integer := 36;  -- in bits
46
    addr_width_g        : integer := 32;
47
    tx_len_width_g     : integer := 8;
48
    packet_length_g     : integer := 3;  -- words= payload + hdr
49
    timeout_g           : integer := 0;  -- how many cycles wait for pkt completion
50
    fill_packet_g       : integer := 0;  -- fill pkt with dummy data
51
    lut_en_g            : integer := 1;
52
    net_type_g          : integer;      -- 0 MESH, 1 Octagon
53
    len_flit_en_g      : integer := 1;  -- 2007/08/03 where to place a pkt_len
54
    oaddr_flit_en_g : integer := 1;  -- 2007/08/03 whether to send the orig address
55
    dbg_en_g            : integer := 0;
56
    dbg_width_g         : integer := 1;
57
    status_en_g         : integer := 0
58
    );
59
 
60
  port (
61
    clk   : in std_logic;
62
    rst_n : in std_logic;
63
 
64
    -- Signals between IP block and encoder
65
    av_ip_enc_in     : in  std_logic;
66
    data_ip_enc_in   : in  std_logic_vector (data_width_g-1 downto 0);
67
    we_ip_enc_in     : in  std_logic;
68
    len_ip_enc_in    : in  std_logic_vector( tx_len_width_g-1 downto 0 );
69
    full_enc_ip_out  : out std_logic;
70
    empty_enc_ip_out : out std_logic;
71
 
72
    -- Signals between network and encoder
73
    av_enc_net_out   : out std_logic;
74
    data_enc_net_out : out std_logic_vector (data_width_g-1 downto 0);
75
    we_enc_net_out   : out std_logic;
76
    full_net_enc_in  : in  std_logic;
77
    empty_net_enc_in : in  std_logic;
78
 
79
    -- Signals between network and decoder
80
    data_net_dec_in  : in  std_logic_vector (data_width_g-1 downto 0);
81
    empty_net_dec_in : in  std_logic;
82
    re_dec_net_out   : out std_logic;
83
 
84
    -- Signals between IP block and decoder
85
    av_dec_ip_out    : out std_logic;
86
    data_dec_ip_out  : out std_logic_vector (data_width_g-1 downto 0);
87
    re_ip_dec_in     : in  std_logic;
88
    empty_dec_ip_out : out std_logic;
89
 
90
    dbg_out          : out std_logic_vector(dbg_width_g - 1 downto 0);
91
 
92
    -- MONITORING (Antti Alhonen 2010)
93
    re_ip_tx_for_monitor_no_overhead_out : out std_logic;
94
    empty_ip_tx_for_monitor_no_overhead_out : out std_logic
95
 
96
    );
97
 
98
end packet_encoder_decoder_for_monitor;
99
 
100
architecture structural of packet_encoder_decoder_for_monitor is
101
 
102
  constant fifo_width_c : integer := data_width_g +1;  -- data + av
103
  constant fifo_depth_c : integer := packet_length_g;  -- payload_words + hdr_words
104
 
105
 
106
  component packet_encoder_ctrl
107
    generic (
108
      wait_empty_fifo_g   :    integer := 0;
109
      data_width_g        :    integer := 0;
110
      addr_width_g        :    integer := 32;  -- lsb part of data_width_g
111
      tx_len_width_g      :    integer := 4;
112
      packet_length_g     :    integer := 0;
113
      timeout_g           :    integer := 0;
114
      fill_packet_g       :    integer := 0;
115
      lut_en_g            :    integer := 1;
116
      net_type_g          :    integer;
117
      len_flit_en_g      :    integer := 1;  -- 2007/08/03 where to place a pkt_len
118
      oaddr_flit_en_g :    integer := 1;  -- 2007/08/03 whether to send the orig address
119
      dbg_en_g            :    integer;
120
      dbg_width_g         :    integer;
121
      status_en_g         :    integer := 0
122
      );
123
    port (
124
      clk                 : in std_logic;
125
      rst_n               : in std_logic;
126
 
127
      ip_av_in      : in  std_logic;
128
      ip_data_in    : in  std_logic_vector (data_width_g-1 downto 0);
129
      ip_we_in      : in  std_logic;
130
      ip_tx_len_in  : in  std_logic_vector (tx_len_width_g-1 downto 0);
131
      ip_stall_out  : out std_logic;
132
 
133
      fifo_av_in    : in  std_logic;
134
      fifo_data_in  : in  std_logic_vector (data_width_g-1 downto 0);
135
      fifo_re_out   : out std_logic;
136
      fifo_full_in  : in  std_logic;
137
      fifo_empty_in : in  std_logic;
138
 
139
      net_av_out   : out std_logic;
140
      net_data_out : out std_logic_vector (data_width_g-1 downto 0);
141
      net_we_out   : out std_logic;
142
      net_empty_in : in  std_logic;
143
      net_full_in  : in  std_logic;
144
      dbg_out      : out std_logic_vector(dbg_width_g - 1 downto 0)
145
      );
146
  end component;
147
 
148
  component packet_decoder_ctrl
149
    generic (
150
      data_width_g    :    integer := 0;
151
      addr_width_g    :    integer := 0;
152
      pkt_len_g       :    integer := 0;
153
      fill_packet_g   :    integer := 0;
154
      len_flit_en_g   :    integer := 1;  -- 2007/08/03 where to place a pkt_len
155
      oaddr_flit_en_g :    integer := 1;  -- 2007/08/03 whether to send the orig address
156
      dbg_en_g        :    integer;
157
      dbg_width_g     :    integer
158
      );
159
    port (
160
      clk             : in std_logic;
161
      rst_n           : in std_logic;
162
 
163
      net_data_in  : in  std_logic_vector (data_width_g-1 downto 0);
164
      net_empty_in : in  std_logic;
165
      net_re_out   : out std_logic;
166
 
167
      fifo_av_out   : out std_logic;
168
      fifo_data_out : out std_logic_vector (data_width_g-1 downto 0);
169
      fifo_we_out   : out std_logic;
170
      fifo_full_in  : in  std_logic;
171
      dbg_out       : out std_logic_vector(dbg_width_g - 1 downto 0)
172
      );
173
  end component;
174
 
175
  component fifo
176
    generic (
177
      data_width_g : integer := 0;
178
      depth_g      : integer := 0
179
      );
180
    port (
181
      clk   : in std_logic;
182
      rst_n : in std_logic;
183
 
184
      data_in   : in  std_logic_vector (data_width_g-1 downto 0);
185
      we_in     : in  std_logic;
186
      full_out  : out std_logic;
187
      one_p_out : out std_logic;
188
 
189
      data_out  : out std_logic_vector (data_width_g-1 downto 0);
190
      re_in     : in  std_logic;
191
      empty_out : out std_logic;
192
      one_d_out : out std_logic
193
      );
194
 
195
  end component;
196
 
197
  -- dbg signals
198
  signal enc_dbg : std_logic_vector(dbg_width_g - 1 downto 0);
199
  signal dec_dbg : std_logic_vector(dbg_width_g - 1 downto 0);
200
 
201
  -- Signals for enc-fifo
202
  signal d_av_to_encfifo    : std_logic_vector (fifo_width_c-1 downto 0) ;-- (data_width_g+1-1 downto 0);
203
  signal d_av_from_encfifo  : std_logic_vector (fifo_width_c-1 downto 0) ;-- (data_width_g+1-1 downto 0);
204
  signal full_from_encfifo  : std_logic;
205
  signal empty_from_encfifo : std_logic;
206
  signal we_to_encfifo      : std_logic;
207
 
208
  -- Signals for encoding
209
  signal av_fifo_enc   : std_logic;
210
  signal data_fifo_enc : std_logic_vector (data_width_g-1 downto 0);
211
  signal re_enc_fifo   : std_logic;
212
  signal stall_from_enc : std_logic;
213
 
214
  -- Signals between the control and the fifo of decoder
215
  signal d_av_to_decfifo   : std_logic_vector (fifo_width_c-1 downto 0) ;-- (data_width_g+1-1 downto 0);
216
  signal d_av_from_decfifo : std_logic_vector (fifo_width_c-1 downto 0) ;-- (data_width_g+1-1 downto 0);
217
 
218
  signal av_dec_fifo   : std_logic;
219
  signal data_dec_fifo : std_logic_vector (data_width_g-1 downto 0);
220
  signal we_dec_fifo   : std_logic;
221
  signal full_fifo_dec : std_logic;
222
 
223
begin
224
 
225
  -- for xbar_util_mon
226
  gen_dbg: if dbg_en_g = 1 generate
227
    dbg_out(0) <= we_ip_enc_in and
228
                  not(stall_from_enc or full_from_encfifo) and
229
                  not(av_ip_enc_in);
230
  end generate gen_dbg;
231
 
232
  -- Concurrent assignments
233
  -- 1) outputs
234
  full_enc_ip_out  <= stall_from_enc or full_from_encfifo;
235
  empty_enc_ip_out <= empty_from_encfifo;
236
  av_dec_ip_out    <= d_av_from_decfifo (0);
237
  data_dec_ip_out  <= d_av_from_decfifo (data_width_g downto 1);
238
 
239
  -- 2) to enc-fifo
240
  we_to_encfifo                          <= we_ip_enc_in and not(stall_from_enc);
241
  d_av_to_encfifo(data_width_g downto 1) <= data_ip_enc_in;
242
  d_av_to_encfifo(0)                     <= av_ip_enc_in;
243
 
244
  -- 3) to encoder ctrl
245
  data_fifo_enc <= d_av_from_encfifo (data_width_g downto 1);
246
  av_fifo_enc   <= d_av_from_encfifo (0);
247
 
248
  -- 4) to dec-fifo
249
  d_av_to_decfifo (data_width_g downto 1) <= data_dec_fifo;
250
  d_av_to_decfifo (0)                     <= av_dec_fifo;
251
 
252
 
253
 
254
  encode_control : packet_encoder_ctrl
255
    generic map (
256
      wait_empty_fifo_g => wait_empty_fifo_g,
257
      data_width_g      => data_width_g,
258
      addr_width_g      => addr_width_g,
259
      tx_len_width_g    => tx_len_width_g,
260
      packet_length_g   => packet_length_g,
261
      timeout_g         => timeout_g,
262
      fill_packet_g     => fill_packet_g,
263
      lut_en_g          => lut_en_g,
264
      net_type_g        => net_type_g,
265
      len_flit_en_g     => len_flit_en_g,    -- 2007/08/03
266
      oaddr_flit_en_g   => oaddr_flit_en_g,  -- 2007/08/03
267
      dbg_en_g          => dbg_en_g,
268
      dbg_width_g       => dbg_width_g,
269
      status_en_g       => status_en_g
270
      )
271
    port map (
272
      clk               => clk,
273
      rst_n             => rst_n,
274
 
275
      ip_av_in      => av_ip_enc_in,
276
      ip_data_in    => data_ip_enc_in,
277
      ip_we_in      => we_ip_enc_in,
278
      ip_tx_len_in  => len_ip_enc_in,
279
      ip_stall_out  => stall_from_enc,
280
 
281
      fifo_av_in    => av_fifo_enc,
282
      fifo_data_in  => data_fifo_enc,
283
      fifo_full_in  => full_from_encfifo,
284
      fifo_empty_in => empty_from_encfifo,
285
      fifo_re_out   => re_enc_fifo,
286
 
287
      net_av_out   => av_enc_net_out,
288
      net_data_out => data_enc_net_out,
289
      net_we_out   => we_enc_net_out,
290
      net_empty_in => empty_net_enc_in,
291
      net_full_in  => full_net_enc_in,
292
      dbg_out      => enc_dbg
293
      );
294
 
295
 
296
  decode_control : packet_decoder_ctrl
297
    generic map (
298
      data_width_g    => data_width_g,
299
      addr_width_g    => addr_width_g,
300
      pkt_len_g       => packet_length_g,
301
      fill_packet_g   => fill_packet_g,
302
      len_flit_en_g   => len_flit_en_g,    -- 2007/08/03
303
      oaddr_flit_en_g => oaddr_flit_en_g,  -- 2007/08/03
304
      dbg_en_g        => dbg_en_g,
305
      dbg_width_g     => dbg_width_g
306
      )
307
    port map (
308
      clk             => clk,
309
      rst_n           => rst_n,
310
 
311
      net_data_in  => data_net_dec_in,
312
      net_empty_in => empty_net_dec_in,
313
      net_re_out   => re_dec_net_out,
314
 
315
      fifo_av_out   => av_dec_fifo,
316
      fifo_data_out => data_dec_fifo,
317
      fifo_we_out   => we_dec_fifo,
318
      fifo_full_in  => full_fifo_dec,
319
      dbg_out       => dec_dbg
320
      );
321
 
322
  encode_fifo : fifo
323
    generic map (
324
      data_width_g => fifo_width_c,
325
      depth_g      => fifo_depth_c
326
      )
327
    port map (
328
      clk       => clk,
329
      rst_n     => rst_n,
330
      data_In   => d_av_to_encfifo,
331
      we_in     => we_to_encfifo,
332
      full_out  => full_from_encfifo,
333
      data_out  => d_av_from_encfifo,
334
      re_in     => re_enc_fifo,
335
      empty_out => empty_from_encfifo
336
      );
337
 
338
  empty_ip_tx_for_monitor_no_overhead_out <= empty_from_encfifo;
339
  re_ip_tx_for_monitor_no_overhead_out <= re_enc_fifo;
340
 
341
  decode_fifo : fifo
342
    generic map (
343
      data_width_g => fifo_width_c,
344
      depth_g      => fifo_depth_c
345
      )
346
    port map (
347
      clk       => clk,
348
      rst_n     => rst_n,
349
      data_In   => d_av_to_decfifo,
350
      we_in     => we_dec_fifo,
351
      full_out  => full_fifo_dec,
352
      data_out  => d_av_from_decfifo,
353
      re_in     => re_ip_dec_in,
354
      empty_out => empty_dec_ip_out
355
      );
356
 
357
end structural;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.