ApiDetails
See also API concept.
An optionally activatable macro CHECK_RULES(...) is used to check optional some design rules. This makes simulation slower but checks some parameters for correct usage and e.g. checks if there was a completion if needed.
For code documentation see doxygen documentation and code in the svn https://svn.greensocs.com/local/greensocs/packages/greenbus
Example Sender
- // //////// Memory Read ///////////
- dat = new std::vector<gs_uint8>(data_size+100); // +100 for test purpose
- ah = mAPI.create_transaction();
- // Make Memory Read TLP
- ah->init_Memory_Read( targetAddr, *dat, data_size ); // read data_size bytes from address targetAddr to vector dat
- mAPI.send_transaction(ah);
- PCIeDEBUG("process completion:");
- if (ah->get_Completion_Status() == SuccessfulCompletion) {
- cout << " Completion status: successfull"<<endl;
- cout << " Completion answered by completer's function no. "<< (unsigned int) ah->get_completers_Function_Number()<<endl;
- PCIeDEBUG("read data:");
- cout << " ";
- for (unsigned int i = 0; i < data_size; i++) {
- }
- cout << endl;
- } else
- cout << " Completion status: not successfull ("<<(unsigned int)ah->get_Completion_Status() <<dec<<")"<<endl;
Example Receiver
- void PCIeRecvDevice::b_transact(PCIeTransactionHandle th) {
- PCIeDEBUG("b_transact: received transaction");
- PCIeSlaveAccessHandle ah = _getSlaveAccessHandle(th);
- unsigned int cmd = ah->get_TLP_type();
- switch(cmd) {
- case MemRead:
- {
- // Process data
- std::vector<gs_uint8> *dat;
- dat = &(ah->getMData().getData());
- for (unsigned int i = 0; i < ah->getMBurstLength(); i++) {
- dat->at(i) = i+100;
- }
- // Send Completion
- ah->init_Memory_Read_Completion(SuccessfulCompletion, 3);
- }
- break;
Root Complex
The Root Complex is a device with an internal PCIe switch. To help the user with implementing the Root Complex there is a class PCIeRootComplex (see greenbus/api/PCIe/PCIeRootComplex.h). This derives from the PCIeRouter class, accordingly the user is able to connect devices and switches to its Downstream Port. Do not connect the Upstream Port: it is bound internally to the down_to_router_port which is another PCIeAPI port. That port is the connection to PCIe and should be used by the user to implement the Root Complex functionality.
At minimum the user has to implement the method PCIeRootComplex::down_to_router_port_b_transact(PCIeTransactionHandle th). To be able to extend the Root Complex the user should derive from this class, e.g. MyPCIeRootComplex. See greenbus/examples/PCIe/platform for an example.
- The
PCIeRootComplexis aPCIeRouter. - Use Downstream Port to connect the PCIe tree topology.
- Do not use the Upstream Port which is connected internally.
- Use the port
down_to_router_portto access the PCIe topology. - Implement
down_to_router_port_b_transactto handle incoming TLPs from the PCIe topology. - Derive from
PCIeRootComplexto extend functionality, e.g. to add a SC_METHOD.
Posted January 8th, 2008 by MarkBurton