Unsigned Inputs - 2024.2 English - UG1399

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
UG1399
Release Date
2024-11-13
Version
2024.2 English

The DSP48 and DSP58 both contain signed multipliers. This implies that when using DSP intrinsics to multiply unsigned values, one must explicitly create them by setting the MSB to 0, otherwise an unsigned input with the MSB set to 1 would be interpreted as a negative number. The easiest mechanism is to explicitly use unsigned types with one less bit.

For Example:

#include "hls_dsp_builtins.h"
using namespace hls::dsp58;
...
ap_uint<57> test(ap_uint<26> d, ap_uint<26> a, ap_uint<23> b, ap_uint<57> c) {
    return add_mul_add<...>((ap_uint<27>(d), ap_uint<27>(a), ap_uint<24>(b), ap_uint<58>(c));
}