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

Last change on this file since 146 was 139, checked in by rosiere, 14 years ago
  • Add test for all configuration
  • RAT : add rat scheme (depth_save)
  • Property svn:keywords set to Id
File size: 5.6 KB
RevLine 
[42]1#ifndef morpheo_behavioural_Component_h
2#define morpheo_behavioural_Component_h
[31]3
4/*
5 * $Id: Component.h 139 2010-07-30 14:47:27Z rosiere $
6 *
[82]7 * [ Description ]
[31]8 *
9 */
10
11#include <stdint.h>
12#include <iostream>
13#include <list>
[42]14#include <map>
15#ifdef VHDL
16#include "Behavioural/include/Vhdl.h"
17#endif
18//#include "Behavioural/include/Description.h"
[31]19#include "Behavioural/include/Entity.h"
[44]20#include "Common/include/ToString.h"
21#include "Common/include/Debug.h"
[57]22#include "Behavioural/include/Usage.h"
[31]23
24namespace morpheo              {
25namespace behavioural          {
26
[115]27  /*
[78]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
[115]43*/
[131]44
[78]45# define PORT_MAP(x,a,b,c,d)                                            \
46  do                                                                    \
47    {                                                                   \
48      x->port_map(a,b,c,d);                                             \
49    }                                                                   \
50  while (0)
[115]51// #endif
[78]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
[57]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
[82]70  class Component
[57]71  {
[82]72    typedef struct
73    {
74    public : Component * _component;
75    public : Entity    * _entity   ;
76    public : Tinstance_t _instance ;
[113]77    public : std::string _architecture;
[82]78    } Tcomponent_t;   
[57]79 
[82]80    // -----[ fields ]----------------------------------------------------
[78]81  private   : const Tusage_t             _usage;
82  private   : Entity                   * _entity        ;
[75]83  private   : std::list<Tcomponent_t*> * _list_component;
[57]84
[82]85    // -----[ methods ]---------------------------------------------------
86  public    :                       Component         (Tusage_t usage);
[42]87  public    :                       Component         (const Component & component);
88  public    :                       ~Component        ();
[31]89
[82]90  public    : std::string           get_name          (void);
91
[71]92  public    : Entity *              set_entity        (std::string        name   
93                                                       ,std::string        type 
[42]94#ifdef POSITION
95                                                       ,schema_t      schema
96#endif
97                                                       );
[78]98  private   : std::string           get_entity        (void);
[31]99
[42]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
[57]107                                                       ,Tinstance_t instance=INSTANCE_ALL
[113]108                                                       ,std::string architecture=""
[42]109                                                       );
[31]110
[78]111  private   : std::string           get_component     (void);
[31]112
[71]113  private   : Entity *              find_entity       (std::string name);
114//private   : Interface *           find_interface    (std::string   name  ,
[62]115//                                                     Entity * entity);
[31]116
[42]117#ifdef VHDL
118  public    : void                  vhdl_instance     (Vhdl * & vhdl);
119#endif
120
[62]121
122  private   : Signal *              signal_internal   (Entity * entity_productor,
[113]123                                                       Signal * signal_productor,
124                                                       Entity * entity_consumer,
125                                                       Signal * signal_consumer);
[62]126
[71]127  public    : void                  port_map          (std::string component_src ,
128                                                       std::string port_src      ,
129                                                       std::string component_dest,
130                                                       std::string port_dest    );
[42]131
[78]132  public    : bool                  test_map          (bool recursive=true);
[139]133//private   : bool                  test_map          (bool recursive);
[62]134
[113]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
[82]141//   public    : bool                  test_equi         (bool recursive=true);
142//   private   : bool                  test_equi         (uint32_t depth, bool recursive);
143
[42]144#ifdef POSITION
[71]145  public    : void                  interface_map     (std::string component_src ,
146                                                       std::string port_dest,
147                                                       std::string component_dest,
148                                                       std::string port_dest     );
[42]149
150  public    : XML                   toXML             (void);
151
[31]152  public    : void                  generate_file     (void);
[42]153#endif   
[78]154  public    : friend std::ostream&  operator<<        (std::ostream& output_stream,
155                                                       morpheo::behavioural::Component & x);
[113]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    };
[31]183  };
184
185}; // end namespace behavioural         
186}; // end namespace morpheo             
187
188#endif
Note: See TracBrowser for help on using the repository browser.