Re: [sv-bc] RE: clog2 problem

From: Greg Jaxon <Greg.Jaxon_at_.....>
Date: Wed Jan 23 2008 - 11:42:23 PST
Arturo is right, but thanks to the madness of context-sensitive
expression width rules, even N|1 is dangerous when N is an expression.
     (expr) | signed'(1'b1)
may work better in a macro or other type-independent setting.
Note that 1'sb1 would be sign-extended to match width (bad!), whereas
signed'(1'b1) will 0-extend the literal before cloaking it with
signedness (so as to not poison expr with unsignedness).

Greg

Arturo Salz wrote:
> Shalom,
> 
>  
> 
> No. I meant “N | 1” (the bitwise or operator). I didn’t use + because
> addition could cause a wrap-around to 0 and distort the result.
> 
> Using “N | 1” works for all positive numbers, even 0. (btw, I changed
> the subject line)
> 
>  
> 
>             Arturo
> 
>  
> 
> ------------------------------------------------------------------------
> 
> *From:* Bresticker, Shalom [mailto:shalom.bresticker@intel.com]
> *Sent:* Tuesday, January 22, 2008 2:05 AM
> *To:* Arturo Salz; sv-bc@eda.org
> *Subject:* RE: [sv-bc] Agenda: January 21, 2008 SV-BC Meeting (NOTE: NEW
> CALL LOGISTICS)
> 
>  
> 
> Arturo,
> 
>  
> 
> Did you mean $clog2(N+1) ?
> 
>  
> 
> Thanks,
> 
> Shalom
> 
>      
> 
>      
> 
>     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)*.
> 
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by *MailScanner* <http://www.mailscanner.info/>, 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 Wed Jan 23 13:06:34 2008

This archive was generated by hypermail 2.1.8 : Wed Jan 23 2008 - 13:08:39 PST