Sqrt

Calculate square root, signed square root, or reciprocal of square root (HDL Coder)

Description

The Sqrt block is available with Simulink®.

For information about the simulation behavior and block parameters, see Sqrt.

HDL Architecture

This block has multi-cycle implementations that introduce additional latency in the generated code. To see the added latency, view the generated model or validation model. See Generated Model and Validation Model.

ArchitectureParameterAdditional cycles of latencyDescription
SqrtFunction (default)None0

Use a bitset shift/addition algorithm.

The SqrtFunction architecture is equivalent to the SqrtBitset architecture with UseMultiplier set to off.

SqrtBitsetUseMultiplier0

Algorithm depends on the UseMultiplier setting:

  • off (default): Use a bitset shift/addition algorithm.

  • on: Use a multiply/add algorithm.

SqrtNewtonIterationsIterations + 3

Use the iterative Newton method. Select this option to optimize area.

The default value for Iterations is 3.

The recommended value for Iterations is from 2 through 10. If Iterations is outside the recommended range, HDL Coder™ generates a message.

SqrtNewtonSingleRateIterations(Iterations * 4) + 6

Use the single rate pipelined Newton method. Select this option to optimize speed, or if you want a single rate implementation.

The default value for Iterations is 3.

The recommended value for Iterations is from 2 through 10. If Iterations is outside the recommended range, the coder generates a message.

HDL Block Properties

ConstrainedOutputPipeline

Number of registers to place at the outputs by moving existing delays within your design. Distributed pipelining does not redistribute these registers. The default is 0. See also ConstrainedOutputPipeline.

Iterations

Number of iterations for SqrtNewton or SqrtNewtonSingleRate implementation.

InputPipeline

Number of input pipeline stages to insert in the generated code. Distributed pipelining and constrained output pipelining can move these registers. The default is 0. See also InputPipeline.

OutputPipeline

Number of output pipeline stages to insert in the generated code. Distributed pipelining and constrained output pipelining can move these registers. The default is 0. See also OutputPipeline.

UseMultiplier

Select algorithm for SqrtBitset implementation. The default is off.

Restrictions

  • Input must be an unsigned scalar value.

  • Output is a fixed-point scalar value.

Was this topic helpful?