Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - problem with variable values

 
Thread Tools Search this Thread
Old 05-25-2006, 06:13 PM   #1
Default problem with variable values


Hi!

I'm writing a program in VHDL which should draw a line on the monitor.
I have implemented vga_sync module, RAM memory and other necesarry
things. Almost everything is OK. So i don't know what is happening with
variables values

I have a process which is writing to memory pixel coordinates in
resolution 80x60 at the Altera UP-2 (Flex 10K) Board.

CODE
------------------------------------------------------------------------------------------------------------------------------------
bresenham rocess

variable punkt1_x : std_logic_vector(6 downto 0) :=
CONV_STD_LOGIC_VECTOR(20,7);
variable punkt2_x : std_logic_vector(6 downto 0) :=
CONV_STD_LOGIC_VECTOR(20,7);
variable punkt1_y : std_logic_vector(6 downto 0) :=
CONV_STD_LOGIC_VECTOR(40,7);
variable punkt2_y : std_logic_vector(6 downto 0) :=
CONV_STD_LOGIC_VECTOR(40,7);

variable i :integer;

variable delta_x : std_logic_vector (6 downto 0) ;
variable delta_y : std_logic_vector (6 downto 0) ;

variable det : std_logic_vector (6 downto 0) ;

variable flag2 : std_logic ;

begin
WAIT UNTIL flag'event and flag='1';

if punkt2_y >= punkt1_y then
flag2 := '0';
delta_y := punkt2_y - punkt1_y;
else
flag2 := '1';
delta_y := punkt1_y - punkt2_y;
end if;

delta_x := punkt2_x - punkt1_x;
pixels_to_save <= "1";
if delta_x = "0000000" and delta_y = "0000000" then
adres_pixela_w <= "0100101001010";
else
adres_pixela_w <= "0110111001110";

if delta_x = "0000000" then
if punkt2_y >= punkt1_y then
punkt1_y := punkt1_y + 1;
--p1_y <= punkt1_y;
else
punkt1_y := punkt1_y - 1;
--p1_y <= punkt1_y;
end if;
elsif delta_y = "0000000" then
if punkt2_x >= punkt1_x then
punkt1_x := punkt1_x + 1;
--p1_x <= punkt1_x;
else
punkt1_x := punkt1_x + 1;
--p1_x <= punkt1_x;
end if;
else

if delta_x >"0000000" then
if flag2= '0' then
if delta_x >= delta_y then
det := delta_y(5 downto 0)&"0" - delta_x;
if det >= "0000000" then
punkt1_x := punkt1_x + "0000001";
punkt1_y := punkt1_y + "0000001";
--p1_x <= punkt1_x;
--p1_y <= punkt1_y;
else
punkt1_x := punkt1_x +1;
--p1_x <= punkt1_x;
end if;
else
det := delta_x(5 downto 0)&"0" - delta_y;
if det >= "0000000" then
punkt1_x := punkt1_x + "0000001";
punkt1_y := punkt1_y + "0000001";
--p1_x <= punkt1_x;
--p1_y <= punkt1_y;
else
punkt1_y := punkt1_y + "0000001";
--p1_y <= punkt1_y;
end if;
end if;

else --delta_y < 0
if delta_x >= delta_y then
det := delta_y(5 downto 0)&"0" - delta_x;
if det >= "0000000" then
punkt1_x := punkt1_x + "0000001";
punkt1_y := punkt1_y - "0000001";
--p1_x <= punkt1_x;
--p1_y <= punkt1_y;
else
punkt1_x := punkt1_x + "0000001";
--p1_x <= punkt1_x;
end if;

else --przyrasta po y
det := delta_x(5 downto 0)&"0" - delta_y;
if det >= "0000000" then
punkt1_x := punkt1_x + "0000001";
punkt1_y := punkt1_y - "0000001";
--p1_x <= punkt1_x;
--p1_y <= punkt1_y;
else
punkt1_y := punkt1_y - "0000001";
--p1_y <= punkt1_y;
end if;

end if;
end if;
end if ;
end if ;
end if;

end process bresenham;
---------------------------------------------------------------------------
Siganl flag in the high is determining that we can write to the memory.


And the main problem is here :
CODE
-----------------------------------
if delta_x = "0000000" and delta_y = "0000000" then
adres_pixela_w <= "0110111001110";
else
adres_pixela_w <= "0110111001110";
end if;
------------------------------------
As you can see the value of delta_x and delta_y is constant and equal
0. So WHY this process is writing two points not one.

The adres_pixela_w is a signal which is determining the address in
memory.

link to the complete project is here

http://student.agh.edu.pl/~dzmuda/put_pixel.zip

Can anybody say me why it is happening?

Thanks a lot,
Daniel.



nulon@o2.pl
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox values problem in gridview thanigaimani.thirumalai Software 0 11-09-2007 05:12 AM
Dial Up Problem smackedass A+ Certification 3 02-02-2007 11:59 PM
Re: Virus Problem ** Help!** David BlandIII A+ Certification 1 03-02-2004 06:00 PM
Re: Serious Computer Problem hootnholler A+ Certification 1 11-24-2003 12:18 PM
Re: Serious Computer Problem Bret A+ Certification 0 11-19-2003 12:51 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46