RE: [sv-bc] scope of break/continue within foreach loop

From: Daniel Mlynek <daniel.mlynek@aldec.com.pl>
Date: Wed Jun 02 2010 - 03:31:02 PDT

Imho break should break the whole loop any other hahviour would be just
hard to understand ie:

module top;
int arr[10][3];
initial
foreach (arr[i,j]) begin
        $display(i, j);
        if (i==2) break; //this breaks the foreach and finishes whole tests
end
endmodule

DANiel

-----Original Message-----
From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Paul
Graham
Sent: Tuesday, June 01, 2010 11:55 PM
To: sv-bc
Subject: [sv-bc] scope of break/continue within foreach loop

A foreach statement with multiple variables is defined as equivalent to a
set of nested for loops. If a break statement is executed in the body of a
forever loop, does it break out of the innermost of these nested for loops,
or does it break out of the outermost? Likewise for a continue statement.
I guess it should be the outermost loop. Could this be clarified?

Paul

--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Jun 2 03:31:21 2010

This archive was generated by hypermail 2.1.8 : Wed Jun 02 2010 - 03:34:02 PDT