Menu
Coddy logo textTech

Recap - Loop Patterns

Part of the Fundamentals section of Coddy's Verilog journey. Lesson 63 of 90.

challenge icon

Challenge

Complete the missing parts in each loop to produce the expected output.

What to do:

  1. Use a for loop to print numbers 0 to 3
  2. Use a while loop to print numbers 0 to 2
  3. Use a repeat loop to print "Hello" 3 times

Try it yourself

module loop_patterns;
  integer i;
  
  initial begin
    $display("For Loop:");
    // TODO: Add for loop (i=0 to 3)
    
    
    $display("While Loop:");
    i = 0;
    // TODO: Add while loop (i=0 to 2)
    
    
    $display("Repeat Loop:");
    // TODO: Add repeat loop (print "Hello" 3 times)
    
    
    $finish;
  end
endmodule

All lessons in Fundamentals

Practice on your own: Online Verilog compiler