Main Content

Guideline for Using Sqrt Block for HDL Code Generation

Follow these guidelines when you use Sqrt blocks in your model to improve performance in terms of frequency, area, and accuracy.

Each guideline has a severity level that indicates the level of compliance requirements. To learn more, see HDL Modeling Guidelines Severity Levels.

Use SqrtFunction Architecture for Square Root Block

Guideline ID

2.11.1

Severity

Recommended

Description

When you use the Sqrt block in your model, set the HDL architecture to SqrtFunction for improved circuit area, timing on FPGA target, and accuracy. Using this architecture for a Sqrt block has several advantages over the Newton-Raphson-based architectures. The table compares synthesis results between the different HDL architectures of the Sqrt block. The results in this table are from Sqrt operation on a logic synthesis with the uint8 data type on an Xilinx® Kintex® 7 XC7K325T FFG900 device.

Sqrt Block Synthesis Results

ArchitectureIterationsMaximum Frequency (in MHz)FPGA Resource Usage
LUTsRegistersDSPs
SqrtFunction No iteration settings35420490
SqrtNewton31892901373
53381875
RecipSqrtNewton31851411644
52032466
SqrtNewtonSingleRate32286013186
583946810
RecipSqrtNewtonSingleRate324620831811
531748417

By selecting the SqrtFunction architecture, you can also enable UseMultiplier property to compute the square root by using multipliers. This property is off by default and the square root is computed using the shift-add algorithm.

You can increase the design frequency and reduce resource utilization by setting the UseMultiplier to off and LatencyStrategy to inherit.

If you choose to use the Newton-Raphson-based architectures, follow these design guidelines:

  • When designing a model for high frequency, use single-rate architectures such as SqrtNewtonSingleRate or RecipSqrtNewtonSingleRate. The resource consumption for single rate implementation is high because the implementation is performed without overclocking.

  • You can increase the iterations for single-rate architecture to improve the accuracy. Recommended iteration values are between 3 to 10. However, even a greater number of iterations cannot make single-rate implementation more accurate than the SqrtFunction architecture. The simulation results of the Sqrt block with SqrtFunction architecture are the same as those of Simulink. By contrast, the simulation results for Newton-Raphson-based implementation can yield results that are less accurate and numerically different.

  • Increasing number of iteration can increase latency and resource consumption. Additional cycles of latency depends on the architecture and iterations. For more information, see HDL Code Generation section in Sqrt.

See Also

|