Changes between Version 24 and Version 25 of Writing Rules/Tlmt
- Timestamp:
- Dec 27, 2007, 1:27:20 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Writing Rules/Tlmt
v24 v25 2 2 #!html 3 3 <h1>Writing efficient TLM-T SystemC simulation models for SoCLib</h1> 4 }}} 4 5 5 6 Authors : Alain Greiner, François Pécheux, Emmanuel Viaud, Nicolas Pouillon 6 7 7 }}}8 8 [[PageOutline]] 9 9 … … 22 22 [[Image(tlmt_figure_1.png, nolink)]] 23 23 24 Contrary to the initiator, the target module has a purely reactive behaviour. There is no need to use a SC_THREAD : The target behaviour is entirely described by the call-back function '''cmdReceived()''', that is executed when a VCI command 25 packet is received by the target module. 24 Contrary to the initiator, the target module has a purely reactive behaviour. 25 There is no need to use a SC_THREAD : The target behaviour is entirely described by the call-back function '''cmdReceived()''', 26 that is executed when a VCI command packet is received by the target module. 26 27 27 28 The VCI communication channel is a point-to-point bi-directionnal channel, encapsulating two separated uni-directionnal channels : one to transmit the VCI command packet, one to transmit the VCI response packet. … … 53 54 uint32_t length; // number of words in the packet 54 55 bool eop; // end of packet marker 55 uint32_t srcid; // SRCID VCI56 uint32_t trdid; // TRDID VCI57 uint32_t pktid; // PKTID VCI56 uint32_t srcid; // VCI Source ID 57 uint32_t trdid; // VCI Thread ID 58 uint32_t pktid; // VCI Packet ID 58 59 } 59 60 }}} 60 The possible values for the '''cmd''' fied are VCI_CMD_READ, VCI_CMD_WRITE, VCI_CMD_READLINKED, 61 and VCI_CMD_STORECONDITIONAL Le champ address contient un ensemble d’adresses valides dans l’espace mémoire partagé du système modélisé. The contig field can be used for optimisation. 61 62 The possible values for the '''cmd''' fied are `vci_param::CMD_READ`, `vci_param::CMD_WRITE`, `vci_param::CMD_READ_LOCKED`, 63 and `vci_param::CMD_STORE_COND`. 64 '''address'''es may be any value contained in the whole system address space. 65 The '''contig''' field can be used for optimisation. 62 66 63 67 The '''cmdSend()''' function is non-blocking. To implement a blocking transaction (such as a cache line read, where the processor is ''frozen'' during the VCI transaction), the model designer must use the '''wait()''' method, that is a member function of the '''!VciInitiatorPort''' class. The '''execLoop()''' thread is suspended. It will be activated when the response packet is received by the '''notify()''' method, that is also a member function of the '''!VciInitiatorPort'''. … … 67 71 To receive a VCI response packet, a call-back function must be defined as a member function of the class '''my_initiator'''. This call-back function (named '''rspReceived()''' in the example), will be executed each time a VCI response packet is received on the '''p_vci''' port. The function name is not constrained, but the arguments must respect the following prototype: 68 72 {{{ 69 void rspReceived(vci_rsp_t *rsp, 70 sc_time time) 71 }}} 73 void rspReceived(vci_rsp_t *rsp, sc_time time) 74 }}} 75 72 76 The informations transported by a VCI command packet are defined below: 73 77 {{{ … … 76 80 uint32_t length; // number of words in the packet 77 81 bool eop; // end of packet marker 78 uint32_t srcid; // SRCID VCI79 uint32_t trdid; // TRDID VCI80 uint32_t pktid; // PKTID VCI82 uint32_t srcid; // VCI Source ID 83 uint32_t trdid; // VCI Thread ID 84 uint32_t pktid; // VCI Packet ID 81 85 } 82 86 }}} 83 The actions executed by the call-back function depend on the transaction type ('''cmd''' field), as well as the '''pktid''' and '''trdid''' fields. In the proposed example : 87 88 The actions executed by the call-back function depend on the transaction type ('''cmd''' field), as well as the '''pktid''' and '''trdid''' fields. 89 90 In the proposed example : 84 91 * In case of of a blocking read , the call-back function updates the local time, and activates the suspended thread. 85 92 * In case of a non-blocking write, the call-back function does nothing. … … 88 95 89 96 The constructor of the class '''my_initiator''' must initialize all the member variables, including the '''p_vci''' port. The '''rspReceived()''' call-back function being executed in the context of the thread sending the response packet, a link between the '''p_vci''' port and the call-back function must be established. Moreover, the '''p_vci''' port must contain a pointer to the initiator local time. 97 90 98 The '''!VciInitiatorPort''' constructor must be called with the following arguments: 91 99 {{{ … … 98 106 99 107 To solve this problem, it is necessary to define - for each initiator module- a '''lookahead''' parameter. This parameter defines the maximum number of cycles that can be executed by the thread before it stops. The '''lookahead''' parameter allows the system designer to bound the de-synchronization between threads. 108 100 109 A small value for this parameter result in a better timing accuracy for the simulation, but implies a larger number of context switch, and a slower simulation speed. 101 110 … … 104 113 {{{ 105 114 template <typename vci_param> 106 class my_initiator : Tlmt::BaseModule {115 class my_initiator : tlmt::BaseModule { 107 116 public: 108 117 VciInitiatorPort <vci_param> p_vci; … … 113 122 uint32_t lookahead) : 114 123 p_vci(“vci”, this, &my_initiator::rspReceived, &m_time), 115 BaseModule(name),116 m_time(0) ,124 tlmt::BaseModule(name), 125 m_time(0) 117 126 { 118 127 m_index = InitiatorIndex; … … 123 132 124 133 private: 125 tlmt_ Time m_time; // local clock134 tlmt_time m_time; // local clock 126 135 uint32_t m_index; // initiator index 127 136 uint32_t m_counter; // iteration counter … … 168 177 In the proposed example, the target handle two types of command : a read burst of 8 words, and a write burst of 8 words. To simplify the model, there is no error management. 169 178 170 The class '''my_target''' inherit the class '''!BaseModule''', that is the basis for all TLM-T modules. The class '''my_target''' contains a member variable '''p_vci''' of type '''!VciTargetPort'''. This object has a template parameter <'''vci_param'''>defining the widths of the VCI ADRESS & DATA fields.179 The class '''my_target''' inherit the class '''!BaseModule''', that is the basis for all TLM-T modules. The class '''my_target''' contains a member variable '''p_vci''' of type '''!VciTargetPort'''. This object has a template parameter '''<vci_param>''' defining the widths of the VCI ADRESS & DATA fields. 171 180 172 181 == D.1) Receiving a VCI command packet == … … 194 203 The '''!VciTargetPort''' constructor must be called with the following arguments: 195 204 {{{ 196 p_vci(“vci”, this, &my_initiator::cmdReceived) ;205 p_vci(“vci”, this, &my_initiator::cmdReceived) 197 206 }}} 198 207 … … 200 209 {{{ 201 210 template <typename vci_param> 202 class my_target : Tlmt::BaseModule {211 class my_target : tlmt::BaseModule { 203 212 public: 204 213 VciTargetPort<vci_param> p_vci; … … 209 218 sc_time latency): 210 219 p_vci(“vci”,this, &my_target::cmdReceived), 211 BaseModule(name)220 tlmt::BaseModule(name) 212 221 { 213 222 m_latency = latency; … … 275 284 276 285 Interrupts are asynchronous events that are not transported by the VCI network. 286 277 287 As illustrated in Figure 5, each interrupt line is modeled by a specific point to point, uni-directional channel. It use two ports of type '''!IrqOutPort''' and '''!IrqinPort''' that must be declared as member variables of the source and destination modules respectively. 278 288 … … 283 293 The source module (named '''my_source''' in this example) must contain a member variable '''p_irq''' of type '''!IrqOutPort'''. To activate, or desactivate an interruption, the source module must use the '''irqSend()''' method, that is a member function of the '''!IrqOutPort''' class. Those interrupt packets transport both a Boolean, and a date. The '''irqSend()''' prototype is defined as follows : 284 294 {{{ 285 void irqSend( bool val, 286 sc_time time) 295 void irqSend( bool val, sc_time time) 287 296 }}} 288 297 … … 294 303 A link between the '''p_irq''' port and the call-back function mus be established by the port constructor in the constructor of the class '''my_processor''' : 295 304 {{{ 296 p_irq(“irq”, this, &my_processor::irqReceived) ,305 p_irq(“irq”, this, &my_processor::irqReceived) 297 306 }}} 298 307 299 308 In the Parallel Discrete Event Simulation, the pessimistic approach suppose that any PDES process is not allowed to update his local time until he has received messages on all input ports with dates larger than his local time. 309 300 310 Therefore, a SC_THREAD modeling the behavior of a processor containing an '''!IrqInPort''' should in principle wait a dated packet on this interrupt port before executing instructions. Such behavior would be very inefficient, and could create dead-lock situations. 301 311 … … 310 320 311 321 {{{ 312 class my_processor : Tlmt::BaseModule {322 class my_processor : tlmt::BaseModule { 313 323 public: 314 324 IrqInPort p_irq; … … 319 329 p_irq(“irq”, this, &my_initiator::irqReceived), 320 330 m_time(0), 321 BaseModule(name)331 tlmt::BaseModule(name) 322 332 { 323 333 m_lookahed = lookahead; … … 328 338 329 339 private: 330 tlmt_ Time m_time; // local clock340 tlmt_time m_time; // local clock 331 341 bool m_irqpendig; // pending interrupt request 332 342 sc_time m_irqtime; // irq date