Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] "Power" operator with LUT exponent

Status
Not open for further replies.

clros

Member level 2
Joined
May 26, 2018
Messages
45
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
387
Hi to all,
I have a problem with Quartus II (Altera),that depends on my poor knowledge of vhdl.
This code:
Code:
[…]
type lut_array_type is array(3 downto 0) of std_logic_vector(5 downto 0);
signal myLUT : lut_array_type ;
[...]
myLUT(0)<="10011";
myLUT(1)<="11011";
myLUT(2)<="10010";
myLUT(3)<="10101";
[…]
result <= (2**myLUT(0));
I have an error on last row; "... can't determine definition of operator ""**"" -- found 0 possible definitions"
Why? Can you help me?
 

What makes you think that ** operator is defined for integer ** std_logic_vector?

For a complete question, you need to specify the imported libraries and definition of result.

As far as I'm aware of, ** isn't synthesizable, power of two can be however represented by SHL operator, with argument types supported by the respective libraries.
 

I had not thought about the fact that it also depended on the type of arguments.

In my example I included:

Code:
[B]library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;[/B]

If I use an integer LUT, apparently it works fine.

But is it also possible to use a power with bases different from 2?
 

But is it also possible to use a power with bases different from 2?
Quartus will tell you that it's not synthesizable. You can implement it as repeated multiply, of course only useful for small exponents or in a pipelined design.

What do yo want to achieve? Under circumstances, it's better to use a precalculated table of powers.


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
entity pwr is port(
   exp   : in  integer range 0 TO 3;
   base  : in  integer range 0 TO 3;
   result: out integer range 0 to 31
   );
end pwr;
 
architecture rtl of pwr is
 
function power(base: integer; exp: positive; bound: positive) return integer is
variable temp: integer;
begin 
   temp := 1;
   for i in 1 to bound loop
      if i <= exp then
         temp := base*temp;
      end if;
   end loop;
   return temp;
end;
 
begin                       
   result <= power(base, exp, exp'high);
end;

 
  • Like
Reactions: clros

    clros

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top