library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity di is port( clk50_in : in std_logic; red_out : out std_logic; green_out : out std_logic; blue_out : out std_logic; hs_out : out std_logic; vs_out : out std_logic); end di; architecture Behavioral of di is signal clk25 : std_logic; signal horizontal_counter : std_logic_vector (9 downto 0); signal vertical_counter : std_logic_vector (9 downto 0); signal kockamozgat : std_logic; signal x_pos : std_logic_vector (9 downto 0); signal y_pos : std_logic_vector (9 downto 0); begin process (clk50_in) begin if clk50_in'event and clk50_in='1' then if(clk25 = '0') then clk25 <= '1'; else clk25 <= '0'; end if; end if; end process; process (clk25) constant x_start : integer := 144; constant y_start : integer := 39; begin if clk25'event and clk25 = '1' then if( kockamozgat = '1' ) then if( x_pos = CONV_STD_LOGIC_VECTOR(590,10) ) then x_pos <= CONV_STD_LOGIC_VECTOR(0,10); if( y_pos >= CONV_STD_LOGIC_VECTOR(430,10) ) then y_pos <= CONV_STD_LOGIC_VECTOR(0,10); else y_pos <= y_pos + CONV_STD_LOGIC_VECTOR(50,10); end if; else x_pos <= x_pos + CONV_STD_LOGIC_VECTOR(1,10); end if; kockamozgat <= '0'; end if; if( ( horizontal_counter >= CONV_STD_LOGIC_VECTOR(144,10) + x_pos) and (horizontal_counter < CONV_STD_LOGIC_VECTOR(x_start + 50,10) + x_pos ) and (vertical_counter >= CONV_STD_LOGIC_VECTOR(y_start,10) + y_pos ) and (vertical_counter < CONV_STD_LOGIC_VECTOR(y_start + 50,10) + y_pos ) ) then red_out <= '1'; green_out <= '1'; blue_out <= '1'; else red_out <= '0'; green_out <= '0'; blue_out <= '0'; end if; if( horizontal_counter > "0000000000" ) and (horizontal_counter < "0001100001" ) -- 96+1 then hs_out <= '0'; else hs_out <= '1'; end if; if (vertical_counter > "0000000000" ) and (vertical_counter < "0000000011" ) -- 2+1 then vs_out <= '0'; else vs_out <= '1'; end if; horizontal_counter <= horizontal_counter+"0000000001"; if (horizontal_counter="1100100000") then vertical_counter <= vertical_counter+"0000000001"; horizontal_counter <= "0000000000"; end if; if( vertical_counter = CONV_STD_LOGIC_VECTOR(526,10) ) then kockamozgat <= '1'; end if; if (vertical_counter="1000001110") then vertical_counter <= "0000000000"; end if; end if; end process; end Behavioral;