Pregunta

I'm trying to do a few mathematical operations on integers in a piece of vhdl code but when i try to compile the tool says "0 definitions of operator "+" match here". Here is what i'm trying to do:

for i in 0 to arr_size - 1 loop
   for j in 0 to arr_size - 1 loop
      for k in 0 to arr_size - 1 loop
         for l in 0 to arr_size - 1 loop
            for m in 0 to arr_size - 1 loop
               mega_array(i)(j)(k)(l)(m) <= i*(arr_size**4) + j*(arr_size**3) + k*(arr_size**2) + l*(arr_size**1) + m*(arr_size**0);
            end loop;
         end loop;
      end loop;
   end loop;
end loop;

The problem was encountered in the line where mega_array is set. Note that this whole block is in a process.

Additionally:

arr_size : integer := 4;
sig_size : integer := 32

type \1-line\ is array (arr_size - 1 downto 0) of unsigned (sig_size - 1 downto 0);
type square is array (arr_size - 1 downto 0) of \1-line\;
type cube is array (arr_size - 1 downto 0) of square;
type hypercube is array (arr_size - 1 downto 0) of cube;
type \5-cube\ is array (arr_size - 1 downto 0) of hypercube;

signal mega_array : \5-cube\;
¿Fue útil?

Solución

When reading your older post, the mega_array is an array of 4 levels with at the lowest level an unsigned. In your code in this question I see 5 levels. So at the fifth level you have bit. You can not assign an integer to a std_logic.

Could it be this code is what you want?

    for i in 0 to arr_size - 1 loop                -- 5-cube
        for j in 0 to arr_size - 1 loop            -- hypercube
            for k in 0 to arr_size - 1 loop        -- cube
                for l in 0 to arr_size - 1 loop    -- square
                   for m in 0 to arr_size - 1 loop -- 1-line
                      mega_array(i)(j)(k)(l) <= to_unsigned(i*(arr_size**4) + j*(arr_size**3) + k*(arr_size**2) + l*(arr_size**1), 32);
                   end loop
                end loop;
            end loop;
        end loop;
    end loop;

The to_unsigned functions converts the integer to an unsigned, what is the type of 1-line. The second parameter is the size of the vector to convert the integer into. It must be the same as the size of 1-line.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top