No i dont want to accumulate all these values,just 4 of them each time so its ok.To be more specific in order to help you understand exactly what i want to do.
Imagine a 20x20 array with integer values from 0 to 255(grayscale).
I want to separate this array in 25 arrays each of one 4x4 and compute the sum of each one of these
arrays.So i think that the best way to implement this, is to insert one array(4x4) compute the sum of its values,then insert the next array do the same thing
etc.Do you thing that is right this way?I did something like this:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
ENTITY test IS
PORT( x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16 : IN INTEGER RANGE 0 TO 255;
clk,load : IN STD_LOGIC;
output : out INTEGER RANGE 0 TO 2040);
END test;
ARCHITECTURE behavioral OF test IS
TYPE filters1 IS ARRAY(0 TO 24) OF INTEGER RANGE 0 TO 2040;
TYPE filters2 IS ARRAY(0 TO 24) OF INTEGER RANGE 0 TO 2040;
signal fil1 : filters1;
signal fil2 : filters2;
BEGIN
PROCESS(clk)
variable count : integer:=(0);
variable sum1_or,sum2_or,sum3_or,sum4_or,sum1_kath,sum2_kath,sum3_kath,sum4_kath : integer range 0 to 1020;
variable filter1,filter2 : integer range 0 to 2040;
begin
IF(clk'EVENT AND clk='1') THEN
IF(load='1') THEN
IF(count<26) THEN
sum1_or := x1+x2+x3+x4;
sum2_or := x5+x6+x7+x8;
sum3_or := x9+x10+x11+x12;
sum4_or := x13+x14+x15+x16;
filter1:=(sum1_or+sum2_or)-(sum3_or+sum4_or);
fil1(count)<=filter1;
sum1_kath := x1+x5+x9+x13;
sum2_kath := x2+x6+x10+x14;
sum3_kath := x3+x7+x11+x15;
sum4_kath := x4+x8+x12+x16;
filter2:=(sum1_kath+sum2_kath)-(sum3_kath+sum4_kath);
fil2(count)<=filter2;
count:=count+1;
END IF;
END IF;
end if;
END PROCESS;
output<=fil1(0);
END behavioral;
Is it the right way?Thanks