Challenge - 5 Problems
Edge Detector Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateDetecting a rising edge output
What is the output of the
rising_edge_detected signal after the clock cycle when signal_in changes from 0 to 1?Verilog
module edge_detector( input wire clk, input wire signal_in, output reg rising_edge_detected ); reg signal_in_d; always @(posedge clk) begin signal_in_d <= signal_in; rising_edge_detected <= signal_in & ~signal_in_d; end endmodule
Attempts:
2 left
💡 Hint
Think about how the delayed signal_in_d helps detect the rising edge.
✗ Incorrect
The code stores the previous value of signal_in in signal_in_d. The expression signal_in & ~signal_in_d is true only when signal_in is 1 and the previous value was 0, which means a rising edge happened.
❓ Predict Output
intermediateDetecting a falling edge output
What is the value of
falling_edge_detected after the clock cycle when signal_in changes from 1 to 0?Verilog
module edge_detector( input wire clk, input wire signal_in, output reg falling_edge_detected ); reg signal_in_d; always @(posedge clk) begin signal_in_d <= signal_in; falling_edge_detected <= ~signal_in & signal_in_d; end endmodule
Attempts:
2 left
💡 Hint
Look at how the delayed signal_in_d is used with the inverted signal_in.
✗ Incorrect
The expression ~signal_in & signal_in_d is true only when signal_in is 0 and the previous value was 1, indicating a falling edge.
❓ Predict Output
advancedDetecting both rising and falling edges
What is the output of
edge_detected signal when signal_in changes from 0 to 1 or from 1 to 0?Verilog
module edge_detector( input wire clk, input wire signal_in, output reg edge_detected ); reg signal_in_d; always @(posedge clk) begin signal_in_d <= signal_in; edge_detected <= signal_in ^ signal_in_d; end endmodule
Attempts:
2 left
💡 Hint
XOR (^) is true when inputs differ.
✗ Incorrect
The XOR of current and previous signal_in is 1 when signal_in changes value, so edge_detected is 1 for one clock cycle after any edge.
🧠 Conceptual
advancedUnderstanding edge detection timing
Why does the edge detector use a delayed version of
signal_in (like signal_in_d) to detect edges?Attempts:
2 left
💡 Hint
Think about how you know if a signal changed from one moment to the next.
✗ Incorrect
By storing the previous value, the circuit can compare it with the current value to see if the signal changed, which means an edge happened.
🔧 Debug
expertIdentify the error in this edge detector code
What error will this Verilog code cause when synthesizing an edge detector for rising edges?
Verilog
module edge_detector( input wire clk, input wire signal_in, output reg rising_edge_detected ); reg signal_in_d; always @(posedge clk) begin signal_in_d <= signal_in; rising_edge_detected = signal_in & ~signal_in_d; end endmodule
Attempts:
2 left
💡 Hint
Consider the difference between blocking (=) and non-blocking (<=) assignments in sequential logic.
✗ Incorrect
Inside a clocked always block, non-blocking assignments (<=) must be used to ensure correct timing and behavior. Using blocking assignment (=) can cause race conditions and incorrect simulation/synthesis results.
