Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.22 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.NUMERIC_STD.ALL;
  4. use IEEE.NUMERIC_BIT.ALL;
  5.  
  6.  
  7. entity pic is
  8.   port (
  9.             CLK_50MHz : in  STD_LOGIC;
  10.             PIX_X : in STD_LOGIC_VECTOR(9 downto 0);
  11.             PIX_Y : in STD_LOGIC_VECTOR(8 downto 0);
  12.          RGB : out  STD_LOGIC_VECTOR(2 downto 0)
  13.          );
  14. end pic;
  15.  
  16. architecture Behavioral of pic is
  17. signal cnt : integer range 0 to 50000000 := 0;
  18. signal cnt2 : integer range 0 to 50000000 := 0;
  19. --type RGB_ARR is array (0 to 5) of std_logic_vector(2 downto 0);
  20. signal P_Y,P_X : integer range 0 to 800 := 0;
  21. --signal ARR : RGB_ARR := ( "001", "010", "100", "011", "110", "101");
  22. signal ARR : std_logic_vector(17 downto 0) := ( "001010100011110101");
  23. signal ULX : integer := 31;
  24. signal ULY : integer := 215;
  25.  
  26. begin
  27.  
  28.    P_Y <= To_Integer(Unsigned(PIX_Y));
  29.    P_X <= To_Integer(Unsigned(PIX_X));
  30.    
  31.    
  32.    
  33. -- 50000000 clocks per sec
  34. counter: process(CLK_50MHz)
  35.  
  36.    begin
  37.       if rising_edge(CLK_50MHz) then
  38.          if cnt2 < 1666667 then
  39.             cnt2 <= cnt2 + 1;
  40.          else
  41.             cnt2 <= 0;
  42.             if ULX < 600 then
  43.               ULX <= ULX + 1;
  44.             else
  45.               ULX <= 0;
  46.             end if;
  47.          end if;
  48.          
  49.          if cnt < 50000000 then
  50.             cnt <= cnt + 1;
  51.          else
  52.             cnt <= 0;
  53.             ARR <= ARR(14 downto 0) & ARR(17 downto 15);
  54.          end if;          
  55.       end if;
  56.    end process counter;
  57.  
  58.  
  59. vertical: process(P_Y,P_X)
  60.     begin
  61.          if (P_Y < 240) then
  62.             if (P_X < 213) then
  63.                RGB <= ARR(2 downto 0);
  64.             elsif (P_X < 426) then
  65.                RGB <= ARR(5 downto 3);
  66.             else
  67.                RGB <= ARR(8 downto 6);
  68.             end if;
  69.          else
  70.             if (P_X < 213) then
  71.                RGB <= ARR(11 downto 9);
  72.             elsif (P_X < 426) then
  73.                RGB <= ARR(14 downto 12);
  74.             else
  75.                RGB <= ARR(17 downto 15);
  76.             end if;
  77.          end if;
  78.  
  79.          if (P_Y > ULY and P_Y < ULY+50) then
  80.             if (P_X > ULX and P_X < ULX + 50) then
  81.                RGB <= "000";
  82.             end if;
  83.          end if;        
  84.          
  85.    end process vertical;
  86.  
  87.  
  88. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement