Run the Behavioral Model - 2022.2 English

Vitis Networking P4 Getting Started Guide (UG1373)

Document ID
UG1373
Version
2022.2 English
Revision

The behavioral model can be used to verify the functionality of a P4 program before progressing to synthesis. See the Vitis Networking P4 User Guide (UG1308), Chapter 3, for more information on the behavioral model.

To verify the functionality of <testname>.p4 (along with input packet data <packetname>_in.<pcap|user>), complete the following steps:
  1. Compile the P4 program using p4c-vitisnet. This generates a JSON file that can be used in the behavioral model:

    p4c-vitisnet <testname>.p4 -o <json_name>.json

  2. Create a <testcase>.txt text file containing a command to run the traffic data, ensuring that the input packet data file follows the <name>_in.<pcap|user> naming convention. If there are any tables in the P4 program, the table entries should be added to this testcase file (before the run_traffic command):

    echo 'run_traffic <packetname>' > <testcase>.txt

    The format of a table_add command looks as follows:

    table_add <table_name> <action_name> <key0> <key1> <key2>... => <response0> <response1>...

  3. Run the run-p4bm-vitisnet application to generate outputs from the model:

    run-p4bm-vitisnet -j <json_name>.json -s <testcase>.txt

    If successful, this generates <packetname>_out.<pcap|user> and <packetname>_out.meta files, which can be verified against simulated design data.