entity sel_gen is
port(clk : in std_logic;
rst : in std_logic;
vsync : in std_logic;
sel : out std_logic;
clear : out std_logic);
end sel_gen
architecture rtl_sel_gen of sel_gen is
signal clken : std_logic;
signal cleartemp : std_logic;
signal inputrega : std_logic;
signal inputregb : std_logic;
signal qn : std_logic_vector(1 downto 0);
signal seltemp : std_logic;
begin
process(rst,vsync)
begin
if rst'event and rst=‘0’ then
cleartemp <=‘1’;
end if;
if(vsync=‘0’)then
cleartemp <=‘0’;
end if;
end process;
clear<=cleartemp;
process(clk)
begin
if clk'event and clk=‘1’then
inputregb <= inputrega;
inputrega <= not vsync;
end if;
end process;
clken <= not inputregb and inputrega;
process (clk,rst)
begin
if (rst-‘1’) then
qn <= (others = >‘0’);
elsif clk'event and clk = ‘1’ then
if clken=‘1’ then
if qn = 3 then
qn <= (others =>‘0’);
else
qn <=qn +1;
end if;
end if;
end if;
seltemp <=qn(1);
end process;
sel <= seltemp;
end rtl sel gen;