Escolar Documentos
Profissional Documentos
Cultura Documentos
The problem: I want to display dynamic characters on the screen. The normal work is
to use a SDRAM to save the contents of the VGA matrix. If I will use 680 * 460 so I
have to use matrix 680*460 of 3 bytes for the red and green and blue.
But I will make it simple and will use 2 colors so I just need 1 bit. So I can design a
matrix using VHDL which will be 680*640. Oh, there is another problem. It takes too
much time to synthesize the code because every bit is connected as a signal.
I had a nice idea. I will show the char in 10*10 bit. So the 680*460 matrix can be
only 86*46. it will take no time in systemization. I considered the 86*46 matrix as a
pointer which point at the small matrices.
I wanted to make a complete system which contain (keyboard, VGA, UART, GPIO,
LCD and soft-processor). I have already design the rest of the system but I want to
make it completely.
Well, I don't like to talk much. Just look at the code. It is for Spartan 3E for
simplification.
Anyway, this is the code. It is not the final code but you will see some alphabets in
some places in the screen. You just have to get an input from outside to write on the
screen wherever you want.
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 15:40:42 12/08/2008
-- Design Name:
-- Module Name: Sync_XY_generator - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use ieee.numeric_std.all;
use ieee.math_real.all;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity vga is
Port ( CLK50_in : in STD_LOGIC;
HS : out STD_LOGIC;
VS : out STD_LOGIC;
r,g,b : out std_logic
);
end vga;
constant am : memory_array:= (
"0000000000",
"0111111110", --
"0111111110" , --
"0110000110", --
"0110000110" , --
"0111111110", --
"0111111110", --
"0110000110", --
"0110000110", --
"0000000000"
);
constant bm : memory_array:= (
"0000000000",
"0111111110", --
"0111111110" , --
"0110000110", --
"0110000110" , --
"0111111100", --
"0110000110", --
"0110000110", --
"0111111110",--
"0000000000"
);
--b_on <=
--'1' when (b_x_l <= x ) and (x <= b_x_r) and (b_y_u <=y) and (b_y_d >= y) else
--'0';
--c_on <=
--'1' when (c_x_l <= x ) and (x <= c_x_r) and (c_y_u <=y) and (c_y_d >= y) else
--'0';
--process(clk50_in,tick)
--begin
--if tick='1' then
--ball_x_r <= ball_x_r + 1;
--ball_x_l <= ball_x_l + 1;
--end if;
--if ball_x_r = 510 then
--ball_x_r <=100;
--ball_x_l <=107;
--end if;
--end process;
x <= H_counter_value-144;
y <= V_counter_value-31;
--if (H_counter_value >=144 and H_counter_value < 783 and V_counter_value >=31
and V_counter_value <510) then
-- if((x>=0)and(x<256)and(y>=0)and(y<256))then
-- addr<=addr+1;
-- ena<='1';
-- r<='0';b<='0';--g<=(others=>'0');
-- g<='1';
--else
-- r<='1';b<='0';g<='0';addr<="0000000000000000";
-- ena<='0';
-- end if;
--else
-- r<='0';g<='0';b<='0';addr<="0000000000000000";
--reed<='0';ena<='0';
--end if;
if (H_counter_value < 96)then
HS <= '0';
else
HS <= '1';
end if;
if (V_counter_value < 2)then
VS <= '0';
else
VS <= '1';
end if;
end if;
end process;
-------process(clk25,a_on,b_on,c_on)
--variable x_object,y_object :integer;
--variable d:std_logic;
--variable mem:memory_array;
--begin
--if clk25'event and clk25='0' then
--if a_on ='1' then
--x_object:= x - a_x_l ;
--y_object:= y - a_y_u ;
--data :=mem1(y_object);
--c<= data (x_object);
--mem(x)(y) <= mem1(x_object)(y_object);
--elsif b_on ='1' then
--x_object:= x - b_x_l;
--y_object:= y - b_y_u;
--data :=mem2(y_object);
--c<= data (x_object);
--mem(x)(y) <= mem2(x_object)(y_object);
--elsif c_on='1' then
--x_object:= x - c_x_l;
--y_object:= y - c_y_u;
--mem(x)(y) <= mem3(x_object)(y_object);
--data :=mem3(y_object);
--c<= data (x_object);
--end if;
--end if;
--end process;
mem(0,0)<= "00000001";
mem(1,0)<= "00000010";
mem(0,3)<= "00000011";
mem(10,10)<= "00001100";
mem(11,25)<= "00010110";
mem(0,30)<= "00001011";
process(clk25,x,y)
variable v,u:integer;
begin
for t in 0 to 64 loop
u:= t * 10;
if u=y then
yd:=t;
end if;
end loop;
c<= mem (xd,yd);
xx<= x - 10* xd;
yy<=y - 10*yd;
end if;
end process;
with c select
data<= am(yy) when "00000001",
bm(yy) when "00000010",
cm(yy) when "00000011",
dm(yy) when "00000100",
em(yy) when "00000101",
fm(yy) when "00000110",
gm(yy) when "00000111",
hm(yy) when "00001000",
im(yy) when "00001001",
jm(yy) when "00001010",
km(yy) when "00001011",
lm(yy) when "00001100",
mm(yy) when "00001101",
nm(yy) when "00001110",
om(yy) when "00001111",
pm(yy) when "00010000",
qm(yy) when "00010001",
rm(yy) when "00010010",
sm(yy) when "00010011",
tm(yy) when "00010100",
um(yy) when "00010101",
vm(yy) when "00010110",
wm(yy) when "00010111",
xm(yy) when "00011000",
ym(yy) when "00011001",
zm(yy) when "00011010",
spa(yy) when others;
process(clk25,H_counter_value,V_counter_value,c)
begin
if (H_counter_value >=144 and H_counter_value < 783 and V_counter_value >=31
and V_counter_value <510) then
r<='0';
b<=data(xx);
g<='0';
end if;
end process;
end Behavioral;
Muhammad
modeonz007@yahoo.com