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

Last change on this file since 82 was 82, checked in by rosiere, 16 years ago
  • support locale (now must "just" translate)
  • update all component with new test format
  • update all component with usage
  • New component : decod queue and prediction_unit
  • Property svn:keywords set to Id
File size: 17.1 KB
RevLine 
[81]1#ifndef morpheo_behavioural_Allocation_h
2#define morpheo_behavioural_Allocation_h
[73]3
[82]4/*
5 * $Id: Allocation.h 82 2008-05-01 16:48:45Z rosiere $
6 *
7 * [ Description ]
8 *
9 */
10
[81]11#include "Common/include/Debug.h"
12
[73]13// Help to allocate interface
[81]14#define INTERFACE_PRINT(name) log_printf(TRACE,true,"allocation","Interface's creation : %s (%s, %d)",name,__FILE__,__LINE__);
[73]15
16// ----------------------------------------------------------------------
17// -----[ NO ITERATION ]-------------------------------------------------
18// ----------------------------------------------------------------------
19
[78]20#define __ALLOC_SIGNAL(sig, name, type)         \
21  {                                             \
22    sig = new type (name);                      \
23  }
24
[73]25#ifdef POSITION
26#define ALLOC_INTERFACE( name, direction, localisation, str)            \
[81]27  INTERFACE_PRINT(name);                                                \
[73]28  Interface_fifo * interface = _interfaces->set_interface( name, direction, localisation, str);
29#else
30#define ALLOC_INTERFACE( name, direction, localisation, str)            \
[81]31  INTERFACE_PRINT(name);                                                \
[73]32  Interface_fifo * interface = _interfaces->set_interface( name);
33#endif
34
[78]35#define ALLOC_VAL_ACK_IN(  sig, name, type)                             \
[73]36  {                                                                     \
37    sig = interface->set_signal_valack_in (name, type);                 \
38  }                                                                     
[78]39#define ALLOC_VAL_ACK_OUT( sig, name, type)                             \
[73]40  {                                                                     \
41    sig = interface->set_signal_valack_out(name, type);                 \
42  }                                                                     
[78]43#define ALLOC_VALACK_IN(     sig, type)                                 \
[73]44  {                                                                     \
[78]45    sig = interface->set_signal_valack_in (type);                       \
[73]46  }                                                                     
[78]47#define ALLOC_VALACK_OUT(    sig, type)                                 \
[73]48  {                                                                     \
[78]49    sig = interface->set_signal_valack_out(type);                       \
[73]50  }                                                                     
51#define ALLOC_SIGNAL_IN(  sig, name, type, size)                        \
[76]52  if (size > 0)                                                         \
53    {                                                                   \
54      sig = interface->set_signal_in <type> (name, size);               \
[82]55    }                                                                   \
56  else                                                                  \
57    {                                                                   \
58      log_printf(INFO,true,FUNCTION,_("%s %s.%s.%s : size is nul."),MSG_INFORMATION,_component->get_name().c_str(),interface->get_name().c_str(),name); \
59    }
60 
[73]61#define ALLOC_SIGNAL_OUT( sig, name, type, size)                        \
[76]62  if (size > 0)                                                         \
63    {                                                                   \
64      sig = interface->set_signal_out<type> (name, size);               \
[82]65    }                                                                   \
66  else                                                                  \
67    {                                                                   \
68      log_printf(INFO,true,FUNCTION,_("%s %s.%s.%s : size is nul."),MSG_INFORMATION,_component->get_name().c_str(),interface->get_name().c_str(),name); \
[76]69    }
[73]70
[81]71#define DELETE_SIGNAL( sig, size)                                       \
72  if (size > 0)                                                         \
73    {                                                                   \
74      delete sig;                                                       \
75    }
76
[73]77#define ALLOC_SC_SIGNAL(  sig, name, type)                              \
78  sc_signal<type> * sig = new sc_signal<type> (name);
79
80#define INSTANCE_SC_SIGNAL(component, sig)      \
[82]81  {                                             \
82    TEST_PTR(component->sig);                   \
83    TEST_PTR(sig);                              \
84    (*(component->sig)) (*(sig));               \
85  }
[73]86
[82]87#define DELETE_SC_SIGNAL( sig)                  \
88  {                                             \
89    delete sig;                                 \
90  }
[81]91
[73]92// ----------------------------------------------------------------------
93// -----[ ITERATION 1 ]--------------------------------------------------
94// ----------------------------------------------------------------------
95
[81]96#define __ALLOC1_INTERFACE(name, it1)                                   \
97  INTERFACE_PRINT(name);                                                \
98  const std::string interface_name = name;                              \
[78]99  const uint32_t iterator_1 = it1;
100
101#define __ALLOC1_SIGNAL_IN( sig, name, type)            \
102  {                                                                     \
103    sig = new SC_IN(type) * [iterator_1];                               \
104    std::string separator="_";                                          \
105    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
106      {                                                                 \
107        std::string str = "in_"+interface_name+separator+toString(alloc_signal_it1)+separator+name; \
108        sig [alloc_signal_it1] = new SC_IN(type) (str.c_str());         \
109      }                                                                 \
110  }
111
112#define __ALLOC1_SIGNAL_OUT( sig, name, type)           \
113  {                                                                     \
114    sig = new SC_OUT(type) * [iterator_1];                              \
115    std::string separator="_";                                          \
116    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
117      {                                                                 \
118        std::string str = "out_"+interface_name+separator+toString(alloc_signal_it1)+separator+name; \
119        sig [alloc_signal_it1] = new SC_OUT(type) (str.c_str());                \
120      }                                                                 \
121  }
122
[73]123#ifdef POSITION
124#define ALLOC1_INTERFACE( name, direction, localisation, str, it1)      \
[81]125  INTERFACE_PRINT(name);                                                \
[76]126  const uint32_t iterator_1 = it1;                                      \
127  Interface_fifo * interface [iterator_1];                              \
[73]128  {                                                                     \
[78]129    std::string separator="_";                                          \
130    for (uint32_t alloc_interface_it1=0; alloc_interface_it1<iterator_1; alloc_interface_it1++) \
[73]131      {                                                                 \
[78]132        interface [alloc_interface_it1] = _interfaces->set_interface( name+separator+toString(alloc_interface_it1), direction, localisation, str); \
[73]133      }                                                                 \
134  }
135#else
136#define ALLOC1_INTERFACE( name, direction, localisation, str, it1)      \
[81]137  INTERFACE_PRINT(name);                                                \
[76]138  const uint32_t iterator_1 = it1;                                      \
139  Interface_fifo * interface [iterator_1];                              \
[73]140  {                                                                     \
[78]141    std::string separator="_";                                          \
142    for (uint32_t alloc_interface_it1=0; alloc_interface_it1<iterator_1; alloc_interface_it1++) \
[73]143      {                                                                 \
[78]144        interface [alloc_interface_it1] = _interfaces->set_interface( name+separator+toString(alloc_interface_it1)); \
[73]145      }                                                                 \
146  }
147#endif
148
[78]149#define ALLOC1_VAL_ACK_IN( sig, name, type)                             \
[73]150  {                                                                     \
[76]151    sig = new SC_IN (Tcontrol_t) * [iterator_1];                        \
[78]152    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
[73]153      {                                                                 \
[78]154        sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_valack_in (name, type); \
[73]155      }                                                                 \
156  }
[78]157#define ALLOC1_VAL_ACK_OUT(sig, name, type)                             \
[73]158  {                                                                     \
[76]159    sig = new SC_OUT(Tcontrol_t) * [iterator_1];                        \
[78]160    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
[73]161      {                                                                 \
[78]162        sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_valack_out(name, type); \
[73]163      }                                                                 \
164  }
[78]165#define ALLOC1_VALACK_IN(    sig, type)                                 \
[73]166  {                                                                     \
[76]167    sig = new SC_IN (Tcontrol_t) * [iterator_1];                        \
[78]168    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
[73]169      {                                                                 \
[78]170        sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_valack_in (type); \
[73]171      }                                                                 \
172  }
[78]173#define ALLOC1_VALACK_OUT(   sig, type)                                 \
[73]174  {                                                                     \
[76]175    sig = new SC_OUT(Tcontrol_t) * [iterator_1];                        \
[78]176    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
[73]177      {                                                                 \
[78]178        sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_valack_out(type); \
[73]179      }                                                                 \
180  }
[76]181#define ALLOC1_SIGNAL_IN( sig, name, type, size)                        \
[81]182  {                                                                     \
183    sig = new SC_IN (type) * [iterator_1];                              \
184    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
185      {                                                                 \
186        if (size > 0)                                                   \
187          {                                                             \
188            sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_in <type> (name, size); \
189          }                                                             \
[82]190        else                                                            \
191          {                                                             \
192            log_printf(INFO,true,FUNCTION,_("%s %s.%s.%s : size is nul."),MSG_INFORMATION,_component->get_name().c_str(),interface[alloc_signal_it1]->get_name().c_str(),name); \
193          }                                                             \
[81]194      }                                                                 \
195  }
[73]196
[76]197#define ALLOC1_SIGNAL_OUT(sig, name, type, size)                        \
[81]198  {                                                                     \
199    sig = new SC_OUT(type) * [iterator_1];                              \
200    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
201      {                                                                 \
202        if (size > 0)                                                   \
203          {                                                             \
204            sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_out<type> (name, size); \
205          }                                                             \
[82]206        else                                                            \
207          {                                                             \
208            log_printf(INFO,true,FUNCTION,_("%s %s.%s.%s : size is nul."),MSG_INFORMATION,_component->get_name().c_str(),interface[alloc_signal_it1]->get_name().c_str(),name); \
209          }                                                             \
[81]210      }                                                                 \
211  }
[73]212
[81]213#define DELETE1_SIGNAL(sig, it1, size)                                  \
214  {                                                                     \
215    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
216      {                                                                 \
217        if (size > 0)                                                   \
218          {                                                             \
219            delete sig[alloc_signal_it1];                               \
220          }                                                             \
221      }                                                                 \
222    delete [] sig;                                                      \
223  }
224
[73]225#define ALLOC1_SC_SIGNAL( sig, name, type, it1)                         \
226  sc_signal<type> ** sig = new sc_signal<type> * [it1];                 \
227  {                                                                     \
228    std::string separator="_";                                          \
229    std::string str;                                                    \
[78]230    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
[73]231      {                                                                 \
[78]232        str = name+separator+toString(alloc_signal_it1);                \
233        sig [alloc_signal_it1] = new sc_signal<type> (str.c_str());     \
[73]234      }                                                                 \
235  }
236
[78]237#define INSTANCE1_SC_SIGNAL(component, sig, it1)                        \
238  for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
239    {                                                                   \
[82]240      TEST_PTR(component->sig [alloc_signal_it1]);                      \
241      TEST_PTR(sig            [alloc_signal_it1]);                      \
[78]242      (*(component->sig[alloc_signal_it1])) (*(sig[alloc_signal_it1])); \
[73]243    }
244
[81]245#define DELETE1_SC_SIGNAL(sig, it1)                                     \
246  {                                                                     \
247    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
248      {                                                                 \
249        delete sig[alloc_signal_it1];                                   \
250      }                                                                 \
251    delete [] sig;                                                      \
252  }
253
[78]254// ----------------------------------------------------------------------
255// -----[ ITERATION 2 ]--------------------------------------------------
256// ----------------------------------------------------------------------
257
258#ifdef POSITION
259#define ALLOC2_INTERFACE( name, direction, localisation, str, it1, it2) \
[81]260  INTERFACE_PRINT(name);                                                \
[78]261  uint32_t iterator_1 = 0;                                              \
262  uint32_t iterator_2 = 0;                                              \
263  Interface_fifo *** interface;                                         \
264  {                                                                     \
265    std::string separator="_";                                          \
266    iterator_1 = it1;                                                   \
267    interface = new Interface_fifo ** [iterator_1];                     \
268    for (uint32_t alloc_interface_it1=0; alloc_interface_it1<iterator_1; alloc_interface_it1++) \
269      {                                                                 \
270        iterator_2 = it2;                                               \
271        interface [alloc_interface_it1] = new Interface_fifo * [iterator_2]; \
272        for (uint32_t alloc_interface_it2=0; alloc_interface_it2<iterator_2; alloc_interface_it2++) \
273          {                                                             \
274            interface [alloc_interface_it1][alloc_interface_it2] = _interfaces->set_interface( name+separator+toString(alloc_interface_it1)+separator+toString(alloc_interface_it2), direction, localisation, str); \
275          }                                                             \
276      }                                                                 \
277  }
278#else
279#define ALLOC2_INTERFACE( name, direction, localisation, str, it1, it2) \
[81]280  INTERFACE_PRINT(name);                                                \
[78]281  uint32_t iterator_1 = 0;                                              \
282  uint32_t iterator_2 = 0;                                              \
283  Interface_fifo *** interface;                                         \
284  {                                                                     \
285    std::string separator="_";                                          \
286    iterator_1 = it1;                                                   \
287    interface = new Interface_fifo ** [iterator_1];                     \
288    for (uint32_t alloc_interface_it1=0; alloc_interface_it1<iterator_1; alloc_interface_it1++) \
289      {                                                                 \
290        iterator_2 = it2;                                               \
291        interface [alloc_interface_it1] = new Interface_fifo * [iterator_2]; \
292        for (uint32_t alloc_interface_it2=0; alloc_interface_it2<iterator_2; alloc_interface_it2++) \
293          {                                                             \
294            interface [alloc_interface_it1][alloc_interface_it2] = _interfaces->set_interface( name+separator+toString(alloc_interface_it1)+separator+toString(alloc_interface_it2)); \
295          }                                                             \
296      }                                                                 \
297  }
[73]298#endif
[78]299
300#define _ALLOC2_VAL_ACK_IN( sig, name, type, it1, it2)                  \
301  {                                                                     \
302    sig = new SC_IN (Tcontrol_t) ** [it1];                              \
303    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
304      {                                                                 \
305        sig [alloc_signal_it1] = new SC_IN (Tcontrol_t) * [it2];        \
306        for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
307          {                                                             \
308            sig [alloc_signal_it1][alloc_signal_it2] = interface[alloc_signal_it1][alloc_signal_it2]->set_signal_valack_in (name, type); \
309          }                                                             \
310      }                                                                 \
311  }
312
313#define _ALLOC2_VAL_ACK_OUT( sig, name, type, it1, it2)                 \
314  {                                                                     \
315    sig = new SC_OUT (Tcontrol_t) ** [it1];                             \
316    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
317      {                                                                 \
318        sig [alloc_signal_it1] = new SC_OUT (Tcontrol_t) * [it2];       \
319        for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
320          {                                                             \
321            sig [alloc_signal_it1][alloc_signal_it2] = interface[alloc_signal_it1][alloc_signal_it2]->set_signal_valack_out (name, type); \
322          }                                                             \
323      }                                                                 \
324  }
325
326#define _ALLOC2_VALACK_IN(    sig,type, it1, it2)                       \
327  {                                                                     \
328    sig = new SC_IN (Tcontrol_t) ** [it1];                              \
329    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
330      {                                                                 \
331        sig [alloc_signal_it1] = new SC_IN (Tcontrol_t) * [it2];        \
332        for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
333          {                                                             \
334            sig [alloc_signal_it1][alloc_signal_it2] = interface[alloc_signal_it1][alloc_signal_it2]->set_signal_valack_in (type); \
335          }                                                             \
336      }                                                                 \
337  }
338
339#define _ALLOC2_VALACK_OUT(    sig,type, it1, it2)                      \
340  {                                                                     \
341    sig = new SC_OUT (Tcontrol_t) ** [it1];                             \
342    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
343      {                                                                 \
344        sig [alloc_signal_it1] = new SC_OUT (Tcontrol_t) * [it2];       \
345        for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
346          {                                                             \
347            sig [alloc_signal_it1][alloc_signal_it2] = interface[alloc_signal_it1][alloc_signal_it2]->set_signal_valack_out (type); \
348          }                                                             \
349      }                                                                 \
350  }
351
352#define _ALLOC2_SIGNAL_IN( sig, name, type, size, it1, it2)             \
[81]353  {                                                                     \
354    sig = new SC_IN (type) ** [it1];                                    \
355    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
356      {                                                                 \
357        sig [alloc_signal_it1] = new SC_IN (type) * [it2];              \
358        for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
359          {                                                             \
360            if (size > 0)                                               \
361              {                                                         \
362                sig [alloc_signal_it1][alloc_signal_it2] = interface[alloc_signal_it1][alloc_signal_it2]->set_signal_in <type> (name, size); \
363              }                                                         \
[82]364            else                                                        \
365              {                                                         \
366                log_printf(INFO,true,FUNCTION,_("%s %s.%s.%s : size is nul."),MSG_INFORMATION,_component->get_name().c_str(),interface[alloc_signal_it1][alloc_signal_it2]->get_name().c_str(),name); \
367              }                                                         \
[81]368          }                                                             \
369      }                                                                 \
370  }
[78]371
372#define _ALLOC2_SIGNAL_OUT( sig, name, type, size, it1, it2)            \
[81]373  {                                                                     \
374    sig = new SC_OUT (type) ** [it1];                                   \
375    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
376      {                                                                 \
377        sig [alloc_signal_it1] = new SC_OUT (type) * [it2];             \
378        for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
379          {                                                             \
380            if (size > 0)                                               \
381              {                                                         \
382                sig [alloc_signal_it1][alloc_signal_it2] = interface[alloc_signal_it1][alloc_signal_it2]->set_signal_out <type> (name, size); \
383              }                                                         \
[82]384            else                                                        \
385              {                                                         \
386                log_printf(INFO,true,FUNCTION,_("%s %s.%s.%s : size is nul."),MSG_INFORMATION,_component->get_name().c_str(),interface[alloc_signal_it1][alloc_signal_it2]->get_name().c_str(),name); \
387              }                                                         \
[81]388          }                                                             \
389      }                                                                 \
390  }
[78]391
392#define ALLOC2_VAL_ACK_IN( sig, name, type      ) _ALLOC2_VAL_ACK_IN( sig, name, type      , iterator_1, iterator_2)
393#define ALLOC2_VAL_ACK_OUT(sig, name, type      ) _ALLOC2_VAL_ACK_OUT(sig, name, type      , iterator_1, iterator_2)
394#define ALLOC2_VALACK_IN(  sig,       type      ) _ALLOC2_VALACK_IN(  sig,       type      , iterator_1, iterator_2)
395#define ALLOC2_VALACK_OUT( sig,       type      ) _ALLOC2_VALACK_OUT( sig,       type      , iterator_1, iterator_2)
396#define ALLOC2_SIGNAL_IN(  sig, name, type, size) _ALLOC2_SIGNAL_IN(  sig, name, type, size, iterator_1, iterator_2)
397#define ALLOC2_SIGNAL_OUT( sig, name, type, size) _ALLOC2_SIGNAL_OUT( sig, name, type, size, iterator_1, iterator_2)
398
[81]399#define DELETE2_SIGNAL(sig, it1,it2, size)                              \
400  {                                                                     \
401    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
402      {                                                                 \
403        for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
404          {                                                             \
405            if (size > 0)                                               \
406              {                                                         \
407                delete sig[alloc_signal_it1][alloc_signal_it2];         \
408              }                                                         \
409          }                                                             \
410        delete [] sig[alloc_signal_it1];                                \
411      }                                                                 \
412    delete [] sig;                                                      \
413  }
414
[78]415#define ALLOC2_SC_SIGNAL( sig, name, type, it1, it2)                    \
416  sc_signal<type> *** sig = new sc_signal<type> ** [it1];               \
417  {                                                                     \
418    std::string separator="_";                                          \
419    std::string str;                                                    \
420    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
421      {                                                                 \
422        sig [alloc_signal_it1] = new sc_signal<type> * [it2];           \
423        for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
424          {                                                             \
425            str = name+separator+toString(alloc_signal_it1)+separator+toString(alloc_signal_it2); \
426            sig [alloc_signal_it1][alloc_signal_it2] = new sc_signal<type> (str.c_str()); \
427          }                                                             \
428      }                                                                 \
429  }
430
431#define INSTANCE2_SC_SIGNAL(component, sig, it1, it2)                   \
432  for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
433    for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
434      {                                                                 \
[82]435        TEST_PTR(component->sig [alloc_signal_it1][alloc_signal_it2]);  \
436        TEST_PTR(sig            [alloc_signal_it1][alloc_signal_it2]);  \
[78]437        (*(component->sig[alloc_signal_it1][alloc_signal_it2])) (*(sig[alloc_signal_it1][alloc_signal_it2])); \
438      }
[81]439
440#define DELETE2_SC_SIGNAL(sig,it1,it2)                                  \
441  {                                                                     \
442    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
443      {                                                                 \
444        for (uint32_t alloc_signal_it2=0; alloc_signal_it2<it2; alloc_signal_it2++) \
445          {                                                             \
446            delete sig[alloc_signal_it1][alloc_signal_it2];             \
447          }                                                             \
448        delete [] sig[alloc_signal_it1];                                \
449      }                                                                 \
450    delete [] sig;                                                      \
451  }
452
[78]453#endif
Note: See TracBrowser for help on using the repository browser.