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