Загрузка данных


library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity slow_generator is
    port (
        clk        : in  std_logic;
        reset_btn  : in  std_logic;
        show_btn   : in  std_logic;
        slow       : out std_logic;
        slow_fall  : out std_logic
    );
end slow_generator;

architecture rtl of slow_generator is

    signal show_clean : std_logic;
    signal show_prev  : std_logic := '0';
    signal slow_prev  : std_logic := '0';
    
    -- ✅ ВНУТРЕННИЙ сигнал slow_internal
    signal slow_internal : std_logic := '0';

begin

    -- Фильтр кнопки
    process(clk)
        variable counter : integer range 0 to 1000000 := 0;
    begin
        if rising_edge(clk) then
            if reset_btn = '0' then
                if counter < 1000000 then
                    counter := counter + 1;
                    show_clean <= '0';
                else
                    show_clean <= '1';
                end if;
            else
                counter := 0;
                show_clean <= '0';
            end if;
        end if;
    end process;

    -- Детектор фронта → Slow (1 такт)
    process(clk)
    begin
        if rising_edge(clk) then
            if reset_btn = '1' then
                show_prev <= '0';
                slow_internal <= '0';  -- ✅ Используем внутренний сигнал
            else
                show_prev <= show_clean;
                if show_clean = '1' and show_prev = '0' then
                    slow_internal <= '1';
                else
                    slow_internal <= '0';
                end if;
            end if;
        end if;
    end process;

    -- Детектор спада Slow
    process(clk)
    begin
        if rising_edge(clk) then
            if reset_btn = '1' then
                slow_prev <= '0';
            else
                slow_prev <= slow_internal;  -- ✅ Читаем из внутреннего сигнала
            end if;
        end if;
    end process;
    
    slow_fall <= slow_prev and not slow_internal;  -- ✅ Используем внутренний сигнал
    
    -- ✅ Присваиваем внутренний сигнал выходному порту
    slow <= slow_internal;

end rtl;