Skip to content
Snippets Groups Projects
Commit e4385599 authored by Mlinkó Péter's avatar Mlinkó Péter
Browse files

Main file modified

parent 06e01d3d
Branches
No related tags found
No related merge requests found
......@@ -58,8 +58,8 @@ port
end component;
signal clk_25MHz, locked : std_logic;
signal cells : std_logic_vector(0 to cell_number-1) := (others => '0');
signal cells_to_draw : std_logic_vector(0 to cell_number-1) := (others => '0');
signal cells : std_logic_vector(0 to cell_number*cell_number-1) := (511 => '1', 512 => '1', 513 => '1',others => '0');
signal cells_to_draw : std_logic_vector(0 to cell_number*cell_number-1) := (others => '0');
-- drawing period's constants
constant HORIZONTAL_SYNC_PULSE : integer := 800;
......@@ -96,6 +96,7 @@ clk_gen_25MHz : clk_wiz_0
);
options : process(clk_25MHz,locked)
variable neighbour_cnt : unsigned(3 downto 0) := (others=>'0');
begin
if locked = '0' then
horizontal_counter <= (others => '0');
......@@ -131,11 +132,45 @@ begin
end if;
-- handle shift registers
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+2 and vertical_counter(9 downto 3) < cell_number+2 then
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) & cells(to_integer(vertical_counter(9 downto 3) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)));
neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & cells(to_integer(vertical_counter(9 downto 3) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)));
-- TODO
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
shift_register_middle <= shift_register_middle(1 to cell_number-1) & cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1));
neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & cells(to_integer((vertical_counter(9 downto 3) -1)* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1));
else
shift_register_middle <= shift_register_middle(1 to cell_number-1) & '0';
neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & '0';
end if;
if vertical_counter(9 downto 3) >= 2 and horizontal_counter(9 downto 3) >= 2 then
neighbour_cnt := (others=>'0');
for i in 0 to 8 loop
if (neighbours(i)) = '1' then
neighbour_cnt := neighbour_cnt+1;
end if;
end loop;
if neighbours(4)='1' then
if neighbour_cnt = 3 or neighbour_cnt = 4 then
cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '1';
cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '1';
else
cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '0';
cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '0';
end if;
else
if neighbour_cnt = 3 then
cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '1';
cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '1';
else
cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '0';
cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '0';
end if;
end if;
end if;
end if;
-- sign options
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment