Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
14Activity
0 of .
Results for:
No results containing your search query
P. 1
Simple VGA

Simple VGA

Ratings: (0)|Views: 2,687 |Likes:
Published by muhammad
this is a simple VGA code for spartan 3E.
this is a simple VGA code for spartan 3E.

More info:

Published by: muhammad on Apr 20, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

01/09/2013

pdf

text

original

 
Simple VGA output using Spartan 3eWhile I was working on the vga module I have produced some objects with differentcolors and shapes. Unfortunately, Spartan 3e can provide only 1 bit for each color andthis limits your choices. Not like Spartan 3e which has 4 bit for each color, also not asvirtex2 which has 8 bit color using an IC .This is a simple code for the VGA using Spartan 3elibrary IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;use ieee.numeric_std.all;---- Uncomment the following library declaration if instantiating---- any Xilinx primitives in this code.--library UNISIM;--use UNISIM.VComponents.all;entity vga isPort ( CLK50_in : in STD_LOGIC;
 
HS : out STD_LOGIC;VS : out STD_LOGIC;r,g,b : out std_logic);end vga;architecture Behavioral of vga is------- signals declarationssignal clk25,reed,ena : std_logic;signal H_counter_value : integer;--std_logic_vector(9 downto 0);signal V_counter_value : integer;--std_logic_vector(9 downto 0);signal x ,x_ball: integer; --std_logic_vector(9 downto 0);signal y ,y_ball: integer; -- std_logic_vector(9 downto 0);signal data : std_logic_vector(7 downto 0);signal addr : std_logic_vector(15 downto 0);signal c:std_logic;constant obj1_x_l : integer := 20 ;constant obj1_x_r: integer := 30 ;constant obj2_x_l : integer := 200 ;constant obj2_x_r: integer := 230;constant obj2_y_u : integer := 50 ;constant obj2_y_d: integer := 150 ;constant ball_x_l : integer := 100 ;constant ball_x_r: integer := 107;constant ball_y_u : integer := 150 ;constant ball_y_d: integer := 157 ;--signal gdata: std_logic_vector(7 downto 0):="11110000";signal obj1_rgb:std_logic_vector(2 downto 0) := "001";signal obj2_rgb:std_logic_vector(2 downto 0) := "010";signal ball_rgb:std_logic_vector(2 downto 0) := "011";signal obj1_on,obj2_on,ball_on:std_logic;--subtype tmp is integer;type memory_array is array ( 0 to 7 ) of std_logic_vector ( 0 to 7 ) ;constant mem : memory_array:= ("00111100", -- * * * *"01111110" , -- * * * * * *"11111111", -- * * * * * * * *"11111111" , -- * * * * * * * *"11111111", -- * * * * * * * *"11111111", -- * * * * * * * *"01111110", -- * * * * * *"00111100" -- * * * *); begin
 
obj1_on <='1' when (obj1_x_l <= x ) and (x <= obj1_x_r) else'0';obj2_on <='1' when (obj2_x_l <= x ) and (x <= obj2_x_r) and (obj2_y_u <=y) and (obj2_y_d >=y) else'0'; ball_on <='1' when (ball_x_l <= x ) and (x <= ball_x_r) and (ball_y_u <=y) and (ball_y_d >= y)else'0';-- generate a 25Mhz clock divide_by_two_counter :process (clk50_in)beginif clk50_in'event and clk50_in='1' thenclk25 <= not clk25;end if;end process;HS_VS_generator :process (clk25) beginif clk25'event and clk25='1' thenH_counter_value <= H_counter_value +1;if (H_counter_value = 800)thenH_counter_value <= 0;V_counter_value <= V_counter_value +1;end if;if (V_counter_value = 521)thenV_counter_value <= 0;end if;x <= H_counter_value-143;y <= V_counter_value-31;x_ball<= x - ball_x_l;y_ball<= y - ball_y_u;--if (H_counter_value >=144 and H_counter_value < 783 and V_counter_value >=31and V_counter_value <510) then--if((x>=0)and(x<256)and(y>=0)and(y<256))then--addr<=addr+1;--reed<='1';ena<='1';--r<='0';b<='0';--g<=(others=>'0');--g<='1';--else

Activity (14)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
liked this
Martin Mitton liked this
sareluis2727 liked this
Laurentscribd liked this
mus0potamia liked this
haseeb_00001 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->