コンパクトなDフリップフロップ

関連: コンパクトなDフリップフロップ -
参考: Effective Coding with VHDL: Principles and Best Practice (The MIT Press), p.262

library ieee;
use ieee.std_logic_1164.all;

entity d_flip_flop is
    port(
        aclr_n : in  std_logic;
        clk    : in  std_logic;
        d      : in  std_logic;
        q0     : out std_logic;
        q1     : out std_logic
    );
end entity;

architecture rtl of d_flip_flop is
begin

   --process文にしてしまいがちであるが、
    process(clk, aclr_n)
    begin
        if not aclr_n then
            q0 <= '0';
        elsif rising_edge(clk) then
            q0 <= d;
        end if;
    end process;


   --concurrent文でも書ける。
    q1 <=
        '0' when (not aclr_n) else
        d   when rising_edge(clk);
        

end architecture;