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

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