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