Shalom, count is initialized to -1. loop3 of 2nd loop is initialized to -1 and count is incremented to 0. loop3 of 3rd loop is initialized to 0 and count is incremented to 1. The initial block begins. The first loop executes, each time around triggering a call to counter(). loop1 progresses through 1, 2, 3, causing count to be incremented through 2, 3, 4, which values are printed by the first series of $displays. The second loop executes with no effect on count, so each time around it $displays 4's. The third loop executes, again with no effect on count, so each time around it $displays some more 4's. Although according to 6.7, "Setting the initial value of a static variable as part of the variable declaration (including static class members) shall occur before any initial or always blocks are started.", the LRM does not specify the execution order of static initializers. Most implementations do these in source order. I don't know what happens in practice if they are in different modules, especially on different command lines. -- Brad -----Original Message----- From: Bresticker, Shalom [mailto:shalom.bresticker@intel.com] Sent: Tuesday, August 28, 2007 2:26 AM To: Rich, Dave; Brad Pierce; sv-champions@eda.org Subject: RE: [sv-champions] 5-day email vote - 1556 Hi, Regarding 1556: > > 4) The example is confusing. > [DR] Not to me :) I think more explanatory comments would be helpful, either as code comments or as text before or after the example. I can figure it out, but it takes some work. Other people might have more trouble. > > 5) The comments in the example are wrong, because > they say 1 > 2 > > 3 3 3 3 3 3 3 3 should be printed, but actually it should > be 2 3 4 4 4 > 4 > > 4 4 4 > [DR] The results assumes the illegal statement is not executed. > Perhaps that should be shown as a completely separate module. Would > that be less confusing? I am confused, because Brad asserts that the comments say that 9 or 10 numbers should be printed, whereas I only see two comments, one says "end // prints 1 2 3" and the other says, "end // prints 3 3 3". Where do the other 3 or 4 come from? I understand that there is an additional print task call. But there is no comment saying what it will display. And another question: There is an initialization of int at the top of the module: int count = -1; // static keyword not required Afterwards, there is another initialization: static int loop3 = counter(); // static keyword required where function int counter(); return count++; endfunction Is there something in the LRM that guarantees that the initialization of count will occur before the initialization of loop3? Finally, and this is not intended to suggest a modification of this proposal, I think that 6.21 and 6.7 should xref each other, as both talk about variable initialization. In particular, 6.21 is missing the information about when this occurs, which is relevant in this example. I would also cross-reference between 9.2.1, which discusses intial procedures, and 6.7, which discusses the scheduling of variable initialization, particularly as this is different than in 1364. Thanks, Shalom -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Tue Aug 28 09:05:14 2007
This archive was generated by hypermail 2.1.8 : Tue Aug 28 2007 - 09:05:19 PDT