RE: Definition of integer division

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Thu Dec 15 2005 - 03:34:14 PST
1800 says (study the examples as well),

"8.4 Operations on logic and bit types
All Verilog operators are defined for 4-state values. In SystemVerilog,
operators may be applied to 2-state
values or to a mixture of 2-state and 4-state values. The result is the
same as if all values were treated as 4-state values and the Verilog
operators were applied. In most cases, if all operands are 2-state, the
result is
in the 2-state value set. The only exceptions involve operators where
Verilog produces an X result for operands
in the 2-state value set (e.g., division by zero).

int n = 8, zero = 0;
int res = 'b01xz | n;      // res gets 'b11xz coerced to int, or 'b1100
int sum = n + n;           // sum gets 16 coerced to int, or 16
int sumx = 'x + n;         // sumx gets 'x coerced to int, or 0
int div2 = n/zero + n;     // div2 gets 'x coerced to int, or 0
integer div4 = n/zero + n; // div4 gets 'x

Shalom

> -----Original Message-----
> From: owner-verilog-ams@eda.org [mailto:owner-verilog-
> ams@eda.org] On Behalf Of Kevin Cameron
> Sent: Wednesday, December 14, 2005 11:33 PM
> To: Geoffrey.Coram
> Cc: Verilog-A Reflector
> Subject: Re: Definition of integer division
> 
> 
> Not much you can do about integer division by zero. Presumably
> this will
> have to be addressed in SV which supports 2-state types (where
> x cannot
> be the result) - I can't remember it coming up.
> 
> Kev.
> 
> Geoffrey.Coram wrote:
> 
> >Kevin -
> >OK, I had been searching for "coerc" when I found that one
> >statement.  A few paragraphs above, I found this:
> >
> >- Expression type depends only on the operands. It does ot
> >  depend on the LHS (if any).
> >
> >followed by
> >- For non-self-determined operands the following rules apply:
> >    if any operand is real, the result is real;
> >
> >
> >If I have
> >  real a;
> >  a = 5.0 + 1/2;
> >
> >then I guess "1/2" is an expression (and its type is
> >integer), and thus "integer division" is performed
> >(no coercion is needed).
> >
> >At first I thought "5.0 + 1/2" was the expression.
> >
> >
> >I'm still a little concerned about the sentence (in 4.1.5)
> >  For the division or modulus operators, if the second operand
> >  is a zero, then the entire result value shall be x.
> >
> >because "x" doesn't make sense in an analog context.
> >
> >-Geoffrey
> >
> >
> >
Received on Thu Dec 15 03:34:32 2005

This archive was generated by hypermail 2.1.8 : Thu Dec 15 2005 - 03:34:48 PST