Main Content

Sin

Compute sine operation using CORDIC approximation method and simulate with latency

Since R2020b

  • HDL Math Sine Block

Libraries:
HDL Coder

Description

HDL Math Sine Block

The Sin block computes the sine of input signal by using the coordinate rotation digital computer (CORDIC) approximation method. 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:

open_system('HDLMathLib')
You can simulate the Sin block with latency. For more information, Latency Considerations.

Examples

Ports

Input

expand all

Input data signal to compute sine function, specified as a scalar or vector. The input value ranges from -2π to 2*π.

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, specified as a scalar.

Data Types: Boolean

Output

expand all

Output data signal that is the sine of the input signal, returned as a scalar or vector.

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

Output control signal that indicates whether output signal is valid, returned as a scalar.

Data Types: Boolean

Parameters

expand all

Specify the number of iterations for CORDIC algorithm.

Programmatic Use

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

Specify whether to use minimum, maximum, custom, or zero latency. For more information, see Latency Strategy.

To use custom latency for the block, set the Latency strategy to Custom and enter the latency value in the Custom latency field.

You can also control the number of pipeline stages for the iterative algorithm. To customize the latency for iterative algorithm, set the Latency strategy to Custom(PerIteration) and enter the iterations per pipeline value in the IterationsPerPipeline field. (since R2025a)

Programmatic Use

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

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 Sin block. For more information, see CustomLatency.

Dependency

To enable this parameter, set Latency strategy to Custom.

Programmatic Use

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

Since R2025a

Specify the iterations to use per each pipeline stage in the algorithm.

Dependency

To enable this parameter, set Latency strategy to Custom(PerIteration).

Programmatic Use

Block Parameter: iterationsPerPipelineValue
Type: Integer
Values: Positive integer
Default: 1

Algorithms

expand all

References

[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.

Extended Capabilities

expand all

Version History

Introduced in R2020b

expand all