Documentation

HDL Reciprocal

Calculate reciprocal with Newton-Raphson approximation method

Library

HDL Coder / HDL Operations

Description

TheHDL Reciprocalblock 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 ) = 1 x a

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

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

x i + 1 = x i f ( x i ) f ' ( x i ) = x i + ( x i a x i 2 ) = x i . ( 2 a x i )

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

Following table shows comparison of simulation behavior ofHDL ReciprocalwithMath Reciprocalblock:

Math Reciprocal HDL Reciprocal

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

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

To match the simulation results with theMath Reciprocalblock, increase the number of iterations for theHDL Reciprocalblock.

Parameters

Number of iterations

Number of Newton-Raphson iterations. The default is 3.

Ports

The block has the following ports:

Input
  • Supported data types: Fixed-point, integer (signed or unsigned), double, single

  • Minimum bit width: 2

  • Maximum bit width: 128

Output

Input data type Output data type
double double
single single
built-in integer built-in integer
built-in fixed-point built-in fixed-point

fi(value, 0,word_length,fraction_length)

fi(value, 0,word_length,word_lengthfraction_length–1)

fi(value, 1,word_length,fraction_length)

fi(value, 1,word_length,word_lengthfraction_length–2)

Introduced in R2014b

Was this topic helpful?