library IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity pix_gen is
port
(
clk50,video_on: in std_logic;
pixel_x,pixel_y : in std_logic_vector(9 downto 0) := (others =>'0');
color: in std_logic_vector(2 downto 0);
red_out, green_out, blue_out: out std_logic
);
end entity;
architecture rtl of pix_gen is
signal clk25: std_logic;
constant blue : std_logic_vector(2 downto 0) := "001";
constant red : std_logic_vector(2 downto 0) := "100";
constant yellow : std_logic_vector(2 downto 0) := "110";
constant green : std_logic_vector(2 downto 0) := "010";
constant black : std_logic_vector(2 downto 0) := "000";
constant white : std_logic_vector(2 downto 0) := "111";
begin
process (clk50) is
begin
if rising_edge(clk50) then
clk25 <= not clk25;
end if;
end process;
process (clk25, color, pixel_x, pixel_y, video_on)is
begin
if video_on = '1' then
if rising_edge(clk25) then
if color = red then
if pixel_x < 640/2 and pixel_y < 480/2 then
red_out <= color(2);
green_out <= color(1);
blue_out <= color(0);
else
red_out <= black(2);
green_out <= black(1);
blue_out <= black(0);
end if;
elsif color = green then
if (pixel_x > 640/2 and pixel_x < 640) and pixel_y < 480/2 then
red_out <= color(2);
green_out <= color(1);
blue_out <= color(0);
else
red_out <= black(2);
green_out <= black(1);
blue_out <= black(0);
end if;
elsif color = blue then
if pixel_x < 640/2 and (pixel_y > 480/2 and pixel_y < 480 ) then
red_out <= color(2);
green_out <= color(1);
blue_out <= color(0);
else
red_out <= black(2);
green_out <= black(1);
blue_out <= black(0);
end if;
elsif color = yellow then
if (pixel_x > 640/2 and pixel_x < 640) and (pixel_y > 480/2 and pixel_y < 480) then
red_out <= color(2);
green_out <= color(1);
blue_out <= color(0);
else
red_out <= black(2);
green_out <= black(1);
blue_out <= black(0);
end if;
elsif color = white then
red_out <= color(2);
green_out <= color(1);
blue_out <= color(0);
else
red_out <= black(2);
green_out <= black(1);
blue_out <= black(0);
end if;
end if;
end if;
end process;
end rtl;