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

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

1) Add modelsim simulation systemC
2) Modelsim cosimulation systemC / VHDL is not finish !!!! (cf execute_queue and write_unit)
3) Add multi architecture
5) Add template for comparator, multiplier and divider
6) Change Message
Warning) Various test macro have change, many selftest can't compile

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