Writing Traffic Generators in C++ - 2023.2 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
Release Date
2023.2 English

For API/pseudo code, a single instance of AXI4 memory map transaction is used for the complete transaction. This is in line with how payload is used in the AMD SystemC modules. For AXI4 Master, there is a b_transport(aximm_packet) API. After the call, aximm_packet is updated with a response given by AXI4 Slave. For AXI4 Slave, there are sample_transaction() and send_response(aximm_packet) APIs.

The following code snippets show the API usage in the context of C++.

  • Code snippet for C++ Master:
    auto payload = generate_random_transaction(); //Custom Random transaction generator. Users can configure AXI propeties on the payload.
    /* Or User can set the AXI transaction properties as follows
    payload->set_addr(std::rand() * 4);
    payload->set_len(1 + (std::rand() % 255));
    payload->set_size(1 << (std::rand() % 3));
    master_uti.b_transport(*payload.get(), std::rand() % 0x10); //A blocking call. Response will be updated in the same payload. Each AXI MM transaction will use same payload for whole transaction
    std::cout << "-----------Transaction Response------------" << std::endl;
    std::cout << *payload << std::endl; //Prints AXI transaction info
  • Code snippet for C++ Slave:
    auto& payload = slave_util.sample_transaction(); // Sample the transaction
    //If it is read transaction, give read data
    if(payload.cmd() == xtlm_ipc::aximm_packet_command_READ)
        std::generate(rd_resp.begin(), rd_resp.end(), []()
        {   return std::rand()%0x100;});
    //Set AXI response (for Read & Write)
    slave_util.send_response(payload); //Send the response to the master