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