[29] | 1 | #ifndef morpheo_behavioural_Interface_h |
---|
| 2 | #define morpheo_behavioural_Interface_h |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | * $Id: Interface.h 113 2009-04-14 18:39:12Z rosiere $ |
---|
| 6 | * |
---|
| 7 | * [ Description ] |
---|
| 8 | * |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | #ifdef SYSTEMC |
---|
| 12 | #include "systemc.h" |
---|
| 13 | #endif |
---|
| 14 | |
---|
| 15 | #include <stdint.h> |
---|
| 16 | #include <iostream> |
---|
| 17 | #include <list> |
---|
| 18 | #include "Behavioural/include/Signal.h" |
---|
| 19 | #include "Behavioural/include/Direction.h" |
---|
| 20 | #include "Behavioural/include/Localisation.h" |
---|
| 21 | #ifdef VHDL |
---|
| 22 | #include "Behavioural/include/Vhdl.h" |
---|
| 23 | #endif |
---|
[62] | 24 | #include "Common/include/ChangeCase.h" |
---|
[44] | 25 | #include "Common/include/ToString.h" |
---|
| 26 | #include "Common/include/ErrorMorpheo.h" |
---|
| 27 | #include "Common/include/Debug.h" |
---|
[57] | 28 | #include "Behavioural/include/Usage.h" |
---|
[29] | 29 | |
---|
| 30 | namespace morpheo { |
---|
| 31 | namespace behavioural { |
---|
| 32 | |
---|
| 33 | class Interface |
---|
| 34 | { |
---|
| 35 | // -----[ fields ]---------------------------------------------------- |
---|
[88] | 36 | protected : const std::string _name ; |
---|
[42] | 37 | #ifdef POSITION |
---|
[40] | 38 | protected : const direction_t _direction ; |
---|
| 39 | protected : const localisation_t _localisation ; |
---|
[57] | 40 | #endif |
---|
| 41 | protected : const Tusage_t _usage; |
---|
| 42 | |
---|
| 43 | #ifdef POSITION |
---|
[88] | 44 | protected : std::string _comment ; |
---|
[42] | 45 | #endif |
---|
[29] | 46 | |
---|
[88] | 47 | protected : std::list<Signal *> * _list_signal ; |
---|
[38] | 48 | |
---|
[31] | 49 | #ifdef POSITION |
---|
[40] | 50 | protected : bool _is_map ; |
---|
| 51 | protected : void * _entity_map ; // Entity -> erreur cyclique |
---|
| 52 | protected : void * _interface_map; // pour être homogène avec _entity_map |
---|
[31] | 53 | #endif |
---|
| 54 | |
---|
[40] | 55 | #ifdef VHDL_TESTBENCH |
---|
[41] | 56 | private : uint32_t _nb_cycle ; |
---|
[40] | 57 | #endif |
---|
| 58 | |
---|
[29] | 59 | // -----[ methods ]--------------------------------------------------- |
---|
[71] | 60 | public : Interface (std::string name |
---|
[42] | 61 | #ifdef POSITION |
---|
| 62 | ,direction_t direction |
---|
| 63 | ,localisation_t localisation |
---|
| 64 | #endif |
---|
[82] | 65 | ,Tusage_t usage |
---|
[42] | 66 | ); |
---|
[29] | 67 | |
---|
[31] | 68 | public : Interface (const Interface & interface); |
---|
[29] | 69 | public : ~Interface (); |
---|
| 70 | |
---|
[88] | 71 | public : std::string get_name (); |
---|
[42] | 72 | |
---|
| 73 | #ifdef POSITION |
---|
[71] | 74 | public : void set_comment (std::string comment); |
---|
[88] | 75 | protected : std::string get_comment (void); |
---|
[42] | 76 | #endif |
---|
[29] | 77 | |
---|
[88] | 78 | protected : std::string signal_name (std::string name_interface, |
---|
| 79 | std::string name_signal , |
---|
[40] | 80 | direction_t direction ); |
---|
| 81 | |
---|
[71] | 82 | public : Signal * find_signal (std::string name); |
---|
[42] | 83 | public : bool find_signal (Signal * signal); |
---|
| 84 | |
---|
[88] | 85 | protected : std::string get_signal (void); |
---|
| 86 | public : Signal * set_signal (std::string name , |
---|
[29] | 87 | direction_t direction, |
---|
| 88 | uint32_t size , |
---|
| 89 | presence_port_t presence_port = PORT_VHDL_YES_TESTBENCH_YES); |
---|
[88] | 90 | public : std::list<Signal *> * get_signal_list (void); |
---|
[29] | 91 | |
---|
| 92 | #ifdef SYSTEMC |
---|
[113] | 93 | |
---|
| 94 | #undef FUNCTION |
---|
| 95 | #define FUNCTION "Interface::set_signal_clk" |
---|
[88] | 96 | public : sc_in_clk * set_signal_clk (std::string name , |
---|
[29] | 97 | uint32_t size , |
---|
[41] | 98 | presence_port_t presence_port=CLOCK_VHDL_YES) |
---|
[29] | 99 | { |
---|
[113] | 100 | log_begin(Behavioural,FUNCTION); |
---|
[38] | 101 | |
---|
[41] | 102 | if ((presence_port != CLOCK_VHDL_YES) and |
---|
| 103 | (presence_port != CLOCK_VHDL_NO )) |
---|
| 104 | throw ErrorMorpheo ("Signal \""+name+"\" is a clock, bad presence_port."); |
---|
| 105 | |
---|
[113] | 106 | LowerCase(name); |
---|
| 107 | |
---|
[42] | 108 | Signal * sig = set_signal (name, IN , size, presence_port); |
---|
[57] | 109 | sc_in_clk * port; |
---|
[38] | 110 | |
---|
[113] | 111 | if (_usage & USE_SYSTEMC_INTERFACE) |
---|
[57] | 112 | { |
---|
| 113 | port = new sc_in_clk (sig->_name.c_str()); |
---|
| 114 | sig->alloc<bool> (static_cast<void *>(port)); |
---|
| 115 | } |
---|
| 116 | else |
---|
| 117 | { |
---|
| 118 | port = NULL; |
---|
| 119 | } |
---|
[42] | 120 | |
---|
[113] | 121 | log_end(Behavioural,FUNCTION); |
---|
[38] | 122 | |
---|
[42] | 123 | return port; |
---|
[29] | 124 | }; |
---|
| 125 | |
---|
[113] | 126 | #undef FUNCTION |
---|
| 127 | #define FUNCTION "Interface::set_signal_in" |
---|
[29] | 128 | public : template <typename T> |
---|
[88] | 129 | sc_in <T> * set_signal_in (std::string name , |
---|
[29] | 130 | uint32_t size , |
---|
| 131 | presence_port_t presence_port=PORT_VHDL_YES_TESTBENCH_YES) |
---|
| 132 | { |
---|
[113] | 133 | log_begin(Behavioural,FUNCTION); |
---|
[38] | 134 | |
---|
[41] | 135 | if ((presence_port == CLOCK_VHDL_YES) or |
---|
| 136 | (presence_port == CLOCK_VHDL_NO )) |
---|
| 137 | throw ErrorMorpheo ("Signal \""+name+"\" is not a clock, bad presence_port."); |
---|
| 138 | |
---|
[113] | 139 | LowerCase(name); |
---|
| 140 | |
---|
[42] | 141 | Signal * sig = set_signal (name, IN , size, presence_port); |
---|
[57] | 142 | sc_in <T> * port; |
---|
[42] | 143 | |
---|
[113] | 144 | if (_usage & USE_SYSTEMC_INTERFACE) |
---|
[57] | 145 | { |
---|
| 146 | port = new sc_in <T> (sig->_name.c_str()); |
---|
| 147 | sig->alloc<T> (static_cast<void *>(port)); |
---|
| 148 | } |
---|
| 149 | else |
---|
| 150 | { |
---|
| 151 | port = NULL; |
---|
| 152 | } |
---|
[38] | 153 | |
---|
[113] | 154 | log_end(Behavioural,FUNCTION); |
---|
[38] | 155 | |
---|
| 156 | return port; |
---|
[29] | 157 | }; |
---|
| 158 | |
---|
[113] | 159 | #undef FUNCTION |
---|
| 160 | #define FUNCTION "Interface::set_signal_out" |
---|
[29] | 161 | public : template <typename T> |
---|
[88] | 162 | sc_out <T> * set_signal_out (std::string name , |
---|
[29] | 163 | uint32_t size , |
---|
| 164 | presence_port_t presence_port=PORT_VHDL_YES_TESTBENCH_YES) |
---|
| 165 | { |
---|
[113] | 166 | log_begin(Behavioural,FUNCTION); |
---|
[38] | 167 | |
---|
[113] | 168 | LowerCase(name); |
---|
| 169 | |
---|
[41] | 170 | if ((presence_port == CLOCK_VHDL_YES) or |
---|
| 171 | (presence_port == CLOCK_VHDL_NO )) |
---|
| 172 | throw ErrorMorpheo ("Signal \""+name+"\" is not a clock, bad presence_port."); |
---|
| 173 | |
---|
[31] | 174 | Signal * sig = set_signal (name, OUT , size, presence_port); |
---|
[57] | 175 | sc_out <T> * port; |
---|
[42] | 176 | |
---|
[113] | 177 | if (_usage & USE_SYSTEMC_INTERFACE) |
---|
[57] | 178 | { |
---|
| 179 | port = new sc_out <T> (sig->_name.c_str()); |
---|
| 180 | sig->alloc<T> (static_cast<void *>(port)); |
---|
| 181 | } |
---|
| 182 | else |
---|
| 183 | { |
---|
| 184 | port = NULL; |
---|
| 185 | } |
---|
[38] | 186 | |
---|
[113] | 187 | log_end(Behavioural,FUNCTION); |
---|
[38] | 188 | |
---|
| 189 | return port; |
---|
[29] | 190 | }; |
---|
[42] | 191 | |
---|
[113] | 192 | #undef FUNCTION |
---|
| 193 | #define FUNCTION "Interface::set_signal_internal" |
---|
[42] | 194 | public : template <typename T> |
---|
[71] | 195 | sc_signal <T> * set_signal_internal (std::string name, |
---|
[42] | 196 | uint32_t size) |
---|
| 197 | { |
---|
[113] | 198 | log_begin(Behavioural,FUNCTION); |
---|
[42] | 199 | |
---|
[113] | 200 | LowerCase(name); |
---|
| 201 | |
---|
[42] | 202 | Signal * sig = set_signal (name, INTERNAL , size, PORT_VHDL_NO_TESTBENCH_NO); |
---|
[57] | 203 | sc_signal <T> * port; |
---|
[42] | 204 | |
---|
[113] | 205 | if (_usage & USE_SYSTEMC_INTERFACE) |
---|
[57] | 206 | { |
---|
| 207 | port = new sc_signal <T> (sig->_name.c_str()); |
---|
| 208 | sig->alloc<T> (static_cast<void *>(port)); |
---|
| 209 | } |
---|
| 210 | else |
---|
| 211 | { |
---|
| 212 | port = NULL; |
---|
| 213 | } |
---|
[42] | 214 | |
---|
[113] | 215 | log_end(Behavioural,FUNCTION); |
---|
[42] | 216 | |
---|
| 217 | return port; |
---|
| 218 | }; |
---|
| 219 | |
---|
[29] | 220 | #endif |
---|
| 221 | |
---|
| 222 | #ifdef VHDL |
---|
| 223 | public : void set_port (Vhdl * & vhdl); |
---|
[42] | 224 | # ifdef VHDL_TESTBENCH |
---|
[41] | 225 | public : void set_signal (Vhdl * & vhdl); |
---|
[75] | 226 | public : void get_signal (std::list<std::string> * & list_signal); |
---|
[42] | 227 | # endif |
---|
[29] | 228 | #endif |
---|
| 229 | #ifdef VHDL_TESTBENCH |
---|
[41] | 230 | public : uint32_t get_cycle (void); |
---|
[42] | 231 | public : Signal * get_clock (void); |
---|
| 232 | public : Signal * get_reset (void); |
---|
[41] | 233 | |
---|
| 234 | public : void testbench (void); |
---|
| 235 | public : void testbench_cycle (void); |
---|
| 236 | public : void testbench_body (Vhdl * & vhdl , |
---|
[88] | 237 | std::string counter_name , |
---|
| 238 | std::string reset_name ); |
---|
[82] | 239 | public : std::string testbench_test (Vhdl * & vhdl , |
---|
[88] | 240 | std::string counter_name, |
---|
| 241 | std::string reset_name); |
---|
| 242 | public : std::string testbench_test_ok (Vhdl * & vhdl); |
---|
| 243 | protected : std::string testbench_test_name (Vhdl * & vhdl); |
---|
| 244 | protected : std::string testbench_test_ok_name (Vhdl * & vhdl); |
---|
| 245 | protected : std::string testbench_test_transaction_name (Vhdl * & vhdl); |
---|
[29] | 246 | #endif |
---|
| 247 | |
---|
[82] | 248 | public : bool test_map (uint32_t depth, bool top_level, bool is_behavioural); |
---|
[88] | 249 | //public : bool test_equi (uint32_t depth); |
---|
[62] | 250 | |
---|
[31] | 251 | #ifdef POSITION |
---|
[42] | 252 | public : void interface_map (void * entity, |
---|
[31] | 253 | void * interface); |
---|
[29] | 254 | public : XML toXML (void); |
---|
[31] | 255 | public : XML toXML_mapping (void); |
---|
| 256 | #endif |
---|
[88] | 257 | public : friend std::ostream& operator<< (std::ostream& output_stream, |
---|
| 258 | morpheo::behavioural::Interface & x); |
---|
[29] | 259 | |
---|
| 260 | }; |
---|
| 261 | |
---|
| 262 | }; // end namespace behavioural |
---|
| 263 | }; // end namespace morpheo |
---|
| 264 | |
---|
| 265 | #endif |
---|