andreahmed

Untitled

Nov 25th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.NUMERIC_STD.ALL;
  4.  
  5.  
  6. entity VGA_display is
  7. port (
  8. -- Assuming 50MHz clock.If the clock is reduced then it might give the unexpected output.
  9. clock: in std_logic;
  10.  
  11. -- The counter tells whether the correct position on the screen is reached where the data is to be displayed.
  12. hcounter: in integer range 0 to 1023;
  13. vcounter: in integer range 0 to 1023;
  14.  
  15. -- Output the colour that should appear on the screen.
  16. pixels : out std_logic_vector(7 downto 0)
  17. );
  18. end VGA_display;
  19.  
  20. architecture Behavioral of VGA_display is
  21. -- Intermediate register telling the exact position on display on screen.
  22. signal x : integer range 0 to 1023 := 100;
  23. signal y : integer range 0 to 1023 := 80;
  24. signal addr: INTEGER RANGE 0 TO 15;
  25. signal pix: STD_LOGIC_VECTOR(7 DOWNTO 0);
  26. -- Clock period definitions
  27. constant Clk_period : time := 10 ns;
  28.  
  29. begin
  30.  
  31.  
  32. rom1: entity work.rom port map(address => addr, data_out => pix, clk => clock);
  33.  
  34.  
  35.  
  36. -- On every positive edge of the clock counter condition is checked,
  37. output1: process(clock)
  38. begin
  39. if rising_edge (clock) then
  40.  
  41. -- If the counter satisfy the condition, then output the colour that should appear.
  42. if (hcounter >= 1) and (hcounter < 128) and (vcounter >= 1) and (vcounter < 128
  43. ) then
  44.  
  45. addr <= vcounter * 128 + hcounter;
  46.  
  47. pixels <= pix;
  48.  
  49. -- If the condition is not satisfied then the output colour will be black.
  50. else
  51. pixels <= x"00";
  52. end if;
  53. end if;
  54. end process;
  55. end Behavioral;
Add Comment
Please, Sign In to add comment