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