异步采样模块的VHDL实现如下:
--this process is triggered by clks
process(rst, clks)
begin
if rst=‘0’ then
ff1 <= (others=>‘0’);
ff2 <= (others=>‘0’);
elsif clks‘event and clks=‘1’ then
ff1 <= din; --din is the signal triggered by clk
ff2 <= ff1;
end if;
end process;
-- this process is triggered by clk
process(rst, clk)
begin
if rst=‘0’ then
ff3 <= (others=>‘0’);
ff4 <= (others=>‘0’);
elsif clk′event and clk=‘1’ then
ff3 <= ff2;
ff4 <= ff3;
end if;
end process;
dout <= ff4; -- dout is output random signal