Complete the code to declare the D input port.
entity DFF is
Port (
clk : in std_logic;
rst : in std_logic;
[1] : in std_logic;
q : out std_logic
);
end DFF;The D input is named d as per convention for D flip-flops.
Complete the process sensitivity list to include clock and asynchronous reset.
architecture Behavioral of DFF is
begin
process([1])
begin
-- process body
end process;
end Behavioral;The process must be sensitive to the clock and asynchronous reset signals.
Fix the error in the if statement to check asynchronous reset correctly.
process(clk, rst) begin if [1] = '1' then q <= '0'; elsif rising_edge(clk) then q <= d; end if; end process;
The asynchronous reset signal is rst, so the if condition must check rst = '1'.
Fill both blanks to assign the output and handle the clock edge.
process(clk, rst) begin if rst = '1' then [1] <= '0'; elsif [2](clk) then q <= d; end if; end process;
The output q is reset to '0'. The clock edge is detected with rising_edge(clk).
Fill all three blanks to complete the D flip-flop with asynchronous reset.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity DFF is
Port (
clk : in std_logic;
rst : in std_logic;
[1] : in std_logic;
q : out std_logic
);
end DFF;
architecture Behavioral of DFF is
begin
process(clk, rst)
begin
if rst = '1' then
[2] <= '0';
elsif [3](clk) then
q <= d;
end if;
end process;
end Behavioral;The input is d, output is q, and clock edge detection uses rising_edge(clk).
