Article ID: 000075172 Content Type: Troubleshooting Last Reviewed: 09/11/2012

Are there any problems in the Quartus II software when using the log and floor functions in the math_real VHDL package?

Environment

BUILT IN - ARTICLE INTRO SECOND COMPONENT
Description

Yes, there is an approximation issue when using the math_real VHDL package in the Quartus® II software for log and floor functions together. In certain circumstances, a rounding error can lead to incorrect floor values being calculated.

For example, when using the math_real package function to calculate log2(8.0) the correct answer should be 3.0, but the actual calculated value in the Quartus II software is 2.9999999999999996. When this result is then floored, the result is 2.0 instead of 3.0.

Example

floor(log2(real(8))) = 2.0

To work around this problem in the Quartus II software, use one of the following options

  • If the floor function is applied to log calculations, add a margin of error
    • Example: floor(0.000001 log2(real(8))) = 3.0
  • Use the integer conversion function instead of the floor function
    • Example: integer (log2(real(8))) = 3.0

This problem is scheduled to be fixed in a future release of the Quartus II software.

Related Products

This article applies to 1 products

Intel® Programmable Devices