HLS-Lens is a collection of pretty-printing scripts for GDB to display Vitis High-Level Synthesis (HLS) types, primarily ap_int
, ap_fixed
, and ap_float
, during C-simulation debugging.
Simply download the .gdb_pp_vitis.py
script and source it when you start your GDB session:
gdb -q \
-ex "source .gdb_pp_vitis.py" \
--args hls_prj_dir/solution_dir/csim/build/csim.exe
If you’re using VS Code, you can set up a debug configuration to enable pretty-printing of Vitis HLS types in the VS Code debugger UI:
{
"version": "0.2.0",
"configurations": [
{
"name": "csim debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/hls_prj_dir/solution_dir/csim/build/csim.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/hls_prj_dir/solution_dir/csim/build/",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"text": "source ${workspaceFolder}/.gdb_pp_vitis.py"
}
]
}
]
}
This setup assumes there is a Vitis HLS project hls_prj_dir
with a solution solution_dir
and the csim executable is located a
661B
t hls_prj_dir/solution_dir/csim/build/csim.exe
all under the current workspace folder ${workspaceFolder}
. This also assumes the .gdb_pp_vitis.py
script is located at the root of the current workspace folder.
Without pretty printing, GDB and VS Code will show an ap_fixed
type as follows:
- a = {…}
- ap_fixed_base<16, 8, true, AP_TRN, AP_WRAP, 0> (base) = ap_fixed_base<16, 8, true, AP_TRN, AP_WRAP, 0>
- ssdm_int_sim<16, true> (base) = ssdm_int_sim<16, true>
- V
- mask = 65535
- not_mask = 18446744073709486080
- sign_bit_mask = 9223372036854775808
- width = 16
- VAL = 960
- valid = true
- width = 16
- iwidth = 8
- qmode = AP_TRN
- omode = AP_WRAP
This is useful, but in most cases we just want to look at a decimal representation of the underlying fixed-point value.
With pretty printing, GDB and VS Code will show an ap_fixed
type as follows:
- a = {…}
- ap_fixed_base<...> = 3.75
Which solves our problem!
The current pretty print script supports the following Vitis HLS types: ap_int
, ap_uint
, ap_fixed
, ap_ufixed
, and ap_float
.
The current .gdb_pp_vitis.py
script is simply a copy of the gdbinit
file included with the GDB shipped in the Xilinx Vitis installation. We believe it is valuable to extract it into a separate file, host it here, and share it with others to lower the barriers to HLS development and debugging.
We plan to extend this in the future to support other vendor types. At that stage, we will also consider rewriting the script so that we can license it ourselves.