Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

VHDL Math Real & Quartus

I've been using the VHDL package ieee.math_real to declare parameters, the idea being to condense as much information in a design file as possible. in particular, for fixed point operations in feedback controls systems, it helps to see the scaling of the parameters directly in the design file. For example, the code below does synthesize correctly in Quartus:

constant RecipSqrt3  :   signed(N-1 downto 0) := to_signed(integer(real(ROUND((2.0**15)*(0.577350269189626)))),16);

However, the code below does not:

variable RecipFactor :   real := ROUND((2.0**15)*(1.0/(SQRT(3.0))));

Quartus gives a message about this; upon further checking the / operator is not defined for A/B where both A and B are real. It is defined, however, for the complex numbers in the complex package of math_real.

I like the notation of 1.0/SQRT(3.0) better than 0.577350269189626 for example.

Has anyone had success with the / operator for complex numbers or real numbers? Thanks in advance. James

11 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I remember having that divide problem once also, but I forgot when ... I don't divide many 'real's though, but recently I did this:

    ARCZ => integer( ( real(PI_TIMES_TWO) * ARCTAN( 2.0 ** (-(i))) / MATH_2_PI)) ,

    This is in Quartus II 11.1sp1.

    I tried your code
    	variable RecipFactor :   real := ROUND((2.0**15)*(1.0/(SQRT(3.0))));
    
    and got no other warning than:

    --- Quote Start ---

    Warning (10542): VHDL Variable Declaration warning at math_real.vhd(2373): used initial value expression for variable "RECIPROCAL" because variable was never assigned a value

    --- Quote End ---

    but that is a long time annoyance ...