Changes between Version 2 and Version 3 of Writing Rules/Tlmt


Ignore:
Timestamp:
Dec 24, 2007, 9:29:00 PM (16 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Writing Rules/Tlmt

    v2 v3  
    1616Besides you may also want to follow the [WritingRules/General general SoCLib rules].
    1717
    18 = B) VCI Communication between a single initiator and a single target =
     18= B) Single VCI initiator and single VCI target =
    1919
    2020Figure 1 presents a minimal system containing one single initiator, and a single target. In the proposed example, the initiator module doesn't contains any parallelism, and can be modeled by a single SC_THREAD, describing a single PDES process. The activity of the '''my_initiator ''' module is described by the SC_THREAD '''execLoop()''', that contain an infinite loop. The variable '''m_time''' represents the PDES process local time.
     
    2626= C) Initiator Modeling =
    2727
    28 In the proposed example, the initiator module is modeled by the '''my_initiator''' class. This class inherit the '''Tlmt::BaseModule'''' class, that is the basis for all TLM-T modules. As there is only one thread in my_initiator, there is only one member variable '''time'' of type '''tlmt_time'''. This object can be accessed through the '''getTime()''', '''addTime()''' and '''setTime()''' methods. The '''execLoop()''' method, describing the initiator activity must be declared as a member function of the '''my_initiator''' class.
     28In the proposed example, the initiator module is modeled by the '''my_initiator''' class. This class inherit the '''BaseModule''' class, that is the basis for all TLM-T modules. As there is only one thread in this module, there is only one member variable '''time''' of type '''tlmt_time'''. This object can be accessed through the '''getTime()''', '''addTime()''' and '''setTime()''' methods.
     29
     30The '''execLoop()''' method, describing the initiator activity must be declared as a member function of the '''my_initiator''' class.
     31
     32Finally, the class '''my_initiator''' must contain a member variable '''p_vci''', of type '''VciInitiatorPort'''. This object has a template parameter <'''vci_param'''> defining the widths of the VCI ADRESS & DATA fields.
    2933
    3034== C.1) Sending a VCI command packet ==
    3135
    32 The class '''my_initiator''' must contain a member variable '''p_vci''', of type '''VciInitiatorPort'''. This object has a template parameter <'''vci_param'''> defining the widths of the VCI ADRESS & DATA fields.
    33 
    3436To send a VCI command packet, the '''execLoop()''' method must use the '''cmdSend()''' method, that is a member function of the '''p_vci''' port. The prototype is the following:
    3537{{{
    36 void cmdSend(   vci_cmd_t       *cmd,   // VCI command packet   
    37                                 sc_time         time);  // initiator local time
     38void cmdSend(vci_cmd_t  *cmd,   // VCI command packet   
     39                   sc_time time);       // initiator local time
    3840}}}
    3941
     
    5355}
    5456}}}
     57The possible values for the '''cmd''' fied are  VCI_CMD_READ, VCI_CMD_WRITE, VCI_CMD_READLINKED,
     58and 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.
     59
     60The '''cmdSend()''' function is non-blocking. To implement a blocking transaction (such as a cache line read, where the processor is blocked 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'''.
    5561
    5662== C.2) Receiving a VCI response packet ==
     
    6672class my_initiator : Tlmt::BaseModule {
    6773public:
    68                 VciInitiatorPort <vci_param>            p_vci;
     74    VciInitiatorPort <vci_param>                p_vci;
    6975               
    70 //////// constructor
    71                 my_initiator (  sc_module_name  name,
    72 uint32_t                initiatorIndex
    73 uint32_t                lookahead) :
    74                         p_vci(“vci”, this, &my_initiator::rspReceived, &m_time) ,
    75                         BaseModule(name),
    76 m_time(0),
    77 {
    78 m_index = InitiatorIndex;
    79 m_lookahed = lookahead;
    80 m_counter = 0;
    81 SC_THREAD(execLoop);
    82 } // end constructor
     76    //////// constructor
     77    my_initiator (sc_module_name name,
     78                         uint32_t initiatorIndex
     79                         uint32_t lookahead) :
     80    p_vci(“vci”, this, &my_initiator::rspReceived, &m_time),
     81    BaseModule(name),
     82    m_time(0),
     83    {
     84    m_index = InitiatorIndex;
     85    m_lookahed = lookahead;
     86    m_counter = 0;
     87    SC_THREAD(execLoop);
     88    } // end constructor
    8389               
    8490private:
    85 tlmt_Time               m_time;         // local clock
    86                 uint32_t                m_index;                // initiator index
    87                 uint32_t                m_counter;      // iteration counter
    88                 uint32_t                m_lookahed;     // lookahead value
    89                 vci_param::data_t       m_data[8];      // local buffer
    90                 vci_cmd_t       m_cmd;          // paquet VCI commande
     91    tlmt_Time m_time;           // local clock
     92    uint32_t m_index;           // initiator index
     93    uint32_t m_counter; // iteration counter
     94    uint32_t m_lookahed;        // lookahead value
     95    vci_param::data_t m_data[8];        // local buffer
     96    vci_cmd_t   m_cmd;          // paquet VCI commande
    9197
    92 //////// thread
    93                 void execLoop()
    94                 {
    95                         while(1) {
    96                                
    97                                 m_cmd.cmd = VCI_CMD_READ;
    98 p_vci.cmdSend(&m_cmd, m_time.get_time());       // lecture bloquante
    99                                 p_vci.wait();
    100                                
    101                                 m_cmd.cmd = VCI_CMD_WRITE;
    102                                 p_vci.send(VCI_CMD_WRITE,…);   
    103 p_vci.cmdSend(&m_cmd, m_time.get_time());       // écriture non bloquante
    104                                 ...
    105                                 // lookahead management
    106 m_counter++ ;
    107                                 if (m_counter >= m_lookahead) {
    108                                         m_counter = 0 ;
    109                                         wait(SC_ZERO_TIME) ;
    110                                 } // end if
    111                         m_time.addtime(1) ;
    112 } // end while
    113                 } // end execLoop()
     98    //////// thread
     99    void execLoop()
     100    {
     101    while(1) {
     102       
     103        m_cmd.cmd = VCI_CMD_READ;
     104        p_vci.cmdSend(&m_cmd, m_time.getTime());        // lecture bloquante
     105        p_vci.wait();
     106       
     107        m_cmd.cmd = VCI_CMD_WRITE;
     108        p_vci.send(VCI_CMD_WRITE,…);   
     109        p_vci.cmdSend(&m_cmd, m_time.getTime());        // écriture non bloquante
     110        ...
     111        // lookahead management
     112        m_counter++ ;
     113        if (m_counter >= m_lookahead) {
     114            m_counter = 0 ;
     115            wait(SC_ZERO_TIME) ;
     116        } // end if
     117        m_time.addtime(1) ;
     118        } // end while
     119    } // end execLoop()
    114120
    115 //////////////// call-back function
    116 void  rspReceived(vci_cmd_t *cmd, sc_time rsp_time)
    117 {
    118                 if(cmd == VCI_CMD_READ) {
    119 m_time.set_time(rsp_time + length);
    120 p_vci.notify() ;
    121 }
    122                         } // end rspReceived()
     121    //////////////// call-back function
     122    void  rspReceived(vci_cmd_t *cmd, sc_time rsp_time)
     123    {
     124    if(cmd == VCI_CMD_READ) {
     125        m_time.set_time(rsp_time + length);
     126        p_vci.notify() ;
     127    }
     128    } // end rspReceived()
    123129} // end class my_initiator
    124 
    125130}}}
    126131