Skip to content
Snippets Groups Projects
Commit 09a4baf6 authored by vagle's avatar vagle
Browse files

some edgy commit

parent acc2b904
Branches
No related tags found
No related merge requests found
......@@ -85,6 +85,11 @@ signal frame_sig : std_logic_vector(11 downto 0);
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 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_middle : std_logic_vector(0 to cell_number-1);
--signal copy_actual_register : std_logic_vector(0 to 0);
signal neighbours : std_logic_vector(0 to 8);
signal neighbours_count : unsigned(3 downto 0);
signal frame_counter : unsigned(6 downto 0);
......@@ -162,17 +167,46 @@ begin
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);
--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) /= 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
--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;
--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_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)));
--copy_actual_register(0) <= cells(to_integer((vertical_counter(9 downto 3))* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)));
else
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_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 <= (others => '0');
-- left top corner
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);
-- right top corner
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));
-- left bottom corner
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));
-- right bottom corner
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));
-- top edge
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);
-- left edge
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);
-- right edge
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));
-- bottom edge
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));
end if;
actual_register(0) <= cells(to_integer((vertical_counter(9 downto 3))* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)));
end if;
if vertical_counter(9 downto 3) >= 2 and horizontal_counter(9 downto 3) >= 2 then
......@@ -251,6 +285,8 @@ begin
-- position changing
if vertical_counter = VERTICAL_SYNC_PULSE-1 then
vertical_counter <= (others => '0');
neighbours_count <= (others => '0');
neighbours <= (others => '0');
if frame_counter = 63 then
frame_counter <= (others => '0');
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment