Square Root - 2024.1 English

Vitis Libraries

Release Date
2024-05-30
Version
2024.1 English

The Sqrt function computes the square root of a 16-bit fixed point number using the non-restoring square root algorithm. The non-restoring square root algorithm uses the two’s complement representation for the square root result. At each iteration the algorithm can generate exact result value even in the last bit.

Input argument D must be 16-bit number, though it is declared as 32-bit. The output sqrt(D) is 16-bit type. If format of D is QM.N (where M+N = 1) then format of output is Q(M/2).N

To get a precision of ‘n’ bits in fractional part, you can simply left shift the radicand (D) by ‘2n’ before the function call and shift the solution right by ‘n’ to get the correct answer. For example, to find the square root of 35 (01100011:sub:2) with one bit after the decimal point, that is, N=1:

  1. Shift the number (0110001100:sub:2) left by 2
  2. Shift the answer (1011:sub:2) right by 1. The correct answer is 101.1, which is 5.5.

API Syntax

int Sqrt(unsigned int D)

Parameter Descriptions

The following table describes the template and the function parameters.

Table 762 Table . Sqrt Parameter Description
Parameter Description
D Input data in a 16-bit fixed-point format.
Return Output value in short int format.

Resource Utilization

The following table summarizes the resource utilization of the Sqrt function, generated using Vivado HLS 2019.1 tool for the Xilinx Xczu9eg-ffvb1156-1-i-es1 FPGA.

Table 763 Table . Sqrt Function Resource Utilization Summary

Operating Frequency

(MHz)

Utilization Estimate
BRAM_18K DSP_48Es FF LUT CLB
300 0 0 8 6 1

Performance Estimate

The following table summarizes the performance in different configurations, as generated using Vivado HLS 2019.1 tool for the Xilinx Xczu9eg-ffvb1156-1-i-es1 FPGA.

Table 764 Table . Sqrt Function Performance Estimate Summary

Operating Frequency

(MHz)

Latency Estimate
Min (cycles) Max (cycles)
300 18 18