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/] [hibi/] [3.0/] [tb/] [sad_tb/] [top_level.hh] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/*
2
 * Author: Lasse Lehtonen
3
 *
4
 * Top level containing all components for SAD hibi testbench:
5
 * hibi network's top-level, set of agents, and clk generation.
6
 *
7
 * $Id: top_level.hh 2002 2011-10-04 13:18:30Z ege $
8
 *
9
 */
10
 
11
 
12
#ifndef SAD_HIBI_TOPLEVEL_HH
13
#define SAD_HIBI_TOPLEVEL_HH
14
 
15
#include "constants.hh" // system size etc.
16
#include "agent.hh"     // stimulus + check
17
#include "hibiv3_r4.hh" // network toplevel
18
#include "hibiv3_r3.hh" // network toplevel
19
 
20
#include 
21
#include 
22
using namespace std;
23
 
24
#include 
25
using namespace sc_core;
26
using namespace sc_dt;
27
 
28
 
29
class TopLevel : public sc_module
30
{
31
public:
32
 
33
   SC_HAS_PROCESS(TopLevel);
34
 
35
   //* Constructor
36
   /* There are few #ifndefs in constructor because r3 and r4
37
    * have different interface ports.
38
    */
39
 
40
   TopLevel(sc_module_name name)
41
      : sc_module(name),
42
        clk_ip("clk_ip", sc_core::sc_time(1000/agent_freq_c, sc_core::SC_NS)),
43
        clk_bus("clk_bus", sc_core::sc_time(1000/bus_freq_c, sc_core::SC_NS)),
44
        rst_n("rst_n"),
45
        b_comm_in("b_comm_in"),
46
        b_data_in("b_data_in"),
47
#ifndef USE_R3_WRAPPERS
48
        b_av_in("b_av_in"),
49
#else
50
        b_addr_in("b_addr_in"),
51
#endif
52
        b_we_in("b_we_in"),
53
        b_re_in("b_re_in"),
54
        b_comm_out("b_comm_out"),
55
        b_data_out("b_data_out"),
56
#ifndef USE_R3_WRAPPERS
57
        b_av_out("b_av_out"),
58
#else
59
        b_addr_out("b_addr_out"),
60
#endif
61
        b_full_out("b_full_out"),
62
        b_one_p_out("b_one_p_out"),
63
        b_empty_out("b_empty_out"),
64
        b_one_d_out("b_one_d_out"),
65
#ifndef USE_R3_WRAPPERS
66
        hibi("HIBI", "hibiv3_r4")
67
#else
68
        b_msg_comm_in("b_msg_comm_in"),
69
        b_msg_data_in("b_msg_data_in"),
70
        b_msg_addr_in("b_msg_addr_in"),
71
        b_msg_we_in("b_msg_we_in"),
72
        b_msg_re_in("b_msg_re_in"),
73
        b_msg_comm_out("b_msg_comm_out"),
74
        b_msg_data_out("b_msg_data_out"),
75
        b_msg_addr_out("b_msg_addr_out"),
76
        b_msg_full_out("b_msg_full_out"),
77
        b_msg_one_p_out("b_msg_one_p_out"),
78
        b_msg_empty_out("b_msg_empty_out"),
79
        b_msg_one_d_out("b_msg_one_d_out"),
80
        hibi("HIBI", "hibiv3_r3")
81
 
82
#endif
83
   {
84
      // Activate reset (active low)
85
      rst_n.write(false);
86
 
87
      // Create agents (stimulus components)
88
      for(int i = 0; i < n_agents_c; ++i)
89
      {
90
         ostringstream name;
91
         name << "SAD_AGENT_" << i;
92
         agents.push_back(new Agent
93
                                       comm_width_c, separate_addr_c>
94
                          (name.str().c_str(), i, agents));
95
      }
96
 
97
      // Bind agents to signals
98
      for(int i = 0; i < n_agents_c; ++i)
99
      {
100
         agents.at(i)->clk.bind(clk_ip);
101
         agents.at(i)->rst_n.bind(rst_n);
102
         agents.at(i)->comm_out.bind(a_comm_out[i]);
103
         agents.at(i)->data_out.bind(a_data_out[i]);
104
#ifndef USE_R3_WRAPPERS
105
         agents.at(i)->av_out.bind(a_av_out[i]);
106
#else
107
         agents.at(i)->addr_out.bind(a_addr_out[i]);
108
#endif
109
         agents.at(i)->we_out.bind(a_we_out[i]);
110
         agents.at(i)->re_out.bind(a_re_out[i]);
111
         agents.at(i)->comm_in.bind(a_comm_in[i]);
112
         agents.at(i)->data_in.bind(a_data_in[i]);
113
#ifndef USE_R3_WRAPPERS
114
         agents.at(i)->av_in.bind(a_av_in[i]);
115
#else
116
         agents.at(i)->addr_in.bind(a_addr_in[i]);
117
#endif
118
         agents.at(i)->full_in.bind(a_full_in[i]);
119
         agents.at(i)->one_p_in.bind(a_one_p_in[i]);
120
         agents.at(i)->empty_in.bind(a_empty_in[i]);
121
         agents.at(i)->one_d_in.bind(a_one_d_in[i]);
122
 
123
#ifdef USE_R3_WRAPPERS
124
         agents.at(i)->msg_comm_out.bind(a_msg_comm_out[i]);
125
         agents.at(i)->msg_data_out.bind(a_msg_data_out[i]);
126
         agents.at(i)->msg_addr_out.bind(a_msg_addr_out[i]);
127
         agents.at(i)->msg_we_out.bind(a_msg_we_out[i]);
128
         agents.at(i)->msg_re_out.bind(a_msg_re_out[i]);
129
         agents.at(i)->msg_comm_in.bind(a_msg_comm_in[i]);
130
         agents.at(i)->msg_data_in.bind(a_msg_data_in[i]);
131
         agents.at(i)->msg_addr_in.bind(a_msg_addr_in[i]);
132
         agents.at(i)->msg_full_in.bind(a_msg_full_in[i]);
133
         agents.at(i)->msg_one_p_in.bind(a_msg_one_p_in[i]);
134
         agents.at(i)->msg_empty_in.bind(a_msg_empty_in[i]);
135
         agents.at(i)->msg_one_d_in.bind(a_msg_one_d_in[i]);
136
#endif
137
      }
138
 
139
      // Bind HIBI ports to signals
140
      hibi.clk_ip.bind(clk_ip);
141
      hibi.clk_noc.bind(clk_bus);
142
      hibi.rst_n.bind(rst_n);
143
 
144
      hibi.agent_comm_in.bind(b_comm_in);
145
      hibi.agent_data_in.bind(b_data_in);
146
#ifndef USE_R3_WRAPPERS
147
      hibi.agent_av_in.bind(b_av_in);
148
#else
149
      hibi.agent_addr_in.bind(b_addr_in);
150
#endif
151
      hibi.agent_we_in.bind(b_we_in);
152
      hibi.agent_re_in.bind(b_re_in);
153
      hibi.agent_comm_out.bind(b_comm_out);
154
      hibi.agent_data_out.bind(b_data_out);
155
#ifndef USE_R3_WRAPPERS
156
      hibi.agent_av_out.bind(b_av_out);
157
#else
158
      hibi.agent_addr_out.bind(b_addr_out);
159
#endif
160
      hibi.agent_full_out.bind(b_full_out);
161
      hibi.agent_one_p_out.bind(b_one_p_out);
162
      hibi.agent_empty_out.bind(b_empty_out);
163
      hibi.agent_one_d_out.bind(b_one_d_out);
164
 
165
#ifdef USE_R3_WRAPPERS
166
      hibi.agent_msg_comm_in.bind(b_msg_comm_in);
167
      hibi.agent_msg_data_in.bind(b_msg_data_in);
168
      hibi.agent_msg_addr_in.bind(b_msg_addr_in);
169
      hibi.agent_msg_we_in.bind(b_msg_we_in);
170
      hibi.agent_msg_re_in.bind(b_msg_re_in);
171
      hibi.agent_msg_comm_out.bind(b_msg_comm_out);
172
      hibi.agent_msg_data_out.bind(b_msg_data_out);
173
      hibi.agent_msg_addr_out.bind(b_msg_addr_out);
174
      hibi.agent_msg_full_out.bind(b_msg_full_out);
175
      hibi.agent_msg_one_p_out.bind(b_msg_one_p_out);
176
      hibi.agent_msg_empty_out.bind(b_msg_empty_out);
177
      hibi.agent_msg_one_d_out.bind(b_msg_one_d_out);
178
#endif
179
 
180
      // Spawn process to pass the data between hibi and agents
181
      SC_METHOD(connectSignals);
182
      for(int i = 0; i < n_agents_c; ++i)
183
      {
184
         sensitive << agents.at(i)->comm_out
185
                   << agents.at(i)->data_out
186
#ifndef USE_R3_WRAPPERS
187
                   << agents.at(i)->av_out
188
#else
189
                   << agents.at(i)->addr_out
190
#endif
191
                   << agents.at(i)->we_out
192
                   << agents.at(i)->re_out;
193
#ifdef USE_R3_WRAPPERS
194
         sensitive << agents.at(i)->msg_comm_out
195
                   << agents.at(i)->msg_data_out
196
                   << agents.at(i)->msg_addr_out
197
                   << agents.at(i)->msg_we_out
198
                   << agents.at(i)->msg_re_out;
199
#endif
200
      }
201
      sensitive << hibi.agent_comm_out
202
                << hibi.agent_data_out
203
#ifndef USE_R3_WRAPPERS
204
                << hibi.agent_av_out
205
#else
206
                << hibi.agent_addr_out
207
#endif
208
                << hibi.agent_full_out
209
                << hibi.agent_one_p_out
210
                << hibi.agent_empty_out
211
                << hibi.agent_one_d_out;
212
#ifdef USE_R3_WRAPPERS
213
      sensitive << hibi.agent_msg_comm_out
214
                << hibi.agent_msg_data_out
215
                << hibi.agent_msg_full_out
216
                << hibi.agent_msg_one_p_out
217
                << hibi.agent_msg_empty_out
218
                << hibi.agent_msg_one_d_out;
219
#endif
220
 
221
   }
222
 
223
   //* Destructor
224
   ~TopLevel()
225
   {
226
      for(int i = 0; i < n_agents_c; ++i)
227
      {
228
         delete agents.at(i); agents.at(i) = 0;
229
      }
230
   }
231
 
232
   //* Sets reset to some value
233
   void setResetN(bool value)
234
   {
235
      rst_n.write(value);
236
   }
237
 
238
 
239
private:
240
 
241
 
242
   //* Connects signals from hibi to the agents and vice versa
243
   void connectSignals(void)
244
   {
245
      sc_bv  b_comm_s;
246
      sc_bv  b_data_s;
247
#ifndef USE_R3_WRAPPERS
248
      sc_bv                 b_av_s;
249
#else
250
      sc_bv  b_addr_s;
251
#endif
252
      sc_bv                 b_we_s;
253
      sc_bv                 b_re_s;
254
 
255
#ifdef USE_R3_WRAPPERS
256
      sc_bv  b_msg_comm_s;
257
      sc_bv  b_msg_data_s;
258
      sc_bv  b_msg_addr_s;
259
      sc_bv                 b_msg_we_s;
260
      sc_bv                 b_msg_re_s;
261
#endif
262
 
263
      for(int i = 0; i < n_agents_c; ++i)
264
      {
265
         a_comm_in[i].write
266
            (b_comm_out.read().range((i+1)*comm_width_c-1, i*comm_width_c));
267
         a_data_in[i].write
268
            (b_data_out.read().range((i+1)*data_width_c-1, i*data_width_c));
269
#ifndef USE_R3_WRAPPERS
270
         a_av_in[i].write(b_av_out.read()[i].to_bool());
271
#else
272
         a_addr_in[i].write
273
            (b_addr_out.read().range((i+1)*addr_width_c-1, i*addr_width_c));
274
#endif
275
         a_full_in[i].write(b_full_out.read()[i].to_bool());
276
         a_one_p_in[i].write(b_one_p_out.read()[i].to_bool());
277
         a_empty_in[i].write(b_empty_out.read()[i].to_bool());
278
         a_one_d_in[i].write(b_one_d_out.read()[i].to_bool());
279
 
280
         b_comm_s.range((i+1)*comm_width_c-1, i*comm_width_c) =
281
            a_comm_out[i].read();
282
         b_data_s.range((i+1)*data_width_c-1, i*data_width_c) =
283
            a_data_out[i].read();
284
#ifndef USE_R3_WRAPPERS
285
         b_av_s[i] = a_av_out[i].read();
286
#else
287
         b_addr_s.range((i+1)*addr_width_c-1, i*addr_width_c) =
288
            a_addr_out[i].read();
289
#endif
290
         b_we_s[i] = a_we_out[i].read();
291
         b_re_s[i] = a_re_out[i].read();
292
 
293
#ifdef USE_R3_WRAPPERS
294
         a_msg_comm_in[i].write
295
            (b_msg_comm_out.read().range((i+1)*comm_width_c-1, i*comm_width_c));
296
         a_msg_data_in[i].write
297
            (b_msg_data_out.read().range((i+1)*data_width_c-1, i*data_width_c));
298
         a_msg_addr_in[i].write
299
            (b_msg_addr_out.read().range((i+1)*addr_width_c-1, i*addr_width_c));
300
         a_msg_full_in[i].write(b_msg_full_out.read()[i].to_bool());
301
         a_msg_one_p_in[i].write(b_msg_one_p_out.read()[i].to_bool());
302
         a_msg_empty_in[i].write(b_msg_empty_out.read()[i].to_bool());
303
         a_msg_one_d_in[i].write(b_msg_one_d_out.read()[i].to_bool());
304
 
305
         b_msg_comm_s.range((i+1)*comm_width_c-1, i*comm_width_c) =
306
            a_msg_comm_out[i].read();
307
         b_msg_data_s.range((i+1)*data_width_c-1, i*data_width_c) =
308
            a_msg_data_out[i].read();
309
         b_msg_addr_s.range((i+1)*addr_width_c-1, i*addr_width_c) =
310
            a_msg_addr_out[i].read();
311
         b_msg_we_s[i] = a_msg_we_out[i].read();
312
         b_msg_re_s[i] = a_msg_re_out[i].read();
313
#endif
314
      }
315
 
316
      b_comm_in.write(b_comm_s);
317
      b_data_in.write(b_data_s);
318
#ifndef USE_R3_WRAPPERS
319
      b_av_in.write(b_av_s);
320
#else
321
      b_addr_in.write(b_addr_s);
322
#endif
323
      b_we_in.write(b_we_s);
324
      b_re_in.write(b_re_s);
325
 
326
#ifdef USE_R3_WRAPPERS
327
      b_msg_comm_in.write(b_msg_comm_s);
328
      b_msg_data_in.write(b_msg_data_s);
329
      b_msg_addr_in.write(b_msg_addr_s);
330
      b_msg_we_in.write(b_msg_we_s);
331
      b_msg_re_in.write(b_msg_re_s);
332
#endif
333
 
334
   }
335
 
336
   // Declare internals signals between agents and HIBI
337
   sc_clock          clk_ip;
338
   sc_clock          clk_bus;
339
   sc_signal   rst_n;
340
 
341
   sc_signal >  b_comm_in;
342
   sc_signal >  b_data_in;
343
#ifndef USE_R3_WRAPPERS
344
   sc_signal >                 b_av_in;
345
#else
346
   sc_signal >  b_addr_in;
347
#endif
348
   sc_signal >                 b_we_in;
349
   sc_signal >                 b_re_in;
350
   sc_signal >  b_comm_out;
351
   sc_signal >  b_data_out;
352
#ifndef USE_R3_WRAPPERS
353
   sc_signal >                 b_av_out;
354
#else
355
   sc_signal >  b_addr_out;
356
#endif
357
   sc_signal >                 b_full_out;
358
   sc_signal >                 b_one_p_out;
359
   sc_signal >                 b_empty_out;
360
   sc_signal >                 b_one_d_out;
361
 
362
   sc_signal >  a_comm_out[n_agents_c];
363
   sc_signal >  a_data_out[n_agents_c];
364
#ifndef USE_R3_WRAPPERS
365
   sc_signal                  a_av_out[n_agents_c];
366
#else
367
   sc_signal >  a_addr_out[n_agents_c];
368
#endif
369
   sc_signal                  a_we_out[n_agents_c];
370
   sc_signal                  a_re_out[n_agents_c];
371
   sc_signal >  a_comm_in[n_agents_c];
372
   sc_signal >  a_data_in[n_agents_c];
373
#ifndef USE_R3_WRAPPERS
374
   sc_signal                  a_av_in[n_agents_c];
375
#else
376
   sc_signal >  a_addr_in[n_agents_c];
377
#endif
378
   sc_signal                  a_full_in[n_agents_c];
379
   sc_signal                  a_one_p_in[n_agents_c];
380
   sc_signal                  a_empty_in[n_agents_c];
381
   sc_signal                  a_one_d_in[n_agents_c];
382
 
383
#ifdef USE_R3_WRAPPERS
384
   sc_signal >  b_msg_comm_in;
385
   sc_signal >  b_msg_data_in;
386
   sc_signal >  b_msg_addr_in;
387
   sc_signal >                 b_msg_we_in;
388
   sc_signal >                 b_msg_re_in;
389
   sc_signal >  b_msg_comm_out;
390
   sc_signal >  b_msg_data_out;
391
   sc_signal >  b_msg_addr_out;
392
   sc_signal >                 b_msg_full_out;
393
   sc_signal >                 b_msg_one_p_out;
394
   sc_signal >                 b_msg_empty_out;
395
   sc_signal >                 b_msg_one_d_out;
396
 
397
   sc_signal >  a_msg_comm_out[n_agents_c];
398
   sc_signal >  a_msg_data_out[n_agents_c];
399
   sc_signal >  a_msg_addr_out[n_agents_c];
400
   sc_signal                  a_msg_we_out[n_agents_c];
401
   sc_signal                  a_msg_re_out[n_agents_c];
402
   sc_signal >  a_msg_comm_in[n_agents_c];
403
   sc_signal >  a_msg_data_in[n_agents_c];
404
   sc_signal >  a_msg_addr_in[n_agents_c];
405
   sc_signal                  a_msg_full_in[n_agents_c];
406
   sc_signal                  a_msg_one_p_in[n_agents_c];
407
   sc_signal                  a_msg_empty_in[n_agents_c];
408
   sc_signal                  a_msg_one_d_in[n_agents_c];
409
#endif
410
 
411
 
412
   // Instantiate the network
413
#ifndef USE_R3_WRAPPERS
414
   hibiv3_r4
415
             counter_width_c, rel_agent_freq_c, rel_bus_freq_c,
416
             arb_type_c, fifo_sel_c, rx_fifo_depth_c, rx_msg_fifo_depth_c,
417
             tx_fifo_depth_c, tx_msg_fifo_depth_c, max_send_c,
418
             n_cfg_pages_c, n_time_slots_c, keep_slot_c, n_extra_params_c,
419
             cfg_re_c, cfg_we_c, debug_width_c,
420
             n_agents_c, n_segments_c, separate_addr_c> hibi;
421
#else
422
   hibiv3_r3
423
             counter_width_c, rel_agent_freq_c, rel_bus_freq_c,
424
             arb_type_c, fifo_sel_c, rx_fifo_depth_c, rx_msg_fifo_depth_c,
425
             tx_fifo_depth_c, tx_msg_fifo_depth_c, max_send_c,
426
             n_cfg_pages_c, n_time_slots_c, keep_slot_c, n_extra_params_c,
427
             cfg_re_c, cfg_we_c, debug_width_c,
428
             n_agents_c, n_segments_c, separate_addr_c> hibi;
429
#endif
430
 
431
   // Pointers and dynamically created because constructor parameters can't
432
   // be given to tables of thingys
433
   vector
434
                comm_width_c, separate_addr_c>* > agents;
435
 
436
   friend class Stimuli;
437
 
438
};
439
 
440
 
441
#endif
442
 
443
 
444
// Local Variables:
445
// mode: c++
446
// c-file-style: "ellemtel"
447
// c-basic-offset: 3
448
// End:
449
 

powered by: WebSVN 2.1.0

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