The AI Engine
simulator supports the CSV file format for PLIO-based simulation. CSV file format provides
more control over transactions and allows for cycle-by-cycle injection of traffic to AI Engine. CSV file format also
offers the flexibility to add empty clock cycles to the traffic injection, use the STALL command to inject multiple empty cycles, and specify
TLAST and TKEEP
values explicitly. With these features, you can simulate complex scenarios and analyze the
behavior of the design.
To associate the CSV file with a PLIO-based input or output, you need to specify the CSV file during the graph PLIO creation.
adf::input_plio in = adf::input_plio::create("DataIn", adf::plio_32_bits, "data/input.csv");
adf::input_plio out = adf::output_plio::create("DataOut", adf::plio_32_bits, "data/output.csv");
Input File
The input CSV file to the AI Engine simulator consists of a number of comma separated columns of
data. The first row in the file is the header line. The header line is defined as a CMD column, followed by data D columns, followed by the TLAST and TKEEP columns.
The number of data D columns must
equal the PLIO buswidth/datawidth of kernel data being input. For example the header below
corresponds to data being provided for a PLIO buswidth of 32-bit, and datawidth of int16.
Hence, there are two data sample D columns in the header
line.
CMD, D, D, TLAST, TKEEP
The DATA command must be used to
provide data input in the lines that follow the header line.
CMD, D, D, TLAST, TKEEP
DATA, 16, 20, 0, -1
DATA, 15, 11, 0, -1
You must use the STALL command to
specify the number of empty cycles to be injected in the data traffic. The STALL command mimics back pressure in the input traffic that
can be useful in simulating real-life data input.
CMD, D, D, TLAST, TKEEP
DATA, 16, 20, 0, -1
DATA, 15, 11, 0, -1
STALL:100
| Column | Description |
|---|---|
| CMD |
A pre-defined set of keywords for the parser to act on.
Possible values are
|
| D |
|
| TKEEP |
The TKEEP column can be used to specify how the D (data)
columns are processed. Based on the PLIO bus width, the allowable value of the
TKEEP column and its impact will differ. The 32 bit PLIO buswidth:
64 bit PLIO buswidth:
128 bit PLIO buswidth:
Below are examples of appropriate TKEEP combinations and their
impact (in comment) during the simulation for a CSV file that represents 32 bit
data type, 64 bit PLIO bus
width.
|
| TLAST |
|
CMD,D,D,TLAST,TKEEP
DATA,3,2, ,
| Data Type | PLIO 32 bit | PLIO 64 bit | PLIO 128 bit |
|---|---|---|---|
adf::input_plio in =
adf::input_plio::create("DataIn1", adf::plio_32_bits,
"input.csv");
|
adf::input_plio in =
adf::input_plio::create("DataIn1", adf::plio_64_bits,
"input.csv");
|
adf::input_plio in =
adf::input_plio::create("DataIn1", adf::plio_128_bits,
"input.csv");
|
|
| int8 | Four data columns expected. For
example:
|
Eight data columns expected. For
example:
|
16 data columns expected. For
example:
|
| int16 | Two data columns expected. For
example:
|
Four data columns expected. For
example:
|
Eight data columns expected. For
example:
|
| int32 | One data column
expected.
|
Two data columns expected. For
example:
|
Four data columns expected. For
example:
|
| int64 | N/A | One data column
expected.
|
Two data columns expected. For
example:
|
| cint16 | Two data columns expected to represent one cint value (real, imag). For
example:
|
Two cint values (real,
imag) represented by four data columns expected. For
example:
|
Four cint values (real,
imag) represented by 8 data columns expected. For
example:
|
| cint32 | N/A | One cint value (real, imag)
represented by two data columns expected. For
example:
|
Two cint values represented
by four data columns expected. For
example:
|
| float | One data column expected. For
example:
|
Two data columns expected. For
example:
|
Four data columns expected. For
example:
|
| cfloat | N/A | One floating point cfloat
value represented using two data columns expected. For
example:
|
Two floating point cfloat
values represented using four data columns expected. For
example:
|
| bfloat16 | Two data columns expected. For
example:
|
Four data columns expected. For
example:
|
Eight data columns expected. For
example:
|
| fp16 1 |
|
|
|
| mx9 1 |
|
|
|
|
|||
bool hex parameter to true in the adf::input_plio::create() API. For details, see input_plio/output_plio in
AI
Engine Kernel and Graph Programming Guide (UG1079). CSV File Format and Error Checks During Simulation
The AI Engine simulation execution generates an ERROR message for a CSV with incorrect data. The following table lists some simulation error-checking conditions the simulator applies when a CSV file is used as input.
| Error Scenario | CSV Input | Error Message |
|---|---|---|
| The number of DATA columns are not equal to PLIO buswidth / datawidth | For example, if buswidth =
64, and datawidth = 16, you need four
D columns.Two Few D Columns:
|
[ ERROR ] : In <filename>, the number of data (D) columns is not equal to PLIO buswidth/sample datawidth. Expected <expected_number> |
Two Many D
Columns:
|
||
| Partial data provided in the DATA columns of the CSV | For example, if buswidth = 64, and datawidth = 16, you need
four D columns. You must provide data samples in all four D columns. If partial data
is provided, appropriate TKEEP with TLAST=1 needs to be set. The TKEEP values determine whether the lower 32 bit is valid or the full 64
bit is valid.Missing One Data Sample:
Missing Two Data Samples:
|
[ ERROR ] : In <filename>, in line <linenumber> , partial data is being fed to plio. To feed partial data, provide appropriate TKEEP value with TLAST = 1 |
| Empty line in the CSV file | Empty
Line:
|
This line is ignored by the tool. |
| Invalid value specified in the CMD or D column | Invalid Command in the CMD
Column:
|
[ ERROR ] : Invalid command specified at <Filename:line number> |
|
Invalid Data Sample in D Columns:
|
[ ERROR ] : Invalid data value detected <filename:line number>. | |
| DATA columns ordered incorrectly | D Columns are Not Side-by-Side (Incorrect
Order):
|
[ ERROR ] : Ensure all the data columns (D) are specified in sequence right after the CMD column in <Filename> |
| DATA value is out of range for a specific datatypes | For example, if data type is int8, buswidth is 32, and data sample 2323 is out of range. DATA Value 2323 is Out of Range:
|
[ ERROR ] : Out of range data value detected in <filename>. Datatype is <datatype_provided_from_graph>. Range is <corresponding_range> |
| DATA value provided is invalid | Invalid Data Sample in D
Column:
|
[ ERROR ] : In <filename>, invalid data value is provided at <line number>. |
Output File
As with the input CSV file, you can specify to generate a CSV file for a PLIO output port. The simulator writes the simulation output corresponding to the appropriate PLIO port into the specified output CSV file.
adf::output_plio out1 = adf::output_plio::create("DataOut1",adf::plio_32_bits,"output1.csv");
adf::output_plio out2 = adf::output_plio::create("DataOut2",adf::plio_64_bits,"output2.csv");
adf::output_plio out3 = adf::output_plio::create("DataOut3",adf::plio_128_bits,"output3.csv");
The CSV file output includes both TLAST and TKEEP data. Each output line also
includes the timestamp so that you can estimate the data throughput during the simulation.
The timestamp is output in ns as the last column in the
output CSV file.
...
CMD, D, D, TLAST, TKEEP, TIME_NS
DATA:1, 0, 1, 0, -1, 720
DATA:1, 2, 3, 0, -1, 918.4
DATA:1, 4, 5, 0, -1, 1116.8
DATA:1, 6, 7, 0, -1, 1315.2
DATA:1, 8, 9, 0, -1, 1513.6
DATA:1, 10, 11, 0, -1, 1712
DATA:1, 12, 13, 0, -1, 1910.4
DATA:1, 14, 15, 0, -1, 2108.8
DATA:1, 16, 17, 0, -1, 2307.2
DATA:1, 18, 19, 0, -1, 2505.6
DATA:1, 20, 21, 0, -1, 2704
DATA:1, 22, 23, 0, -1, 2902.4
DATA:1, 24, 25, 0, -1, 3100.8
DATA:1, 26, 27, 0, -1, 3299.2
DATA:1, 28, 29, 0, -1, 3497.6
DATA:1, 30, 31, 0, -1, 3696
DATA:1, 32, 33, 0, -1, 3894.4
DATA:1, 34, 35, 0, -1, 4092.8
DATA:1, 36, 37, 0, -1, 4291.2
DATA:1, 38, 39, 0, -1, 4489.6
DATA:1, 40, 41, 0, -1, 4688
DATA:1, 42, 43, 0, -1, 4886.4
DATA:1, 44, 45, 0, -1, 5084.8
DATA:1, 46, 47, 0, -1, 5283.2
DATA:1, 48, 49, 0, -1, 5481.6
DATA:1, 50, 51, 0, -1, 5680
DATA:1, 52, 53, 0, -1, 5878.4
DATA:1, 54, 55, 0, -1, 6076.8
DATA:1, 56, 57, 0, -1, 6275.2
DATA:1, 58, 59, 0, -1, 6473.6
DATA:1, 60, 61, 0, -1, 6672
DATA:1, 62, 63, 0, -1, 6870.4
DATA:1, 0, 1, 0, -1, 7068.8
DATA:1, 2, 3, 0, -1, 7267.2
DATA:1, 4, 5, 0, -1, 7465.6
DATA:1, 6, 7, 0, -1, 7664
DATA:1, 8, 9, 0, -1, 7862.4
DATA:1, 10, 11, 0, -1, 8060.8
DATA:1, 12, 13, 0, -1, 8259.2
DATA:1, 14, 15, 0, -1, 8457.6
...
CMD, D, TLAST, TKEEP, TIME_NS
DATA:1, 2.002000093e+00, 0, 0, 3264
DATA:1, 4.004000187e+00, 0, 0, 3267.2
DATA:1, 6.006000042e+00, 0, 0, 3270.4
DATA:1, 8.008000374e+00, 0, 0, 3273.6
DATA:1, 1.001000023e+01, 0, 0, 3276.8
DATA:1, 1.201200008e+01, 0, 0, 3280
DATA:1, 1.401399994e+01, 0, 0, 3283.2
DATA:1, 1.601600075e+01, 0, 0, 3286.4
DATA:1, 1.801799965e+01, 0, 0, 3328
DATA:1, 2.002000046e+01, 0, 0, 3331.2
DATA:1, 2.202199936e+01, 0, 0, 3334.4
DATA:1, 2.402400017e+01, 0, 0, 3337.6
DATA:1, 2.602599907e+01, 0, 0, 3340.8
DATA:1, 2.802799988e+01, 0, 0, 3344
DATA:1, 3.003000069e+01, 0, 0, 3347.2
DATA:1, 3.203200150e+01, 0, 0, 3350.4
DATA:1, 3.403400040e+01, 0, 0, 3395.2
Viewing the Stalls in Analysis View of the Vitis Unified IDE
You can use the STALL command in the
CSV file, after you run the AI Engine and opt to generate simulation trace data. You can open the
simulation run summary and view the stalls in the Vitis
unified IDE. The STALL:<n> inserts stalls for
n empty cycles from the PL domain. You can see the
stall duration based on the PL frequency. For example,STALL:100 inserts 100 empty cycles from the PL for the duration of 1000 ns when
the PL frequency is 100 MHz.
Example 1: Design with direct stream connections (no buffer) results in a stream stall for the 500 empty cycles (from the PL domain) specified.
Example 2: Design with buffer-connected streams results in a lock stall for the 1000 empty cycles (from the PL domain) specified.