source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Allocation.h @ 128

Last change on this file since 128 was 128, checked in by rosiere, 15 years ago

1) Correct bug in link two signal
2) Fix error detected with valgrind
3) modif distexe script

  • Property svn:keywords set to Id
File size: 67.6 KB
Line 
1#ifndef morpheo_behavioural_Allocation_h
2#define morpheo_behavioural_Allocation_h
3
4/*
5 * $Id: Allocation.h 128 2009-06-26 08:43:23Z rosiere $
6 *
7 * [ Description ]
8 *
9 */
10
11#include "Common/include/Debug.h"
12
13// ======================================================================
14// =====[ ALLOCATION / DELETE of ARRAY ]=================================
15// ======================================================================
16#define ALLOC0(var,type)                        \
17  do                                            \
18    {                                           \
19      var = new type;                           \
20    } while (0)
21
22#define ALLOC1(var,type,s1)                     \
23  do                                            \
24    {                                           \
25      var = new type [s1];                      \
26    } while (0)
27
28#define ALLOC2(var,type,s1,s2)                   \
29  do                                             \
30    {                                            \
31      var = new type * [s1];                     \
32      for (uint32_t it1=0; it1<s1; ++it1)        \
33        {                                        \
34          var [it1] = new type [s2];             \
35        }                                        \
36    } while (0)
37
38#define ALLOC3(var,type,s1,s2,s3)                \
39  do                                             \
40    {                                            \
41      var = new type ** [s1];                    \
42      for (uint32_t it1=0; it1<s1; ++it1)        \
43        {                                        \
44          var [it1] = new type * [s2];           \
45          for (uint32_t it2=0; it2<s2; ++it2)    \
46            {                                    \
47              var [it1][it2] = new type [s3];    \
48            }                                    \
49        }                                        \
50    } while (0)
51
52#define ALLOC4(var,type,s1,s2,s3,s4)                    \
53  do                                                    \
54    {                                                   \
55      var = new type *** [s1];                          \
56      for (uint32_t it1=0; it1<s1; ++it1)               \
57        {                                               \
58          var [it1] = new type ** [s2];                 \
59          for (uint32_t it2=0; it2<s2; ++it2)           \
60            {                                           \
61              var [it1][it2] = new type * [s3];         \
62              for (uint32_t it3=0; it3<s3; ++it3)       \
63                {                                       \
64                  var [it1][it2][it3] = new type [s4];  \
65                }                                       \
66            }                                           \
67        }                                               \
68    } while (0)
69
70#define DELETE0(var)                            \
71  do                                            \
72    {                                           \
73      delete var;                               \
74    } while (0)
75
76#define DELETE1(var,s1)                         \
77  do                                            \
78    {                                           \
79      delete [] var;                            \
80    } while (0)
81
82#define DELETE2(var,s1,s2)                      \
83  do                                            \
84    {                                            \
85      for (uint32_t it1=0; it1<s1; ++it1)        \
86        {                                        \
87          delete [] var [it1];                   \
88        }                                        \
89      delete [] var;                             \
90    } while (0)
91
92#define DELETE3(var,s1,s2,s3)                    \
93  do                                             \
94    {                                            \
95      for (uint32_t it1=0; it1<s1; ++it1)        \
96        {                                        \
97          for (uint32_t it2=0; it2<s2; ++it2)    \
98            {                                    \
99              delete [] var [it1][it2];          \
100            }                                    \
101          delete [] var [it1];                   \
102        }                                        \
103      delete [] var;                             \
104    } while (0)
105
106#define DELETE4(var,s1,s2,s3,s4)                        \
107  do                                                    \
108    {                                                   \
109      for (uint32_t it1=0; it1<s1; ++it1)               \
110        {                                               \
111          for (uint32_t it2=0; it2<s2; ++it2)           \
112            {                                           \
113              for (uint32_t it3=0; it3<s3; ++it3)       \
114                {                                       \
115                  delete [] var [it1][it2][it3];        \
116                }                                       \
117              delete [] var [it1][it2];                 \
118            }                                           \
119          delete [] var [it1];                          \
120        }                                               \
121      delete [] var;                                    \
122    } while (0)
123
124// ======================================================================
125// =====[ ALLOCATION / DELETE of SIGNAL]=================================
126// ======================================================================
127
128// Help to allocate interface
129#define INTERFACE_PRINT(name) log_printf(TRACE,Allocation,FUNCTION,"<%s> : Interface's creation : %s (%s, %d)",_name.c_str(),name,__FILE__,__LINE__);
130#define PRINT_SIGNAL_ADDRESS(name,address) log_printf(TRACE,Allocation,FUNCTION,"Signal : %s 0x%.8x(%s, %d)",name,(uint32_t)((uint64_t)(address)),__FILE__,__LINE__);
131#define PRINT_SIZE_NUL(component,interface,signal) log_printf(TRACE,Allocation,FUNCTION,_("<%s> %s.%s.%s : size is nul."),_name.c_str(),component->get_name().c_str(),interface->get_name().c_str(),signal);
132#define TEST_SIGNAL(name,address) PRINT_SIGNAL_ADDRESS(name,address); TEST_PTR(address)
133#define INSTANCE_FOREIGN_PRINT(name) log_printf(TRACE,Allocation,FUNCTION,"<%s> : %s (%s, %d)",_name.c_str(),name,__FILE__,__LINE__);
134
135// ----------------------------------------------------------------------
136// -----[ NO ITERATION ]-------------------------------------------------
137// ----------------------------------------------------------------------
138
139#define __ALLOC0_SIGNAL(sig, name, type)        \
140  do                                            \
141    {                                           \
142      sig = new type (name);                    \
143    } while (0)
144
145#ifdef POSITION
146#define ALLOC0_INTERFACE_BEGIN( name, direction, localisation, str)     \
147  INTERFACE_PRINT(name);                                                \
148  morpheo::behavioural::Interface_fifo * interface = _interfaces->set_interface( name, direction, localisation, str);
149#else
150#define ALLOC0_INTERFACE_BEGIN( name, direction, localisation, str)     \
151  INTERFACE_PRINT(name);                                                \
152  morpheo::behavioural::Interface_fifo * interface = _interfaces->set_interface( name);
153#endif
154
155#define ALLOC0_INTERFACE_END()
156
157#define ALLOC0_VAL_ACK_IN(  sig, name, type)                            \
158  do                                                                    \
159    {                                                                   \
160      sig = interface->set_signal_valack_in (name, type);               \
161    } while (0)
162
163#define ALLOC0_VAL_ACK_OUT( sig, name, type)                            \
164  do                                                                    \
165    {                                                                   \
166      sig = interface->set_signal_valack_out(name, type);               \
167    } while (0)
168                                                                 
169#define ALLOC0_VALACK_IN(     sig, type)                                \
170  do                                                                    \
171    {                                                                   \
172      sig = interface->set_signal_valack_in (type);                     \
173    } while (0)
174                                                                   
175#define ALLOC0_VALACK_OUT(    sig, type)                                \
176  do                                                                    \
177    {                                                                   \
178      sig = interface->set_signal_valack_out(type);                     \
179    } while (0)
180                                                                     
181#define ALLOC0_SIGNAL_IN(  sig, name, type, size)                       \
182  do                                                                    \
183    {                                                                   \
184      if (size > 0)                                                     \
185        {                                                               \
186          sig = interface->set_signal_in <type> (name, size);           \
187        }                                                               \
188      else                                                              \
189        {                                                               \
190          PRINT_SIZE_NUL(_component,interface,name);                    \
191        }                                                               \
192    } while (0)
193
194#define ALLOC0_SIGNAL_OUT( sig, name, type, size)                       \
195  do                                                                    \
196    {                                                                   \
197      if (size > 0)                                                     \
198        {                                                               \
199          sig = interface->set_signal_out<type> (name, size);           \
200        }                                                               \
201      else                                                              \
202        {                                                               \
203          PRINT_SIZE_NUL(_component,interface,name);                    \
204        }                                                               \
205    } while (0)
206
207#define DELETE0_SIGNAL( sig, size)                                      \
208  do                                                                    \
209    {                                                                   \
210      if (size > 0)                                                     \
211        {                                                               \
212          delete sig;                                                   \
213        }                                                               \
214    } while (0)
215
216#define ALLOC0_FOREIGN_SIGNAL_IN(  sig, interface, name, type, size)    \
217  do                                                                    \
218    {                                                                   \
219      if (size > 0)                                                     \
220        {                                                               \
221          std::string str = (toString("in")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(name)); \
222          sig = new SC_IN    (type) (str.c_str());                      \
223        }                                                               \
224    } while (0)
225
226#define ALLOC0_FOREIGN_SIGNAL_OUT( sig, interface, name, type, size)    \
227  do                                                                    \
228    {                                                                   \
229      if (size > 0)                                                     \
230        {                                                               \
231          std::string str = (toString("out")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(name)); \
232          sig = new SC_OUT   (type) (str.c_str());                      \
233        }                                                               \
234    } while (0)
235
236#define DELETE0_FOREIGN_SIGNAL( sig, size)                              \
237  do                                                                    \
238    {                                                                   \
239      DELETE0_SIGNAL(sig,size);                                         \
240    } while (0)
241
242#define INSTANCE0_FOREIGN_SIGNAL(component, sig, type, name, size)      \
243  do                                                                    \
244    {                                                                   \
245      if (size > 0)                                                     \
246        {                                                               \
247          INSTANCE_FOREIGN_PRINT(name);                                 \
248          _component->set_sc_signal<type>(_name,name,static_cast<void*>(component->sig)); \
249        }                                                               \
250    } while (0)
251
252#define ALLOC0_SC_SIGNAL(  sig, name, type)                             \
253  do                                                                    \
254    {                                                                   \
255      sig = new sc_signal<type> (name);                                 \
256      PRINT_SIGNAL_ADDRESS(name,sig);                                   \
257    } while (0)
258
259#define INSTANCE0_SC_SIGNAL(component, sig)                             \
260  do                                                                    \
261    {                                                                   \
262      TEST_SIGNAL(component->sig->name(),component->sig);               \
263      TEST_SIGNAL(sig           ->name(),sig);                          \
264      (*(component->sig)) (*(sig));                                     \
265    } while (0)
266
267#define _INSTANCE0_SC_SIGNAL(component, sig1,sig2)                      \
268  do                                                                    \
269    {                                                                   \
270      TEST_SIGNAL(component->sig1->name(),component->sig1);             \
271      TEST_SIGNAL(sig2           ->name(),sig2);                        \
272      (*(component->sig1)) (*(sig2));                                   \
273    } while (0)
274
275#define DELETE0_SC_SIGNAL( sig)                                         \
276  do                                                                    \
277    {                                                                   \
278      PRINT_SIGNAL_ADDRESS("",sig);                                     \
279      delete sig;                                                       \
280    } while (0)
281
282// ----------------------------------------------------------------------
283// -----[ ITERATION 1 ]--------------------------------------------------
284// ----------------------------------------------------------------------
285
286#define __ALLOC1_INTERFACE_BEGIN(name, x1)                              \
287  INTERFACE_PRINT(name);                                                \
288  const std::string interface_name = name;                              \
289  const uint32_t iterator_1 = x1;
290
291#define __ALLOC1_INTERFACE_END(x1)
292
293#define __ALLOC1_SIGNAL_IN( sig, name, type)                            \
294  do                                                                    \
295    {                                                                   \
296      sig = new SC_IN(type) * [iterator_1];                             \
297      std::string separator="_";                                        \
298      for (uint32_t it1=0; it1<iterator_1; it1++)                       \
299        {                                                               \
300          std::string str = "in_"+interface_name+separator+toString(it1)+separator+name; \
301          sig [it1] = new SC_IN(type) (str.c_str());                    \
302        }                                                               \
303    } while (0)
304
305
306#define __ALLOC1_SIGNAL_OUT( sig, name, type)                           \
307  do                                                                    \
308    {                                                                   \
309      sig = new SC_OUT(type) * [iterator_1];                            \
310      std::string separator="_";                                        \
311      for (uint32_t it1=0; it1<iterator_1; it1++)                       \
312        {                                                               \
313          std::string str = "out_"+interface_name+separator+toString(it1)+separator+name; \
314          sig [it1] = new SC_OUT(type) (str.c_str());                   \
315        }                                                               \
316    } while (0)
317
318#ifdef POSITION
319#define ALLOC1_INTERFACE_BEGIN( name, direction, localisation, str, x1) \
320  INTERFACE_PRINT(name);                                                \
321  uint32_t iterator_1 = 0;                                              \
322  morpheo::behavioural::Interface_fifo ** interface;                    \
323  {                                                                     \
324    std::string separator="_";                                          \
325    iterator_1 = x1;                                                    \
326    interface = new morpheo::behavioural::Interface_fifo * [iterator_1]; \
327    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
328      {                                                                 \
329        interface [it1] = _interfaces->set_interface( name+separator+toString(it1), direction, localisation, str); \
330      }                                                                 \
331  }
332#else
333#define ALLOC1_INTERFACE_BEGIN( name, direction, localisation, str, x1) \
334  INTERFACE_PRINT(name);                                                \
335  uint32_t iterator_1 = 0;                                              \
336  morpheo::behavioural::Interface_fifo ** interface;                    \
337  {                                                                     \
338    std::string separator="_";                                          \
339    iterator_1 = x1;                                                    \
340    interface = new morpheo::behavioural::Interface_fifo * [iterator_1]; \
341    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
342      {                                                                 \
343        interface [it1] = _interfaces->set_interface( name+separator+toString(it1)); \
344      }                                                                 \
345  }
346#endif
347
348#define ALLOC1_INTERFACE_END(x1)                                        \
349  do                                                                    \
350    {                                                                   \
351      delete [] interface;                                              \
352    } while (0)
353
354#define ALLOC1_VAL_ACK_IN( sig, name, type)                             \
355  do                                                                    \
356    {                                                                   \
357      sig = new SC_IN (Tcontrol_t) * [iterator_1];                      \
358      for (uint32_t it1=0; it1<iterator_1; it1++)                       \
359        {                                                               \
360          sig [it1] = interface[it1]->set_signal_valack_in (name, type); \
361        }                                                               \
362    } while (0)
363
364#define ALLOC1_VAL_ACK_OUT(sig, name, type)                             \
365  do                                                                    \
366    {                                                                   \
367      sig = new SC_OUT(Tcontrol_t) * [iterator_1];                      \
368      for (uint32_t it1=0; it1<iterator_1; it1++)                       \
369        {                                                               \
370          sig [it1] = interface[it1]->set_signal_valack_out(name, type); \
371        }                                                               \
372    } while (0)
373
374#define ALLOC1_VALACK_IN(    sig, type)                                 \
375  do                                                                    \
376    {                                                                   \
377      sig = new SC_IN (Tcontrol_t) * [iterator_1];                      \
378      for (uint32_t it1=0; it1<iterator_1; it1++)                       \
379        {                                                               \
380          sig [it1] = interface[it1]->set_signal_valack_in (type);      \
381        }                                                               \
382    } while (0)
383
384#define ALLOC1_VALACK_OUT(   sig, type)                                 \
385  do                                                                    \
386    {                                                                   \
387      sig = new SC_OUT(Tcontrol_t) * [iterator_1];                      \
388      for (uint32_t it1=0; it1<iterator_1; it1++)                       \
389        {                                                               \
390          sig [it1] = interface[it1]->set_signal_valack_out(type);      \
391        }                                                               \
392    } while (0)
393
394#define ALLOC1_SIGNAL_IN( sig, name, type, size)                        \
395  do                                                                    \
396    {                                                                   \
397      sig = new SC_IN (type) * [iterator_1];                            \
398      for (uint32_t it1=0; it1<iterator_1; it1++)                       \
399        {                                                               \
400          if (size > 0)                                                 \
401            {                                                           \
402              sig [it1] = interface[it1]->set_signal_in <type> (name, size); \
403            }                                                           \
404          else                                                          \
405            {                                                           \
406              PRINT_SIZE_NUL(_component,interface[it1],name);           \
407            }                                                           \
408        }                                                               \
409    } while (0)
410
411#define ALLOC1_SIGNAL_OUT(sig, name, type, size)                        \
412  do                                                                    \
413    {                                                                   \
414      sig = new SC_OUT(type) * [iterator_1];                            \
415      for (uint32_t it1=0; it1<iterator_1; it1++)                       \
416        {                                                               \
417          if (size > 0)                                                 \
418            {                                                           \
419              sig [it1] = interface[it1]->set_signal_out<type> (name, size); \
420            }                                                           \
421          else                                                          \
422            {                                                           \
423              PRINT_SIZE_NUL(_component,interface[it1],name);           \
424            }                                                           \
425        }                                                               \
426    } while (0)
427
428#define DELETE1_SIGNAL(sig, x1, size)                                   \
429  do                                                                    \
430    {                                                                   \
431      for (uint32_t it1=0; it1<x1; it1++)                               \
432        {                                                               \
433          if (size > 0)                                                 \
434            {                                                           \
435              delete sig[it1];                                          \
436            }                                                           \
437        }                                                               \
438      delete [] sig;                                                    \
439    } while (0)
440
441#define ALLOC1_FOREIGN_SIGNAL_IN(sig, interface, name, type, size,x1)   \
442  do                                                                    \
443    {                                                                   \
444      sig = new SC_IN (type) * [x1];                                    \
445      for (uint32_t it1=0; it1<x1; it1++)                               \
446        if (size > 0)                                                   \
447          {                                                             \
448            std::string str = (toString("in")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(name)); \
449            sig [it1] = new SC_IN (type) (str.c_str());                 \
450          }                                                             \
451    } while (0)
452
453#define ALLOC1_FOREIGN_SIGNAL_OUT(sig, interface, name, type, size,x1)  \
454  do                                                                    \
455    {                                                                   \
456      sig = new SC_OUT (type) * [x1];                                   \
457      for (uint32_t it1=0; it1<x1; it1++)                               \
458        if (size > 0)                                                   \
459          {                                                             \
460            std::string str = (toString("out")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(name)); \
461            sig [it1] = new SC_OUT (type) (str.c_str());                \
462          }                                                             \
463    } while (0)
464
465#define DELETE1_FOREIGN_SIGNAL( sig, size,x1)                           \
466  do                                                                    \
467    {                                                                   \
468      DELETE1_SIGNAL(sig,x1,size);                                      \
469    } while (0)
470
471#define ALLOC1_SC_SIGNAL( sig, name, type, x1)                          \
472  do                                                                    \
473    {                                                                   \
474      sig = new sc_signal<type> * [x1];                                 \
475      {                                                                 \
476        std::string separator="_";                                      \
477        std::string str;                                                \
478        for (uint32_t it1=0; it1<x1; it1++)                             \
479          {                                                             \
480            str = name+separator+toString(it1);                         \
481            sig [it1] = new sc_signal<type> (str.c_str());              \
482            PRINT_SIGNAL_ADDRESS(str.c_str(),sig[it1]);                 \
483          }                                                             \
484      }                                                                 \
485    } while (0)
486
487#define INSTANCE1_SC_SIGNAL(component, sig, x1)                         \
488  do                                                                    \
489    {                                                                   \
490      for (uint32_t it1=0; it1<x1; it1++)                               \
491        {                                                               \
492          TEST_SIGNAL(component->sig [it1]->name(),component->sig [it1]); \
493          TEST_SIGNAL(sig            [it1]->name(),sig            [it1]); \
494          (*(component->sig[it1])) (*(sig[it1]));                       \
495        }                                                               \
496    } while (0)
497
498#define _INSTANCE1_SC_SIGNAL(component, sig1, sig2, x1)                 \
499  do                                                                    \
500    {                                                                   \
501      for (uint32_t it1=0; it1<x1; it1++)                               \
502        {                                                               \
503          TEST_SIGNAL(component->sig1 [it1]->name(),component->sig1 [it1]); \
504          TEST_SIGNAL(sig2            [it1]->name(),sig2            [it1]); \
505          (*(component->sig1[it1])) (*(sig2[it1]));                     \
506        }                                                               \
507    } while (0)
508
509#define DELETE1_SC_SIGNAL(sig, x1)                                      \
510  do                                                                    \
511    {                                                                   \
512      for (uint32_t it1=0; it1<x1; it1++)                               \
513        {                                                               \
514          PRINT_SIGNAL_ADDRESS("",sig[it1]);                            \
515          delete sig[it1];                                              \
516        }                                                               \
517      delete [] sig;                                                    \
518    } while (0)
519
520// ----------------------------------------------------------------------
521// -----[ ITERATION 2 ]--------------------------------------------------
522// ----------------------------------------------------------------------
523
524#ifdef POSITION
525#define ALLOC2_INTERFACE_BEGIN( name, direction, localisation, str, x1, x2) \
526  INTERFACE_PRINT(name);                                                \
527  uint32_t iterator_1 = 0;                                              \
528  uint32_t iterator_2 = 0;                                              \
529  morpheo::behavioural::Interface_fifo *** interface;                   \
530  {                                                                     \
531    std::string separator="_";                                          \
532    iterator_1 = x1;                                                    \
533    interface = new morpheo::behavioural::Interface_fifo ** [iterator_1]; \
534    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
535      {                                                                 \
536        iterator_2 = x2;                                                \
537        interface [it1] = new morpheo::behavioural::Interface_fifo * [iterator_2]; \
538        for (uint32_t it2=0; it2<iterator_2; it2++)                     \
539          {                                                             \
540            interface [it1][it2] = _interfaces->set_interface( name+separator+toString(it1)+separator+toString(it2), direction, localisation, str); \
541          }                                                             \
542      }                                                                 \
543  }
544#else
545#define ALLOC2_INTERFACE_BEGIN( name, direction, localisation, str, x1, x2) \
546  INTERFACE_PRINT(name);                                                \
547  uint32_t iterator_1 = 0;                                              \
548  uint32_t iterator_2 = 0;                                              \
549  morpheo::behavioural::Interface_fifo *** interface;                   \
550  {                                                                     \
551    std::string separator="_";                                          \
552    iterator_1 = x1;                                                    \
553    interface = new morpheo::behavioural::Interface_fifo ** [iterator_1]; \
554    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
555      {                                                                 \
556        iterator_2 = x2;                                                \
557        interface [it1] = new morpheo::behavioural::Interface_fifo * [iterator_2]; \
558        for (uint32_t it2=0; it2<iterator_2; it2++)                     \
559          {                                                             \
560            interface [it1][it2] = _interfaces->set_interface( name+separator+toString(it1)+separator+toString(it2)); \
561          }                                                             \
562      }                                                                 \
563  }
564#endif
565
566#define ALLOC2_INTERFACE_END(x1, x2)                                    \
567  do                                                                    \
568    {                                                                   \
569      for (uint32_t it1=0; it1<x1; it1++)                               \
570        delete [] interface [it1];                                      \
571      delete [] interface;                                              \
572    } while (0)
573
574#define _ALLOC2_VAL_ACK_IN( sig, name, type, x1, x2)                    \
575  do                                                                    \
576    {                                                                   \
577      sig = new SC_IN (Tcontrol_t) ** [x1];                             \
578      for (uint32_t it1=0; it1<x1; it1++)                               \
579        {                                                               \
580          sig [it1] = new SC_IN (Tcontrol_t) * [x2];                    \
581          for (uint32_t it2=0; it2<x2; it2++)                           \
582            {                                                           \
583              sig [it1][it2] = interface[it1][it2]->set_signal_valack_in (name, type); \
584            }                                                           \
585        }                                                               \
586    } while (0)
587
588#define _ALLOC2_VAL_ACK_OUT( sig, name, type, x1, x2)                   \
589  do                                                                    \
590    {                                                                   \
591      sig = new SC_OUT (Tcontrol_t) ** [x1];                            \
592      for (uint32_t it1=0; it1<x1; it1++)                               \
593        {                                                               \
594          sig [it1] = new SC_OUT (Tcontrol_t) * [x2];                   \
595          for (uint32_t it2=0; it2<x2; it2++)                           \
596            {                                                           \
597              sig [it1][it2] = interface[it1][it2]->set_signal_valack_out (name, type); \
598            }                                                           \
599        }                                                               \
600    } while (0)
601
602#define _ALLOC2_VALACK_IN(    sig,type, x1, x2)                         \
603  do                                                                    \
604    {                                                                   \
605      sig = new SC_IN (Tcontrol_t) ** [x1];                             \
606      for (uint32_t it1=0; it1<x1; it1++)                               \
607        {                                                               \
608          sig [it1] = new SC_IN (Tcontrol_t) * [x2];                    \
609          for (uint32_t it2=0; it2<x2; it2++)                           \
610            {                                                           \
611              sig [it1][it2] = interface[it1][it2]->set_signal_valack_in (type); \
612            }                                                           \
613        }                                                               \
614    } while (0)
615
616#define _ALLOC2_VALACK_OUT(    sig,type, x1, x2)                        \
617  do                                                                    \
618    {                                                                   \
619      sig = new SC_OUT (Tcontrol_t) ** [x1];                            \
620      for (uint32_t it1=0; it1<x1; it1++)                               \
621        {                                                               \
622          sig [it1] = new SC_OUT (Tcontrol_t) * [x2];                   \
623          for (uint32_t it2=0; it2<x2; it2++)                           \
624            {                                                           \
625              sig [it1][it2] = interface[it1][it2]->set_signal_valack_out (type); \
626            }                                                           \
627        }                                                               \
628    } while (0)
629
630#define _ALLOC2_SIGNAL_IN( sig, name, type, size, x1, x2)               \
631  do                                                                    \
632    {                                                                   \
633      sig = new SC_IN (type) ** [x1];                                   \
634      for (uint32_t it1=0; it1<x1; it1++)                               \
635        {                                                               \
636          sig [it1] = new SC_IN (type) * [x2];                          \
637          for (uint32_t it2=0; it2<x2; it2++)                           \
638            {                                                           \
639              if (size > 0)                                             \
640                {                                                       \
641                  sig [it1][it2] = interface[it1][it2]->set_signal_in <type> (name, size); \
642                }                                                       \
643              else                                                      \
644                {                                                       \
645                  PRINT_SIZE_NUL(_component,interface[it1][it2],name);  \
646                }                                                       \
647            }                                                           \
648        }                                                               \
649    } while (0)
650
651#define _ALLOC2_SIGNAL_OUT( sig, name, type, size, x1, x2)              \
652  do                                                                    \
653    {                                                                   \
654      sig = new SC_OUT (type) ** [x1];                                  \
655      for (uint32_t it1=0; it1<x1; it1++)                               \
656        {                                                               \
657          sig [it1] = new SC_OUT (type) * [x2];                         \
658          for (uint32_t it2=0; it2<x2; it2++)                           \
659            {                                                           \
660              if (size > 0)                                             \
661                {                                                       \
662                  sig [it1][it2] = interface[it1][it2]->set_signal_out <type> (name, size); \
663                }                                                       \
664              else                                                      \
665                {                                                       \
666                  PRINT_SIZE_NUL(_component,interface[it1][it2],name);  \
667                }                                                       \
668            }                                                           \
669        }                                                               \
670    } while (0)
671
672#define ALLOC2_VAL_ACK_IN( sig, name, type      ) _ALLOC2_VAL_ACK_IN( sig, name, type      , iterator_1, iterator_2)
673#define ALLOC2_VAL_ACK_OUT(sig, name, type      ) _ALLOC2_VAL_ACK_OUT(sig, name, type      , iterator_1, iterator_2)
674#define ALLOC2_VALACK_IN(  sig,       type      ) _ALLOC2_VALACK_IN(  sig,       type      , iterator_1, iterator_2)
675#define ALLOC2_VALACK_OUT( sig,       type      ) _ALLOC2_VALACK_OUT( sig,       type      , iterator_1, iterator_2)
676#define ALLOC2_SIGNAL_IN(  sig, name, type, size) _ALLOC2_SIGNAL_IN(  sig, name, type, size, iterator_1, iterator_2)
677#define ALLOC2_SIGNAL_OUT( sig, name, type, size) _ALLOC2_SIGNAL_OUT( sig, name, type, size, iterator_1, iterator_2)
678
679#define DELETE2_SIGNAL(sig, x1,x2, size)                                \
680  do                                                                    \
681    {                                                                   \
682      for (uint32_t it1=0; it1<x1; it1++)                               \
683        {                                                               \
684          for (uint32_t it2=0; it2<x2; it2++)                           \
685            {                                                           \
686              if (size > 0)                                             \
687                {                                                       \
688                  delete sig[it1][it2];                                 \
689                }                                                       \
690            }                                                           \
691          delete [] sig[it1];                                           \
692        }                                                               \
693      delete [] sig;                                                    \
694    } while (0)
695
696#define ALLOC2_FOREIGN_SIGNAL_IN( sig, interface, name, type, size, x1, x2) \
697  do                                                                    \
698    {                                                                   \
699      sig = new SC_IN (type) ** [x1];                                   \
700      for (uint32_t it1=0; it1<x1; it1++)                               \
701        {                                                               \
702          sig [it1] = new SC_IN (type) * [x2];                          \
703          for (uint32_t it2=0; it2<x2; it2++)                           \
704            if (size > 0)                                               \
705              {                                                         \
706                std::string str = (toString("in")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(it2)+"_"+toString(name)); \
707                sig [it1][it2] = new SC_IN    (type) (str.c_str());     \
708              }                                                         \
709        }                                                               \
710    } while (0)
711
712#define ALLOC2_FOREIGN_SIGNAL_OUT( sig, interface, name, type, size, x1, x2) \
713  do                                                                    \
714    {                                                                   \
715      sig = new SC_OUT (type) ** [x1];                                  \
716      for (uint32_t it1=0; it1<x1; it1++)                               \
717        {                                                               \
718          sig [it1] = new SC_OUT (type) * [x2];                         \
719          for (uint32_t it2=0; it2<x2; it2++)                           \
720            if (size > 0)                                               \
721              {                                                         \
722                std::string str = (toString("out")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(it2)+"_"+toString(name)); \
723                sig [it1][it2] = new SC_IN    (type) (str.c_str());     \
724              }                                                         \
725        }                                                               \
726    } while (0)
727
728#define DELETE2_FOREIGN_SIGNAL( sig, size,x1,x2)            \
729  do                                                        \
730    {                                                       \
731      DELETE2_SIGNAL(sig,x1,x2,size);                       \
732    } while (0)
733
734#define ALLOC2_SC_SIGNAL( sig, name, type, x1, x2)                      \
735  do                                                                    \
736    {                                                                   \
737      sig = new sc_signal<type> ** [x1];                                \
738      {                                                                 \
739        std::string separator="_";                                      \
740        std::string str;                                                \
741        for (uint32_t it1=0; it1<x1; it1++)                             \
742          {                                                             \
743            sig [it1] = new sc_signal<type> * [x2];                     \
744            for (uint32_t it2=0; it2<x2; it2++)                         \
745              {                                                         \
746                str = name+separator+toString(it1)+separator+toString(it2); \
747                sig [it1][it2] = new sc_signal<type> (str.c_str());     \
748                PRINT_SIGNAL_ADDRESS(str.c_str(),sig[it1][it2]);        \
749              }                                                         \
750          }                                                             \
751      }                                                                 \
752    } while (0)
753
754#define INSTANCE2_SC_SIGNAL(component, sig, x1, x2)                     \
755  do                                                                    \
756    {                                                                   \
757      for (uint32_t it1=0; it1<x1; it1++)                               \
758        for (uint32_t it2=0; it2<x2; it2++)                             \
759          {                                                             \
760            TEST_SIGNAL(component->sig  [it1][it2]->name(),component->sig  [it1][it2]); \
761            TEST_SIGNAL(sig             [it1][it2]->name(),sig             [it1][it2]); \
762            (*(component->sig[it1][it2])) (*(sig[it1][it2]));           \
763          }                                                             \
764    } while (0)
765
766#define _INSTANCE2_SC_SIGNAL(component, sig1, sig2, x1, x2)             \
767  do                                                                    \
768    {                                                                   \
769      for (uint32_t it1=0; it1<x1; it1++)                               \
770        for (uint32_t it2=0; it2<x2; it2++)                             \
771          {                                                             \
772            TEST_SIGNAL(component->sig1 [it1][it2]->name(),component->sig1 [it1][it2]); \
773            TEST_SIGNAL(sig2            [it1][it2]->name(),sig2            [it1][it2]); \
774            (*(component->sig1[it1][it2])) (*(sig2[it1][it2]));         \
775          }                                                             \
776    } while (0)
777
778#define DELETE2_SC_SIGNAL(sig,x1,x2)                                    \
779  do                                                                    \
780    {                                                                   \
781      for (uint32_t it1=0; it1<x1; it1++)                               \
782        {                                                               \
783          for (uint32_t it2=0; it2<x2; it2++)                           \
784            {                                                           \
785              PRINT_SIGNAL_ADDRESS("",sig[it1][it2]);                   \
786              delete sig[it1][it2];                                     \
787            }                                                           \
788          delete [] sig[it1];                                           \
789        }                                                               \
790      delete [] sig;                                                    \
791    } while (0)
792
793// ----------------------------------------------------------------------
794// -----[ ITERATION 3 ]--------------------------------------------------
795// ----------------------------------------------------------------------
796
797#ifdef POSITION
798#define ALLOC3_INTERFACE_BEGIN( name, direction, localisation, str, x1, x2, x3) \
799  INTERFACE_PRINT(name);                                                \
800  uint32_t iterator_1 = 0;                                              \
801  uint32_t iterator_2 = 0;                                              \
802  uint32_t iterator_3 = 0;                                              \
803  morpheo::behavioural::Interface_fifo **** interface;                  \
804  {                                                                     \
805    std::string separator="_";                                          \
806    iterator_1 = x1;                                                    \
807    interface = new morpheo::behavioural::Interface_fifo *** [iterator_1]; \
808    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
809      {                                                                 \
810        iterator_2 = x2;                                                \
811        interface [it1] = new morpheo::behavioural::Interface_fifo ** [iterator_2]; \
812        for (uint32_t it2=0; it2<iterator_2; it2++)                     \
813          {                                                             \
814            iterator_3 = x3;                                            \
815            interface [it1][it2] = new morpheo::behavioural::Interface_fifo * [iterator_3]; \
816            for (uint32_t it3=0; it3<iterator_3; it3++)                 \
817              {                                                         \
818                interface [it1][it2][it3] = _interfaces->set_interface( name+separator+toString(it1)+separator+toString(it2)+separator+toString(it3), direction, localisation, str); \
819              }                                                         \
820          }                                                             \
821      }                                                                 \
822  }
823#else
824#define ALLOC3_INTERFACE_BEGIN( name, direction, localisation, str, x1, x2, x3) \
825  INTERFACE_PRINT(name);                                                \
826  uint32_t iterator_1 = 0;                                              \
827  uint32_t iterator_2 = 0;                                              \
828  uint32_t iterator_3 = 0;                                              \
829  morpheo::behavioural::Interface_fifo **** interface;                  \
830  {                                                                     \
831    std::string separator="_";                                          \
832    iterator_1 = x1;                                                    \
833    interface = new morpheo::behavioural::Interface_fifo *** [iterator_1]; \
834    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
835      {                                                                 \
836        iterator_2 = x2;                                                \
837        interface [it1] = new morpheo::behavioural::Interface_fifo ** [iterator_2]; \
838        for (uint32_t it2=0; it2<iterator_2; it2++)                     \
839          {                                                             \
840            iterator_3 = x3;                                            \
841            interface [it1][it2] = new morpheo::behavioural::Interface_fifo * [iterator_3]; \
842            for (uint32_t it3=0; it3<iterator_3; it3++)                 \
843              {                                                         \
844                interface [it1][it2][it3] = _interfaces->set_interface( name+separator+toString(it1)+separator+toString(it2)+separator+toString(it3)); \
845              }                                                         \
846          }                                                             \
847      }                                                                 \
848  }
849#endif
850
851#define ALLOC3_INTERFACE_END(x1, x2, x3)                         \
852  do                                                                    \
853    {                                                                   \
854      for (uint32_t it1=0; it1<x1; it1++)                               \
855        {                                                               \
856          for (uint32_t it2=0; it2<x2; it2++)                           \
857            delete [] interface [it1][it2];                             \
858          delete [] interface [it1];                                    \
859        }                                                               \
860      delete [] interface;                                              \
861    } while (0)
862
863// #define _ALLOC3_VAL_ACK_IN( sig, name, type, x1, x2, x3)
864// #define _ALLOC3_VAL_ACK_OUT( sig, name, type, x1, x2, x3)
865
866#define _ALLOC3_VALACK_IN(    sig,type, x1, x2, x3)                     \
867  do                                                                    \
868    {                                                                   \
869      sig = new SC_IN (Tcontrol_t) *** [x1];                            \
870      for (uint32_t it1=0; it1<x1; it1++)                               \
871        {                                                               \
872          sig [it1] = new SC_IN (Tcontrol_t) ** [x2];                   \
873          for (uint32_t it2=0; it2<x2; it2++)                           \
874            {                                                           \
875              sig [it1][it2] = new SC_IN (Tcontrol_t) * [x3];           \
876              for (uint32_t it3=0; it3<x3; it3++)                       \
877                {                                                       \
878                  sig [it1][it2][it3] = interface[it1][it2][it3]->set_signal_valack_in (type); \
879                }                                                       \
880            }                                                           \
881        }                                                               \
882    } while (0)
883
884#define _ALLOC3_VALACK_OUT(    sig,type, x1, x2, x3)                    \
885  do                                                                    \
886    {                                                                   \
887      sig = new SC_OUT (Tcontrol_t) *** [x1];                           \
888      for (uint32_t it1=0; it1<x1; it1++)                               \
889        {                                                               \
890          sig [it1] = new SC_OUT (Tcontrol_t) ** [x2];                  \
891          for (uint32_t it2=0; it2<x2; it2++)                           \
892            {                                                           \
893              sig [it1][it2] = new SC_OUT (Tcontrol_t) * [x3];          \
894              for (uint32_t it3=0; it3<x3; it3++)                       \
895                {                                                       \
896                  sig [it1][it2][it3] = interface[it1][it2][it3]->set_signal_valack_out (type); \
897                }                                                       \
898            }                                                           \
899        }                                                               \
900    } while (0)
901
902
903#define _ALLOC3_SIGNAL_IN( sig, name, type, size, x1, x2,x3)            \
904  do                                                                    \
905    {                                                                   \
906      sig = new SC_IN (type) *** [x1];                                  \
907      for (uint32_t it1=0; it1<x1; it1++)                               \
908        {                                                               \
909          sig [it1] = new SC_IN (type) ** [x2];                         \
910          for (uint32_t it2=0; it2<x2; it2++)                           \
911            {                                                           \
912              sig [it1][it2] = new SC_IN (type) * [x3];                 \
913              for (uint32_t it3=0; it3<x3; it3++)                       \
914                {                                                       \
915                  if (size > 0)                                         \
916                    {                                                   \
917                      sig [it1][it2][it3] = interface[it1][it2][it3]->set_signal_in <type> (name, size); \
918                    }                                                   \
919                  else                                                  \
920                    {                                                   \
921                      PRINT_SIZE_NUL(_component,interface[it1][it2][it3],name); \
922                    }                                                   \
923                }                                                       \
924            }                                                           \
925        }                                                               \
926    } while (0)
927
928#define _ALLOC3_SIGNAL_OUT( sig, name, type, size, x1, x2,x3)           \
929  do                                                                    \
930    {                                                                   \
931      sig = new SC_OUT (type) *** [x1];                                 \
932      for (uint32_t it1=0; it1<x1; it1++)                               \
933        {                                                               \
934          sig [it1] = new SC_OUT (type) ** [x2];                        \
935          for (uint32_t it2=0; it2<x2; it2++)                           \
936            {                                                           \
937              sig [it1][it2] = new SC_OUT (type) * [x3];                \
938              for (uint32_t it3=0; it3<x3; it3++)                       \
939                {                                                       \
940                  if (size > 0)                                         \
941                    {                                                   \
942                      sig [it1][it2][it3] = interface[it1][it2][it3]->set_signal_out <type> (name, size); \
943                    }                                                   \
944                  else                                                  \
945                    {                                                   \
946                      PRINT_SIZE_NUL(_component,interface[it1][it2][it3],name); \
947                    }                                                   \
948                }                                                       \
949            }                                                           \
950        }                                                               \
951    } while (0)
952
953// #define ALLOC3_VAL_ACK_IN( sig, name, type      ) _ALLOC3_VAL_ACK_IN( sig, name, type      , iterator_1, iterator_2, iterator_3)
954// #define ALLOC3_VAL_ACK_OUT(sig, name, type      ) _ALLOC3_VAL_ACK_OUT(sig, name, type      , iterator_1, iterator_2, iterator_3)
955#define ALLOC3_VALACK_IN(  sig,       type      ) _ALLOC3_VALACK_IN(  sig,       type      , iterator_1, iterator_2, iterator_3)
956#define ALLOC3_VALACK_OUT( sig,       type      ) _ALLOC3_VALACK_OUT( sig,       type      , iterator_1, iterator_2, iterator_3)
957#define ALLOC3_SIGNAL_IN(  sig, name, type, size) _ALLOC3_SIGNAL_IN(  sig, name, type, size, iterator_1, iterator_2, iterator_3)
958#define ALLOC3_SIGNAL_OUT( sig, name, type, size) _ALLOC3_SIGNAL_OUT( sig, name, type, size, iterator_1, iterator_2, iterator_3)
959
960#define DELETE3_SIGNAL(sig, x1, x2, x3, size)                           \
961  do                                                                    \
962    {                                                                   \
963      for (uint32_t it1=0; it1<x1; it1++)                               \
964        {                                                               \
965          for (uint32_t it2=0; it2<x2; it2++)                           \
966            {                                                           \
967              for (uint32_t it3=0; it3<x3; it3++)                       \
968                {                                                       \
969                  if (size > 0)                                         \
970                    {                                                   \
971                      delete sig[it1][it2][it3];                        \
972                    }                                                   \
973                }                                                       \
974              delete [] sig[it1][it2];                                  \
975            }                                                           \
976          delete [] sig[it1];                                           \
977        }                                                               \
978      delete [] sig;                                                    \
979    } while (0)
980
981#define ALLOC3_FOREIGN_SIGNAL_IN( sig, interface, name, type, size, x1, x2,x3)     \
982  do                                                                    \
983    {                                                                   \
984      sig = new SC_IN (type) *** [x1];                                  \
985      for (uint32_t it1=0; it1<x1; it1++)                               \
986        {                                                               \
987          sig [it1] = new SC_IN (type) ** [x2];                         \
988          for (uint32_t it2=0; it2<x2; it2++)                           \
989            {                                                           \
990              sig [it1][it2] = new SC_IN (type) * [x3];                 \
991              for (uint32_t it3=0; it3<x3; it3++)                       \
992                if (size > 0)                                           \
993                  {                                                     \
994                    std::string str = (toString("in")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(it2)+"_"+toString(it3)+"_"+toString(name)); \
995                    sig [it1][it2][it3] = new SC_IN (type) (str.c_str()); \
996                  }                                                     \
997            }                                                           \
998        }                                                               \
999    } while (0)
1000
1001#define ALLOC3_FOREIGN_SIGNAL_OUT( sig, interface, name, type, size, x1, x2,x3)    \
1002  do                                                                    \
1003    {                                                                   \
1004      sig = new SC_OUT (type) *** [x1];                                 \
1005      for (uint32_t it1=0; it1<x1; it1++)                               \
1006        {                                                               \
1007          sig [it1] = new SC_OUT (type) ** [x2];                        \
1008          for (uint32_t it2=0; it2<x2; it2++)                           \
1009            {                                                           \
1010              sig [it1][it2] = new SC_OUT (type) * [x3];                \
1011              for (uint32_t it3=0; it3<x3; it3++)                       \
1012                if (size > 0)                                           \
1013                  {                                                     \
1014                    std::string str = (toString("out")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(it2)+"_"+toString(it3)+"_"+toString(name)); \
1015                    sig [it1][it2][it3] = new SC_OUT(type) (str.c_str()); \
1016                  }                                                     \
1017            }                                                           \
1018        }                                                               \
1019    } while (0)
1020
1021#define DELETE3_FOREIGN_SIGNAL( sig, size,x1,x2,x3)            \
1022  do                                                           \
1023    {                                                          \
1024      DELETE3_SIGNAL(sig,x1,x2,x3,size);                       \
1025    } while (0)
1026
1027#define ALLOC3_SC_SIGNAL( sig, name, type, x1, x2, x3)                  \
1028  do                                                                    \
1029    {                                                                   \
1030      sig = new sc_signal<type> *** [x1];                               \
1031      {                                                                 \
1032        std::string separator="_";                                      \
1033        std::string str;                                                \
1034        for (uint32_t it1=0; it1<x1; it1++)                             \
1035          {                                                             \
1036            sig [it1] = new sc_signal<type> ** [x2];                    \
1037            for (uint32_t it2=0; it2<x2; it2++)                         \
1038              {                                                         \
1039                sig [it1][it2] = new sc_signal<type> * [x3];            \
1040                for (uint32_t it3=0; it3<x3; it3++)                     \
1041                  {                                                     \
1042                    str = name+separator+toString(it1)+separator+toString(it2)+separator+toString(it3); \
1043                    sig [it1][it2][it3] = new sc_signal<type> (str.c_str()); \
1044                    PRINT_SIGNAL_ADDRESS(str.c_str(),sig[it1][it2][it3]); \
1045                  }                                                     \
1046              }                                                         \
1047          }                                                             \
1048      }                                                                 \
1049    } while (0)
1050
1051#define INSTANCE3_SC_SIGNAL(component, sig, x1, x2, x3)                 \
1052  do                                                                    \
1053    {                                                                   \
1054      for (uint32_t it1=0; it1<x1; it1++)                               \
1055        for (uint32_t it2=0; it2<x2; it2++)                             \
1056          for (uint32_t it3=0; it3<x3; it3++)                           \
1057            {                                                           \
1058              TEST_SIGNAL(component->sig  [it1][it2][it3]->name(),component->sig  [it1][it2][it3]); \
1059              TEST_SIGNAL(sig             [it1][it2][it3]->name(),sig             [it1][it2][it3]); \
1060              (*(component->sig[it1][it2][it3])) (*(sig[it1][it2][it3])); \
1061            }                                                           \
1062    } while (0)
1063
1064#define _INSTANCE3_SC_SIGNAL(component, sig1, sig2, x1, x2, x3)         \
1065  do                                                                    \
1066    {                                                                   \
1067      for (uint32_t it1=0; it1<x1; it1++)                               \
1068        for (uint32_t it2=0; it2<x2; it2++)                             \
1069          for (uint32_t it3=0; it3<x3; it3++)                           \
1070            {                                                           \
1071              TEST_SIGNAL(component->sig1 [it1][it2][it3]->name(),component->sig1 [it1][it2][it3]); \
1072              TEST_SIGNAL(sig2            [it1][it2][it3]->name(),sig2            [it1][it2][it3]); \
1073              (*(component->sig1[it1][it2][it3])) (*(sig2[it1][it2][it3])); \
1074            }                                                           \
1075    } while (0)
1076
1077#define DELETE3_SC_SIGNAL(sig,x1,x2,x3)                                 \
1078  do                                                                    \
1079    {                                                                   \
1080      for (uint32_t it1=0; it1<x1; it1++)                               \
1081        {                                                               \
1082          for (uint32_t it2=0; it2<x2; it2++)                           \
1083            {                                                           \
1084              for (uint32_t it3=0; it3<x3; it3++)                       \
1085                {                                                       \
1086                  PRINT_SIGNAL_ADDRESS("",sig[it1][it2][it3]);          \
1087                  delete sig[it1][it2][it3];                            \
1088                }                                                       \
1089              delete [] sig[it1][it2];                                  \
1090            }                                                           \
1091          delete [] sig[it1];                                           \
1092        }                                                               \
1093      delete [] sig;                                                    \
1094    } while (0)
1095
1096#endif
Note: See TracBrowser for help on using the repository browser.