1 | #ifndef morpheo_behavioural_Component_h |
---|
2 | #define morpheo_behavioural_Component_h |
---|
3 | |
---|
4 | /* |
---|
5 | * $Id: Component.h 82 2008-05-01 16:48:45Z 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 | |
---|
24 | namespace morpheo { |
---|
25 | namespace 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 | } Tcomponent_t; |
---|
75 | |
---|
76 | // -----[ fields ]---------------------------------------------------- |
---|
77 | private : const Tusage_t _usage; |
---|
78 | private : Entity * _entity ; |
---|
79 | private : std::list<Tcomponent_t*> * _list_component; |
---|
80 | |
---|
81 | // -----[ methods ]--------------------------------------------------- |
---|
82 | public : Component (Tusage_t usage); |
---|
83 | public : Component (const Component & component); |
---|
84 | public : ~Component (); |
---|
85 | |
---|
86 | public : std::string get_name (void); |
---|
87 | |
---|
88 | public : Entity * set_entity (std::string name |
---|
89 | ,std::string type |
---|
90 | #ifdef POSITION |
---|
91 | ,schema_t schema |
---|
92 | #endif |
---|
93 | ); |
---|
94 | private : std::string get_entity (void); |
---|
95 | |
---|
96 | public : void set_component (Component * component |
---|
97 | #ifdef POSITION |
---|
98 | ,uint32_t pos_x |
---|
99 | ,uint32_t pos_y |
---|
100 | ,uint32_t size_x |
---|
101 | ,uint32_t size_y |
---|
102 | #endif |
---|
103 | ,Tinstance_t instance=INSTANCE_ALL |
---|
104 | ); |
---|
105 | |
---|
106 | private : std::string get_component (void); |
---|
107 | |
---|
108 | private : Entity * find_entity (std::string name); |
---|
109 | //private : Interface * find_interface (std::string name , |
---|
110 | // Entity * entity); |
---|
111 | |
---|
112 | #ifdef VHDL |
---|
113 | public : void vhdl_instance (Vhdl * & vhdl); |
---|
114 | #endif |
---|
115 | |
---|
116 | |
---|
117 | private : Signal * signal_internal (Entity * entity_productor, |
---|
118 | Signal * signal_productor); |
---|
119 | |
---|
120 | public : void port_map (std::string component_src , |
---|
121 | std::string port_src , |
---|
122 | std::string component_dest, |
---|
123 | std::string port_dest ); |
---|
124 | |
---|
125 | public : bool test_map (bool recursive=true); |
---|
126 | private : bool test_map (uint32_t depth, bool recursive); |
---|
127 | |
---|
128 | // public : bool test_equi (bool recursive=true); |
---|
129 | // private : bool test_equi (uint32_t depth, bool recursive); |
---|
130 | |
---|
131 | #ifdef POSITION |
---|
132 | public : void interface_map (std::string component_src , |
---|
133 | std::string port_dest, |
---|
134 | std::string component_dest, |
---|
135 | std::string port_dest ); |
---|
136 | |
---|
137 | public : XML toXML (void); |
---|
138 | |
---|
139 | public : void generate_file (void); |
---|
140 | #endif |
---|
141 | public : friend std::ostream& operator<< (std::ostream& output_stream, |
---|
142 | morpheo::behavioural::Component & x); |
---|
143 | }; |
---|
144 | |
---|
145 | }; // end namespace behavioural |
---|
146 | }; // end namespace morpheo |
---|
147 | |
---|
148 | #endif |
---|