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/] [fh_crossbar/] [1.0/] [vhd/] [crossbar_with_monitor.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-----------------------------------------------------------------
2
-- file         : crossbar.vhdl/ crossbar_with_monitor.vhdl
3
-- Description  : Top level of crossbar. Includes io_block with
4
--                fifos, arbiter and switch matrix.
5
-- 
6
-- Designer     : Erno salminen 19.06.2003
7
-- last modified
8
-- Antti Alhonen 09.07.2009 - added monitoring.
9
-- THIS DOES NOT USE PACKETS!
10
-----------------------------------------------------------------
11
-------------------------------------------------------------------------------
12
-- Copyright (c) 2011 Tampere University of Technology
13
-------------------------------------------------------------------------------
14
--  This file is part of Transaction Generator.
15
--
16
--  Transaction Generator is free software: you can redistribute it and/or
17
--  modify it under the terms of the Lesser GNU General Public License as
18
--  published by the Free Software Foundation, either version 3 of the License,
19
--  or (at your option) any later version.
20
--
21
--  Transaction Generator is distributed in the hope that it will be useful,
22
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
--  Lesser GNU General Public License for more details.
25
--
26
--  You should have received a copy of the Lesser GNU General Public License
27
--  along with Transaction Generator.  If not, see
28
--  <http://www.gnu.org/licenses/>.
29
-------------------------------------------------------------------------------
30
 
31
 
32
library ieee;
33
use ieee.std_logic_1164.all;
34
use ieee.std_logic_arith.all;
35
 
36
use work.mon_pkg.all;
37
 
38
entity crossbar_with_monitor is
39
  generic (
40
    n_ag_g          :    integer;
41
    data_width_g    :    integer;
42
    pkt_switch_en_g :    integer := 0;  --14.10.06 es
43
    stfwd_en_g      :    integer := 0;  --14.10.06 es
44
    max_send_g      :    integer := 9;  -- 0=no limit
45
    net_freq_g      :    integer := 1;  -- relative crossbar freq
46
    lut_en_g        :    integer := 1;  -- 19.10.2006 ES
47
    ip_freq_g       :    integer := 1;  -- relative IP freq
48
    fifo_depth_g    :    integer;
49
    sim_dbg_en_g    :    integer := 0;
50
    dbg_en_g        :    integer := 0;
51
    dbg_width_g     :    integer
52
    );
53
  port (
54
    rst_n           : in std_logic;
55
    clk_net         : in std_logic;
56
    clk_ip          : in std_logic;
57
 
58
    tx_av_in     : in  std_logic_vector (n_ag_g - 1 downto 0);
59
    tx_data_in   : in  std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
60
    tx_we_in     : in  std_logic_vector (n_ag_g - 1 downto 0);
61
    tx_full_out  : out std_logic_vector (n_ag_g - 1 downto 0);
62
    tx_empty_out : out std_logic_vector (n_ag_g - 1 downto 0);
63
 
64
    rx_av_out    : out std_logic_vector (n_ag_g - 1 downto 0);
65
    rx_data_out  : out std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
66
    rx_empty_out : out std_logic_vector (n_ag_g - 1 downto 0);
67
    rx_full_out  : out std_logic_vector (n_ag_g - 1 downto 0);
68
    rx_re_in     : in  std_logic_vector (n_ag_g - 1 downto 0);
69
 
70
    dbg_out      : out std_logic_vector (dbg_width_g - 1 downto 0);
71
 
72
    -- MONITOR SIGNALS (AA)
73
    mon_UART_rx_in  : in  std_logic;
74
    mon_UART_tx_out : out std_logic;
75
    mon_command_in  :  in std_logic_vector(mon_command_width_c-1 downto 0)
76
    );
77
end crossbar_with_monitor;
78
 
79
architecture top_level of crossbar_with_monitor is
80
 
81
 
82
  function log2(input : integer)
83
    return integer is
84
  begin
85
    for i in 1 to 100 loop
86
      if (2**i >= input) then
87
        return(i);
88
      end if;
89
    end loop;  -- i
90
    return 100;
91
  end log2;
92
 
93
  -- addresses are from 0 to n_ag - 1
94
  --constant addr_width_c : integer := log2(n_ag_g);
95
  constant addr_width_c : integer := data_width_g;
96
 
97
  -- switch addresses are from 1 to n_ag, value n_ag= illegal
98
  constant switch_addr_width_c : integer := log2(n_ag_g + 1);
99
 
100
  component io_block
101
    generic (
102
      data_width_g    :    integer;
103
      fifo_depth_g    :    integer;
104
      addr_width_g    :    integer;
105
      pkt_switch_en_g :    integer := 0;  --14.10.06 es
106
      stfwd_en_g      :    integer := 0;  --14.10.06 es
107
      max_send_g      :    integer := 9;  -- 0=no limit
108
      net_freq_g      :    integer;
109
      sim_dbg_en_g    :    integer;
110
      ip_freq_g       :    integer
111
      );
112
    port (
113
      clk_net         : in std_logic;
114
      clk_ip          : in std_logic;
115
      rst_n           : in std_logic;
116
 
117
      -- Signals from agent
118
      ip_av_in        : in  std_logic;    -- 15.09.2006 
119
      ip_data_in      : in  std_logic_vector (data_width_g-1 downto 0);
120
      ip_we_in        : in  std_logic;
121
      ip_tx_full_out  : out std_logic;
122
      ip_tx_empty_out : out std_logic;
123
 
124
      -- Signals to bus and arbiter
125
      net_av_out       : out std_logic;
126
      net_flit_out     : out std_logic_vector (data_width_g-1 downto 0);
127
      net_we_out   : out std_logic;
128
      net_req_addr_out : out std_logic_vector (addr_width_g  -1 downto 0);
129
      net_req_out      : out std_logic;
130
      net_hold_out     : out std_logic;
131
      net_grant_in     : in  std_logic;
132
      net_full_in      : in  std_logic;
133
 
134
      -- Signals from bus and arbiter
135
      net_av_in     : in  std_logic;
136
      net_data_in   : in  std_logic_vector (data_width_g -1 downto 0);
137
      net_we_in     : in  std_logic;
138
      net_full_out  : out std_logic;
139
      net_empty_out : out std_logic;
140
 
141
      -- Signals to agent
142
      ip_av_out       : out std_logic;    -- 15.09.2006 
143
      ip_data_out     : out std_logic_vector (data_width_g -1 downto 0);
144
      ip_re_in        : in  std_logic;
145
      ip_rx_full_out  : out std_logic;
146
      ip_rx_empty_out : out std_logic
147
      );
148
  end component;
149
 
150
  component addr_lut
151
    generic (
152
      in_addr_w_g  : integer := 32;
153
      out_addr_w_g : integer := 36;
154
      cmp_high_g   : integer := 31;
155
      cmp_low_g    : integer := 0;
156
      net_type_g   : integer := 0;
157
      lut_en_g     : integer := 1         -- if disabled, out <= in
158
      );
159
    port (
160
      addr_in  : in  std_logic_vector (in_addr_w_g-1 downto 0);
161
      addr_out : out std_logic_vector (out_addr_w_g-1 downto 0)
162
      );
163
  end component; --addr_lut;
164
 
165
 
166
  component allocator
167
    generic (
168
      n_ag_g              :     integer;
169
      addr_width_g        :     integer;
170
      switch_addr_width_g :     integer
171
      );
172
    port(
173
      clk                 : in  std_logic;
174
      rst_n               : in  std_logic;
175
      req_addr_in         : in  std_logic_vector (n_ag_g * addr_width_g - 1 downto 0);
176
      req_in              : in  std_logic_vector (n_ag_g - 1 downto 0);
177
      hold_in             : in  std_logic_vector (n_ag_g - 1 downto 0);
178
      grant_out           : out std_logic_vector (n_ag_g - 1 downto 0);
179
      src_id_out          : out std_logic_vector (n_ag_g * switch_addr_width_g - 1 downto 0)
180
      );
181
  end component;
182
 
183
  component switch_matrix
184
    generic (
185
      n_ag_g       :     integer;
186
      data_width_g :     integer;
187
      addr_width_g :     integer
188
      );
189
    port (
190
      av_in        : in  std_logic_vector (n_ag_g - 1 downto 0);
191
      data_in      : in  std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
192
      we_in        : in  std_logic_vector (n_ag_g-1 downto 0);
193
      we_out       : out std_logic_vector (n_ag_g-1 downto 0);
194
      av_out       : out std_logic_vector (n_ag_g - 1 downto 0);
195
      data_out     : out std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
196
      src_id_in    : in  std_logic_vector (n_ag_g * addr_width_g - 1 downto 0);
197
      full_in      : in  std_logic_vector (n_ag_g - 1 downto 0);
198
      full_out     : out std_logic_vector (n_ag_g - 1 downto 0)
199
      );
200
  end component;  --switch_matrix;
201
 
202
  component monitor_top_xbar
203
    generic (
204
      num_of_links_g : integer);
205
    port (
206
      holds_in       : in  std_logic_vector(num_of_links_g-1 downto 0);
207
      grants_in      : in  std_logic_vector(num_of_links_g-1 downto 0);
208
      reqs_in        : in  std_logic_vector(num_of_links_g-1 downto 0);
209
      uart_rx_in     : in  std_logic;
210
      uart_tx_out    : out std_logic;
211
      clk            : in  std_logic;
212
      rst_n          : in  std_logic;
213
      mon_command_in : in  std_logic_vector(mon_command_width_c-1 downto 0));
214
  end component;
215
 
216
 
217
 
218
  type net_flit_type is array (n_ag_g - 1 downto 0) of std_logic_vector (data_width_g -1 downto 0);
219
  signal net_flit   : net_flit_type;
220
 
221
 
222
  -- Arbiter signals
223
  signal empty_io_arb      : std_logic_vector (n_ag_g-1 downto 0);
224
  signal grant_arb_io      : std_logic_vector (n_ag_g-1 downto 0);
225
  signal req_io_arb        : std_logic_vector (n_ag_g-1 downto 0);
226
  signal hold_io_arb       : std_logic_vector (n_ag_g - 1 downto 0);
227
  signal ctrl_arb_switches : std_logic_vector (n_ag_g * switch_addr_width_c - 1 downto 0);
228
 
229
  --signal req_addr_io_arb   : std_logic_vector (n_ag_g * addr_width_c - 1 downto 0);
230
  signal req_addr_io_lut  : std_logic_vector (n_ag_g * addr_width_c - 1 downto 0);
231
  signal req_addr_lut_arb : std_logic_vector (n_ag_g * switch_addr_width_c - 1 downto 0);
232
 
233
 
234
 
235
  -- IO <-> Switch matrix
236
  signal av_io_xbar   : std_logic_vector (n_ag_g-1 downto 0);
237
  signal data_io_xbar : std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
238
  signal we_io_xbar   : std_logic_vector (n_ag_g-1 downto 0);
239
  signal full_xbar_io : std_logic_vector (n_ag_g - 1 downto 0);
240
 
241
  signal av_xbar_io   : std_logic_vector (n_ag_g-1 downto 0);
242
  signal data_xbar_io : std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
243
  signal we_xbar_io   : std_logic_vector (n_ag_g-1 downto 0);
244
  signal full_io_xbar : std_logic_vector (n_ag_g - 1 downto 0);
245
 
246
  -- IO -> IP, 28.07
247
  signal rx_data_from_io  : std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
248
  signal rx_empty_from_io : std_logic_vector (n_ag_g - 1 downto 0);
249
 
250
 
251
  -- Array signals for debugging and visualization
252
  type net_addr_type is array (n_ag_g - 1 downto 0) of std_logic_vector (addr_width_c-1 downto 0);
253
  type swi_addr_type is array (n_ag_g - 1 downto 0) of std_logic_vector (switch_addr_width_c-1 downto 0);
254
  signal req_addr_io_lut_dbg : net_addr_type;
255
  signal req_addr_arr_dbg : swi_addr_type;
256
  signal ctrl_arr_dbg     : swi_addr_type;
257
  signal data_arr_dbg     : net_flit_type;
258
 
259
begin
260
 
261
 
262
  debug: if dbg_en_g = 1 generate
263
      dbg_out <= we_io_xbar and not(full_xbar_io);
264
  end generate debug;
265
 
266
  gen_net_pkt : for i in 0 to n_ag_g - 1 generate
267
    data_io_xbar ((i+1)*data_width_g - 1 downto i*data_width_g) <= net_flit(i)(data_width_g - 1 downto 0);
268
 
269
    -- Debug
270
    req_addr_io_lut_dbg (i) <= req_addr_io_lut ((i+1)*addr_width_c -1 downto i*addr_width_c);
271
    req_addr_arr_dbg (i)    <= req_addr_lut_arb ((i+1)*switch_addr_width_c -1 downto i*switch_addr_width_c);
272
    ctrl_arr_dbg (i)        <= ctrl_arb_switches ((i+1)*switch_addr_width_c -1 downto i*switch_addr_width_c);
273
    data_arr_dbg (i)        <= net_flit (i) (data_width_g-1 downto 0);
274
  end generate gen_net_pkt;
275
 
276
 
277
  -- SWITCH MATRIX
278
  swi_mtrx : switch_matrix
279
    generic map (
280
      n_ag_g       => n_ag_g,
281
      data_width_g => data_width_g,
282
      addr_width_g => switch_addr_width_c
283
      )
284
    port map(
285
      av_in        => av_io_xbar,
286
      data_in      => data_io_xbar,
287
      we_in        => we_io_xbar,
288
      full_out     => full_xbar_io,
289
      av_out       => av_xbar_io,
290
      data_out     => data_xbar_io,
291
      we_out       => we_xbar_io,
292
      src_id_in    => ctrl_arb_switches,
293
      full_in      => full_io_xbar
294
      );
295
 
296
  -- IO BLOCKS
297
  map_io_blocks : for i in 0 to n_ag_g-1 generate
298
    Blocki      : io_block
299
      generic map (
300
        data_width_g    => data_width_g,
301
        fifo_depth_g    => fifo_depth_g,
302
        addr_width_g    => addr_width_c,
303
        pkt_switch_en_g => pkt_switch_en_g,  --14.10.06 
304
        stfwd_en_g      => stfwd_en_g,       --14.10.06 es
305
        max_send_g      => max_send_g,       -- 0=no limit
306
        net_freq_g      => net_freq_g,
307
        sim_dbg_en_g    => sim_dbg_en_g,
308
        ip_freq_g       => ip_freq_g
309
        )
310
      port map (
311
        clk_net         => clk_net,
312
        clk_ip          => clk_ip,
313
        rst_n           => rst_n,
314
 
315
        ip_av_in        => tx_av_in     (i),
316
        ip_data_in      => tx_data_in  ((i+1)*data_width_g - 1 downto i*data_width_g),
317
        ip_we_in        => tx_we_in     (i),
318
        ip_tx_full_out  => tx_full_out  (i),
319
        ip_tx_empty_out => tx_empty_out (i),
320
 
321
        net_av_out       => av_io_xbar      (i),
322
        net_flit_out     => net_flit        (i),
323
        net_we_out       => we_io_xbar      (i),
324
        net_req_addr_out => req_addr_io_lut ((i+1) * addr_width_c - 1 downto i * addr_width_c),
325
        net_req_out      => req_io_arb      (i),
326
        net_hold_out     => hold_io_arb     (i),
327
        net_grant_in     => grant_arb_io    (i),
328
        net_full_in      => full_xbar_io    (i),
329
 
330
        net_av_in     => av_xbar_io    (i),
331
        net_data_in   => data_xbar_io ((i+1)*data_width_g - 1 downto i*data_width_g),  --(i),
332
        net_we_in     => we_xbar_io    (i),
333
        net_full_out  => full_io_xbar  (i),
334
        net_empty_out => empty_io_arb  (i),
335
 
336
        ip_av_out       => rx_av_out     (i),
337
        ip_data_out     => rx_data_from_io ((i+1)*data_width_g - 1 downto i*data_width_g),
338
        ip_re_in        => rx_re_in      (i),
339
        ip_rx_empty_out => rx_empty_from_io (i),
340
        ip_rx_full_out  => rx_full_out   (i)
341
        );
342
 
343
 
344
    -- Addr_lut is connected between io_block and allocator
345
    ad_lut_i: addr_lut
346
      generic map(
347
        in_addr_w_g  => addr_width_c,
348
        out_addr_w_g => switch_addr_width_c,
349
        cmp_high_g   => addr_width_c-1,
350
        cmp_low_g    => 0,
351
        net_type_g   => 2, --3, depends on lut type. _lut_example:use 2, lut+pkg:use 3
352
        lut_en_g     => lut_en_g --1         -- if disabled, out <= in
353
        )
354
      port map(
355
        addr_in  => req_addr_io_lut ((i+1) * addr_width_c - 1 downto i * addr_width_c),
356
        addr_out => req_addr_lut_arb ((i+1) * switch_addr_width_c - 1 downto i * switch_addr_width_c)
357
        );
358
  end generate map_io_blocks;
359
 
360
 
361
  -- Allocator controls the switch
362
  alc : allocator
363
    generic map (
364
      n_ag_g              => n_ag_g,
365
      --addr_width_g        => addr_width_c,
366
      addr_width_g        => switch_addr_width_c,
367
      switch_addr_width_g => switch_addr_width_c
368
      )
369
    port map (
370
      clk                 => clk_net,
371
      rst_n               => rst_n,
372
      req_addr_in         => req_addr_lut_arb,
373
      req_in              => req_io_arb,
374
      hold_in             => hold_io_arb,
375
      grant_out           => grant_arb_io,
376
      src_id_out          => ctrl_arb_switches
377
      );
378
 
379
  -- 28.07
380
  visualize_rx_data : process (rx_data_from_io, rx_empty_from_io)
381
  begin  -- process visualize_rx_data
382
    for a in 0 to n_ag_g-1 loop
383
 
384
      -- Simple "others => '0'" causes problems with design_compiler
385
      if sim_dbg_en_g = 0 then
386
        -- This if-clause added 04.12.2006 es
387
        rx_data_out ((a+1)*data_width_g - 1 downto a*data_width_g) <= rx_data_from_io ((a+1)*data_width_g - 1 downto a*data_width_g);
388
      else
389
        -- 04.12.06 this was orig. code, "others" casues problems with design_compiler
390
        if rx_empty_from_io (a) = '0' then  -- Paketti tulossa
391
          rx_data_out ((a+1)*data_width_g - 1 downto a*data_width_g) <= rx_data_from_io ((a+1)*data_width_g - 1 downto a*data_width_g);
392
        else
393
          rx_data_out ((a+1)*data_width_g - 1 downto a*data_width_g) <= (others => '0');
394
        end if;
395
 
396
      end if;
397
 
398
    end loop;  -- a
399
 
400
 
401
 
402
    rx_empty_out <= rx_empty_from_io;
403
  end process visualize_rx_data;
404
 
405
  -----------------------------------------------------------------------------
406
  -- MONITOR
407
  -----------------------------------------------------------------------------
408
  monitor: monitor_top_xbar
409
    generic map (
410
        num_of_links_g => n_ag_g)
411
    port map (
412
        holds_in       => hold_io_arb,  -- allocator's hold_in
413
        grants_in      => grant_arb_io, -- allocator's grant_out
414
        reqs_in        => req_io_arb,   -- allocator's req_in
415
        uart_rx_in     => mon_UART_rx_in,
416
        uart_tx_out    => mon_UART_tx_out,
417
        clk            => clk_net,
418
        rst_n          => rst_n,
419
        mon_command_in => mon_command_in);
420
 
421
end top_level;

powered by: WebSVN 2.1.0

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