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