J
John
Guest
Hi
I've heard that you can use 2 flip flops to synchronize 2 different clock
domains. Is this correct?
I've tried to do it using the following code, but the output is far from
correct. Can anyone point out what I'm doing wrong?
Thanks in advance,
FLIP FLOP
=========
entity flipflop is
Port ( D : in std_logic;
C : in std_logic;
Q : out std_logic
);
end flipflop;
architecture Behavioral of flipflop is
begin
ff : process(C)
begin
if C'event and C = '1' then
Q <= D;
end if;
end process ff;
end Behavioral;
THE PART TO DO THE SYNC
=======================
CLK is the fast clock in the first domain and SIG_IN is the slower clock in
the second domain.
entity sync is
Port ( CLK : in std_logic;
SIG_IN : std_logic;
SYNC_OUT : out std_logic
);
end sync;
architecture Behavioral of sync is
COMPONENT flipflop
PORT(
D : IN std_logic;
C : IN std_logic;
Q : OUT std_logic
);
END COMPONENT;
signal wire : std_logic;
begin
ff0 : flipflop PORT MAP(
D => SIG_IN,
C => CLK,
Q => wire
);
ff1 : flipflop PORT MAP(
D => wire,
C => CLK,
Q => SYNC_OUT
);
end Behavioral;
I've heard that you can use 2 flip flops to synchronize 2 different clock
domains. Is this correct?
I've tried to do it using the following code, but the output is far from
correct. Can anyone point out what I'm doing wrong?
Thanks in advance,
FLIP FLOP
=========
entity flipflop is
Port ( D : in std_logic;
C : in std_logic;
Q : out std_logic
);
end flipflop;
architecture Behavioral of flipflop is
begin
ff : process(C)
begin
if C'event and C = '1' then
Q <= D;
end if;
end process ff;
end Behavioral;
THE PART TO DO THE SYNC
=======================
CLK is the fast clock in the first domain and SIG_IN is the slower clock in
the second domain.
entity sync is
Port ( CLK : in std_logic;
SIG_IN : std_logic;
SYNC_OUT : out std_logic
);
end sync;
architecture Behavioral of sync is
COMPONENT flipflop
PORT(
D : IN std_logic;
C : IN std_logic;
Q : OUT std_logic
);
END COMPONENT;
signal wire : std_logic;
begin
ff0 : flipflop PORT MAP(
D => SIG_IN,
C => CLK,
Q => wire
);
ff1 : flipflop PORT MAP(
D => wire,
C => CLK,
Q => SYNC_OUT
);
end Behavioral;