Dave,
I'm sorry, but strictly your example is not a side-effect - the second function call doesn't change any state.
What makes this function problematic is that it is preserving state from one call to the next. And, automatic functions can also preserve state, for example via hierarchical references, dynamic memory allocation, indirectly by calling other state-preserving/changing functions, etc...
I believe that the automatic requirement is necessary to avoid data storage in output arguments (including the return value) and in variable local to the function, but it is not sufficient. Perhaps the parenthetical sentence can be moved out of the parenthesis.
Incidentally, that particular statement was copied from the constraints section, which uses the same verbiage for the same reason. If we change it in one place, we may want to do it in both.
Arturo
-----Original Message-----
From: owner-sv-ac@eda.org [mailto:owner-sv-ac@eda.org] On Behalf Of Rich, Dave
Sent: Friday, November 05, 2010 11:24 AM
To: Little Scott-B11206; sv-ac@eda.org
Subject: RE: [sv-ac] Preserve no state information?
Scott,
"Functions shall have no side effects" should be sufficient. Restricting
them to automatic would be great (see mantis 2035 and the supporting
discussions). But just making a function automatic is not enough be it
may contain local static variables.
You can have a static function with no locally declared variables be the
return value is static.
function int foo(int A, bit B);
if (B) foo=A;
endfunction
If B is 0, foo returns the value from the previous call to foo. That is
a side effect.
Dave Rich
Verification Technologist
Mentor Graphics Corporation
> -----Original Message-----
> From: owner-sv-ac@eda.org [mailto:owner-sv-ac@eda.org] On Behalf Of
> Little Scott-B11206
> Sent: Friday, November 05, 2010 5:58 AM
> To: sv-ac@eda.org
> Subject: [sv-ac] Preserve no state information?
>
> Hi all:
>
> In looking at modifications for 2328, I came across the following
> restriction in section 16.6.
>
> -Functions shall be automatic (or preserve no state information) and
> have no side effects.
>
> My question is what types of additional functions does the
parenthetical
> statement allow? My understanding is that this statement allows
static
> functions that don't have any locally declared variables. It seems to
> me that these functions can be declared automatic to meet the
> requirement without the parenthetical statement. Is this correct? Is
> there anything else the parenthetical statement allows?
>
> I would like to remove the parenthetical statement as I believe it
> simplifies the restriction. If my understanding above is correct, any
> code that becomes noncompliant because of the change could become
> compliant by adding automatic to the function declaration.
>
> Thanks,
> Scott
>
>
> --
> 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. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Fri Nov 5 12:51:43 2010
This archive was generated by hypermail 2.1.8 : Fri Nov 05 2010 - 12:51:49 PDT