The verbiage of the $clog2 function is contradictory and misleading. The first paragraph containing the formal definition of the function and the second paragraph are contradictory: The system function $clog2 shall return the ceiling of the log base 2 of the argument (the log rounded up to an integer value). The argument can be an integer or an arbitrary sized vector value. The argument shall be treated as an unsigned value, and an argument value of 0 shall produce a result of 0. This system function can be used to compute the minimum address width necessary to address a memory of a given size or the minimum vector width necessary to represent a given number of states. For example: integer result; result = $clog2(n); The second paragraph has led some users to believe that $clog2 returns the minimum number of bits needed to store a particular value, but, that is not true if $clog2 is indeed ceil( log2( N ) ). The general expression needed to determine the minimum number of bits would be $clog2(N | 1) not $clog2(N). The example seems to reinforce this idea. The second paragraph's intent seems to be informational only, that is, the $clog2 function can be used *as an aid* to compute the minimum vector width. Arturo -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Mon Jan 21 11:29:24 2008
This archive was generated by hypermail 2.1.8 : Mon Jan 21 2008 - 12:04:53 PST