Changes between Version 65 and Version 66 of Writing Rules/Tlmt
- Timestamp:
- Nov 15, 2008, 5:59:14 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Writing Rules/Tlmt
v65 v66 42 42 channels: one to transmit the VCI command packet, one to transmit the VCI response packet. 43 43 44 = C) VCI initiator Modeling = 45 46 In the proposed example, the initiator module is modeled by the '''my_initiator''' class. 47 This class inherits from the standard SystemC '''sc_core::sc_module''' class, that acts as the root class for all TLM-T modules. 48 49 The initiator local time is contained in a member variable named '''m_localTime''', of type '''sc_core::sc_time'''. The 50 local time can be accessed with the following accessors: '''addLocalTime()''', '''setLocalTime()''' 51 and '''getLocalTime()'''. 52 {{{ 53 sc_core::sc_time m_localTime; // the initiator local time 54 ... 55 void addLocalTime(sc_core::sc_time t); // add an increment to the local time 56 void setLocalTime(sc_core::sc_time& t); // set the local time 57 sc_core::sc_time getLocalTime(void); // get the local time 58 }}} 59 60 The boolean member variable '''m_activity''' indicates if the initiator is currently active. 61 It is used by the arbitration threads contained in the '''vci_vgmn''' interconnect, as described in section E. 62 The corresponding access functions are '''setActivity()''' and '''getActivity()'''. 63 {{{ 64 bool m_activity; 65 ... 66 void setActivity(bool t); // set the activity status (true if the component is active) 67 bool getActivity(void); // get the activity state 68 }}} 69 70 The '''execLoop()''' method, describing the initiator behaviour must be declared as a member function. 71 72 Finally, the class '''my_initiator''' must contain a member variable '''p_vci_init''', of type '''tlmt_simple_initiator_socket'''. 73 This member variable represents the VCI initiator port. 74 75 == C.1) Sending a VCI command packet == 76 77 To send a VCI command packet, the '''execLoop()''' method must use the '''nb_transport_fw()''' method, that is a member 78 function of the '''p_vci_init''' port. The prototype of this method is the following: 79 {{{ 80 81 tlm::tlm_sync_enum nb_transport_fw /// sync status 82 ( soclib_vci_types::tlm_payload_type &payload, ///< VCI payload pointer 83 soclib_vci_types::tlm_phase_type &phase, ///< transaction phase 84 sc_core::sc_time &time); ///< time 85 }}} 86 87 The first parameter of this member function is the VCI packet, the second represents the phase (TLMT_CMD in this case), and the third 88 parameter contains the initiator local time. 89 90 To prepare a VCI packet for sending, the '''execLoop''' function must declare two objects locally, '''payload''' and '''phase'''. 91 {{{ 92 soclib_vci_types::tlm_payload_type payload; 93 soclib_vci_types::tlm_phase_type phase; 94 }}} 44 = C) TLM-T VCI Transaction = 45 46 The TLM2.0 standard allows the user to redefine both the payload and the phases of a transaction. 47 Two classes are defined in '''soclib_vci_types''' : a '''tlmt_vci_transaction''' and a '''tlmt_phase". 48 95 49 A payload of type '''soclib_vci_types::tlm_payload_type''' corresponds to a '''tlmt_vci_transaction'''. 96 50 It contains three groups of information: … … 98 52 * TLM-T related fields 99 53 * VCI related fields 100 The contents of a '''tlmt_vci_transaction''' is defined below:101 54 {{{ 102 55 class tlmt_vci_transaction … … 139 92 and '''set_store_cond()''' (for atomic store conditional). The '''set_src_id()''', '''set_trd_id()''' and '''set_pkt_id()''' functions 140 93 respectively set the VCI source, thread and packet identifiers. 141 The following example describes a VCI write command: 142 {{{ 143 payload.set_address(0x10000000);//ram 0 144 payload.set_byte_enable_ptr(byte_enable); 145 payload.set_byte_enable_length(nbytes); 146 payload.set_data_ptr(data); 147 payload.set_data_length(nbytes); // 5 words of 32 bits 148 149 payload.set_write(); 150 payload.set_src_id(m_id); 151 payload.set_trd_id(0); 152 payload.set_pkt_id(pktid); 153 154 phase= soclib::tlmt::TLMT_CMD; 155 sendTime = getLocalTime(); 156 157 p_vci_init->nb_transport_fw(payload, phase, sendTime); 158 }}} 159 94 95 = D) VCI initiator Modeling = 96 97 == D1) Member variables == 98 99 In the proposed example, the initiator module is modeled by the '''my_initiator''' class. 100 This class inherits from the standard SystemC '''sc_core::sc_module''' class, that acts as the root class for all TLM-T modules. 101 102 The initiator local time is contained in a member variable named '''m_localTime''', of type '''sc_core::sc_time'''. The 103 local time can be accessed with the following accessors: '''addLocalTime()''', '''setLocalTime()''' 104 and '''getLocalTime()'''. 105 {{{ 106 sc_core::sc_time m_localTime; // the initiator local time 107 ... 108 void addLocalTime(sc_core::sc_time t); // add an increment to the local time 109 void setLocalTime(sc_core::sc_time& t); // set the local time 110 sc_core::sc_time getLocalTime(void); // get the local time 111 }}} 112 113 The boolean member variable '''m_activity''' indicates if the initiator is currently active. 114 It is used by the arbitration threads contained in the '''vci_vgmn''' interconnect, as described in section E. 115 The corresponding access functions are '''setActivity()''' and '''getActivity()'''. 116 {{{ 117 bool m_activity; 118 ... 119 void setActivity(bool t); // set the activity status (true if the component is active) 120 bool getActivity(void); // get the activity state 121 }}} 122 123 The '''execLoop()''' method, describing the initiator behaviour must be declared as a member function. 124 125 Finally, the class '''my_initiator''' must contain a member variable '''p_vci_init''', of type '''tlmt_simple_initiator_socket'''. 126 This member variable represents the VCI initiator port. 127 128 == D.2) Sending a VCI command packet == 129 130 To send a VCI command packet, the '''execLoop()''' method must use the '''nb_transport_fw()''' method, that is a member 131 function of the '''p_vci_init''' port. The prototype of this method is the following: 132 {{{ 133 134 tlm::tlm_sync_enum nb_transport_fw 135 ( soclib_vci_types::tlm_payload_type &payload, // VCI payload pointer 136 soclib_vci_types::tlm_phase_type &phase, // transaction phase (TLMT_CMD) 137 sc_core::sc_time &time); // local time 138 }}} 139 140 The first argument is a pointer to the payload, the second represents the phase (TLMT_CMD in this case), and the third 141 argument contains the initiator local time. 160 142 161 143 The '''nb_transport_fw()''' function is non-blocking. … … 164 146 the '''execLoop()''' thread is then suspended, and will be reactivated when the response packet is actually received. 165 147 166 == C.2) Receiving a VCI response packet ==148 == D.3) Receiving a VCI response packet == 167 149 168 150 To receive a VCI response packet, a call-back function must be defined as a member function of the 169 class '''my_initiator'''. This call-back function (named '''vci_rsp_received()''' in the example), must be 170 declared in the '''my_initiator''' class and 151 class '''my_initiator'''. This call-back function (named '''vci_rsp_received()''' in the example), 171 152 is executed each time a VCI response packet is received on the '''p_vci_init''' port. The function name is not 172 153 constrained, but the arguments must respect the following prototype: … … 174 155 tlm::tlm_sync_enum vci_rsp_received 175 156 ( soclib_vci_types::tlm_payload_type &payload, // payload 176 soclib_vci_types::tlm_phase_type &phase, // transaction phase 177 sc_core::sc_time &time); // resp time 178 }}} 179 The return value (type tlm::tlm_sync_enum) must be sytematically set to tlm::TLM_COMPLETED in this implementation 180 The function parameters are identical to those described in the forward transport function 157 soclib_vci_types::tlm_phase_type &phase, // transaction phase (TLMT_RSP) 158 sc_core::sc_time &time); // response time 159 }}} 160 The return value (type tlm::tlm_sync_enum) is not used in this tlmt implementation, and must be sytematically set to tlm::TLM_COMPLETED. 181 161 182 162 In the general case, the actions executed by the call-back function depend on the response transaction type ('''m_command''' field), as well as 183 163 the '''pktid''' and '''trdid''' fields. 184 For sake of simplicity, the call-back function proposed below does not make any distinction between VCItransaction types.185 186 == C.3) Initiator Constructor ==164 For sake of simplicity, the call-back function proposed in the example below does not make any distinction between transaction types. 165 166 == D.4) Initiator Constructor == 187 167 188 168 The constructor of the class '''my_initiator''' must initialize all the member variables, including … … 195 175 }}} 196 176 197 == C.4) Lookahead parameter ==177 == D.5) Lookahead parameter == 198 178 199 179 The SystemC simulation engine behaves as a cooperative, non-preemptive multi-tasks system. Any thread in the system must stop execution … … 208 188 and a slower simulation speed. 209 189 210 == C.4) VCI initiator example ==190 == D.6) VCI initiator example == 211 191 212 192 {{{ … … 220 200 }}} 221 201 222 = D) VCI target modeling =202 = E) VCI target modeling = 223 203 224 204 In the proposed example, the '''my_target''' component handles all VCI commands in the same way, and there is no error management. 205 206 == E1) Member variables & methods 225 207 226 208 The class '''my_target''' inherits from the class '''sc_core::sc_module'''. The class '''my_target''' contains a member 227 209 variable '''p_vci_target''' of type '''tlmt_simple_target_socket'''. This object has 3 template parameters, that are identical to 228 210 those used for declaring initiator ports (see above). 229 230 == D.1) Receiving a VCI command packet == 211 It contains a call-back function as described below. 212 213 == E.2) Receiving a VCI command packet == 231 214 232 215 To receive a VCI command packet, a call-back function must be defined as a member function of the class '''my_target'''. 233 This call-back function (named '''vci_cmd_received()''' in the example), will beexecuted each time a VCI command packet is received on216 This call-back function (named '''vci_cmd_received()''' in the example), is executed each time a VCI command packet is received on 234 217 the '''p_vci_target''' port. The function name is not constrained, but the arguments must respect the following prototype: 235 218 {{{ … … 240 223 }}} 241 224 242 == D.2) Sending a VCI response packet ==243 244 To send a VCI response packet the call-back function '''vci_cmd_received()''' mustuse the '''nb_transport_bw()''' method, that is a member function of225 == E.3) Sending a VCI response packet == 226 227 To send a VCI response packet the call-back function '''vci_cmd_received()''' use the '''nb_transport_bw()''' method, that is a member function of 245 228 the class '''tlmt_simple_target_socket''', and has the same arguments as the '''nb_transport_fw()''' function. 246 229 Respecting the general TLM2.0 policy, the payload argument refers to the same '''tlmt_vci_transaction''' object for both the '''nb_transport_fw()''' and '''nb_transport_bw()''' functions, 247 and the associated call-back functions. The set_response_status field must be documented for all transaction types, but only two values are used in this implementation:230 and the associated call-back functions. The set_response_status field must be documented for all transaction types, but only two values are used in this TLM-T implementation: 248 231 * TLMT_OK_RESPONSE 249 232 * TLMT_ERROR_RESPONSE … … 257 240 }}} 258 241 259 == D.3) Target Constructor ==242 == E.4) Target Constructor == 260 243 261 244 The constructor of the class '''my_target''' must initialize all the member variables, including … … 267 250 }}} 268 251 269 == D.4) VCI target example ==252 == E.5) VCI target example == 270 253 {{{ 271 254 … … 278 261 }}} 279 262 280 = E) VCI Interconnect modelling =281 282 The VCI interconnect used for the TLM-T simulation is a generic simulation model, named '''!VciVgmn'''.263 = F) VCI Interconnect modelling = 264 265 The VCI interconnect used for the TLM-T simulation is a generic interconnection network, named '''!VciVgmn'''. 283 266 The two main parameters are the number of initiators, and the number of targets. In TLM-T simulation, 284 267 we don't want to reproduce the cycle-accurate behavior of a particular interconnect. We only want to simulate the contention in … … 291 274 [[Image(tlmt_figure_2.png, nolink)]] 292 275 293 == E.1) Generic network modeling ==276 == F.1) Generic network modeling == 294 277 295 278 There is actually two fully independent networks for VCI command packets and VCI response packets. There is a routing function for each input … … 304 287 [[Image(tlmt_figure_3.png, nolink)]] 305 288 306 == E.2) Arbitration Policy ==289 == F.2) Arbitration Policy == 307 290 308 291 As described above, there is one '''cmd_arbitration''' thread associated to each VCI target. This thread is in charge of selecting one timed request between … … 331 314 }}} 332 315 333 As the net-list of the simulated pl tform mus be explicitely defined before constructing those LocalTime and ActivityStatus arrays, the vgmn hardware component316 As the net-list of the simulated platform mus be explicitely defined before constructing those LocalTime and ActivityStatus arrays, the vgmn hardware component 334 317 provides an utility function '''fill_time_activity_arrays()''' that must be called in the SystemC top-cell, before starting the simulation. 335 318