| 152 | The class '''pdes_local_time''' is described in section D.5. |
| 153 | |
| 154 | The initiator activity status (used by the temporal filtering, as described in section F) is managed for the class '''pdes_activity_status'''. |
| 155 | The corresponding access functions are '''set()''' and '''get()'''. |
| 156 | |
| 157 | The '''execLoop()''' method, describing the initiator behaviour must be declared as a member function. |
| 158 | |
| 159 | The '''my_initiator''' class contains a member variable '''p_vci_init''', of type '''tlm_utils::simple_initiator_socket''', representing the VCI initiator port. |
| 160 | |
| 161 | It must also define an interface function to handle the VCI response packets. |
| 162 | |
| 163 | == D.2) Sending a VCI command packet == |
| 164 | |
| 165 | To send a VCI command packet, the '''execLoop()''' method must use the '''nb_transport_fw()''' method, defined by TLM2.0, |
| 166 | that is a member function of the '''p_vci_init''' port. The prototype of this method is the following: |
| 167 | {{{ |
| 168 | tlm::tlm_sync_enum nb_transport_fw |
| 169 | ( tlm::tlm_generic_payload &payload, // payload |
| 170 | tlm::tlm_phase &phase, // phase (TLM::BEGIN_REQ) |
| 171 | sc_core::sc_time &time); // absolute local time |
| 172 | }}} |
| 173 | |
| 174 | The first argument is a pointer to the payload (including the soclib payload extension), |
| 175 | the second represents the phase (always set to TLM::BEGIN_REQ for requests), and the third |
| 176 | argument contains the initiator local time. The return value is not used in this TLM-T implementation. |
| 177 | |
| 178 | The '''nb_transport_fw()''' function is non-blocking. |
| 179 | To implement a blocking transaction (such as a cache line read, where the processor is stalled during the VCI transaction), |
| 180 | the model designer must use the SystemC '''sc_core::wait(x)''' primitive ('''x''' being of type '''sc_core::sc_event'''): |
| 181 | the '''execLoop()''' thread is then suspended, and will be reactivated when the response packet is actually received. |
| 182 | |
| 183 | == D.3) Receiving a VCI response packet == |
| 184 | |
| 185 | To receive a VCI response packet, an interface function must be defined as a member function of the |
| 186 | class '''my_initiator'''. This function (named '''nb_transport_bw()''' in the example), must be linked to |
| 187 | the '''p_vci_init''' port, and is executed each time a VCI response packet is received on the '''p_vci_init''' port. |
| 188 | The function name is not constrained, but the arguments must respect the following prototype: |
| 189 | {{{ |
| 190 | tlm::tlm_sync_enum nb_transport_bw |
| 191 | ( tlm::tlm_generic_payload &payload, // payload |
| 192 | tlm::tlm_phase &phase, // phase (TLM::BEGIN_RESP) |
| 193 | sc_core::sc_time &time); // response time |
| 194 | }}} |
| 195 | The return value (type tlm::tlm_sync_enum) is not used in this TLM-T implementation, and must be sytematically set to tlm::TLM_COMPLETED. |
| 196 | |
| 197 | == D.4) Initiator Constructor == |
| 198 | |
| 199 | The constructor of the class '''my_initiator''' must initialize all the member variables, including |
| 200 | the '''p_vci_init''' port. The '''nb_transport_bw()''' function being executed in the context of the thread sending |
| 201 | the response packet, a link between the '''p_vci_init''' port and this interface function must be established. |
| 202 | |
| 203 | The constructor for the '''p_vci_init''' port must be called with the following arguments: |
| 204 | {{{ |
| 205 | p_vci_init.register_nb_transport_bw(this, &my_initiator::nb_transport_bw); |
| 206 | }}} |
| 207 | |
| 208 | == D.5) Local Time Representation & Synchronization == |
| 209 | |
| 210 | The SystemC simulation engine behaves as a cooperative, non-preemptive multi-tasks system. Any thread in the system must stop execution at some point, in order to allow the other threads to execute. Moreover each PDES process must send null message periodically. |
| 211 | |
| 212 | To solve this issue, it is necessary to define -for each initiator module- a '''synchronization time quantum''' parameter. This parameter defines |
| 213 | the maximum delay between two successive timed messages. When this time quantum is elapsed, the component send a null message, |
| 214 | and the corresponding thread is descheduled. |
| 215 | |
| 216 | This time quantum mechanism is implemented in the '''pdes_local_time''' class. |
| 217 | For each initiator, the time quantum value is a parameter defined as a constructor argument. |
| 218 | The three members methods are... |
164 | | |
165 | | The initiator activity status (used by the temporal filtering, as described in section F) is managed for the class '''pdes_activity_status'''. |
166 | | The corresponding access functions are '''set()''' and '''get()'''. |
167 | | {{{ |
168 | | bool m_activity_status; // the initiator activity status |
169 | | ... |
170 | | pdes_activity_status(); // constructor |
171 | | void set(bool a); // set the activity status (true if the component is active) |
172 | | bool get(); // get the activity state |
173 | | }}} |
174 | | |
175 | | The '''execLoop()''' method, describing the initiator behaviour must be declared as a member function. |
176 | | |
177 | | The '''my_initiator''' class contains a member variable '''p_vci_init''', of type '''tlm_utils::simple_initiator_socket''', representing the VCI initiator port. |
178 | | |
179 | | It must also define an interface function to handle the VCI response packets. |
180 | | |
181 | | == D.2) Sending a VCI command packet == |
182 | | |
183 | | To send a VCI command packet, the '''execLoop()''' method must use the '''nb_transport_fw()''' method, defined by TLM2.0, |
184 | | that is a member function of the '''p_vci_init''' port. The prototype of this method is the following: |
185 | | {{{ |
186 | | tlm::tlm_sync_enum nb_transport_fw |
187 | | ( tlm::tlm_generic_payload &payload, // payload |
188 | | tlm::tlm_phase &phase, // phase (TLM::BEGIN_REQ) |
189 | | sc_core::sc_time &time); // absolute local time |
190 | | }}} |
191 | | |
192 | | The first argument is a pointer to the payload (including the soclib payload extension), |
193 | | the second represents the phase (always set to TLM::BEGIN_REQ for requests), and the third |
194 | | argument contains the initiator local time. The return value is not used in this TLM-T implementation. |
195 | | |
196 | | The '''nb_transport_fw()''' function is non-blocking. |
197 | | To implement a blocking transaction (such as a cache line read, where the processor is stalled during the VCI transaction), |
198 | | the model designer must use the SystemC '''sc_core::wait(x)''' primitive ('''x''' being of type '''sc_core::sc_event'''): |
199 | | the '''execLoop()''' thread is then suspended, and will be reactivated when the response packet is actually received. |
200 | | |
201 | | == D.3) Receiving a VCI response packet == |
202 | | |
203 | | To receive a VCI response packet, an interface function must be defined as a member function of the |
204 | | class '''my_initiator'''. This function (named '''nb_transport_bw()''' in the example), must be linked to |
205 | | the '''p_vci_init''' port, and is executed each time a VCI response packet is received on the '''p_vci_init''' port. |
206 | | The function name is not constrained, but the arguments must respect the following prototype: |
207 | | {{{ |
208 | | tlm::tlm_sync_enum nb_transport_bw |
209 | | ( tlm::tlm_generic_payload &payload, // payload |
210 | | tlm::tlm_phase &phase, // phase (TLM::BEGIN_RESP) |
211 | | sc_core::sc_time &time); // response time |
212 | | }}} |
213 | | The return value (type tlm::tlm_sync_enum) is not used in this TLM-T implementation, and must be sytematically set to tlm::TLM_COMPLETED. |
214 | | |
215 | | == D.4) Initiator Constructor == |
216 | | |
217 | | The constructor of the class '''my_initiator''' must initialize all the member variables, including |
218 | | the '''p_vci_init''' port. The '''nb_transport_bw()''' function being executed in the context of the thread sending |
219 | | the response packet, a link between the '''p_vci_init''' port and this interface function must be established. |
220 | | |
221 | | The constructor for the '''p_vci_init''' port must be called with the following arguments: |
222 | | {{{ |
223 | | p_vci_init.register_nb_transport_bw(this, &my_initiator::nb_transport_bw); |
224 | | }}} |
225 | | |
226 | | == D.5) Local Time Representation & Synchronization == |
227 | | |
228 | | The SystemC simulation engine behaves as a cooperative, non-preemptive multi-tasks system. Any thread in the system must stop execution at some point, in order to allow the other threads to execute. Moreover each PDES process must send null message periodically. |
229 | | |
230 | | To solve this issue, it is necessary to define -for each initiator module- a '''synchronization time quantum''' parameter. This parameter defines |
231 | | the maximum delay between two successive timed messages. When this time quantum is elapsed, the component send a null message, |
232 | | and the corresponding thread is descheduled. |
233 | | |
234 | | This time quantum mechanism is implemented in the '''pdes_local_time''' class. |
235 | | For each initiator, the time quantum value is a parameter defined as a constructor argument. |
236 | | The three members methods are... |
237 | | |