Если я не ошибаюсь, то в вышеприведенных схемах не учтен вопрос метастабильности. Я предпочитаю использовать несколько иную схему, которая учитывает метастабильность триггеров.
Код
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity synchronizer is
Port (
clk: in std_logic;
en: in std_logic;
run: in std_logic;
ce: out std_logic
);
end synchronizer;
architecture Behavioral of synchronizer is
signal Q0, Q1, Q2: std_logic := '0';
begin
process(run,en)
begin
if rising_edge(run) and en='1' then
Q0 <= not Q1;
end if;
end process;
process(clk)
begin
if rising_edge(clk) then
Q1 <= Q0;
Q2 <= Q1;
end if;
end process;
ce <= Q2 xor Q1;
end Behavioral;
Всего три триггера и один инвертор и элемент xor.