| 72 | | 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: |
| 73 | | {{{ |
| 74 | | void rspReceived(vci_rsp_t *rsp, uint32_t time) |
| | 72 | To receive a VCI response packet, a call-back function must be defined as a member function of the class '''!VciSimpleInitiator'''. This call-back function (named '''rspReceived()''' in the example), is 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: |
| | 73 | {{{ |
| | 74 | tmpl(tlmt_core::tlmt_return&)::callback(soclib::tlmt::vci_rsp_packet<vci_param> *pkt, |
| | 75 | const tlmt_core::tlmt_time &time, |
| | 76 | void *private_data) |
| 79 | | class vci_rsp_t { |
| 80 | | vci_command_t cmd; // VCI transaction type |
| 81 | | uint32_t length; // number of words in the packet |
| 82 | | uint32_t error; // error code (0 if no error) |
| 83 | | uint32_t srcid; // VCI Source ID |
| 84 | | uint32_t trdid; // VCI Thread ID |
| 85 | | uint32_t pktid; // VCI Packet ID |
| 86 | | } |
| 87 | | }}} |
| 88 | | |
| 89 | | The actions executed by the call-back function depend on the transaction type ('''cmd''' field), as well as the '''pktid''' and '''trdid''' fields. |
| | 81 | template<typename vci_param> |
| | 82 | class vci_rsp_packet |
| | 83 | { |
| | 84 | public: |
| | 85 | typename vci_param::cmd_t cmd; // VCI transaction type |
| | 86 | size_t length; // number of words in the packet |
| | 87 | uint32_t error; // error code (0 if no error) |
| | 88 | uint32_t srcid; // VCI Source ID |
| | 89 | uint32_t trdid; // VCI Thread ID |
| | 90 | uint32_t pktid; // VCI Packet ID |
| | 91 | }; |
| | 92 | }}} |
| | 93 | |
| | 94 | The actions executed by the call-back function depend on the response transaction type ('''cmd''' field), as well as the '''pktid''' and '''trdid''' fields. |
| 97 | | 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. |
| 98 | | |
| 99 | | The '''!VciInitiatorPort''' constructor must be called with the following arguments: |
| 100 | | {{{ |
| 101 | | p_vci(“vci”, this, &my_initiator::rspReceived, &m_time); |
| | 102 | The constructor of the class '''!VciSimpleInitiator''' 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 thread context '''c0'''. |
| | 103 | |
| | 104 | The '''!VciInitiator''' constructor must be called with the following arguments: |
| | 105 | {{{ |
| | 106 | p_vci("vci", new tlmt_core::tlmt_callback<VciSimpleInitiator,soclib::tlmt::vci_rsp_packet<vci_param> *>( |
| | 107 | this, &VciSimpleInitiator<vci_param>::rspReceived), &c0) |