Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.55 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    20:37:43 01/14/2019
  6. -- Design Name:
  7. -- Module Name:    test - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.numeric_std.all;
  23.  
  24. -- Uncomment the following library declaration if using
  25. -- arithmetic functions with Signed or Unsigned values
  26. --use IEEE.NUMERIC_STD.ALL;
  27.  
  28. -- Uncomment the following library declaration if instantiating
  29. -- any Xilinx primitives in this code.
  30. --library UNISIM;
  31. --use UNISIM.VComponents.all;
  32.  
  33. entity test is
  34.     Port ( CLK_50MHz : in  STD_LOGIC;
  35.            RGB : in  STD_LOGIC_VECTOR (2 downto 0);
  36.            VGA_R : out  STD_LOGIC;
  37.            VGA_G : out  STD_LOGIC;
  38.            VGA_B : out  STD_LOGIC;
  39.            VGA_HS : out  STD_LOGIC;
  40.            VGA_VS : out  STD_LOGIC;
  41.            PIX_X : out  STD_LOGIC_VECTOR (9 downto 0);
  42.            PIX_Y : out  STD_LOGIC_VECTOR (8 downto 0));
  43. end test;
  44.  
  45. architecture Behavioral of test is
  46.     signal CLK_25MHz: STD_LOGIC  := '0';
  47.    signal counter : integer range 0 to 255 := 0;
  48.     signal h_cnt : integer range 0 to 799 := 0;
  49.     signal v_cnt : integer range 0 to 520 := 0;
  50. begin
  51.  
  52. clk_div :process(CLK_50MHz)
  53.     begin
  54.         if rising_edge(CLK_50MHz) then
  55.             if (counter = 1) then
  56.             CLK_25MHz <= NOT(CLK_25MHz);
  57.             counter <= 0;
  58.          else
  59.                 counter <= counter + 1;
  60.             end if;
  61.         end if;
  62.     end process;
  63.    
  64. counters :process(CLK_25MHz)
  65.     begin
  66.         if rising_edge(CLK_25MHz) then
  67.             if (h_cnt = 799) then
  68.                 VGA_HS <= '0'; -- back to start of line
  69.             h_cnt <= 0;
  70.                 v_cnt <= v_cnt + 1;
  71.                
  72.                 if (v_cnt = 520) then
  73.                     VGA_VS <= '0'; -- back to start of monitor
  74.                     v_cnt <= 0;
  75.                 end if;
  76.             else
  77.                 h_cnt <= h_cnt + 1;
  78.                 VGA_HS <= '1'; -- keep signal up
  79.                 VGA_VS <= '1'; -- keep signal up
  80.             end if;
  81.         end if;
  82.     end process;
  83.  
  84. color :process(h_cnt, v_cnt, RGB)
  85.     begin
  86.         if h_cnt < 639 and v_cnt < 479 then
  87.             VGA_R <= RGB(0);
  88.             VGA_G <= RGB(1);
  89.             VGA_B <= RGB(2);
  90.         else
  91.             VGA_R <= '0';
  92.             VGA_G <= '0';
  93.             VGA_B <= '0';
  94.         end if;
  95.     end process;
  96.    
  97.     PIX_X <= std_logic_vector(to_unsigned(myStr( conv_integer(h_cnt)),8));
  98.    PIX_Y <= std_logic_vector(to_unsigned(myStr( conv_integer(v_cnt)),8));
  99.  
  100. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement