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.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-----------------------------------------------------------------
2
-- file         : crossbar.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
--
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
entity crossbar is
37
  generic (
38
    n_ag_g          :    integer;
39
    data_width_g    :    integer;
40
    pkt_switch_en_g :    integer := 0;  --14.10.06 es
41
    stfwd_en_g      :    integer := 0;  --14.10.06 es
42
    max_send_g      :    integer := 9;  -- 0=no limit
43
    net_freq_g      :    integer := 1;  -- relative crossbar freq
44
    lut_en_g        :    integer := 1;  -- 19.10.2006 ES
45
    ip_freq_g       :    integer := 1;  -- relative IP freq
46
    fifo_depth_g    :    integer;
47
    sim_dbg_en_g    :    integer := 0;
48
    dbg_en_g        :    integer := 0;
49
    dbg_width_g     :    integer
50
    );
51
  port (
52
    rst_n           : in std_logic;
53
    clk_net         : in std_logic;
54
    clk_ip          : in std_logic;
55
 
56
    tx_av_in     : in  std_logic_vector (n_ag_g - 1 downto 0);
57
    tx_data_in   : in  std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
58
    tx_we_in     : in  std_logic_vector (n_ag_g - 1 downto 0);
59
    tx_full_out  : out std_logic_vector (n_ag_g - 1 downto 0);
60
    tx_empty_out : out std_logic_vector (n_ag_g - 1 downto 0);
61
 
62
    rx_av_out    : out std_logic_vector (n_ag_g - 1 downto 0);
63
    rx_data_out  : out std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
64
    rx_empty_out : out std_logic_vector (n_ag_g - 1 downto 0);
65
    rx_full_out  : out std_logic_vector (n_ag_g - 1 downto 0);
66
    rx_re_in     : in  std_logic_vector (n_ag_g - 1 downto 0);
67
 
68
    dbg_out      : out std_logic_vector (dbg_width_g - 1 downto 0)
69
    );
70
end crossbar;
71
 
72
architecture top_level of crossbar is
73
 
74
 
75
  function log2(input : integer)
76
    return integer is
77
  begin
78
    for i in 1 to 100 loop
79
      if (2**i >= input) then
80
        return(i);
81
      end if;
82
    end loop;  -- i
83
    return 100;
84
  end log2;
85
 
86
  -- addresses are from 0 to n_ag - 1
87
  --constant addr_width_c : integer := log2(n_ag_g);
88
  constant addr_width_c : integer := data_width_g;
89
 
90
  -- switch addresses are from 1 to n_ag, value n_ag= illegal
91
  constant switch_addr_width_c : integer := log2(n_ag_g + 1);
92
 
93
  component io_block
94
    generic (
95
      data_width_g    :    integer;
96
      fifo_depth_g    :    integer;
97
      addr_width_g    :    integer;
98
      pkt_switch_en_g :    integer := 0;  --14.10.06 es
99
      stfwd_en_g      :    integer := 0;  --14.10.06 es
100
      max_send_g      :    integer := 9;  -- 0=no limit
101
      net_freq_g      :    integer;
102
      sim_dbg_en_g    :    integer;
103
      ip_freq_g       :    integer
104
      );
105
    port (
106
      clk_net         : in std_logic;
107
      clk_ip          : in std_logic;
108
      rst_n           : in std_logic;
109
 
110
      -- Signals from agent
111
      ip_av_in        : in  std_logic;    -- 15.09.2006 
112
      ip_data_in      : in  std_logic_vector (data_width_g-1 downto 0);
113
      ip_we_in        : in  std_logic;
114
      ip_tx_full_out  : out std_logic;
115
      ip_tx_empty_out : out std_logic;
116
 
117
      -- Signals to bus and arbiter
118
      net_av_out       : out std_logic;
119
      net_flit_out     : out std_logic_vector (data_width_g-1 downto 0);
120
      net_we_out   : out std_logic;
121
      net_req_addr_out : out std_logic_vector (addr_width_g  -1 downto 0);
122
      net_req_out      : out std_logic;
123
      net_hold_out     : out std_logic;
124
      net_grant_in     : in  std_logic;
125
      net_full_in      : in  std_logic;
126
 
127
      -- Signals from bus and arbiter
128
      net_av_in     : in  std_logic;
129
      net_data_in   : in  std_logic_vector (data_width_g -1 downto 0);
130
      net_we_in     : in  std_logic;
131
      net_full_out  : out std_logic;
132
      net_empty_out : out std_logic;
133
 
134
      -- Signals to agent
135
      ip_av_out       : out std_logic;    -- 15.09.2006 
136
      ip_data_out     : out std_logic_vector (data_width_g -1 downto 0);
137
      ip_re_in        : in  std_logic;
138
      ip_rx_full_out  : out std_logic;
139
      ip_rx_empty_out : out std_logic
140
      );
141
  end component;
142
 
143
  component addr_lut
144
    generic (
145
      in_addr_w_g  : integer := 32;
146
      out_addr_w_g : integer := 36;
147
      cmp_high_g   : integer := 31;
148
      cmp_low_g    : integer := 0;
149
      net_type_g   : integer := 0;
150
      lut_en_g     : integer := 1         -- if disabled, out <= in
151
      );
152
    port (
153
      addr_in  : in  std_logic_vector (in_addr_w_g-1 downto 0);
154
      addr_out : out std_logic_vector (out_addr_w_g-1 downto 0)
155
      );
156
  end component; --addr_lut;
157
 
158
 
159
  component allocator
160
    generic (
161
      n_ag_g              :     integer;
162
      addr_width_g        :     integer;
163
      switch_addr_width_g :     integer
164
      );
165
    port(
166
      clk                 : in  std_logic;
167
      rst_n               : in  std_logic;
168
      req_addr_in         : in  std_logic_vector (n_ag_g * addr_width_g - 1 downto 0);
169
      req_in              : in  std_logic_vector (n_ag_g - 1 downto 0);
170
      hold_in             : in  std_logic_vector (n_ag_g - 1 downto 0);
171
      grant_out           : out std_logic_vector (n_ag_g - 1 downto 0);
172
      src_id_out          : out std_logic_vector (n_ag_g * switch_addr_width_g - 1 downto 0)
173
      );
174
  end component;
175
 
176
  component switch_matrix
177
    generic (
178
      n_ag_g       :     integer;
179
      data_width_g :     integer;
180
      addr_width_g :     integer
181
      );
182
    port (
183
      av_in        : in  std_logic_vector (n_ag_g - 1 downto 0);
184
      data_in      : in  std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
185
      we_in        : in  std_logic_vector (n_ag_g-1 downto 0);
186
      we_out       : out std_logic_vector (n_ag_g-1 downto 0);
187
      av_out       : out std_logic_vector (n_ag_g - 1 downto 0);
188
      data_out     : out std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
189
      src_id_in    : in  std_logic_vector (n_ag_g * addr_width_g - 1 downto 0);
190
      full_in      : in  std_logic_vector (n_ag_g - 1 downto 0);
191
      full_out     : out std_logic_vector (n_ag_g - 1 downto 0)
192
      );
193
  end component;  --switch_matrix;
194
 
195
 
196
 
197
  type net_flit_type is array (n_ag_g - 1 downto 0) of std_logic_vector (data_width_g -1 downto 0);
198
  signal net_flit   : net_flit_type;
199
 
200
 
201
  -- Arbiter signals
202
  signal empty_io_arb      : std_logic_vector (n_ag_g-1 downto 0);
203
  signal grant_arb_io      : std_logic_vector (n_ag_g-1 downto 0);
204
  signal req_io_arb        : std_logic_vector (n_ag_g-1 downto 0);
205
  signal hold_io_arb       : std_logic_vector (n_ag_g - 1 downto 0);
206
  signal ctrl_arb_switches : std_logic_vector (n_ag_g * switch_addr_width_c - 1 downto 0);
207
 
208
  --signal req_addr_io_arb   : std_logic_vector (n_ag_g * addr_width_c - 1 downto 0);
209
  signal req_addr_io_lut  : std_logic_vector (n_ag_g * addr_width_c - 1 downto 0);
210
  signal req_addr_lut_arb : std_logic_vector (n_ag_g * switch_addr_width_c - 1 downto 0);
211
 
212
 
213
 
214
  -- IO <-> Switch matrix
215
  signal av_io_xbar   : std_logic_vector (n_ag_g-1 downto 0);
216
  signal data_io_xbar : std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
217
  signal we_io_xbar   : std_logic_vector (n_ag_g-1 downto 0);
218
  signal full_xbar_io : std_logic_vector (n_ag_g - 1 downto 0);
219
 
220
  signal av_xbar_io   : std_logic_vector (n_ag_g-1 downto 0);
221
  signal data_xbar_io : std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
222
  signal we_xbar_io   : std_logic_vector (n_ag_g-1 downto 0);
223
  signal full_io_xbar : std_logic_vector (n_ag_g - 1 downto 0);
224
 
225
  -- IO -> IP, 28.07
226
  signal rx_data_from_io  : std_logic_vector (n_ag_g * data_width_g - 1 downto 0);
227
  signal rx_empty_from_io : std_logic_vector (n_ag_g - 1 downto 0);
228
 
229
 
230
  -- Array signals for debugging and visualization
231
  type net_addr_type is array (n_ag_g - 1 downto 0) of std_logic_vector (addr_width_c-1 downto 0);
232
  type swi_addr_type is array (n_ag_g - 1 downto 0) of std_logic_vector (switch_addr_width_c-1 downto 0);
233
  signal req_addr_io_lut_dbg : net_addr_type;
234
  signal req_addr_arr_dbg : swi_addr_type;
235
  signal ctrl_arr_dbg     : swi_addr_type;
236
  signal data_arr_dbg     : net_flit_type;
237
 
238
begin
239
 
240
 
241
  debug: if dbg_en_g = 1 generate
242
      dbg_out <= we_io_xbar and not(full_xbar_io);
243
  end generate debug;
244
 
245
  gen_net_pkt : for i in 0 to n_ag_g - 1 generate
246
    data_io_xbar ((i+1)*data_width_g - 1 downto i*data_width_g) <= net_flit(i)(data_width_g - 1 downto 0);
247
 
248
    -- Debug
249
    req_addr_io_lut_dbg (i) <= req_addr_io_lut ((i+1)*addr_width_c -1 downto i*addr_width_c);
250
    req_addr_arr_dbg (i)    <= req_addr_lut_arb ((i+1)*switch_addr_width_c -1 downto i*switch_addr_width_c);
251
    ctrl_arr_dbg (i)        <= ctrl_arb_switches ((i+1)*switch_addr_width_c -1 downto i*switch_addr_width_c);
252
    data_arr_dbg (i)        <= net_flit (i) (data_width_g-1 downto 0);
253
  end generate gen_net_pkt;
254
 
255
 
256
  -- SWITCH MATRIX
257
  swi_mtrx : switch_matrix
258
    generic map (
259
      n_ag_g       => n_ag_g,
260
      data_width_g => data_width_g,
261
      addr_width_g => switch_addr_width_c
262
      )
263
    port map(
264
      av_in        => av_io_xbar,
265
      data_in      => data_io_xbar,
266
      we_in        => we_io_xbar,
267
      full_out     => full_xbar_io,
268
      av_out       => av_xbar_io,
269
      data_out     => data_xbar_io,
270
      we_out       => we_xbar_io,
271
      src_id_in    => ctrl_arb_switches,
272
      full_in      => full_io_xbar
273
      );
274
 
275
  -- IO BLOCKS
276
  map_io_blocks : for i in 0 to n_ag_g-1 generate
277
    Blocki      : io_block
278
      generic map (
279
        data_width_g    => data_width_g,
280
        fifo_depth_g    => fifo_depth_g,
281
        addr_width_g    => addr_width_c,
282
        pkt_switch_en_g => pkt_switch_en_g,  --14.10.06 
283
        stfwd_en_g      => stfwd_en_g,       --14.10.06 es
284
        max_send_g      => max_send_g,       -- 0=no limit
285
        net_freq_g      => net_freq_g,
286
        sim_dbg_en_g    => sim_dbg_en_g,
287
        ip_freq_g       => ip_freq_g
288
        )
289
      port map (
290
        clk_net         => clk_net,
291
        clk_ip          => clk_ip,
292
        rst_n           => rst_n,
293
 
294
        ip_av_in        => tx_av_in     (i),
295
        ip_data_in      => tx_data_in  ((i+1)*data_width_g - 1 downto i*data_width_g),
296
        ip_we_in        => tx_we_in     (i),
297
        ip_tx_full_out  => tx_full_out  (i),
298
        ip_tx_empty_out => tx_empty_out (i),
299
 
300
        net_av_out       => av_io_xbar      (i),
301
        net_flit_out     => net_flit        (i),
302
        net_we_out       => we_io_xbar      (i),
303
        net_req_addr_out => req_addr_io_lut ((i+1) * addr_width_c - 1 downto i * addr_width_c),
304
        net_req_out      => req_io_arb      (i),
305
        net_hold_out     => hold_io_arb     (i),
306
        net_grant_in     => grant_arb_io    (i),
307
        net_full_in      => full_xbar_io    (i),
308
 
309
        net_av_in     => av_xbar_io    (i),
310
        net_data_in   => data_xbar_io ((i+1)*data_width_g - 1 downto i*data_width_g),  --(i),
311
        net_we_in     => we_xbar_io    (i),
312
        net_full_out  => full_io_xbar  (i),
313
        net_empty_out => empty_io_arb  (i),
314
 
315
        ip_av_out       => rx_av_out     (i),
316
        ip_data_out     => rx_data_from_io ((i+1)*data_width_g - 1 downto i*data_width_g),
317
        ip_re_in        => rx_re_in      (i),
318
        ip_rx_empty_out => rx_empty_from_io (i),
319
        ip_rx_full_out  => rx_full_out   (i)
320
        );
321
 
322
 
323
    -- Addr_lut is connected between io_block and allocator
324
    ad_lut_i: addr_lut
325
      generic map(
326
        in_addr_w_g  => addr_width_c,
327
        out_addr_w_g => switch_addr_width_c,
328
        cmp_high_g   => addr_width_c-1,
329
        cmp_low_g    => 0,
330
        net_type_g   => 2, --3, depends on lut type. _lut_example:use 2, lut+pkg:use 3
331
        lut_en_g     => lut_en_g --1         -- if disabled, out <= in
332
        )
333
      port map(
334
        addr_in  => req_addr_io_lut ((i+1) * addr_width_c - 1 downto i * addr_width_c),
335
        addr_out => req_addr_lut_arb ((i+1) * switch_addr_width_c - 1 downto i * switch_addr_width_c)
336
        );
337
  end generate map_io_blocks;
338
 
339
 
340
  -- Allocator controls the switch
341
  alc : allocator
342
    generic map (
343
      n_ag_g              => n_ag_g,
344
      --addr_width_g        => addr_width_c,
345
      addr_width_g        => switch_addr_width_c,
346
      switch_addr_width_g => switch_addr_width_c
347
      )
348
    port map (
349
      clk                 => clk_net,
350
      rst_n               => rst_n,
351
      req_addr_in         => req_addr_lut_arb,
352
      req_in              => req_io_arb,
353
      hold_in             => hold_io_arb,
354
      grant_out           => grant_arb_io,
355
      src_id_out          => ctrl_arb_switches
356
      );
357
 
358
  -- 28.07
359
  visualize_rx_data : process (rx_data_from_io, rx_empty_from_io)
360
  begin  -- process visualize_rx_data
361
    for a in 0 to n_ag_g-1 loop
362
 
363
      -- Simple "others => '0'" causes problems with design_compiler
364
      if sim_dbg_en_g = 0 then
365
        -- This if-clause added 04.12.2006 es
366
        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);
367
      else
368
        -- 04.12.06 this was orig. code, "others" casues problems with design_compiler
369
        if rx_empty_from_io (a) = '0' then  -- Paketti tulossa
370
          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);
371
        else
372
          rx_data_out ((a+1)*data_width_g - 1 downto a*data_width_g) <= (others => '0');
373
        end if;
374
 
375
      end if;
376
 
377
    end loop;  -- a
378
 
379
 
380
 
381
    rx_empty_out <= rx_empty_from_io;
382
  end process visualize_rx_data;
383
 
384
 
385
end top_level;

powered by: WebSVN 2.1.0

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