0
0
Verilogprogramming~20 mins

Up counter design in Verilog - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Up Counter Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of a 4-bit synchronous up counter
What is the output of the 4-bit synchronous up counter after 5 clock pulses if it starts from 4'b0000?
Verilog
module up_counter(input clk, input reset, output reg [3:0] count);
  always @(posedge clk or posedge reset) begin
    if (reset)
      count <= 4'b0000;
    else
      count <= count + 1;
  end
endmodule
A4'b0101
B4'b0100
C4'b0110
D4'b0011
Attempts:
2 left
💡 Hint
Count increments by 1 on each clock pulse starting from zero after reset.
🧠 Conceptual
intermediate
1:30remaining
Understanding asynchronous reset in up counters
What is the main effect of using an asynchronous reset in an up counter design?
AThe counter resets only on the next clock edge after reset is asserted.
BThe counter ignores the reset signal during counting.
CThe counter counts down instead of up when reset is asserted.
DThe counter resets immediately when reset is asserted, regardless of the clock.
Attempts:
2 left
💡 Hint
Asynchronous means it does not wait for the clock.
🔧 Debug
advanced
2:30remaining
Identify the error in this up counter code
What error will this Verilog code produce when synthesized or simulated?
Verilog
module up_counter(input clk, input reset, output reg [3:0] count);
  always @(posedge clk) begin
    if (reset == 1)
      count = 4'b0000;
    else
      count = count + 1;
  end
endmodule
ANo error, code works correctly.
BRuntime error because count is not initialized.
CSynthesis error due to missing non-blocking assignments.
DSyntax error due to missing semicolon.
Attempts:
2 left
💡 Hint
Consider the difference between blocking (=) and non-blocking (<=) assignments in sequential logic.
📝 Syntax
advanced
2:00remaining
Syntax error in up counter sensitivity list
Which option correctly fixes the sensitivity list for an asynchronous reset in this up counter?
Verilog
always @(posedge clk or reset) begin
  if (reset)
    count <= 0;
  else
    count <= count + 1;
end
Aalways @(posedge clk and posedge reset) begin
Balways @(posedge clk or posedge reset) begin
Calways @(clk or reset) begin
Dalways @(negedge clk or posedge reset) begin
Attempts:
2 left
💡 Hint
Asynchronous reset sensitivity must be on the positive edge of reset signal.
🚀 Application
expert
1:30remaining
Number of states in a 5-bit up counter
How many unique states does a 5-bit up counter cycle through before repeating?
A32
B10
C64
D16
Attempts:
2 left
💡 Hint
Number of states is 2 raised to the number of bits.