Skip to content
Snippets Groups Projects
Commit 094df1d7 authored by vagle's avatar vagle
Browse files

Petőfi állapot

parent 09a4baf6
No related branches found
No related tags found
No related merge requests found
...@@ -15,11 +15,11 @@ set_property PACKAGE_PIN V19 [get_ports {frame[10]}]; # "VGA-R3" ...@@ -15,11 +15,11 @@ set_property PACKAGE_PIN V19 [get_ports {frame[10]}]; # "VGA-R3"
set_property PACKAGE_PIN V18 [get_ports {frame[11]}]; # "VGA-R4" set_property PACKAGE_PIN V18 [get_ports {frame[11]}]; # "VGA-R4"
set_property PACKAGE_PIN Y19 [get_ports {Vsync}]; # "VGA-VS" set_property PACKAGE_PIN Y19 [get_ports {Vsync}]; # "VGA-VS"
#set_property PACKAGE_PIN P16 [get_ports {BTNC}]; # "BTNC" set_property PACKAGE_PIN P16 [get_ports {set_cell}]; # "BTNC"
#set_property PACKAGE_PIN R16 [get_ports {BTND}]; # "BTND" set_property PACKAGE_PIN R16 [get_ports {move_down}]; # "BTND"
#set_property PACKAGE_PIN N15 [get_ports {BTNL}]; # "BTNL" set_property PACKAGE_PIN N15 [get_ports {move_left}]; # "BTNL"
#set_property PACKAGE_PIN R18 [get_ports {BTNR}]; # "BTNR" set_property PACKAGE_PIN R18 [get_ports {move_right}]; # "BTNR"
#set_property PACKAGE_PIN T18 [get_ports {BTNU}]; # "BTNU" set_property PACKAGE_PIN T18 [get_ports {move_up}]; # "BTNU"
set_property PACKAGE_PIN F22 [get_ports {switch_mode}]; # "SW0" set_property PACKAGE_PIN F22 [get_ports {switch_mode}]; # "SW0"
......
...@@ -82,8 +82,8 @@ signal Hsync_sig, Vsync_sig : std_logic; ...@@ -82,8 +82,8 @@ signal Hsync_sig, Vsync_sig : std_logic;
signal frame_sig : std_logic_vector(11 downto 0); signal frame_sig : std_logic_vector(11 downto 0);
-- simulation processers -- simulation processers
signal shift_register_top : std_logic_vector(0 to cell_number-1); signal shift_register_top : std_logic_vector(0 to cell_number+1);
signal shift_register_middle : std_logic_vector(0 to cell_number-1); signal shift_register_middle : std_logic_vector(0 to cell_number+1);
signal actual_register : std_logic_vector(0 to 0); signal actual_register : std_logic_vector(0 to 0);
--signal copy_shift_register_top : std_logic_vector(0 to cell_number-1); --signal copy_shift_register_top : std_logic_vector(0 to cell_number-1);
...@@ -131,6 +131,8 @@ begin ...@@ -131,6 +131,8 @@ begin
neighbours_count <= (others => '0'); neighbours_count <= (others => '0');
frame_counter <= (others => '0'); frame_counter <= (others => '0');
--cursor_pos_x <= to_unsigned(8,10);
--cursor_pos_y <= to_unsigned(8,10);
cursor_pos_x <= (others => '0'); cursor_pos_x <= (others => '0');
cursor_pos_y <= (others => '0'); cursor_pos_y <= (others => '0');
prev_move_left <= move_left; prev_move_left <= move_left;
...@@ -163,50 +165,51 @@ begin ...@@ -163,50 +165,51 @@ begin
end if; end if;
-- handle shift registers -- handle shift registers
--if switch_mode = '1' and frame_counter = 0 and horizontal_counter(2 downto 0) = 0 and horizontal_counter(9 downto 3) < cell_number+2 and vertical_counter(2 downto 0) = 0 and vertical_counter(9 downto 3) < cell_number+2 then if switch_mode = '1' and frame_counter = 0 and horizontal_counter(2 downto 0) = 0 and horizontal_counter(9 downto 3) < cell_number+2 and vertical_counter(2 downto 0) = 0 and vertical_counter(9 downto 3) < cell_number+2 then
if switch_mode = '1' and frame_counter = 0 and horizontal_counter(2 downto 0) = 0 and horizontal_counter(9 downto 3) < cell_number and vertical_counter(2 downto 0) = 0 and vertical_counter(9 downto 3) < cell_number then --if switch_mode = '1' and frame_counter = 0 and horizontal_counter(2 downto 0) = 0 and horizontal_counter(9 downto 3) < cell_number and vertical_counter(2 downto 0) = 0 and vertical_counter(9 downto 3) < cell_number then
shift_register_top <= shift_register_top(1 to cell_number-1) & shift_register_middle(0); shift_register_top <= shift_register_top(1 to cell_number+1) & shift_register_middle(0);
if horizontal_counter(9 downto 3) /= 0 and horizontal_counter(9 downto 3) < cell_number-1 and vertical_counter(9 downto 3) /= 0 and vertical_counter(9 downto 3) < cell_number-1 then if horizontal_counter(9 downto 3) /= 0 and horizontal_counter(9 downto 3) < cell_number+1 and vertical_counter(9 downto 3) /= 0 and vertical_counter(9 downto 3) < cell_number+1 then
--if horizontal_counter(9 downto 3) < cell_number and vertical_counter(9 downto 3) < cell_number then --if horizontal_counter(9 downto 3) < cell_number and vertical_counter(9 downto 3) < cell_number then
--copy_shift_register_top <= shift_register_top(1 to cell_number-1) & shift_register_middle(0); --copy_shift_register_top <= shift_register_top(1 to cell_number-1) & shift_register_middle(0);
shift_register_middle <= shift_register_middle(1 to cell_number-1) & actual_register; shift_register_middle <= shift_register_middle(1 to cell_number+1) & actual_register;
--copy_shift_register_middle <= shift_register_middle(1 to cell_number-1) & actual_register; --copy_shift_register_middle <= shift_register_middle(1 to cell_number-1) & actual_register;
neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & actual_register; neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & actual_register;
neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register); neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register);
actual_register(0) <= cells(to_integer((vertical_counter(9 downto 3))* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3))); actual_register(0) <= cells(to_integer((vertical_counter(9 downto 3)-1)* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1));
--copy_actual_register(0) <= cells(to_integer((vertical_counter(9 downto 3))* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3))); --copy_actual_register(0) <= cells(to_integer((vertical_counter(9 downto 3))* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)));
else else
shift_register_middle <= shift_register_middle(1 to cell_number-1) & actual_register; shift_register_middle <= shift_register_middle(1 to cell_number+1) & actual_register;
neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & actual_register; neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & actual_register;
-- left top corner -- left top corner
if horizontal_counter(9 downto 3) = 0 and vertical_counter(9 downto 3) = 0 then --if horizontal_counter(9 downto 3) = 0 and vertical_counter(9 downto 3) = 0 then
neighbours_count <= neighbours_count + unsigned(neighbours(8 to 8)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register); -- neighbours_count <= neighbours_count + unsigned(neighbours(8 to 8)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register);
-- right top corner -- right top corner
elsif horizontal_counter(9 downto 3) = cell_number-1 and vertical_counter(9 downto 3) = 0 then --elsif horizontal_counter(9 downto 3) = cell_number-1 and vertical_counter(9 downto 3) = 0 then
neighbours_count <= neighbours_count - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)); -- neighbours_count <= neighbours_count - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2));
-- left bottom corner -- left bottom corner
elsif horizontal_counter(9 downto 3) = 0 and vertical_counter(9 downto 3) = cell_number-1 then --elsif horizontal_counter(9 downto 3) = 0 and vertical_counter(9 downto 3) = cell_number-1 then
neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) - unsigned(neighbours(3 to 3)) - unsigned(neighbours(4 to 4)) - unsigned(neighbours(5 to 5)) + unsigned(neighbours(6 to 6)) + unsigned(neighbours(7 to 7)) + unsigned(neighbours(8 to 8)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0)); -- neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) - unsigned(neighbours(3 to 3)) - unsigned(neighbours(4 to 4)) - unsigned(neighbours(5 to 5)) + unsigned(neighbours(6 to 6)) + unsigned(neighbours(7 to 7)) + unsigned(neighbours(8 to 8)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0));
-- right bottom corner -- right bottom corner
elsif horizontal_counter(9 downto 3) = cell_number-1 and vertical_counter(9 downto 3) = cell_number-1 then --elsif horizontal_counter(9 downto 3) = cell_number-1 and vertical_counter(9 downto 3) = cell_number-1 then
neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)); -- neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1));
-- top edge -- top edge
elsif vertical_counter(9 downto 3) = 0 then --elsif vertical_counter(9 downto 3) = 0 then
neighbours_count <= neighbours_count - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register); -- neighbours_count <= neighbours_count - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register);
-- left edge -- left edge
elsif horizontal_counter(9 downto 3) = 0 then --elsif horizontal_counter(9 downto 3) = 0 then
neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) - unsigned(neighbours(3 to 3)) - unsigned(neighbours(4 to 4)) - unsigned(neighbours(5 to 5)) + unsigned(neighbours(6 to 6)) + unsigned(neighbours(7 to 7)) + unsigned(neighbours(8 to 8)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register); -- neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) - unsigned(neighbours(3 to 3)) - unsigned(neighbours(4 to 4)) - unsigned(neighbours(5 to 5)) + unsigned(neighbours(6 to 6)) + unsigned(neighbours(7 to 7)) + unsigned(neighbours(8 to 8)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register);
-- right edge -- right edge
elsif horizontal_counter(9 downto 3) = cell_number-1 then --elsif horizontal_counter(9 downto 3) = cell_number-1 then
neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)); -- neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2));
-- bottom edge -- bottom edge
elsif vertical_counter(9 downto 3) = cell_number-1 then --elsif vertical_counter(9 downto 3) = cell_number-1 then
neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0)); -- neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0));
end if; --end if;
actual_register(0) <= cells(to_integer((vertical_counter(9 downto 3))* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3))); neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register);
actual_register(0) <= '0';--cells(to_integer((vertical_counter(9 downto 3))* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)));
end if; end if;
if vertical_counter(9 downto 3) >= 2 and horizontal_counter(9 downto 3) >= 2 then if vertical_counter(9 downto 3) >= 2 and horizontal_counter(9 downto 3) >= 2 then
...@@ -217,21 +220,26 @@ begin ...@@ -217,21 +220,26 @@ begin
-- end if; -- end if;
--end loop; --end loop;
if horizontal_counter(9 downto 3) = 0 or horizontal_counter(9 downto 3) = cell_number+1 or vertical_counter(9 downto 3) = 0 or vertical_counter(9 downto 3) = cell_number+1 then
cells(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '0';
cells_to_draw(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '0';
else
if neighbours(4)='1' then if neighbours(4)='1' then
if neighbours_count = 3 or neighbours_count = 4 then if neighbours_count = 3 or neighbours_count = 4 then
cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-3)) <= '1'; cells(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '1';
cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-3)) <= '1'; cells_to_draw(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '1';
else else
cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-3)) <= '0'; cells(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '0';
cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-3)) <= '0'; cells_to_draw(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '0';
end if; end if;
else else
if neighbours_count = 3 then if neighbours_count = 3 then
cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-3)) <= '1'; cells(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '1';
cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-3)) <= '1'; cells_to_draw(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '1';
else else
cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-3)) <= '0'; cells(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '0';
cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-3)) <= '0'; cells_to_draw(to_integer((vertical_counter(9 downto 3)-2) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-4)) <= '0';
end if;
end if; end if;
end if; end if;
...@@ -242,15 +250,19 @@ begin ...@@ -242,15 +250,19 @@ begin
-- moving with cursor -- moving with cursor
if switch_mode = '0' then if switch_mode = '0' then
if prev_move_left = '0' and move_left = '1' and cursor_pos_x /= 0 then if prev_move_left = '0' and move_left = '1' and cursor_pos_x /= 0 then
--if prev_move_left = '0' and move_left = '1' and cursor_pos_x /= 8 then
cursor_pos_x <= cursor_pos_x - 8; cursor_pos_x <= cursor_pos_x - 8;
end if; end if;
if prev_move_right = '0' and move_right = '1' and cursor_pos_x /= (cell_number-1)*8 then if prev_move_right = '0' and move_right = '1' and cursor_pos_x /= (cell_number-1)*8 then
--if prev_move_right = '0' and move_right = '1' and cursor_pos_x /= (cell_number-2)*8 then
cursor_pos_x <= cursor_pos_x + 8; cursor_pos_x <= cursor_pos_x + 8;
end if; end if;
if prev_move_up = '0' and move_up = '1' and cursor_pos_y /= 0 then if prev_move_up = '0' and move_up = '1' and cursor_pos_y /= 0 then
--if prev_move_up = '0' and move_up = '1' and cursor_pos_y /= 8 then
cursor_pos_y <= cursor_pos_y - 8; cursor_pos_y <= cursor_pos_y - 8;
end if; end if;
if prev_move_down = '0' and move_down = '1' and cursor_pos_y /= (cell_number-1)*8 then if prev_move_down = '0' and move_down = '1' and cursor_pos_y /= (cell_number-1)*8 then
--if prev_move_down = '0' and move_down = '1' and cursor_pos_y /= (cell_number-2)*8 then
cursor_pos_y <= cursor_pos_y + 8; cursor_pos_y <= cursor_pos_y + 8;
end if; end if;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment