HDL Reciprocal

Calculate reciprocal with Newton-Raphson approximation method (HDL Coder)

Description

The HDL Reciprocal block is available with Simulink®.

For information about the simulation behavior and block parameters, see HDL Reciprocal block in the Simulink documentation.

The HDL Reciprocal block uses the Newton-Raphson iterative method to compute the reciprocal of the block input. The Newton-Raphson method uses linear approximation to successively find better approximations to the roots of a real-valued function.

The reciprocal of a real number a is defined as a zero of the function:

f(x)=1xa

HDL Coder™ chooses an initial estimate in the range 0<x0<2a as this is the domain of convergence for the function.

To successively compute the roots of the function, specify the Number of iterations parameter in the Block Parameters dialog box. The process is repeated as:

xi+1=xif(xi)f'(xi)=xi+(xiaxi2)=xi.(2axi)

f'(x) is the derivative of the function f(x).

Comparison of simulation behavior of HDL Reciprocal with Math Reciprocal block

Math ReciprocalHDL Reciprocal

Computes the reciprocal as 1/N by using the HDL divide operator (/) to implement the division.

Uses the Newton-Rapshon iterative method to compute an approximate value of reciprocal of the block input. This approximation can yield different simulation results compared to the Math Reciprocal block.

To match the simulation results with the Math Reciprocal block, increase the number of iterations for the HDL Reciprocal block. However, increasing the number of iterations increases the number of hardware resources that your design uses.

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.

ArchitectureAdditional cycles of latencyDescription
ReciprocalNewton (default)Iterations + 1

Use the multirate implementation of 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 displays a message.

ReciprocalNewtonSingleRate(Iterations * 2) + 1

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 between 2 and 10. If Iterations is outside the recommended range, the coder displays 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.

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.

Was this topic helpful?