[sv-ec] 10.5.3 The foreach loop

From: danielm <danielm_at_.....>
Date: Fri Jan 18 2008 - 06:12:21 PST
Chapter about foreach loop defines that with such loop we may iterate over
dynamic arrays but it doesn't precise what should happend if size of such
array will change inside lthat oop.
Same about associative array what should happen if we add or remove some
entries from such table inside foreach.
 
I'll give you an example based on string which is also kind of dynamic
array:
 
module top;
        string str="1234567890";
 
        initial begin
                $display("change size to empty string");
                foreach (str [i]) begin
                        if (str[i]=="5")
                                str="";//!!!!size of str variable have
changed 
                        $display(">%s",str[i]);
                end
                str="1234567890";
                $display("change size to shorter string than actual
iterator");
end
 
 
DANiel

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Jan 18 12:37:08 2008

This archive was generated by hypermail 2.1.8 : Fri Jan 18 2008 - 12:37:51 PST