Menu
Coddy logo textTech

Recap - Always vs Initial

Part of the Fundamentals section of Coddy's Verilog journey — lesson 51 of 90.

challenge icon

Challenge

Always vs Initial

Complete both blocks to make this counter work correctly.

What to do:

  • The initial block should initialize count to 0 at time 0
  • The always block should increment count by 1 on each rising clock edge

Try it yourself

module counter;
  reg clk;
  reg [3:0] count;
  
  // Clock generator (already given)
  always #5 clk = ~clk;
  
  // TODO: Add initial block to set count = 0
  
  // TODO: Add always block to increment count on posedge clk
  
endmodule

All lessons in Fundamentals