0

I've got this error for operator "-". Using signed type and ieee.numeric_std. I would like to ask if my usage of "for" is correct.


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_signed.ALL;
use IEEE.STD_LOGIC_TEXTIO.ALL;
use ieee.numeric_std.all;   

entity stage_1 is
Port ( 
clk : in bit;
imagem: in SIGNED (19999 DOWNTO 0);
imagemanterior: in SIGNED (19999 DOWNTO 0);
Ix: out SIGNED (24999 DOWNTO 0);
Iy: out SIGNED (24999 DOWNTO 0);
It: out SIGNED (24999 DOWNTO 0)
);
end stage_1;

architecture Behavioral of stage_1 is
begin
 process (clk)

 begin

If (clk 'event and clk = '1') then

for I in 0 to 2448 loop 
Ix(I*10+9 DOWNTO I*10) <= 1/4 * (imagemanterior((I+1)*8+7 DOWNTO (I+1)*8) -       imagemanterior(I*8+7 DOWNTO I*8) + imagemanterior ((I+1)*8+407 DOWNTO 

(I+1)*8+400) - imagemanterior(I*8+407 DOWNTO I*8+400) + imagem((I+1)*8+7 DOWNTO(I+1)*8) - imagem(I*8+7 DOWNTO I*8)+ imagem((I+1)*8+407 DOWNTO(I+1)*8) - imagem((I)*8+407 DOWNTO I*8 +400));

Iy(I*10+9 DOWNTO I*10) <= 1/4*(imagemanterior((I*8)+407 DOWNTO (I)*8+400) - imagemanterior(I*8+7 DOWNTO I*8) + imagemanterior((I+1)*8+407 DOWNTO (I+1)*8) - imagemanterior((I+1)*8+7 DOWNTO(I+1)*8) + imagem(I*8+407 DOWNTO I*8+400) - imagem(I*8+7 DOWNTO I*68) + imagem((I+1)*8+407 DOWNTO (I+1)*8+400) -imagem((I+1)*8+7 DOWNTO(I+1)*8));

It(I*10+9 DOWNTO I*10) <= 1/4 * (imagem(I*8+7 DOWNTO I*8)- imagemanterior((I*8+7)-I*8) + imagem((I*8)+407 DOWNTO I*8+400)- imagemanterior(I*8+407 DOWNTO I*8+400) +imagem((I+1)*8+7 DOWNTO(I+1)*8)- imagemanterior((I+1)*8+7 DOWNTO(I+1)*8) + imagem((I+1)*8+407 DOWNTO (I+1)*8+400)- imagemanterior((I+1)*8+407 DOWNTO (I+1)*8+400));

end loop;
end if ;
end process;
end Behavioral;

1 Answers1

0

I commented out the assignments not involved in your error.

You could have provided an indication of where (pointed to which line) the error was associated with.

You basically had a - operator instead of a downto in specifying the range of right hand operand of the - operator the error was complaining about. Where is marked with a comment:

 -- downto was "-"

You could have provided a Minimal, Complete, and Verifiable example, which in this case would have implied throwing things out not associated with the error.

library ieee;
use ieee.std_logic_1164.all;
-- use ieee.std_logic_signed.all;
-- use ieee.std_logic_textio.all;
use ieee.numeric_std.all;   

entity stage_1 is
    port ( 
        clk:            in  bit;
        imagem:         in  signed (19999 downto 0);
        imagemanterior: in  signed (19999 downto 0);
        ix:             out signed (24999 downto 0);
        iy:             out signed (24999 downto 0);
        it:             out signed (24999 downto 0)
    );
end entity stage_1;

architecture behavioral of stage_1 is
begin
    process (clk)
    begin
        if (clk 'event and clk = '1') then
            for i in 0 to 2448 loop 
                --ix(i*10+9 downto i*10) <= 1/4 * (imagemanterior((i+1)*8+7 downto (i+1)*8) -       imagemanterior(i*8+7 downto i*8) + imagemanterior ((i+1)*8+407 downto 
                    -- (i+1)*8+400) - imagemanterior(i*8+407 downto i*8+400) + imagem((i+1)*8+7 downto(i+1)*8) - imagem(i*8+7 downto i*8)+ imagem((i+1)*8+407 downto(i+1)*8) - imagem((i)*8+407 downto i*8 +400));

                --iy(i*10+9 downto i*10) <= 1/4*(imagemanterior((i*8)+407 downto (i)*8+400) - imagemanterior(i*8+7 downto i*8) + imagemanterior((i+1)*8+407 downto (i+1)*8) - imagemanterior((i+1)*8+7 downto(i+1)*8) + imagem(i*8+407 downto i*8+400) - imagem(i*8+7 downto i*68) + imagem((i+1)*8+407 downto (i+1)*8+400) -imagem((i+1)*8+7 downto(i+1)*8));

                it( i*10 + 9 downto i * 10) <= 

                1/4 * ( 

                    imagem(i * 8 + 7 downto i * 8) - 

                    imagemanterior( (i * 8 + 7) downto i * 8) +   -- downto was "-"

                     imagem((i * 8 )+ 407 downto i * 8 + 400) - 

                     imagemanterior( i * 8 + 407 downto i * 8 + 400) +

                     imagem((i + 1) * 8 + 7 downto( i + 1) * 8) - 

                     imagemanterior((i + 1) * 8 + 7 downto(i + 1) * 8) + 

                     imagem((i + 1) * 8 + 407 downto (i + 1) * 8 + 400) - 

                     imagemanterior((i + 1) * 8 + 407 downto (i + 1) * 8 + 400)

                 ) ;

             end loop;
         end if ;
     end process;
end architecture behavioral;

After the change of the - operator to the reserved word downto your code analyzes (and I make no claim that it will run, that requires a test bench to drive clk).

Adding a rudimentary testbench to drive clk

Shows that your first assignment:

            ix(i*10+9 downto i*10) <= 1/4 * (imagemanterior((i+1)*8+7 downto (i+1)*8) -       imagemanterior(i*8+7 downto i*8) + imagemanterior ((i+1)*8+407 downto 
                (i+1)*8+400) - imagemanterior(i*8+407 downto i*8+400) + imagem((i+1)*8+7 downto(i+1)*8) - imagem(i*8+7 downto i*8)+ imagem((i+1)*8+407 downto(i+1)*8) - imagem((i)*8+407 downto i*8 +400));

produces a range error (the range of the expression on the right hand side doesn't match the range of the slice on the left hand side).

The same occurs for the second assignment:

            iy(i*10+9 downto i*10) <= 1/4*(imagemanterior((i*8)+407 downto (i)*8+400) - imagemanterior(i*8+7 downto i*8) + imagemanterior((i+1)*8+407 downto (i+1)*8) - imagemanterior((i+1)*8+7 downto(i+1)*8) + imagem(i*8+407 downto i*8+400) - imagem(i*8+7 downto i*68) + imagem((i+1)*8+407 downto (i+1)*8+400) -imagem((i+1)*8+7 downto(i+1)*8));

As well as the last (having the - operator instead of downto, corrected).

These are all run time errors.

Community
  • 1
  • 1