source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Component.h @ 131

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

1) add constant method
2) test with systemc 2.2.0

  • Property svn:keywords set to Id
File size: 5.7 KB
Line 
1#ifndef morpheo_behavioural_Component_h
2#define morpheo_behavioural_Component_h
3
4/*
5 * $Id: Component.h 131 2009-07-08 18:40:08Z rosiere $
6 *
7 * [ Description ]
8 *
9 */
10
11#include <stdint.h>
12#include <iostream>
13#include <list>
14#include <map>
15#ifdef VHDL
16#include "Behavioural/include/Vhdl.h"
17#endif
18//#include "Behavioural/include/Description.h"
19#include "Behavioural/include/Entity.h"
20#include "Common/include/ToString.h"
21#include "Common/include/Debug.h"
22#include "Behavioural/include/Usage.h"
23
24namespace morpheo              {
25namespace behavioural          {
26
27  /*
28#ifdef DEBUG
29# define PORT_MAP(x,a,b,c,d)                                            \
30  do                                                                    \
31    {                                                                   \
32      try                                                               \
33        {                                                               \
34          x->port_map(a,b,c,d);                                         \
35        }                                                               \
36      catch (morpheo::ErrorMorpheo & error)                             \
37        {                                                               \
38          throw (ErrorMorpheo ("In file "+toString(__FILE__)+", at line "+toString(__LINE__)+"\n"+error.what ())); \
39        }                                                               \
40    }                                                                   \
41  while (0)
42#else
43*/
44
45# define PORT_MAP(x,a,b,c,d)                                            \
46  do                                                                    \
47    {                                                                   \
48      x->port_map(a,b,c,d);                                             \
49    }                                                                   \
50  while (0)
51// #endif
52
53#define COMPONENT_MAP(x,a,b,c,d)                                        \
54  do                                                                    \
55    {                                                                   \
56      PORT_MAP(x,a,b,c,d);                                              \
57      PORT_MAP(x,c,d,a,b);                                              \
58    }                                                                   \
59  while (0)
60 
61
62  typedef uint8_t Tinstance_t;
63
64#define INSTANCE_NONE         0x0
65#define INSTANCE_LIBRARY      0x1
66#define INSTANCE_COMPONENT    0x2
67#define INSTANCE_POSITION     0x4
68#define INSTANCE_ALL          0x7
69
70  class Component
71  {
72    typedef struct
73    {
74    public : Component * _component;
75    public : Entity    * _entity   ;
76    public : Tinstance_t _instance ;
77    public : std::string _architecture;
78    } Tcomponent_t;   
79 
80    // -----[ fields ]----------------------------------------------------
81  private   : const Tusage_t             _usage;
82  private   : Entity                   * _entity        ;
83  private   : std::list<Tcomponent_t*> * _list_component;
84
85    // -----[ methods ]---------------------------------------------------
86  public    :                       Component         (Tusage_t usage);
87  public    :                       Component         (const Component & component);
88  public    :                       ~Component        ();
89
90  public    : std::string           get_name          (void);
91
92  public    : Entity *              set_entity        (std::string        name   
93                                                       ,std::string        type 
94#ifdef POSITION
95                                                       ,schema_t      schema
96#endif
97                                                       );
98  private   : std::string           get_entity        (void);
99
100  public    : void                  set_component     (Component * component
101#ifdef POSITION
102                                                       ,uint32_t   pos_x 
103                                                       ,uint32_t   pos_y 
104                                                       ,uint32_t   size_x
105                                                       ,uint32_t   size_y
106#endif
107                                                       ,Tinstance_t instance=INSTANCE_ALL
108                                                       ,std::string architecture=""
109                                                       );
110
111  private   : std::string           get_component     (void);
112
113  private   : Entity *              find_entity       (std::string name);
114//private   : Interface *           find_interface    (std::string   name  ,
115//                                                     Entity * entity);
116
117#ifdef VHDL
118  public    : void                  vhdl_instance     (Vhdl * & vhdl);
119#endif
120
121
122  private   : Signal *              signal_internal   (Entity * entity_productor,
123                                                       Signal * signal_productor,
124                                                       Entity * entity_consumer,
125                                                       Signal * signal_consumer);
126
127  public    : void                  port_map          (std::string component_src ,
128                                                       std::string port_src      ,
129                                                       std::string component_dest,
130                                                       std::string port_dest    );
131
132  public    : bool                  test_map          (bool recursive=true);
133  private   : bool                  test_map          (uint32_t depth, bool recursive);
134
135  public    : void *                get_sc_signal     (std::string component,
136                                                       std::string port     );
137//   public    : void                  set_sc_signal     (std::string component,
138//                                                     std::string port     ,
139//                                                        void *      sc_signal);
140
141//   public    : bool                  test_equi         (bool recursive=true);
142//   private   : bool                  test_equi         (uint32_t depth, bool recursive);
143
144#ifdef POSITION
145  public    : void                  interface_map     (std::string component_src ,
146                                                       std::string port_dest,
147                                                       std::string component_dest,
148                                                       std::string port_dest     );
149
150  public    : XML                   toXML             (void);
151
152  public    : void                  generate_file     (void);
153#endif   
154  public    : friend std::ostream&  operator<<        (std::ostream& output_stream,
155                                                       morpheo::behavioural::Component & x);
156
157
158#undef  FUNCTION
159#define FUNCTION "Component::set_sc_signal"
160  public    : template <typename T>
161  void set_sc_signal (std::string component,
162                      std::string port     ,
163                      void *      sc_signal)
164    {
165      log_begin(Behavioural,FUNCTION);
166     
167      std::string name_entity = _entity->get_name();
168     
169      Entity * entity = find_entity(component);
170     
171      if (entity == NULL)
172        throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\", the component \""+component+"\" is unknow.\n"));
173     
174      Signal * signal = entity->find_signal (port);
175     
176      if (signal == NULL)
177        throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\", the component \""+component+"\" have not the signal \""+port+"\".\n"));
178     
179      signal->alloc<T>(sc_signal);
180     
181      log_end(Behavioural,FUNCTION);
182    };
183  };
184
185}; // end namespace behavioural         
186}; // end namespace morpheo             
187
188#endif
Note: See TracBrowser for help on using the repository browser.