------------------------------------------------------ -- Creació d'una finestra segons l'area i el centre -- -- Creat per: Lluís Magí 1999 --- ------------------------------------------------------ library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; ENTITY finestra IS PORT ( tamany : in integer range 0 to (2**9)-1; centrex : in integer range 0 to (2**11)-1; centrey : in integer range 0 to (2**10)-1; area : in integer range 0 to (2**15)-1; cx : in integer range 0 to (2**11)-1; cy : in integer range 0 to (2**10)-1; imatge_in : in std_logic_vector(23 downto 0); clk : in std_logic; enable : in std_logic; dins_finestra : out std_logic := '1'; imatge_out : out std_logic_vector(23 downto 0) ); constant MAX_X : integer := 524; constant MAX_Y : integer := 285; END finestra; ARCHITECTURE fines OF finestra IS signal b1, b2, b3, b4 : std_logic; BEGIN process (clk) variable finestra_min_x : integer range 0 to (2**11)-1 :=0; variable finestra_min_y : integer range 0 to (2**10)-1 :=0; variable finestra_max_x : integer range 0 to (2**11)-1 :=0; variable finestra_max_y : integer range 0 to (2**10)-1 :=0; variable dins_finestra_x : std_logic := '0'; variable dins_finestra_y : std_logic := '0'; begin if falling_edge(clk) then case enable is when '1' => if centrex > tamany then finestra_min_x := centrex - tamany; else finestra_min_x := 1; end if; if centrey > tamany then finestra_min_y := centrey - tamany; else finestra_min_y := 1; end if; finestra_max_x := centrex + tamany; if finestra_max_x > MAX_X then finestra_max_x := MAX_X; end if; finestra_max_y := centrey + tamany; if finestra_max_y > MAX_Y then finestra_max_y := MAX_Y; end if; if cx < finestra_min_x or cx > finestra_max_x then dins_finestra_x :='0'; else dins_finestra_x :='1'; end if; if cy < finestra_min_y or cy >finestra_max_y then dins_finestra_y :='0'; else dins_finestra_y :='1'; end if; -- bit per indicar que estem dins la finestra ------------- if (dins_finestra_x='1' and dins_finestra_y='1') or area < 100 or (centrex = 0 and centrey = 0) then dins_finestra <= '1'; else dins_finestra <= '0'; end if; ------------------------------------------------------------ if finestra_min_x > 0 then if (cx = finestra_min_x and dins_finestra_x = '1' and dins_finestra_y = '1' and area > 1) then b1 <= '1'; else b1 <= '0'; end if; else b1 <= '0'; end if; if finestra_min_y > 0 then if (cy = finestra_min_y and dins_finestra_x = '1' and dins_finestra_y = '1' and area > 1) then b2 <= '1'; else b2 <= '0'; end if; else b2 <= '0'; end if; if finestra_max_x < MAX_X then if (cx = finestra_max_x and dins_finestra_x = '1' and dins_finestra_y = '1' and area > 1) then b3 <= '1'; else b3 <= '0'; end if; else b3 <= '0'; end if; if finestra_max_y < MAX_Y then if (cy = finestra_max_y and dins_finestra_x = '1' and dins_finestra_y = '1' and area > 1) then b4 <= '1'; else b4 <= '0'; end if; else b4 <= '0'; end if; WHEN OTHERS => b1 <= '0'; b2 <= '0'; b3 <= '0'; b4 <= '0'; dins_finestra <= '1'; END CASE; end if; end process; process(clk) begin if rising_edge(clk) then if (b1='1' or b2='1' or b3='1' or b4='1') then imatge_out(23 downto 0) <= "111111111111111111111111"; else imatge_out <= imatge_in; end if; end if; end process; end fines;