Re: ! vs. ~

Shalom Bresticker (shalom@msil.sps.mot.com)
Thu, 27 May 1999 13:44:25 +0300

Ordinarily, I am against using !, but here I think it is appropriate.

A true/false condition like <condB> is always interpreted as a single-bit binary variable,
whose value can be zero (false) or non-zero (true), even if it is a multi-bit expression.
Any non-zero value is interpreted as true.

The logical NOT operator ! works according to the same interpretation.
It turns any non-zero value (true) into zero (false).

Actually, good practice is to always write <condB> such that its value is always 1 bit.

For example, intead of writing

if ( condB[1:0] )

one should write

if ( condB[1:0] != 2'b00 )

Sincerely,
Shalom Bresticker

******************************************************************************
Shalom Bresticker email: shalom@msil.sps.mot.com
Motorola Semiconductor Israel, Ltd. Tel #: +972 9 9522268
P.O.B. 2208, Herzlia 46120, ISRAEL Fax #: +972 9 9522444
http://www.motorola-semi.co.il/
******************************************************************************

>> From owner-vlog-synth@eda.org Tue May 25 17:22:14 1999
>> From: Ken Coffman <kcoffman@sos.net>
>> Subject: Comments on 1364.1 D1.4

>> 3. I think we may add confusion unless we change the instances of !
>> <condB> to ~<condB>. As you know, these are equivalent only if condB is a
>> single bit variable. All uses of ! should be looked at (like the use of
>> !CLEAR).