Main Content


Implement control signal based atan2 function

Since R2020b

  • HDL Math Atan2 Block


HDL Math Atan2 Block

The Atan2 block performs the four-quadrant arctangent of real-valued input signals, y_dataIn and x_dataIn. The block uses the coordinate rotation digital computer (CORDIC) approximation method to compute the four-quadrant arctangent of the inputs. For more information, see CORDIC approximation method in Algorithms. The block has control signals that indicate whether the input and output data are valid. You can also specify the number of iterations of the algorithm and the latency strategy.

To use this block in your Simulink® model, open the HDLMathLib library by entering this command in the MATLAB® Command Window:


Latency Considerations

You can simulate the Atan2 block with latency. This block is a masked subsystem that contains a MATLAB Function block, LumpLatency. The subsystem uses this MATLAB Function block to compute the latency based on the Number of iterations. To view the function that computes the latency of the block, open the LumpLatency block in the masked subsystem. To view inside the mask, click the ⇩ icon on the block.

The maximum latency LMax of Atan2 block is given by this equation:

LMax = N + 3

where N is the value of the Number of iterations parameter.

The minimum latency LMin of Atan2 block is given by this equation:

LMin = 2 + ceil(N / 3)

The block supports four latency modes. You can specify a custom latency value by setting the Latency Strategy parameter to Custom. For more information, see Custom latency.


  • The block does not support floating-point data types, such as half, single, and double.



expand all

y-coordinate data input signal. The input data must be a real-valued.

Data Types: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | bus

x-coordinate data input signal. The input must be a real-valued.

Data Types: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | bus

Input control signal that indicates whether the input signal is valid.

Data Types: Boolean


expand all

Four quadrant arctangent of x- and y-coordinate input signals. The output is the angle between a vector from the origin to the point (x_dataIn, y_dataIn) and the positive x-axis.

Data Types: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | bus

Output control signal that indicates whether output signal is valid.

Data Types: Boolean


expand all

Specify the number of iterations for the CORDIC algorithm.

Programmatic Use

Block Parameter: iter
Type: character vector
Values: Integer values
Default: '11'

Specify whether to map the blocks in your design to minimum, maximum, custom, or zero latency. For more information, see LatencyStrategy.

Programmatic Use

Block Parameter: latencyMode
Type: character vector
Values: 'Max' | 'Min' | 'Custom' | 'Zero'
Default: 'Max'

When you set Latency strategy to Custom, use this parameter to specify the custom latency value. The latency must be a nonnegative integer in the range [0, L], where L is the maximum latency value of Atan2 block. For more information, see CustomLatency.


To enable this parameter, set Latency strategy to Custom.

Programmatic Use

Block Parameter: customLatencyValue
Type: Integer
Values: 0 to Max latency
Default: 0


The block supports HDL code generation using HDL Coder™. HDL Coder provides additional configuration options that affect HDL implementation and synthesized logic. For more information, see HDL Block Properties.


expand all


[1] Volder, Jack E., “The CORDIC Trigonometric Computing Technique.” IRE Transactions on Electronic Computers EC-8 (1959); 330–334.

[2] Andraka, Ray “A Survey of CORDIC Algorithm for FPGA Based Computers.” Proceedings of the 1998 ACM/SIGDA Sixth International Symposium on Field Programmable Gate Arrays. Feb. 22–24 (1998): 191–200.

[3] Walther, J.S., “A Unified Algorithm for Elementary Functions,” Proceedings of the Spring Joint Computer Conference, May 18-20, 1971: 379–386.

[4] Schelin, Charles W., “Calculator Function Approximation,” The American Mathematical Monthly 90, no. 5 (1983): 317–325.

Version History

Introduced in R2020b