problem with variable values

Guest
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 :process

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.
 

Welcome to EDABoard.com

Sponsor

Back
Top