>From: Surya Pratik Saha <spsaha@cal.interrasystems.com> >If the 'side-effect' is not concern, then I am not clear about the >reason behind the restriction. I don't know all the reasoning, but I can speculate on some of it. 1. Allowing functions without side effects would require defining what that means. The definition for constant functions is inadequate, as there are things allowed in constant functions that would constitute side effects if done at runtime. For example, $display is ignored in a constant function, but not at runtime. Any call to a static function has side effects, since it modifies the arguments and return value, which are static variables accessible from elsewhere. 2. Allowing functions without side effects would require implementations to do an analysis of the function and its entire call graph to determine legality. This is undesirable. Disallowing the function is simple. 3. Why would you want to evaluate a function just to find out the width of the result it would produce, and then throw that result away? If you are planning to follow it by evaluating again and keeping the result the second time, then this is wasteful. You should evaluate it to get the result, and then ask for the width of that. Evaluation takes time. In short, you would have to present a reasonable use for this before the extra complexity would make sense. > $bits can not evaluate width for any >dynamic variables without evaluating it. For e.g. > >string s; >initial begin > s = "abc"; > i = $bits(s); >end > >Is it possible to evaluate the width of 's' without evaluating it? I >don't think so. Here the evaluation is so simple that it may not be easy to see that it is not being evaluated. But $bits does not necessarily need to fetch the value to get the width. If an implementation stores strings as a size plus a data array, all $bits has to do is fetch the size, not the data. So it is not evaluating 's'. To make it clearer, here is an example with a more complex expression: i = $bits({s,s}); Here the result is 2 times the width of s. There is no need to evaluate the expression by constructing the concatenation of s with itself to determine that. Steven Sharp sharp@cadence.com -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Wed Feb 6 09:09:43 2008
This archive was generated by hypermail 2.1.8 : Wed Feb 06 2008 - 09:10:18 PST