Challenge - 5 Problems
D Flip-Flop Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a simple D flip-flop process
What is the output Q after the rising edge of the clock if D = '1' and Q was initially '0'?
VHDL
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity dff is Port ( D : in STD_LOGIC; CLK : in STD_LOGIC; Q : out STD_LOGIC); end dff; architecture Behavioral of dff is signal Q_int : STD_LOGIC := '0'; begin process(CLK) begin if rising_edge(CLK) then Q_int <= D; end if; end process; Q <= Q_int; end Behavioral;
Attempts:
2 left
💡 Hint
Remember that on the rising edge of the clock, the flip-flop captures the value of D.
✗ Incorrect
A D flip-flop captures the input D at the rising edge of the clock and outputs it on Q. Since D is '1' and the clock rises, Q becomes '1'.
🧠 Conceptual
intermediateUnderstanding sensitivity list in D flip-flop process
Which signal(s) should be included in the sensitivity list of a process implementing a D flip-flop with rising edge clock?
Attempts:
2 left
💡 Hint
Think about when the flip-flop updates its output.
✗ Incorrect
A D flip-flop updates output only on the rising edge of the clock, so only CLK needs to be in the sensitivity list.
🔧 Debug
advancedIdentify the error in this D flip-flop code
What error will this VHDL code produce when synthesizing a D flip-flop with rising edge clock?
process(CLK)
begin
if CLK = '1' then
Q <= D;
end if;
end process;
Attempts:
2 left
💡 Hint
Check how the clock condition is checked.
✗ Incorrect
This code uses a level-sensitive condition (CLK = '1') without an else clause or edge detection, causing synthesis tools to infer a flip-flop triggered on high level, not on rising edge.
📝 Syntax
advancedCorrect syntax for rising edge detection
Which of the following is the correct syntax to detect a rising edge of the clock signal CLK in VHDL?
Attempts:
2 left
💡 Hint
There is a built-in function for rising edge detection.
✗ Incorrect
The recommended and clear way is to use the rising_edge function, which checks for a clock transition from '0' to '1'.
🚀 Application
expertOutput behavior with asynchronous reset in D flip-flop
Given this D flip-flop with asynchronous reset, what will be the output Q after the following sequence?
- Initial Q = '0'
- Reset (RST) is asserted ('1') asynchronously
- Then RST is deasserted ('0')
- Then a rising edge of CLK occurs with D = '1'
Code snippet:
process(CLK, RST)
begin
if RST = '1' then
Q <= '0';
elsif rising_edge(CLK) then
Q <= D;
end if;
end process;
Attempts:
2 left
💡 Hint
Asynchronous reset sets Q immediately, clock updates Q only on rising edge after reset is released.
✗ Incorrect
When RST='1', Q is forced to '0' immediately. After RST='0', Q updates to D='1' only on the next rising edge of CLK.
