library IEEE; use IEEE.std_logic_1164.all; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity CameraModule is port ( pclk: in STD_LOGIC; href: in STD_LOGIC; vsync: in STD_LOGIC; x : out STD_LOGIC_VECTOR (9 downto 0); y : out STD_LOGIC_VECTOR (8 downto 0) ); end CameraModule; architecture CameraModule_arch of CameraModule is signal x_count : std_logic_vector(9 downto 0) := "0000000000"; signal y_count : std_logic_vector(8 downto 0) := "000000000"; signal last_href : std_logic := '0'; --subtype pixel is std_logic_vector (5 downto 0); --type alpha is array (383 downto 0) of pixel; --type beta is array (287 downto 0) of alpha; --signal mem : beta; begin x(9 downto 1) <= x_count(8 downto 0); --multiplying x by 2 x(0) <= '0'; process(y_count)--process that accounts for the overflow issues of image enlargment in y-axis begin if(y_count <= "011110000") then -- if y_count >= 240 (240 is key number b/c it is mult by 2 to get 480) y(8 downto 1) <= y_count(7 downto 0); --multiplying y by 2 y(0) <= '0'; else y <= "111011110"; --if y_count >= 240, we default to y_pos 479 end if; end process; process(pclk) begin if falling_edge(pclk) then if(vsync = '1') then x_count <= "0000000000"; y_count <= "000000000"; end if; if(href = '1') then x_count <= x_count + X"1"; end if; if((last_href = '1') and (href = '0')) then x_count <= "0000000000"; y_count <= y_count + X"1"; end if; if(x_count = "1100000000") then -- x_count is 384 x_count <= "0000000000"; end if; if(y_count >= "100100000") then -- y_count is 288 y_count <= "000000000"; end if; last_href <= href; end if; end process; end CameraModule_arch;