SHARE
TWEET

Untitled

andreahmed Nov 18th, 2016 221 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.NUMERIC_STD.ALL;
  4.  
  5. entity VGA_display is
  6.           port (
  7.             -- Assuming 50MHz clock.If the clock is reduced then it might give the unexpected output.      
  8.                   clock: in std_logic;
  9.              
  10.              -- The counter tells whether the correct position on the screen is reached where the data is to be displayed.
  11.                   hcounter: in integer range 0 to 1023;
  12.                   vcounter: in integer range 0 to 1023;
  13.    
  14.           -- Output the colour that should appear on the screen.
  15.                   pixels : out std_logic_vector(7 downto 0)              
  16.                 );
  17. end VGA_display;
  18.  
  19. architecture Behavioral of VGA_display is  
  20.     -- Intermediate register telling the exact position on display on screen.
  21.          signal x : integer range 0 to 1023 := 100;
  22.          signal y : integer range 0 to 1023 := 80;
  23.          signal addr: INTEGER RANGE 0 TO 15;
  24.          signal pix: STD_LOGIC_VECTOR(7 DOWNTO 0);
  25. begin
  26.  
  27.  
  28.       rom1: entity rom port map(address => addr, data_out => pix);
  29.  
  30.  
  31.  -- On every positive edge of the clock counter condition is checked,
  32.   output1: process(clock)
  33.               begin
  34.                     if rising_edge (clock) then
  35.                    
  36.                     -- If the counter satisfy the condition, then output the colour that should appear.
  37.                         if (hcounter >= 1)  and (hcounter < 128) and (vcounter >= 1) and (vcounter < 128
  38.                                ) then
  39.                                
  40.                           addr <= vcounter * 128 + hcounter;
  41.                    
  42.                           pixels <= pix;
  43.  
  44.                    
  45.                     -- If the condition is not satisfied then the output colour will be black.
  46.                         else
  47.                           pixels <= x"00";
  48.                         end if;
  49.               end if;
  50.            end process;
  51. end Behavioral;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top