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

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

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 49.3 KB
Line 
1#ifndef morpheo_behavioural_Allocation_h
2#define morpheo_behavioural_Allocation_h
3
4/*
5 * $Id: Allocation.h 88 2008-12-10 18:31:39Z rosiere $
6 *
7 * [ Description ]
8 *
9 */
10
11#include "Common/include/Debug.h"
12
13// ======================================================================
14// =====[ ALLOCATION / DELETE of ARRAY ]=================================
15// ======================================================================
16
17#define ALLOC1(var,type,s1)                      \
18  var = new type [s1]
19 
20#define ALLOC2(var,type,s1,s2)                   \
21  var = new type * [s1];                         \
22  for (uint32_t it1=0; it1<s1; ++it1)            \
23    {                                            \
24      var [it1] = new type [s2];                 \
25    }
26
27#define ALLOC3(var,type,s1,s2,s3)                \
28  var = new type ** [s1];                        \
29  for (uint32_t it1=0; it1<s1; ++it1)            \
30    {                                            \
31      var [it1] = new type * [s2];               \
32      for (uint32_t it2=0; it2<s2; ++it2)        \
33        {                                        \
34          var [it1][it2] = new type [s3];        \
35        }                                        \
36    }
37 
38#define ALLOC4(var,type,s1,s2,s3,s4)                    \
39  var = new type *** [s1];                              \
40  for (uint32_t it1=0; it1<s1; ++it1)                   \
41    {                                                   \
42      var [it1] = new type ** [s2];                     \
43      for (uint32_t it2=0; it2<s2; ++it2)               \
44        {                                               \
45          var [it1][it2] = new type * [s3];             \
46          for (uint32_t it3=0; it3<s3; ++it3)           \
47            {                                           \
48              var [it1][it2][it3] = new type [s4];      \
49            }                                           \
50        }                                               \
51    }
52 
53#define DELETE1(var,s1)                          \
54  delete [] var;
55
56#define DELETE2(var,s1,s2)                       \
57  for (uint32_t it1=0; it1<s1; ++it1)            \
58    {                                            \
59      delete [] var [it1];                       \
60    }                                            \
61  delete [] var;                         
62 
63#define DELETE3(var,s1,s2,s3)                    \
64  for (uint32_t it1=0; it1<s1; ++it1)            \
65    {                                            \
66      for (uint32_t it2=0; it2<s2; ++it2)        \
67        {                                        \
68          delete [] var [it1][it2];              \
69        }                                        \
70      delete [] var [it1];                       \
71    }                                            \
72  delete [] var;
73 
74#define DELETE4(var,s1,s2,s3,s4)                 \
75  for (uint32_t it1=0; it1<s1; ++it1)            \
76    {                                            \
77      for (uint32_t it2=0; it2<s2; ++it2)        \
78        {                                        \
79          for (uint32_t it3=0; it3<s3; ++it3)    \
80            {                                    \
81              delete [] var [it1][it2][it3];     \
82            }                                    \
83          delete [] var [it1][it2];              \
84        }                                        \
85      delete [] var [it1];                       \
86    }                                            \
87  delete [] var;                                       
88
89// ======================================================================
90// =====[ ALLOCATION / DELETE of SIGNAL]=================================
91// ======================================================================
92
93// Help to allocate interface
94#define INTERFACE_PRINT(name) log_printf(TRACE,Allocation,FUNCTION,"<%s> : Interface's creation : %s (%s, %d)",_name.c_str(),name,__FILE__,__LINE__);
95#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__);
96#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);
97#define TEST_SIGNAL(name,address) PRINT_SIGNAL_ADDRESS(name,address); TEST_PTR(address)
98
99// ----------------------------------------------------------------------
100// -----[ NO ITERATION ]-------------------------------------------------
101// ----------------------------------------------------------------------
102
103#define __ALLOC_SIGNAL(sig, name, type)         \
104  {                                             \
105    sig = new type (name);                      \
106  }
107
108#ifdef POSITION
109#define ALLOC_INTERFACE( name, direction, localisation, str)            \
110  INTERFACE_PRINT(name);                                                \
111  morpheo::behavioural::Interface_fifo * interface = _interfaces->set_interface( name, direction, localisation, str);
112#else
113#define ALLOC_INTERFACE( name, direction, localisation, str)            \
114  INTERFACE_PRINT(name);                                                \
115  morpheo::behavioural::Interface_fifo * interface = _interfaces->set_interface( name);
116#endif
117
118#define ALLOC_VAL_ACK_IN(  sig, name, type)                             \
119  {                                                                     \
120    sig = interface->set_signal_valack_in (name, type);                 \
121  }                                                                     
122#define ALLOC_VAL_ACK_OUT( sig, name, type)                             \
123  {                                                                     \
124    sig = interface->set_signal_valack_out(name, type);                 \
125  }                                                                     
126#define ALLOC_VALACK_IN(     sig, type)                                 \
127  {                                                                     \
128    sig = interface->set_signal_valack_in (type);                       \
129  }                                                                     
130#define ALLOC_VALACK_OUT(    sig, type)                                 \
131  {                                                                     \
132    sig = interface->set_signal_valack_out(type);                       \
133  }                                                                     
134#define ALLOC_SIGNAL_IN(  sig, name, type, size)                        \
135  if (size > 0)                                                         \
136    {                                                                   \
137      sig = interface->set_signal_in <type> (name, size);               \
138    }                                                                   \
139  else                                                                  \
140    {                                                                   \
141      PRINT_SIZE_NUL(_component,interface,name);                        \
142    }
143 
144#define ALLOC_SIGNAL_OUT( sig, name, type, size)                        \
145  if (size > 0)                                                         \
146    {                                                                   \
147      sig = interface->set_signal_out<type> (name, size);               \
148    }                                                                   \
149  else                                                                  \
150    {                                                                   \
151      PRINT_SIZE_NUL(_component,interface,name); \
152    }
153
154#define DELETE_SIGNAL( sig, size)                                       \
155  if (size > 0)                                                         \
156    {                                                                   \
157      delete sig;                                                       \
158    }
159
160#define ALLOC_SC_SIGNAL(  sig, name, type)                              \
161  sc_signal<type> * sig = new sc_signal<type> (name);                   \
162  PRINT_SIGNAL_ADDRESS(name,sig);
163
164#define INSTANCE_SC_SIGNAL(component, sig)                     \
165  {                                                            \
166    TEST_SIGNAL(component->sig->name(),component->sig);        \
167    TEST_SIGNAL(sig           ->name(),sig);                   \
168    (*(component->sig)) (*(sig));                              \
169  }
170
171#define _INSTANCE_SC_SIGNAL(component, sig1,sig2)                       \
172  {                                                                     \
173    TEST_SIGNAL(component->sig1->name(),component->sig1);               \
174    TEST_SIGNAL(sig2           ->name(),sig2);                          \
175    (*(component->sig1)) (*(sig2));                                     \
176  }
177
178#define DELETE_SC_SIGNAL( sig)                  \
179  {                                             \
180    delete sig;                                 \
181  }
182
183
184#define __ALLOC0_SIGNAL(sig, name, type)                      __ALLOC_SIGNAL(sig, name, type)
185
186#define ALLOC0_INTERFACE( name, direction, localisation, str) ALLOC_INTERFACE( name, direction, localisation, str)
187
188#define ALLOC0_VAL_ACK_IN(  sig, name, type)                  ALLOC_VAL_ACK_IN(  sig, name, type)
189#define ALLOC0_VAL_ACK_OUT( sig, name, type)                  ALLOC_VAL_ACK_OUT( sig, name, type)
190#define ALLOC0_VALACK_IN(     sig, type)                      ALLOC_VALACK_IN(     sig, type)
191#define ALLOC0_VALACK_OUT(    sig, type)                      ALLOC_VALACK_OUT(    sig, type)
192#define ALLOC0_SIGNAL_IN(  sig, name, type, size)             ALLOC_SIGNAL_IN(  sig, name, type, size)
193#define ALLOC0_SIGNAL_OUT( sig, name, type, size)             ALLOC_SIGNAL_OUT( sig, name, type, size)
194#define DELETE0_SIGNAL( sig, size)                            DELETE_SIGNAL( sig, size)
195
196#define ALLOC0_SC_SIGNAL(  sig, name, type)                   ALLOC_SC_SIGNAL(  sig, name, type)
197#define INSTANCE0_SC_SIGNAL(component, sig)                   INSTANCE_SC_SIGNAL(component, sig)
198#define _INSTANCE0_SC_SIGNAL(component, sig)                  _INSTANCE_SC_SIGNAL(component, sig)
199#define DELETE0_SC_SIGNAL( sig)                               DELETE_SC_SIGNAL( sig)
200
201// ----------------------------------------------------------------------
202// -----[ ITERATION 1 ]--------------------------------------------------
203// ----------------------------------------------------------------------
204
205#define __ALLOC1_INTERFACE(name, x1)                                    \
206  INTERFACE_PRINT(name);                                                \
207  const std::string interface_name = name;                              \
208  const uint32_t iterator_1 = x1;
209
210#define __ALLOC1_SIGNAL_IN( sig, name, type)                            \
211  {                                                                     \
212    sig = new SC_IN(type) * [iterator_1];                               \
213    std::string separator="_";                                          \
214    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
215      {                                                                 \
216        std::string str = "in_"+interface_name+separator+toString(it1)+separator+name; \
217        sig [it1] = new SC_IN(type) (str.c_str());                      \
218      }                                                                 \
219  }
220
221#define __ALLOC1_SIGNAL_OUT( sig, name, type)                           \
222  {                                                                     \
223    sig = new SC_OUT(type) * [iterator_1];                              \
224    std::string separator="_";                                          \
225    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
226      {                                                                 \
227        std::string str = "out_"+interface_name+separator+toString(it1)+separator+name; \
228        sig [it1] = new SC_OUT(type) (str.c_str());                     \
229      }                                                                 \
230  }
231
232#ifdef POSITION
233#define ALLOC1_INTERFACE( name, direction, localisation, str, x1)       \
234  INTERFACE_PRINT(name);                                                \
235  const uint32_t iterator_1 = x1;                                       \
236  morpheo::behavioural::Interface_fifo * interface [iterator_1];        \
237  {                                                                     \
238    std::string separator="_";                                          \
239    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
240      {                                                                 \
241        interface [it1] = _interfaces->set_interface( name+separator+toString(it1), direction, localisation, str); \
242      }                                                                 \
243  }
244#else
245#define ALLOC1_INTERFACE( name, direction, localisation, str, x1)       \
246  INTERFACE_PRINT(name);                                                \
247  const uint32_t iterator_1 = x1;                                       \
248  morpheo::behavioural::Interface_fifo * interface [iterator_1];        \
249  {                                                                     \
250    std::string separator="_";                                          \
251    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
252      {                                                                 \
253        interface [it1] = _interfaces->set_interface( name+separator+toString(it1)); \
254      }                                                                 \
255  }
256#endif
257
258#define ALLOC1_VAL_ACK_IN( sig, name, type)                             \
259  {                                                                     \
260    sig = new SC_IN (Tcontrol_t) * [iterator_1];                        \
261    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
262      {                                                                 \
263        sig [it1] = interface[it1]->set_signal_valack_in (name, type);  \
264      }                                                                 \
265  }
266#define ALLOC1_VAL_ACK_OUT(sig, name, type)                             \
267  {                                                                     \
268    sig = new SC_OUT(Tcontrol_t) * [iterator_1];                        \
269    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
270      {                                                                 \
271        sig [it1] = interface[it1]->set_signal_valack_out(name, type);  \
272      }                                                                 \
273  }
274#define ALLOC1_VALACK_IN(    sig, type)                                 \
275  {                                                                     \
276    sig = new SC_IN (Tcontrol_t) * [iterator_1];                        \
277    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
278      {                                                                 \
279        sig [it1] = interface[it1]->set_signal_valack_in (type);        \
280      }                                                                 \
281  }
282#define ALLOC1_VALACK_OUT(   sig, type)                                 \
283  {                                                                     \
284    sig = new SC_OUT(Tcontrol_t) * [iterator_1];                        \
285    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
286      {                                                                 \
287        sig [it1] = interface[it1]->set_signal_valack_out(type);        \
288      }                                                                 \
289  }
290#define ALLOC1_SIGNAL_IN( sig, name, type, size)                        \
291  {                                                                     \
292    sig = new SC_IN (type) * [iterator_1];                              \
293    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
294      {                                                                 \
295        if (size > 0)                                                   \
296          {                                                             \
297            sig [it1] = interface[it1]->set_signal_in <type> (name, size); \
298          }                                                             \
299        else                                                            \
300          {                                                             \
301            PRINT_SIZE_NUL(_component,interface[it1],name);             \
302          }                                                             \
303      }                                                                 \
304  }
305
306#define ALLOC1_SIGNAL_OUT(sig, name, type, size)                        \
307  {                                                                     \
308    sig = new SC_OUT(type) * [iterator_1];                              \
309    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
310      {                                                                 \
311        if (size > 0)                                                   \
312          {                                                             \
313            sig [it1] = interface[it1]->set_signal_out<type> (name, size); \
314          }                                                             \
315        else                                                            \
316          {                                                             \
317            PRINT_SIZE_NUL(_component,interface[it1],name);             \
318          }                                                             \
319      }                                                                 \
320  }
321
322#define DELETE1_SIGNAL(sig, x1, size)                                   \
323  {                                                                     \
324    for (uint32_t it1=0; it1<x1; it1++)                                 \
325      {                                                                 \
326        if (size > 0)                                                   \
327          {                                                             \
328            delete sig[it1];                                            \
329          }                                                             \
330      }                                                                 \
331    delete [] sig;                                                      \
332  }
333
334#define ALLOC1_SC_SIGNAL( sig, name, type, x1)                          \
335  sc_signal<type> ** sig = new sc_signal<type> * [x1];                  \
336  {                                                                     \
337    std::string separator="_";                                          \
338    std::string str;                                                    \
339    for (uint32_t it1=0; it1<x1; it1++)                                 \
340      {                                                                 \
341        str = name+separator+toString(it1);                             \
342        sig [it1] = new sc_signal<type> (str.c_str());                  \
343        PRINT_SIGNAL_ADDRESS(str.c_str(),sig[it1]);                     \
344      }                                                                 \
345  }
346
347#define INSTANCE1_SC_SIGNAL(component, sig, x1) \
348  for (uint32_t it1=0; it1<x1; it1++)                                   \
349    {                                                                   \
350      TEST_SIGNAL(component->sig [it1]->name(),component->sig [it1]);   \
351      TEST_SIGNAL(sig            [it1]->name(),sig            [it1]);   \
352      (*(component->sig[it1])) (*(sig[it1]));                           \
353    }
354
355#define _INSTANCE1_SC_SIGNAL(component, sig1, sig2, x1) \
356  for (uint32_t it1=0; it1<x1; it1++)                                   \
357    {                                                                   \
358      TEST_SIGNAL(component->sig1 [it1]->name(),component->sig1 [it1]); \
359      TEST_SIGNAL(sig2            [it1]->name(),sig2            [it1]); \
360      (*(component->sig1[it1])) (*(sig2[it1]));                         \
361    }
362
363#define DELETE1_SC_SIGNAL(sig, x1)                                      \
364  {                                                                     \
365    for (uint32_t it1=0; it1<x1; it1++)                                 \
366      {                                                                 \
367        delete sig[it1];                                                \
368      }                                                                 \
369    delete [] sig;                                                      \
370  }
371
372// ----------------------------------------------------------------------
373// -----[ ITERATION 2 ]--------------------------------------------------
374// ----------------------------------------------------------------------
375
376#ifdef POSITION
377#define ALLOC2_INTERFACE( name, direction, localisation, str, x1, x2)   \
378  INTERFACE_PRINT(name);                                                \
379  uint32_t iterator_1 = 0;                                              \
380  uint32_t iterator_2 = 0;                                              \
381  morpheo::behavioural::Interface_fifo *** interface;                   \
382  {                                                                     \
383    std::string separator="_";                                          \
384    iterator_1 = x1;                                                    \
385    interface = new morpheo::behavioural::Interface_fifo ** [iterator_1]; \
386    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
387      {                                                                 \
388        iterator_2 = x2;                                                \
389        interface [it1] = new morpheo::behavioural::Interface_fifo * [iterator_2]; \
390        for (uint32_t it2=0; it2<iterator_2; it2++)                     \
391          {                                                             \
392            interface [it1][it2] = _interfaces->set_interface( name+separator+toString(it1)+separator+toString(it2), direction, localisation, str); \
393          }                                                             \
394      }                                                                 \
395  }
396#else
397#define ALLOC2_INTERFACE( name, direction, localisation, str, x1, x2)   \
398  INTERFACE_PRINT(name);                                                \
399  uint32_t iterator_1 = 0;                                              \
400  uint32_t iterator_2 = 0;                                              \
401  morpheo::behavioural::Interface_fifo *** interface;                   \
402  {                                                                     \
403    std::string separator="_";                                          \
404    iterator_1 = x1;                                                    \
405    interface = new morpheo::behavioural::Interface_fifo ** [iterator_1]; \
406    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
407      {                                                                 \
408        iterator_2 = x2;                                                \
409        interface [it1] = new morpheo::behavioural::Interface_fifo * [iterator_2]; \
410        for (uint32_t it2=0; it2<iterator_2; it2++)                     \
411          {                                                             \
412            interface [it1][it2] = _interfaces->set_interface( name+separator+toString(it1)+separator+toString(it2)); \
413          }                                                             \
414      }                                                                 \
415  }
416#endif
417
418#define _ALLOC2_VAL_ACK_IN( sig, name, type, x1, x2)                    \
419  {                                                                     \
420    sig = new SC_IN (Tcontrol_t) ** [x1];                               \
421    for (uint32_t it1=0; it1<x1; it1++)                                 \
422      {                                                                 \
423        sig [it1] = new SC_IN (Tcontrol_t) * [x2];                      \
424        for (uint32_t it2=0; it2<x2; it2++)                             \
425          {                                                             \
426            sig [it1][it2] = interface[it1][it2]->set_signal_valack_in (name, type); \
427          }                                                             \
428      }                                                                 \
429  }
430
431#define _ALLOC2_VAL_ACK_OUT( sig, name, type, x1, x2)                   \
432  {                                                                     \
433    sig = new SC_OUT (Tcontrol_t) ** [x1];                              \
434    for (uint32_t it1=0; it1<x1; it1++)                                 \
435      {                                                                 \
436        sig [it1] = new SC_OUT (Tcontrol_t) * [x2];                     \
437        for (uint32_t it2=0; it2<x2; it2++)                             \
438          {                                                             \
439            sig [it1][it2] = interface[it1][it2]->set_signal_valack_out (name, type); \
440          }                                                             \
441      }                                                                 \
442  }
443
444#define _ALLOC2_VALACK_IN(    sig,type, x1, x2)                         \
445  {                                                                     \
446    sig = new SC_IN (Tcontrol_t) ** [x1];                               \
447    for (uint32_t it1=0; it1<x1; it1++)                                 \
448      {                                                                 \
449        sig [it1] = new SC_IN (Tcontrol_t) * [x2];                      \
450        for (uint32_t it2=0; it2<x2; it2++)                             \
451          {                                                             \
452            sig [it1][it2] = interface[it1][it2]->set_signal_valack_in (type); \
453          }                                                             \
454      }                                                                 \
455  }
456
457#define _ALLOC2_VALACK_OUT(    sig,type, x1, x2)                        \
458  {                                                                     \
459    sig = new SC_OUT (Tcontrol_t) ** [x1];                              \
460    for (uint32_t it1=0; it1<x1; it1++)                                 \
461      {                                                                 \
462        sig [it1] = new SC_OUT (Tcontrol_t) * [x2];                     \
463        for (uint32_t it2=0; it2<x2; it2++)                             \
464          {                                                             \
465            sig [it1][it2] = interface[it1][it2]->set_signal_valack_out (type); \
466          }                                                             \
467      }                                                                 \
468  }
469
470#define _ALLOC2_SIGNAL_IN( sig, name, type, size, x1, x2)               \
471  {                                                                     \
472    sig = new SC_IN (type) ** [x1];                                     \
473    for (uint32_t it1=0; it1<x1; it1++)                                 \
474      {                                                                 \
475        sig [it1] = new SC_IN (type) * [x2];                            \
476        for (uint32_t it2=0; it2<x2; it2++)                             \
477          {                                                             \
478            if (size > 0)                                               \
479              {                                                         \
480                sig [it1][it2] = interface[it1][it2]->set_signal_in <type> (name, size); \
481              }                                                         \
482            else                                                        \
483              {                                                         \
484                PRINT_SIZE_NUL(_component,interface[it1][it2],name);    \
485              }                                                         \
486          }                                                             \
487      }                                                                 \
488  }
489
490#define _ALLOC2_SIGNAL_OUT( sig, name, type, size, x1, x2)              \
491  {                                                                     \
492    sig = new SC_OUT (type) ** [x1];                                    \
493    for (uint32_t it1=0; it1<x1; it1++)                                 \
494      {                                                                 \
495        sig [it1] = new SC_OUT (type) * [x2];                           \
496        for (uint32_t it2=0; it2<x2; it2++)                             \
497          {                                                             \
498            if (size > 0)                                               \
499              {                                                         \
500                sig [it1][it2] = interface[it1][it2]->set_signal_out <type> (name, size); \
501              }                                                         \
502            else                                                        \
503              {                                                         \
504                PRINT_SIZE_NUL(_component,interface[it1][it2],name);    \
505              }                                                         \
506          }                                                             \
507      }                                                                 \
508  }
509
510#define ALLOC2_VAL_ACK_IN( sig, name, type      ) _ALLOC2_VAL_ACK_IN( sig, name, type      , iterator_1, iterator_2)
511#define ALLOC2_VAL_ACK_OUT(sig, name, type      ) _ALLOC2_VAL_ACK_OUT(sig, name, type      , iterator_1, iterator_2)
512#define ALLOC2_VALACK_IN(  sig,       type      ) _ALLOC2_VALACK_IN(  sig,       type      , iterator_1, iterator_2)
513#define ALLOC2_VALACK_OUT( sig,       type      ) _ALLOC2_VALACK_OUT( sig,       type      , iterator_1, iterator_2)
514#define ALLOC2_SIGNAL_IN(  sig, name, type, size) _ALLOC2_SIGNAL_IN(  sig, name, type, size, iterator_1, iterator_2)
515#define ALLOC2_SIGNAL_OUT( sig, name, type, size) _ALLOC2_SIGNAL_OUT( sig, name, type, size, iterator_1, iterator_2)
516
517#define DELETE2_SIGNAL(sig, x1,x2, size)                                \
518  {                                                                     \
519    for (uint32_t it1=0; it1<x1; it1++)                                 \
520      {                                                                 \
521        for (uint32_t it2=0; it2<x2; it2++)                             \
522          {                                                             \
523            if (size > 0)                                               \
524              {                                                         \
525                delete sig[it1][it2];                                   \
526              }                                                         \
527          }                                                             \
528        delete [] sig[it1];                                             \
529      }                                                                 \
530    delete [] sig;                                                      \
531  }
532
533#define ALLOC2_SC_SIGNAL( sig, name, type, x1, x2)                      \
534  sc_signal<type> *** sig = new sc_signal<type> ** [x1];                \
535  {                                                                     \
536    std::string separator="_";                                          \
537    std::string str;                                                    \
538    for (uint32_t it1=0; it1<x1; it1++)                                 \
539      {                                                                 \
540        sig [it1] = new sc_signal<type> * [x2];                         \
541        for (uint32_t it2=0; it2<x2; it2++)                             \
542          {                                                             \
543            str = name+separator+toString(it1)+separator+toString(it2); \
544            sig [it1][it2] = new sc_signal<type> (str.c_str());         \
545            PRINT_SIGNAL_ADDRESS(str.c_str(),sig[it1][it2]);            \
546          }                                                             \
547      }                                                                 \
548  }
549
550#define INSTANCE2_SC_SIGNAL(component, sig, x1, x2)                     \
551  for (uint32_t it1=0; it1<x1; it1++)                                   \
552    for (uint32_t it2=0; it2<x2; it2++)                                 \
553      {                                                                 \
554        TEST_SIGNAL(component->sig  [it1][it2]->name(),component->sig  [it1][it2]); \
555        TEST_SIGNAL(sig             [it1][it2]->name(),sig             [it1][it2]); \
556        (*(component->sig[it1][it2])) (*(sig[it1][it2]));               \
557      }
558
559#define _INSTANCE2_SC_SIGNAL(component, sig1, sig2, x1, x2)             \
560  for (uint32_t it1=0; it1<x1; it1++)                                   \
561    for (uint32_t it2=0; it2<x2; it2++)                                 \
562      {                                                                 \
563        TEST_SIGNAL(component->sig1 [it1][it2]->name(),component->sig1 [it1][it2]); \
564        TEST_SIGNAL(sig2            [it1][it2]->name(),sig2            [it1][it2]); \
565        (*(component->sig1[it1][it2])) (*(sig2[it1][it2]));             \
566      }
567
568#define DELETE2_SC_SIGNAL(sig,x1,x2)                                    \
569  {                                                                     \
570    for (uint32_t it1=0; it1<x1; it1++)                                 \
571      {                                                                 \
572        for (uint32_t it2=0; it2<x2; it2++)                             \
573          {                                                             \
574            delete sig[it1][it2];                                       \
575          }                                                             \
576        delete [] sig[it1];                                             \
577      }                                                                 \
578    delete [] sig;                                                      \
579  }
580
581// ----------------------------------------------------------------------
582// -----[ ITERATION 3 ]--------------------------------------------------
583// ----------------------------------------------------------------------
584
585#ifdef POSITION
586#define ALLOC3_INTERFACE( name, direction, localisation, str, x1, x2, x3) \
587  INTERFACE_PRINT(name);                                                \
588  uint32_t iterator_1 = 0;                                              \
589  uint32_t iterator_2 = 0;                                              \
590  uint32_t iterator_3 = 0;                                              \
591  morpheo::behavioural::Interface_fifo **** interface;                  \
592  {                                                                     \
593    std::string separator="_";                                          \
594    iterator_1 = x1;                                                    \
595    interface = new morpheo::behavioural::Interface_fifo *** [iterator_1]; \
596    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
597      {                                                                 \
598        iterator_2 = x2;                                                \
599        interface [it1] = new morpheo::behavioural::Interface_fifo ** [iterator_2]; \
600        for (uint32_t it2=0; it2<iterator_2; it2++)                     \
601          {                                                             \
602            iterator_3 = x3;                                            \
603            interface [it1][it2] = new morpheo::behavioural::Interface_fifo * [iterator_3]; \
604            for (uint32_t it3=0; it3<iterator_3; it3++)                 \
605              {                                                         \
606                interface [it1][it2][it3] = _interfaces->set_interface( name+separator+toString(it1)+separator+toString(it2)+separator+toString(it3), direction, localisation, str); \
607              }                                                         \
608          }                                                             \
609      }                                                                 \
610  }
611#else
612#define ALLOC3_INTERFACE( name, direction, localisation, str, x1, x2, x3) \
613  INTERFACE_PRINT(name);                                                \
614  uint32_t iterator_1 = 0;                                              \
615  uint32_t iterator_2 = 0;                                              \
616  uint32_t iterator_3 = 0;                                              \
617  morpheo::behavioural::Interface_fifo **** interface;                  \
618  {                                                                     \
619    std::string separator="_";                                          \
620    iterator_1 = x1;                                                    \
621    interface = new morpheo::behavioural::Interface_fifo *** [iterator_1]; \
622    for (uint32_t it1=0; it1<iterator_1; it1++)                         \
623      {                                                                 \
624        iterator_2 = x2;                                                \
625        interface [it1] = new morpheo::behavioural::Interface_fifo ** [iterator_2]; \
626        for (uint32_t it2=0; it2<iterator_2; it2++)                     \
627          {                                                             \
628            iterator_3 = x3;                                            \
629            interface [it1][it2] = new morpheo::behavioural::Interface_fifo * [iterator_3]; \
630            for (uint32_t it3=0; it3<iterator_3; it3++)                 \
631              {                                                         \
632                interface [it1][it2][it3] = _interfaces->set_interface( name+separator+toString(it1)+separator+toString(it2)+separator+toString(it3)); \
633              }                                                         \
634          }                                                             \
635      }                                                                 \
636  }
637#endif
638
639// #define _ALLOC3_VAL_ACK_IN( sig, name, type, x1, x2, x3)
640// #define _ALLOC3_VAL_ACK_OUT( sig, name, type, x1, x2, x3)
641
642#define _ALLOC3_VALACK_IN(    sig,type, x1, x2, x3)                     \
643  {                                                                     \
644    sig = new SC_IN (Tcontrol_t) *** [x1];                              \
645    for (uint32_t it1=0; it1<x1; it1++)                                 \
646      {                                                                 \
647        sig [it1] = new SC_IN (Tcontrol_t) ** [x2];                     \
648        for (uint32_t it2=0; it2<x2; it2++)                             \
649          {                                                             \
650            sig [it1][it2] = new SC_IN (Tcontrol_t) * [x3];             \
651            for (uint32_t it3=0; it3<x3; it3++)                         \
652              {                                                         \
653                sig [it1][it2][it3] = interface[it1][it2][it3]->set_signal_valack_in (type); \
654              }                                                         \
655          }                                                             \
656      }                                                                 \
657  }
658
659#define _ALLOC3_VALACK_OUT(    sig,type, x1, x2, x3)                    \
660  {                                                                     \
661    sig = new SC_OUT (Tcontrol_t) *** [x1];                             \
662    for (uint32_t it1=0; it1<x1; it1++)                                 \
663      {                                                                 \
664        sig [it1] = new SC_OUT (Tcontrol_t) ** [x2];                    \
665        for (uint32_t it2=0; it2<x2; it2++)                             \
666          {                                                             \
667            sig [it1][it2] = new SC_OUT (Tcontrol_t) * [x3];            \
668            for (uint32_t it3=0; it3<x3; it3++)                         \
669              {                                                         \
670                sig [it1][it2][it3] = interface[it1][it2][it3]->set_signal_valack_out (type); \
671              }                                                         \
672          }                                                             \
673      }                                                                 \
674  }
675
676
677#define _ALLOC3_SIGNAL_IN( sig, name, type, size, x1, x2,x3)            \
678  {                                                                     \
679    sig = new SC_IN (type) *** [x1];                                    \
680    for (uint32_t it1=0; it1<x1; it1++)                                 \
681      {                                                                 \
682        sig [it1] = new SC_IN (type) ** [x2];                           \
683        for (uint32_t it2=0; it2<x2; it2++)                             \
684          {                                                             \
685            sig [it1][it2] = new SC_IN (type) * [x3];                   \
686            for (uint32_t it3=0; it3<x3; it3++)                         \
687              {                                                         \
688                if (size > 0)                                           \
689                  {                                                     \
690                    sig [it1][it2][it3] = interface[it1][it2][it3]->set_signal_in <type> (name, size); \
691                  }                                                     \
692                else                                                    \
693                  {                                                     \
694                    PRINT_SIZE_NUL(_component,interface[it1][it2][it3],name); \
695                  }                                                     \
696              }                                                         \
697          }                                                             \
698      }                                                                 \
699  }
700
701#define _ALLOC3_SIGNAL_OUT( sig, name, type, size, x1, x2,x3)           \
702  {                                                                     \
703    sig = new SC_OUT (type) *** [x1];                                   \
704    for (uint32_t it1=0; it1<x1; it1++)                                 \
705      {                                                                 \
706        sig [it1] = new SC_OUT (type) ** [x2];                          \
707        for (uint32_t it2=0; it2<x2; it2++)                             \
708          {                                                             \
709            sig [it1][it2] = new SC_OUT (type) * [x3];                  \
710            for (uint32_t it3=0; it3<x3; it3++)                         \
711              {                                                         \
712                if (size > 0)                                           \
713                  {                                                     \
714                    sig [it1][it2][it3] = interface[it1][it2][it3]->set_signal_out <type> (name, size); \
715                  }                                                     \
716                else                                                    \
717                  {                                                     \
718                    PRINT_SIZE_NUL(_component,interface[it1][it2][it3],name); \
719                  }                                                     \
720              }                                                         \
721          }                                                             \
722      }                                                                 \
723  }
724
725// #define ALLOC3_VAL_ACK_IN( sig, name, type      ) _ALLOC3_VAL_ACK_IN( sig, name, type      , iterator_1, iterator_2, iterator_3)
726// #define ALLOC3_VAL_ACK_OUT(sig, name, type      ) _ALLOC3_VAL_ACK_OUT(sig, name, type      , iterator_1, iterator_2, iterator_3)
727#define ALLOC3_VALACK_IN(  sig,       type      ) _ALLOC3_VALACK_IN(  sig,       type      , iterator_1, iterator_2, iterator_3)
728#define ALLOC3_VALACK_OUT( sig,       type      ) _ALLOC3_VALACK_OUT( sig,       type      , iterator_1, iterator_2, iterator_3)
729#define ALLOC3_SIGNAL_IN(  sig, name, type, size) _ALLOC3_SIGNAL_IN(  sig, name, type, size, iterator_1, iterator_2, iterator_3)
730#define ALLOC3_SIGNAL_OUT( sig, name, type, size) _ALLOC3_SIGNAL_OUT( sig, name, type, size, iterator_1, iterator_2, iterator_3)
731
732#define DELETE3_SIGNAL(sig, x1, x2, x3, size)                           \
733  {                                                                     \
734    for (uint32_t it1=0; it1<x1; it1++)                                 \
735      {                                                                 \
736        for (uint32_t it2=0; it2<x2; it2++)                             \
737          {                                                             \
738            for (uint32_t it3=0; it3<x3; it3++)                         \
739              {                                                         \
740                if (size > 0)                                           \
741                  {                                                     \
742                    delete sig[it1][it2][it3];                          \
743                  }                                                     \
744              }                                                         \
745            delete [] sig[it1][it2];                                    \
746          }                                                             \
747        delete [] sig[it1];                                             \
748      }                                                                 \
749    delete [] sig;                                                      \
750  }
751
752#define ALLOC3_SC_SIGNAL( sig, name, type, x1, x2, x3)                  \
753  sc_signal<type> **** sig = new sc_signal<type> *** [x1];              \
754  {                                                                     \
755    std::string separator="_";                                          \
756    std::string str;                                                    \
757    for (uint32_t it1=0; it1<x1; it1++)                                 \
758      {                                                                 \
759         sig [it1] = new sc_signal<type> ** [x2];                       \
760         for (uint32_t it2=0; it2<x2; it2++)                            \
761           {                                                            \
762              sig [it1][it2] = new sc_signal<type> * [x3];              \
763              for (uint32_t it3=0; it3<x3; it3++)                       \
764                {                                                       \
765                  str = name+separator+toString(it1)+separator+toString(it2)+separator+toString(it3); \
766                  sig [it1][it2][it3] = new sc_signal<type> (str.c_str()); \
767                  PRINT_SIGNAL_ADDRESS(str.c_str(),sig[it1][it2][it3]); \
768                }                                                       \
769           }                                                            \
770      }                                                                 \
771  }
772
773#define INSTANCE3_SC_SIGNAL(component, sig, x1, x2, x3)                 \
774  for (uint32_t it1=0; it1<x1; it1++)                                   \
775    for (uint32_t it2=0; it2<x2; it2++)                                 \
776      for (uint32_t it3=0; it3<x3; it3++)                               \
777        {                                                               \
778          TEST_SIGNAL(component->sig  [it1][it2][it3]->name(),component->sig  [it1][it2][it3]); \
779          TEST_SIGNAL(sig             [it1][it2][it3]->name(),sig             [it1][it2][it3]); \
780          (*(component->sig[it1][it2][it3])) (*(sig[it1][it2][it3]));   \
781        }
782
783#define _INSTANCE3_SC_SIGNAL(component, sig1, sig2, x1, x2, x3)         \
784  for (uint32_t it1=0; it1<x1; it1++)                                   \
785    for (uint32_t it2=0; it2<x2; it2++)                                 \
786      for (uint32_t it3=0; it3<x3; it3++)                               \
787        {                                                               \
788          TEST_SIGNAL(component->sig1 [it1][it2][it3]->name(),component->sig1 [it1][it2][it3]); \
789          TEST_SIGNAL(sig2            [it1][it2][it3]->name(),sig2            [it1][it2][it3]); \
790          (*(component->sig1[it1][it2][it3])) (*(sig2[it1][it2][it3])); \
791        }
792
793#define DELETE3_SC_SIGNAL(sig,x1,x2,x3)                                 \
794  {                                                                     \
795    for (uint32_t it1=0; it1<x1; it1++)                                 \
796      {                                                                 \
797        for (uint32_t it2=0; it2<x2; it2++)                             \
798          {                                                             \
799            for (uint32_t it3=0; it3<x3; it3++)                         \
800              {                                                         \
801                delete sig[it1][it2][it3];                              \
802              }                                                         \
803            delete [] sig[it1][it2];                                    \
804          }                                                             \
805        delete [] sig[it1];                                             \
806      }                                                                 \
807    delete [] sig;                                                      \
808  }
809
810#endif
Note: See TracBrowser for help on using the repository browser.