I came across a piece of code where there was a continue inside an always block. For example:

always @(posedge clk) begin count = count + 1; if(count[0]) continue; $display("count: ",count); end 

I am not able to understand how this continue works here as in my opinion continue is only applicable when used in a loop. Please tell anything related to it.

0

1 Answer

According to IEEE Std 1800-2017, section 12.8 Jump statements:

The continue and break statements can only be used in a loop. 

Since the continue statement is not inside a loop (such as a for or while loop), it is illegal syntax. Several simulators on edaplayground generate compile errors. If you do not get an error, your simulator does not comply with the standard, and your code will not be portable with other simulators. Also, since it is explicitly forbidden in the standard, its behavior is undefined.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.