Here is an example code of inserting an 16x16 image.In every clock cycle i read the first 16 values,then other 16 etc.
--suppose we want to insert an 16x16 image.Each element is an integer 0 to 255
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
ENTITY input 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);
END input;
ARCHITECTURE behavioral OF input IS
TYPE row IS ARRAY(1 TO 16) OF INTEGER RANGE 0 TO 255;
BEGIN
PROCESS(clk)
VARIABLE row1,row2,row3,row4,row5,row6,row7,row8,row9,row10,row11,row12,row13,row14,row15,row16 : row;--it could be done with the use of signal as well
VARIABLE count : INTEGER:=(1);
BEGIN
IF(clk'EVENT AND clk='1') THEN
IF(load='1') THEN
IF(count<17) THEN
row1(count):=x1;
row2(count):=x2;
row3(count):=x3;
row4(count):=x4;
row5(count):=x5;
row6(count):=x6;
row7(count):=x7;
row8(count):=x8;
row9(count):=x9;
row10(count):=x10;
row11(count):=x11;
row12(count):=x12;
row13(count):=x13;
row14(count):=x14;
row15(count):=x15;
row16(count):=x16;
count:=count+1;
END IF;
END IF;
END IF;
END PROCESS;
END behavioral;
There is a need for the values to be stored,because in specific clock cycles i want add/substract some values so i must have them somewhere stored.