D-Flip-Flops(DFF)
在所有例子中:
- clk是时钟,
- d是输入,
- q是输出,
- srst是一个有源高同步复位,
- srstn是低电平有效同步复位,
- arst是一个有源高速异步复位,
- arstn是一个低电平有效复位,
- sset是一个高效的同步集,
- ssetn是一个有源低同步集,
- aset是一个活跃的高异步集,
- asetn是一个低有效的低异步集
所有信号均为 ieee.std_logic_1164.std_ulogic 型。使用的语法是使用所有逻辑合成器得到正确合成结果的语法。有关备用语法的讨论,请参阅时钟边沿检测示例。
上升沿时钟
process(clk)
begin
  if rising_edge(clk) then
    q <= d;
  end if;
end process;
下降边缘时钟
process(clk)
begin
  if falling_edge(clk) then
    q <= d;
  end if;
end process;
上升沿时钟,同步有效高电平复位
process(clk)
begin
  if rising_edge(clk) then
    if srst = '1' then
      q <= '0';
    else
      q <= d;
    end if;
  end if;
end process;
上升沿时钟,异步有效高电平复位
process(clk, arst)
begin
  if arst = '1' then
    q <= '0';
  elsif rising_edge(clk) then
    q <= d;
  end if;
end process;
下降沿时钟,异步有效低电平复位,同步有效高电平设置
process(clk, arstn)
begin
  if arstn = '0' then
    q <= '0';
  elsif falling_edge(clk) then
    if sset = '1' then
      q <= '1';
    else
      q <= d;
    end if;
  end if;
end process;
上升沿时钟,异步有效高电平复位,异步低电平有效
注意:set 的优先级高于 reset
process(clk, arst, asetn)
begin
  if asetn = '0' then
    q <= '1';
  elsif arst = '1' then
    q <= '0';
  elsif rising_edge(clk) then
    q <= d;
  end if;
end process;