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/] [basic_tester/] [1.0/] [tb/] [tb_basic_tester.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Testbench for a hibi network
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : tb_basic_tester.vhd
6
-- Author     : ege
7
-- Created    : 2010/03/16
8
-- Last update: 2012-02-03
9
-- Description: 
10
--
11
-------------------------------------------------------------------------------
12
-- Copyright (c) 2010 
13
-------------------------------------------------------------------------------
14
-- Revisions  :
15
-- Date        Version  Author  Description
16
-- 2010/03/16  1.0      ES      Created
17
--
18
-------------------------------------------------------------------------------
19
-------------------------------------------------------------------------------
20
-- Funbase IP library Copyright (C) 2011 TUT Department of Computer Systems
21
--
22
--
23
-- This source file may be used and distributed without
24
-- restriction provided that this copyright statement is not
25
-- removed from the file and that any derivative work contains
26
-- the original copyright notice and the associated disclaimer.
27
--
28
-- This source file is free software; you can redistribute it
29
-- and/or modify it under the terms of the GNU Lesser General
30
-- Public License as published by the Free Software Foundation;
31
-- either version 2.1 of the License, or (at your option) any
32
-- later version.
33
--
34
-- This source is distributed in the hope that it will be
35
-- useful, but WITHOUT ANY WARRANTY; without even the implied
36
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
37
-- PURPOSE.  See the GNU Lesser General Public License for more
38
-- details.
39
--
40
-- You should have received a copy of the GNU Lesser General
41
-- Public License along with this source; if not, download it
42
-- from http://www.opencores.org/lgpl.shtml
43
-------------------------------------------------------------------------------
44
 
45
library ieee;
46
use ieee.std_logic_1164.all;
47
use ieee.numeric_std.all;
48
 
49
use ieee.std_logic_misc.all;
50
use std.textio.all;
51
 
52
--use work.txt_util.all;
53
use work.hibiv3_pkg.all;
54
 
55
entity tb_basic_tester is
56
end tb_basic_tester;
57
 
58
 
59
 
60
architecture structural of tb_basic_tester is
61
 
62
  constant x_pels_c : integer := 640;
63
  constant y_pels_c : integer := 320;
64
 
65
 
66
  constant n_ag_c          : integer := 3;   -- number of agents (=IPs)
67
 
68
  -- HIBI parameters
69
  constant data_width_c    : integer := 32;  -- bits
70
  constant addr_width_c    : integer := 32;  -- bits
71
  constant counter_width_c : integer := 16;  -- bits
72
  constant id_width_c      : integer := 6;   -- bits
73
  constant max_send_c      : integer := 40;  -- words
74
  constant arb_type_c      : integer := 0;   -- 0-3
75
  constant tx_fifo_size_c  : integer := 4;   -- words
76
  constant rx_fifo_size_c  : integer := 4;   -- words
77
 
78
  type gen_addr_array_type    is array (0 to 3) of integer;
79
  constant addresses_c : gen_addr_array_type :=
80
    (16#00000010#,      -- video_gen
81
     16#00000030#,      -- pic manipulator
82
     16#00000050#,      -- ddr
83
     16#00000070#       -- currently unused
84
     );
85
 
86
 
87
  -- IPs and wrappers can run on different frequencies
88
  -- (All Ips using one clock and all wrappers unsing the other)
89
  -- Frequencies must be integer multiple of each other.
90
  -- Edit both period and frequencies manually and ensure consistency.
91
  constant PERIOD_IP_C      : time    := 1*10 ns;
92
  constant PERIOD_HIBI_C    : time    := 1*10 ns;
93
  constant rel_agent_freq_c : integer := 1;
94
  constant rel_bus_freq_c   : integer := 1;
95
 
96
 
97
  -- Global signals
98
  signal clk_ip  : std_logic := '1';
99
  signal clk_noc : std_logic := '1';
100
  signal rst_n   : std_logic := '0';
101
 
102
  -- Define types for arrays. Transposed versions are needed for or_reduce
103
  -- function in bus resolution.
104
  type data_vec_type is array (n_ag_c-1 downto 0) of std_logic_vector (data_width_c-1 downto 0);
105
  type comm_vec_type is array (n_ag_c-1 downto 0) of std_logic_vector (comm_width_c-1 downto 0);
106
  type trnsp_data_vec is array (data_width_c-1 downto 0) of std_logic_vector (n_ag_c-1 downto 0);
107
  type trnsp_comm_vec is array (comm_width_c-1 downto 0) of std_logic_vector (n_ag_c-1 downto 0);
108
 
109
 
110
  -- Signals going from the IPs to the wrappers.
111
  -- Note that full and one_p actually come from wrapper but they are grouped
112
  -- here due their purpose.
113
  signal av_ip_wra    : std_logic_vector ( n_ag_c-1 downto 0);
114
  signal data_ip_wra  : data_vec_type;
115
  signal comm_ip_wra  : comm_vec_type;
116
  signal we_ip_wra    : std_logic_vector ( n_ag_c-1 downto 0);
117
  signal full_wra_ip  : std_logic_vector ( n_ag_c-1 downto 0);
118
  signal one_p_wra_ip : std_logic_vector ( n_ag_c-1 downto 0);
119
 
120
  -- Signals going from the wrappers to the IPs.
121
  signal av_wra_ip    : std_logic_vector ( n_ag_c-1 downto 0);
122
  signal data_wra_ip  : data_vec_type;
123
  signal comm_wra_ip  : comm_vec_type;
124
  signal re_ip_wra    : std_logic_vector ( n_ag_c-1 downto 0);
125
  signal empty_wra_ip : std_logic_vector ( n_ag_c-1 downto 0);
126
  signal one_d_wra_ip : std_logic_vector ( n_ag_c-1 downto 0);
127
 
128
  -- Signals going from the wrappers to the OR ports.
129
  signal av_wra_bus     : std_logic_vector ( n_ag_c-1 downto 0);
130
  signal data_wra_bus   : data_vec_type;
131
  signal comm_wra_bus   : comm_vec_type;
132
  signal trnsp_data_out : trnsp_data_vec;
133
  signal trnsp_comm_out : trnsp_comm_vec;
134
  signal full_wra_bus   : std_logic_vector ( n_ag_c-1 downto 0);
135
  signal lock_wra_bus   : std_logic_vector ( n_ag_c-1 downto 0);
136
 
137
  -- Signals going from the OR ports to the wrappers.
138
  signal av_bus_wra   : std_logic;
139
  signal data_bus_wra : std_logic_vector(data_width_c-1 downto 0);
140
  signal comm_bus_wra : std_logic_vector(comm_width_c-1 downto 0);
141
  signal full_bus_wra : std_logic;
142
  signal lock_bus_wra : std_logic;
143
 
144
 
145
  -- 2007/04/16
146
  constant dbg_width_c  : integer := 1;
147
  signal   debug_tb_wra : std_logic_vector ( dbg_width_c-1 downto 0);
148
 
149
 
150
  --  constant arb_type_c   : integer := 0;
151
 
152
 
153
 
154
 
155
begin  -- structural
156
 
157
 
158
  -- Component 0
159
  sender: entity work.basic_tester_tx
160
 
161
    generic map(
162
      conf_file_g  => "test_tx.txt",
163
      comm_width_g => comm_width_c, --3,
164
      data_width_g => 32
165
      )
166
    port map(
167
      clk          => clk_ip,
168
      rst_n        => rst_n,
169
 
170
      -- done_out     => ,
171
 
172
      agent_av_out   => av_ip_wra (0),
173
      agent_data_out => data_ip_wra (0),
174
      agent_comm_out => comm_ip_wra (0),
175
      agent_we_out   => we_ip_wra (0),
176
      agent_full_in  => full_wra_ip (0),
177
      agent_one_p_in => one_p_wra_ip (0)
178
      );
179
 
180
  re_ip_wra (0)   <= '0';
181
 
182
 
183
  -- Component 1
184
  av_ip_wra (1)   <= '0';
185
  data_ip_wra (1) <= (others => 'Z');
186
  comm_ip_wra (1) <= (others => 'Z');
187
  we_ip_wra (1)   <= '0';
188
 
189
 
190
 
191
  receiver: entity work.basic_tester_rx
192
 
193
    generic map(
194
      conf_file_g  => "test_rx.txt",
195
      comm_width_g => comm_width_c, --3,
196
      data_width_g => 32
197
      )
198
    port map(
199
      clk          => clk_ip,
200
      rst_n        => rst_n,
201
 
202
      -- done_out     => ,
203
 
204
      -- HIBI WRAPPER PORTS
205
      agent_av_in    => av_wra_ip (1),
206
      agent_data_in  => data_wra_ip (1),
207
      agent_comm_in  => comm_wra_ip (1),
208
      agent_re_out   => re_ip_wra (1),
209
      agent_empty_in => empty_wra_ip (1),
210
      agent_one_d_in => one_d_wra_ip (1)
211
      );
212
 
213
 
214
  -- Component 2
215
  av_ip_wra (2)   <= '0';
216
  data_ip_wra (2) <= (others => 'Z');
217
  comm_ip_wra (2) <= (others => 'Z');
218
  we_ip_wra (2)   <= '0';
219
 
220
  re_ip_wra (2)   <= '1';
221
 
222
 
223
 
224
  hibi_net : for ag in 0 to n_ag_c-1 generate
225
    hibi_wrapper_r4_1 : entity work.hibi_wrapper_r4
226
      generic map (
227
        id_g          => ag+1,
228
        id_min_g      => 0,             -- not in hibi_V2
229
        id_max_g      => 0,             -- not supported in hibi_v3
230
        --base_id_g           => 2**id_width_c-1,  not supported in hibi_v3
231
        inv_addr_en_g => 0,
232
        -- first parameter to addresses_c is the segment, 
233
        -- second is the agents number within the segment
234
        addr_g        => addresses_c (ag),
235
 
236
        id_width_g      => id_width_c,
237
        addr_width_g    => addr_width_c,
238
        data_width_g    => data_width_c,
239
        comm_width_g    => comm_width_c, --3,
240
        counter_width_g => counter_width_c,
241
 
242
        rx_fifo_depth_g     => rx_fifo_size_c,
243
        rx_msg_fifo_depth_g => 3, --0,  -- fifo_size_c
244
        tx_fifo_depth_g     => tx_fifo_size_c,
245
        tx_msg_fifo_depth_g => 3,-- 0,  -- fifo_size_c
246
 
247
        rel_agent_freq_g => rel_agent_freq_c,
248
        rel_bus_freq_g   => rel_bus_freq_c,
249
        arb_type_g       => arb_type_c,  --13.4.2007
250
 
251
 
252
        prior_g    => ag +1,
253
        max_send_g => max_send_c,
254
        n_agents_g => n_ag_c,
255
 
256
        n_cfg_pages_g    => 1,
257
        n_time_slots_g   => 0,
258
        n_extra_params_g => 1,
259
        -- multicast_en_g   => 0, not supported in hibi_v3
260
        cfg_re_g         => 0,
261
        cfg_we_g         => 1,  --0,
262
 
263
        debug_width_g => dbg_width_c  --2007/04/16
264
        )
265
      port map (
266
        agent_clk      => clk_ip,
267
        bus_clk        => clk_noc,
268
        bus_sync_clk   => clk_noc,
269
        agent_sync_clk => clk_ip,
270
        rst_n          => rst_n,
271
 
272
        bus_av_in    => av_bus_wra,
273
        bus_data_in  => data_bus_wra,
274
        bus_comm_in  => comm_bus_wra,
275
        bus_full_in  => full_bus_wra,
276
        bus_lock_in  => lock_bus_wra,
277
        bus_av_out   => av_wra_bus   (ag),
278
        bus_data_out => data_wra_bus (ag),
279
        bus_comm_out => comm_wra_bus (ag),
280
        bus_full_out => full_wra_bus (ag),
281
        bus_lock_out => lock_wra_bus (ag),
282
 
283
        agent_av_in      => av_ip_wra    (ag),
284
        agent_data_in    => data_ip_wra  (ag),
285
        agent_comm_in    => comm_ip_wra  (ag),
286
        agent_we_in      => we_ip_wra    (ag),
287
        agent_full_out   => full_wra_ip  (ag),
288
        agent_one_p_out  => one_p_wra_ip (ag),
289
 
290
        agent_re_in      => re_ip_wra    (ag),
291
        agent_av_out     => av_wra_ip    (ag),
292
        agent_data_out   => data_wra_ip  (ag),
293
        agent_comm_out   => comm_wra_ip  (ag),
294
        agent_empty_out  => empty_wra_ip (ag),
295
        agent_one_d_out  => one_d_wra_ip (ag),
296
 
297
        --debug_out => dummy,
298
        debug_in => debug_tb_wra
299
 
300
        );
301
 
302
  end generate hibi_net;
303
 
304
 
305
 
306
 
307
 
308
  -- assign the bus signals. bus signals are first transposed, eg.
309
  -- 3*32b buses -> 32*3b buses
310
  trnsp_bus : for j in 0 to n_ag_c-1 generate
311
 
312
      i : for i in 0 to data_width_c-1 generate
313
        trnsp_data_out (i)(j) <= data_wra_bus (j)(i);
314
      end generate i;
315
 
316
      k : for k in 0 to comm_width_c-1 generate
317
        trnsp_comm_out (k)(j) <= comm_wra_bus (j)(k);
318
      end generate k;
319
  end generate trnsp_bus;
320
 
321
 
322
 
323
 
324
    -- here we or_reduce the transposed signals, so we get the in-signals
325
    -- for wrappers.
326
    or_reduce_data : for i in 0 to data_width_c-1 generate
327
      data_bus_wra (i) <= or_reduce(trnsp_data_out (i));
328
    end generate or_reduce_data;
329
 
330
 
331
    chk_lock: process (lock_wra_bus)
332
      variable n_locks_v : integer := 0;
333
    begin  -- process chk_lock
334
 
335
      n_locks_v := 0;
336
 
337
      for i in 0 to n_ag_c -1 loop
338
        if lock_wra_bus (i) = '1' then
339
          n_locks_v := n_locks_v +1;
340
        end if;
341
      end loop;  -- i
342
 
343
      if n_locks_v > 1 then
344
        assert false report "Multiple drivers for lock signal!!!" severity error;
345
      end if;
346
    end process chk_lock;
347
 
348
    or_reduce_comm : for i in 0 to comm_width_c-1 generate
349
        comm_bus_wra(i) <= or_reduce(trnsp_comm_out(i));
350
    end generate or_reduce_comm;
351
 
352
 
353
    or_reduce_rest : for i in 0 to comm_width_c-1 generate
354
      av_bus_wra   <= or_reduce(av_wra_bus);
355
      lock_bus_wra <= or_reduce(lock_wra_bus);
356
      full_bus_wra <= or_reduce(full_wra_bus);
357
    end generate or_reduce_rest;
358
 
359
    clk_ip  <= not clk_ip  after PERIOD_IP_C/2;
360
    clk_noc <= not clk_noc after PERIOD_HIBI_C/2;
361
    rst_n <= '0', '1'    after 4.6 * PERIOD_HIBI_C;
362
 
363
 
364
end structural;
365
 

powered by: WebSVN 2.1.0

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