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
Line 
1#ifndef morpheo_behavioural_Allocation_h
2#define morpheo_behavioural_Allocation_h
3
4/*
5 * $Id: Allocation.h 82 2008-05-01 16:48:45Z rosiere $
6 *
7 * [ Description ]
8 *
9 */
10
11#include "Common/include/Debug.h"
12
13// Help to allocate interface
14#define INTERFACE_PRINT(name) log_printf(TRACE,true,"allocation","Interface's creation : %s (%s, %d)",name,__FILE__,__LINE__);
15
16// ----------------------------------------------------------------------
17// -----[ NO ITERATION ]-------------------------------------------------
18// ----------------------------------------------------------------------
19
20#define __ALLOC_SIGNAL(sig, name, type)         \
21  {                                             \
22    sig = new type (name);                      \
23  }
24
25#ifdef POSITION
26#define ALLOC_INTERFACE( name, direction, localisation, str)            \
27  INTERFACE_PRINT(name);                                                \
28  Interface_fifo * interface = _interfaces->set_interface( name, direction, localisation, str);
29#else
30#define ALLOC_INTERFACE( name, direction, localisation, str)            \
31  INTERFACE_PRINT(name);                                                \
32  Interface_fifo * interface = _interfaces->set_interface( name);
33#endif
34
35#define ALLOC_VAL_ACK_IN(  sig, name, type)                             \
36  {                                                                     \
37    sig = interface->set_signal_valack_in (name, type);                 \
38  }                                                                     
39#define ALLOC_VAL_ACK_OUT( sig, name, type)                             \
40  {                                                                     \
41    sig = interface->set_signal_valack_out(name, type);                 \
42  }                                                                     
43#define ALLOC_VALACK_IN(     sig, type)                                 \
44  {                                                                     \
45    sig = interface->set_signal_valack_in (type);                       \
46  }                                                                     
47#define ALLOC_VALACK_OUT(    sig, type)                                 \
48  {                                                                     \
49    sig = interface->set_signal_valack_out(type);                       \
50  }                                                                     
51#define ALLOC_SIGNAL_IN(  sig, name, type, size)                        \
52  if (size > 0)                                                         \
53    {                                                                   \
54      sig = interface->set_signal_in <type> (name, size);               \
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 
61#define ALLOC_SIGNAL_OUT( sig, name, type, size)                        \
62  if (size > 0)                                                         \
63    {                                                                   \
64      sig = interface->set_signal_out<type> (name, size);               \
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); \
69    }
70
71#define DELETE_SIGNAL( sig, size)                                       \
72  if (size > 0)                                                         \
73    {                                                                   \
74      delete sig;                                                       \
75    }
76
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)      \
81  {                                             \
82    TEST_PTR(component->sig);                   \
83    TEST_PTR(sig);                              \
84    (*(component->sig)) (*(sig));               \
85  }
86
87#define DELETE_SC_SIGNAL( sig)                  \
88  {                                             \
89    delete sig;                                 \
90  }
91
92// ----------------------------------------------------------------------
93// -----[ ITERATION 1 ]--------------------------------------------------
94// ----------------------------------------------------------------------
95
96#define __ALLOC1_INTERFACE(name, it1)                                   \
97  INTERFACE_PRINT(name);                                                \
98  const std::string interface_name = name;                              \
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
123#ifdef POSITION
124#define ALLOC1_INTERFACE( name, direction, localisation, str, it1)      \
125  INTERFACE_PRINT(name);                                                \
126  const uint32_t iterator_1 = it1;                                      \
127  Interface_fifo * interface [iterator_1];                              \
128  {                                                                     \
129    std::string separator="_";                                          \
130    for (uint32_t alloc_interface_it1=0; alloc_interface_it1<iterator_1; alloc_interface_it1++) \
131      {                                                                 \
132        interface [alloc_interface_it1] = _interfaces->set_interface( name+separator+toString(alloc_interface_it1), direction, localisation, str); \
133      }                                                                 \
134  }
135#else
136#define ALLOC1_INTERFACE( name, direction, localisation, str, it1)      \
137  INTERFACE_PRINT(name);                                                \
138  const uint32_t iterator_1 = it1;                                      \
139  Interface_fifo * interface [iterator_1];                              \
140  {                                                                     \
141    std::string separator="_";                                          \
142    for (uint32_t alloc_interface_it1=0; alloc_interface_it1<iterator_1; alloc_interface_it1++) \
143      {                                                                 \
144        interface [alloc_interface_it1] = _interfaces->set_interface( name+separator+toString(alloc_interface_it1)); \
145      }                                                                 \
146  }
147#endif
148
149#define ALLOC1_VAL_ACK_IN( sig, name, type)                             \
150  {                                                                     \
151    sig = new SC_IN (Tcontrol_t) * [iterator_1];                        \
152    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
153      {                                                                 \
154        sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_valack_in (name, type); \
155      }                                                                 \
156  }
157#define ALLOC1_VAL_ACK_OUT(sig, name, type)                             \
158  {                                                                     \
159    sig = new SC_OUT(Tcontrol_t) * [iterator_1];                        \
160    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
161      {                                                                 \
162        sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_valack_out(name, type); \
163      }                                                                 \
164  }
165#define ALLOC1_VALACK_IN(    sig, type)                                 \
166  {                                                                     \
167    sig = new SC_IN (Tcontrol_t) * [iterator_1];                        \
168    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
169      {                                                                 \
170        sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_valack_in (type); \
171      }                                                                 \
172  }
173#define ALLOC1_VALACK_OUT(   sig, type)                                 \
174  {                                                                     \
175    sig = new SC_OUT(Tcontrol_t) * [iterator_1];                        \
176    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<iterator_1; alloc_signal_it1++) \
177      {                                                                 \
178        sig [alloc_signal_it1] = interface[alloc_signal_it1]->set_signal_valack_out(type); \
179      }                                                                 \
180  }
181#define ALLOC1_SIGNAL_IN( sig, name, type, size)                        \
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          }                                                             \
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          }                                                             \
194      }                                                                 \
195  }
196
197#define ALLOC1_SIGNAL_OUT(sig, name, type, size)                        \
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          }                                                             \
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          }                                                             \
210      }                                                                 \
211  }
212
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
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;                                                    \
230    for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
231      {                                                                 \
232        str = name+separator+toString(alloc_signal_it1);                \
233        sig [alloc_signal_it1] = new sc_signal<type> (str.c_str());     \
234      }                                                                 \
235  }
236
237#define INSTANCE1_SC_SIGNAL(component, sig, it1)                        \
238  for (uint32_t alloc_signal_it1=0; alloc_signal_it1<it1; alloc_signal_it1++) \
239    {                                                                   \
240      TEST_PTR(component->sig [alloc_signal_it1]);                      \
241      TEST_PTR(sig            [alloc_signal_it1]);                      \
242      (*(component->sig[alloc_signal_it1])) (*(sig[alloc_signal_it1])); \
243    }
244
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
254// ----------------------------------------------------------------------
255// -----[ ITERATION 2 ]--------------------------------------------------
256// ----------------------------------------------------------------------
257
258#ifdef POSITION
259#define ALLOC2_INTERFACE( name, direction, localisation, str, it1, it2) \
260  INTERFACE_PRINT(name);                                                \
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) \
280  INTERFACE_PRINT(name);                                                \
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  }
298#endif
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)             \
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              }                                                         \
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              }                                                         \
368          }                                                             \
369      }                                                                 \
370  }
371
372#define _ALLOC2_SIGNAL_OUT( sig, name, type, size, it1, it2)            \
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              }                                                         \
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              }                                                         \
388          }                                                             \
389      }                                                                 \
390  }
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
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
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      {                                                                 \
435        TEST_PTR(component->sig [alloc_signal_it1][alloc_signal_it2]);  \
436        TEST_PTR(sig            [alloc_signal_it1][alloc_signal_it2]);  \
437        (*(component->sig[alloc_signal_it1][alloc_signal_it2])) (*(sig[alloc_signal_it1][alloc_signal_it2])); \
438      }
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
453#endif
Note: See TracBrowser for help on using the repository browser.