Changes between Version 4 and Version 5 of Writing Rules/Tlmt


Ignore:
Timestamp:
Dec 24, 2007, 10:10:46 PM (16 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Writing Rules/Tlmt

    v4 v5  
    4343{{{
    4444class vci_cmd_t {
    45 vci_command_t   cmd;            // VCI transaction type
    46 vci_address_t   *address;       // pointer to an array of addresses on the target side
    47 uint32_t                        *be;                    // pointer to an array of byte_enable signals
    48 bool                    contig;         // contiguous addresses (when true)
    49 vci_data_t             *buf;                // pointer to the local buffer on the initiator
    50 uint32_t                      length;             // number of words in the packet
    51 bool                  eop;                      // end of packet marker
    52 uint32_t                     srcid;                    // SRCID VCI
    53 uint32_t                     trdid;                    // TRDID VCI
    54 uint32_t                     pktid;                    // PKTID VCI
     45vci_command_t  cmd;     // VCI transaction type
     46vci_address_t  *address;  // pointer to an array of addresses on the target side
     47uint32_t         *be;  // pointer to an array of byte_enable signals
     48bool   contig;    // contiguous addresses (when true)
     49vci_param::vci_data_t  *buf;  // pointer to the local buffer on the initiator
     50uint32_t         length;  // number of words in the packet
     51bool  eop;  // end of packet marker
     52uint32_t  srcid;  // SRCID VCI
     53uint32_t         trdid;  // TRDID VCI
     54uint32_t         pktid;  // PKTID VCI
    5555}
    5656}}}
     
    7272class my_initiator : Tlmt::BaseModule {
    7373public:
    74     VciInitiatorPort <vci_param>                p_vci;
     74    VciInitiatorPort <vci_param>  p_vci;
    7575               
    7676    //////// constructor
     
    140140== D4) TLM-T target example
    141141 {{{
    142 Cible TLM-T
    143 
    144142template <typename vci_param>
    145143class my_target : Tlmt::BaseModule {
    146144public:
    147                 VciTargetPort<vci_param>                p_vci;
     145    VciTargetPort<vci_param>  p_vci;
    148146
    149                 ////////////// constructor
    150                 my_target (     sc_module_name  name,
    151 uint32_t                targetIndex,
    152 sc_time         latency):
    153 p_vci(“vci”,this, &my_target::cmdReceived),
    154 BaseModule(name)
    155 {
    156 m_latency = latency;
    157 m_index = targetIndex;
    158 } // end constructor
     147    ////////////// constructor
     148    my_target (sc_module_name   name,
     149              uint32_t targetIndex,
     150              sc_time  latency):
     151    p_vci(“vci”,this, &my_target::cmdReceived),
     152    BaseModule(name)
     153    {
     154    m_latency = latency;
     155    m_index = targetIndex;
     156    } // end constructor
    159157       
    160158private:
    161                 vci_param::data_t       m_data[8];      // local buffer
    162                 sc_time                 m_latency;      // target latency
    163                 uint32_t                m_index;                // target index
    164 vci_rsp_t               m_rsp;          // paquet VCI réponse
     159    vci_param::data_t  m_data[8];  // local buffer
     160    sc_time  m_latency;  // target latency
     161    uint32_t  m_index;  // target index
     162    vci_rsp_t  m_rsp;  // paquet VCI réponse
    165163
    166 /////////////// call-back function
    167 sc_time  cmdReceived(   vci_cmd_t *cmd,
    168 sc_time cmd_time)
    169 {
    170 
    171                 if(cmd->cmd == VCI_CMD_WRITE) {
    172                         for(int i = 0 ; i < length ; i++) m_data[i] = cmd->buf[i];
    173 }
    174 if(cmd->cmd == VCI_CMD_READ) {
    175                         for(int i = 0 ; i < length ; i++) cmd->buf[i] = m_data[i];
    176 }
    177 m_rsp.srcid = cmd->srcid;
    178 m_rsp.trdid  = cmd->trdid;
    179 m_rsp.pktid = cmd>pktid;
    180 m_rsp.length = cmd->length;
    181 m_rsp.error = 0;
    182 rsp_time = cmd_time + latency;
    183 p_vci.rspSend(&m_rsp, rsp_time) ;
    184 return (rsp_time + (sc_time)cmd->length);
    185                         } // end cmdReceived()
    186 
     164    /////////////// call-back function
     165    sc_time  cmdReceived(vci_cmd_t *cmd,
     166                sc_time cmd_time)
     167    {
     168    if(cmd->cmd == VCI_CMD_WRITE) {
     169        for(int i = 0 ; i < length ; i++) m_data[i] = cmd->buf[i];
     170        }
     171    if(cmd->cmd == VCI_CMD_READ) {
     172        for(int i = 0 ; i < length ; i++) cmd->buf[i] = m_data[i];
     173        }
     174    m_rsp.srcid = cmd->srcid;
     175    m_rsp.trdid  = cmd->trdid;
     176    m_rsp.pktid = cmd>pktid;
     177    m_rsp.length = cmd->length;
     178    m_rsp.error = 0;
     179    rsp_time = cmd_time + latency;
     180    p_vci.rspSend(&m_rsp, rsp_time) ;
     181    return (rsp_time + (sc_time)cmd->length);
     182   } // end cmdReceived()
    187183} // end class my_target
    188 
    189184}}}