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

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

Modif for performance :
1) Load Store Unit : store send request to valid exeception
2) Commit_unit : retire can bypass store
3) Commit_unit : add stat to manage store instruction
4) Load Store Unit and Load Store Pointer Manager : add store_queue_ptr_read
5) Fix lot of bug

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