Welcome ! This website will help YOU (recent graduates/professionals) learn verification languages like SystemVerilog and UVM. Register for free and access more content !

break

 
module tb;
    initial begin
 
      // This for loop increments i from 0 to 9 and exit
      for (int i = 0 ; i < 10; i++) begin
        $display ("Iteration [%0d]", i);
 
        // Let's create a condition such that the 
        // for loop exits when i becomes 7
        if (i == 7) 
          break;
      end
    end
endmodule
 
Simulation Log
ncsim> run
Iteration [0]
Iteration [1]
Iteration [2]
Iteration [3]
Iteration [4]
Iteration [5]
Iteration [6]
Iteration [7]
ncsim: *W,RNQUIE: Simulation is complete.

Click to try this example in a simulator!   

continue

 
module tb;
    initial begin
 
      // This for loop increments i from 0 to 9 and exit
      for (int i = 0 ; i < 10; i++) begin 
 
        // Let's create a condition such that the 
        // for loop 
        if (i == 7) 
          continue;
 
        $display ("Iteration [%0d]", i);
      end
    end
endmodule  
 
Simulation Log
ncsim> run
Iteration [0]
Iteration [1]
Iteration [2]
Iteration [3]
Iteration [4]
Iteration [5]
Iteration [6]
Iteration [8]
Iteration [9]
ncsim: *W,RNQUIE: Simulation is complete.

Click to try this example in a simulator!   

Was this article helpful ?



You consent to our cookies if you continue to use our website. To know more about cookies, see our privacy policy. I accept cookies from this site.

Agree