Unit Test for Squared Magnitude Module - 2025.1 English - XD100

Vitis Tutorials: AI Engine Development (XD100)

Document ID
XD100
Release Date
2025-08-25
Version
2025.1 English

Directory structure:

$ cd ../../unit_tests/sqmag
$ tree
.
├── data
│   └── ivec.dat    # stimulus generated by sqmag.jl
├── julia
│   ├── cleanup.jl
│   ├── ovec.dat    # reference result generated by sqmag.jl   ├── README.txt
│   └── sqmag.jl    # Julia script to generate stimulus and reference files
├── Makefile
└── src
    ├── graph.hpp   # ADF graph
    ├── params.h
    ├── sqmag.cpp   # kernel code
    ├── sqmag.hpp
    └── tb.cpp      # simulation code

Examine the stimulus generation script julia/sqmag.jl. Examine the source code in the src directory.

Build and run the design in both functional (x86sim) and cycle-approximate (aiesim) modes. Note the results of the comparison between DUT and reference results.

$ make all | tee build.log

8< --- snip --- >8

Comparing x86sim and reference results...

diff -ws ./Emulation-SW/x86simulator_output/ovec.dat ./julia/ovec.dat
Files ./Emulation-SW/x86simulator_output/ovec.dat and ./julia/ovec.dat are identical

***************************** x86sim completed! *****************************

8< --- snip --- >8

Comparing aiesim and reference results...

diff -ws ./Emulation-HW/aiesimulator_output/ovec_new.dat ./julia/ovec.dat
Files ./Emulation-HW/aiesimulator_output/ovec_new.dat and ./julia/ovec.dat are identical

***************************** aiesim completed! *****************************
$

Examine the input and output streams with Vitis Analyzer:

$ vitis_analyzer Emulation-HW/aiesimulator_output/default.aierun_summary &

Click on Trace in the Analysis pane (see Fig. 12).

Vitis Analyzer: Trace Menu Fig. 12: Vitis Analyzer: Trace Menu

Double-click on the Run - default - AIE SIMULATION window to maximize it (see Fig. 13).

Fig. 13: default - AIE SIMULATOR window Fig. 13: Default - AIE SIMULATOR Window

Double-click on the Vitis Analyzer window to maximize it (double-click again to restore).

Stream Trace Data Fig. 14: Stream Trace Data

The function is executed twice (as specified in src/tb.cpp), processing eight vectors per invocation. Note that there are no spaces between the data in the input stream, but the output stream is “bursty”. This code is not optimized. Optimization in outside the scope of this tutorial.