Changes between Version 24 and Version 25 of Writing Rules/Tlmt


Ignore:
Timestamp:
Dec 27, 2007, 1:27:20 PM (16 years ago)
Author:
Nicolas Pouillon
Comment:

Ponctuation, namespaces, ...

Legend:

Unmodified
Added
Removed
Modified
  • Writing Rules/Tlmt

    v24 v25  
    22#!html
    33<h1>Writing efficient TLM-T SystemC simulation models for SoCLib</h1>
     4}}}
    45
    56Authors : Alain Greiner, François Pécheux, Emmanuel Viaud, Nicolas Pouillon
    67 
    7 }}}
    88[[PageOutline]]
    99
     
    2222[[Image(tlmt_figure_1.png, nolink)]]
    2323
    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.
     24Contrary to the initiator, the target module has a purely reactive behaviour.
     25There is no need to use a SC_THREAD : The target behaviour is entirely described by the call-back function '''cmdReceived()''',
     26that is executed when a VCI command packet is received by the target module.
    2627
    2728The 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.
     
    5354uint32_t  length;  // number of words in the packet
    5455bool  eop;  // end of packet marker
    55 uint32_t  srcid;  // SRCID VCI
    56 uint32_t  trdid;  // TRDID VCI
    57 uint32_t  pktid;  // PKTID VCI
     56uint32_t  srcid;  // VCI Source ID
     57uint32_t  trdid;  // VCI Thread ID
     58uint32_t  pktid;  // VCI Packet ID
    5859}
    5960}}}
    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
     62The possible values for the '''cmd''' fied are  `vci_param::CMD_READ`, `vci_param::CMD_WRITE`, `vci_param::CMD_READ_LOCKED`,
     63and `vci_param::CMD_STORE_COND`.
     64'''address'''es may be any value contained in the whole system address space.
     65The '''contig''' field can be used for optimisation.
    6266
    6367The '''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'''.
     
    6771To 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:
    6872{{{
    69 void  rspReceived(vci_rsp_t  *rsp,
    70                sc_time  time)
    71 }}}
     73void  rspReceived(vci_rsp_t  *rsp, sc_time  time)
     74}}}
     75
    7276The informations transported by a VCI command packet are defined below:
    7377{{{
     
    7680uint32_t  length;  // number of words in the packet
    7781bool  eop;  // end of packet marker
    78 uint32_t  srcid;  // SRCID VCI
    79 uint32_t  trdid;  // TRDID VCI
    80 uint32_t  pktid;  // PKTID VCI
     82uint32_t  srcid;  // VCI Source ID
     83uint32_t  trdid;  // VCI Thread ID
     84uint32_t  pktid;  // VCI Packet ID
    8185}
    8286}}}
    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
     88The actions executed by the call-back function depend on the transaction type ('''cmd'''  field), as well as the '''pktid''' and '''trdid''' fields.
     89
     90In the proposed example :
    8491 * In case of of a blocking read , the call-back function updates the local time, and activates the suspended thread.
    8592 * In case of a non-blocking write, the call-back function does nothing.
     
    8895
    8996The 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
    9098The '''!VciInitiatorPort''' constructor must be called with the following arguments:
    9199{{{
     
    98106
    99107To 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
    100109A 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.
    101110
     
    104113{{{
    105114template <typename vci_param>
    106 class my_initiator : Tlmt::BaseModule {
     115class my_initiator : tlmt::BaseModule {
    107116public:
    108117    VciInitiatorPort <vci_param>  p_vci;
     
    113122                         uint32_t lookahead) :
    114123    p_vci(“vci”, this, &my_initiator::rspReceived, &m_time),
    115     BaseModule(name),
    116     m_time(0),
     124    tlmt::BaseModule(name),
     125    m_time(0)
    117126    {
    118127    m_index = InitiatorIndex;
     
    123132               
    124133private:
    125     tlmt_Time m_time;           // local clock
     134    tlmt_time m_time;           // local clock
    126135    uint32_t m_index;           // initiator index
    127136    uint32_t m_counter; // iteration counter
     
    168177In 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.
    169178
    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.
     179The 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.
    171180
    172181== D.1) Receiving a VCI command packet ==
     
    194203The '''!VciTargetPort''' constructor must be called with the following arguments:
    195204{{{
    196 p_vci(“vci”, this, &my_initiator::cmdReceived);
     205p_vci(“vci”, this, &my_initiator::cmdReceived)
    197206}}}
    198207 
     
    200209 {{{
    201210template <typename vci_param>
    202 class my_target : Tlmt::BaseModule {
     211class my_target : tlmt::BaseModule {
    203212public:
    204213    VciTargetPort<vci_param>  p_vci;
     
    209218              sc_time  latency):
    210219    p_vci(“vci”,this, &my_target::cmdReceived),
    211     BaseModule(name)
     220    tlmt::BaseModule(name)
    212221    {
    213222    m_latency = latency;
     
    275284
    276285Interrupts are asynchronous events that are not transported by the VCI network.
     286
    277287As 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.
    278288
     
    283293The 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 :
    284294{{{
    285 void  irqSend( bool  val,
    286             sc_time  time)
     295void  irqSend( bool  val, sc_time  time)
    287296}}}
    288297
     
    294303A 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''' :
    295304{{{
    296 p_irq(“irq”, this, &my_processor::irqReceived),
     305p_irq(“irq”, this, &my_processor::irqReceived)
    297306}}}
    298307
    299308In 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
    300310Therefore, 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.
    301311
     
    310320
    311321{{{
    312 class my_processor : Tlmt::BaseModule {
     322class my_processor : tlmt::BaseModule {
    313323public:
    314324    IrqInPort           p_irq;
     
    319329    p_irq(“irq”, this, &my_initiator::irqReceived),
    320330    m_time(0),
    321     BaseModule(name)
     331    tlmt::BaseModule(name)
    322332    {
    323333    m_lookahed = lookahead;
     
    328338               
    329339private:
    330     tlmt_Time  m_time;  // local clock
     340    tlmt_time  m_time;  // local clock
    331341    bool  m_irqpendig;  // pending interrupt request
    332342    sc_time  m_irqtime;  // irq date