Challenge - 5 Problems
Down Counter Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a 4-bit down counter
What is the output of the 4-bit down counter after 3 clock cycles if it starts at 4'b1010 (decimal 10)?
Verilog
module down_counter(input clk, input reset, output reg [3:0] count); always @(posedge clk or posedge reset) begin if (reset) count <= 4'b1010; else count <= count - 1; end endmodule
Attempts:
2 left
💡 Hint
Count down from 1010 three times, subtracting 1 each clock cycle.
✗ Incorrect
Starting at 1010 (decimal 10), after 1 clock cycle: 1001 (9), after 2: 1000 (8), after 3: 0111 (7).
🧠 Conceptual
intermediate1:30remaining
Behavior of synchronous reset in down counter
In a synchronous reset down counter, what happens when the reset signal is asserted at the clock edge?
Attempts:
2 left
💡 Hint
Synchronous means reset works with the clock.
✗ Incorrect
Synchronous reset means the reset action happens only on the clock edge, so the counter resets at the next clock edge after reset is asserted.
🔧 Debug
advanced2:30remaining
Identify the error in this down counter code
What error will this Verilog down counter code produce when simulated?
Verilog
module down_counter(input clk, input reset, output reg [3:0] count); always @(posedge clk or posedge reset) begin if (reset == 1'b1) count = 4'b1111; else count = count - 1; end endmodule
Attempts:
2 left
💡 Hint
Check the type of assignment used inside sequential always block.
✗ Incorrect
In sequential logic (inside always @(posedge clk)), non-blocking assignments (<=) should be used to avoid race conditions and ensure correct simulation and synthesis.
📝 Syntax
advanced2:00remaining
Syntax error in down counter module
Which option contains the correct syntax for a 3-bit down counter with asynchronous reset?
Attempts:
2 left
💡 Hint
Check for missing semicolons and correct if syntax.
✗ Incorrect
Option C has correct module declaration, always block sensitivity list, if statement syntax, and uses non-blocking assignments.
🚀 Application
expert3:00remaining
Design a down counter with load and enable signals
Which Verilog code correctly implements a 4-bit down counter with synchronous load and enable signals? When load is high, the counter loads the input value; when enable is high and load is low, the counter counts down by 1 each clock cycle.
Attempts:
2 left
💡 Hint
Reset should be asynchronous; load has priority over enable.
✗ Incorrect
Option D correctly uses asynchronous reset, synchronous load with priority over enable, and non-blocking assignments. Option D misses asynchronous reset. Option D uses blocking assignments. Option D has wrong priority order (enable before load).