Forum Discussion

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

Problens with Sfixed

Firstly sorry for my English, I used a translator.

I'm using the library sfixed used to do mathematical calculations, and because it synthesizes. I'm in trouble and perform the following calculation:

2 ^ 2.22 = 4.6589;

sfixed:

s <= to_sfixed (2 ** (2.22), 20, -20) -- worked!

I wanted to put a variable in place of 2:22, thus:

x <=to_fixed (2.22,20, -20);

s <= to_sfixed (2 **(x), 20, -20);

returns me the following error:

# ** Error: C:/altera/Projetos/expoente/expoente.vhdl(112): No feasible entries for infix operator "**".# ** Error: C:/altera/Projetos/expoente/expoente.vhdl(112): No feasible entries for subprogram "to_sfixed".# ** Error: C:/altera/Projetos/expoente/expoente.vhdl(115): VHDL Compiler exiting

att,

João Pedro

1 Reply

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

    There is no function to do integer ** sfixed. So you will have to either create one yourself, or I suggest using a look up table, as a power of function will be extreamly expensive in terms of logic.

    2.22 is a real type, and integer**real is a valid function, and it works at first because it is a constant value so never changes. Using a variable as the exponent is not a good idea.