Advertisement
wojtas626

Untitled

Jan 28th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.82 KB | None | 0 0
  1. // zegar 40MHz
  2. // 1 cykl 25ns
  3.  
  4.  
  5.  
  6. entity vga is
  7.     port( CLK40 : in std_logic;
  8.           RESET : in std_logic;
  9.           posx : in std_logic_vector(10 downto 0);
  10.           posy : in std_logic_vector(9 downto 0);
  11.           KOLOR : out std_logic_vector(2 downto 0);
  12.           SYN_POZ : out std_logic;
  13.           SYN_PION : out std_logic
  14.     );
  15. end vga;
  16.  
  17. architecture arch_vga of vga is
  18.     signal x : std_logic_vector(10 downto 0);
  19.     signal y : std_logic_vector(9 downto 0);
  20.    
  21.     process (CLK40, RESET)
  22.     begin
  23.         if (RESET = '1') then
  24.             obr <= "010 000 000 000 000 000 000 000 000 000         --rysunek 10x10
  25.                     000 010 001 000 000 000 000 000 000 000
  26.                     000 000 000 000 000 000 000 000 000 000
  27.                     000 000 000 000 110 000 000 000 000 000
  28.                     000 000 000 000 000 000 000 000 000 000
  29.                     000 000 010 000 000 111 000 000 000 000
  30.                     100 000 000 000 000 000 000 000 000 000
  31.                     000 000 000 000 000 000 000 000 000 000
  32.                     000 000 000 000 000 000 000 000 000 000
  33.                     000 000 000 000 000 000 000 000 000 000";
  34.             x <= (others => '0');
  35.             y <= (others => '0');
  36.         elsif (CLK40''event and CLK = '1') then
  37.             if (x > 800 or y > 600) then
  38.                 KOLOR <= "000";
  39.             elsif (x >= posx and x < posx + 10 and y > posy and y < posy + 10) then
  40.                 obr <= obr(296 downto 0) & obr(299 downto 297);
  41.                 KOLOR <= obr(299 downto 297);
  42.             else
  43.                 KOLOR <= "111"; -- biale tlo
  44.  
  45.             x <= x + 1;
  46.             if (x = 1055) then // koniec linii, jeden mniejsze
  47.                 x <= (others => '0');
  48.                 y <= y + 1;
  49.                 if (y = 627) // koniec klatki, jeden mniejsze
  50.                     y <= (other => '0');
  51.                 end if;
  52.             end if;
  53.         end if;
  54.     end process;
  55.  
  56.     SYN_POZ <= '0' when x >= 840 and x <= 968 else '1';
  57.     SYN_PION <= '0' when y >= 601 and y <= 605 else '1';   
  58.  
  59. end arch_vga;
  60.  
  61. kolor <= "000" when x > 1259 or y >= 480 else
  62.         "100" when x >= posx and x < posx + 10 and y >= posy and y < posy + 10 else
  63.         "010";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement