From: Dennis Marsa (drm@xilinx.com)
Date: Fri Mar 01 2002 - 11:50:48 PST
Precedence: bulk
Michael McNamara wrote:
>
> > Thus, declarations such as:
> >
> > reg [2**5-1:0] data;
> >
> > would be illegal.
> >
> > Dennis
> >
>
> I am not sure what the issue is here.
>
> Indeed, if either operand is signed, or real, then inoder to in the
> general case retain the highest precision, the expression X ** Y must
> be calculated by first promoting each operand to real, generating a
> real result. Then as would proceed usually when using a real in a
> place where an unsigned quantity is needed, the final result will be
> converted as necessary as a subsequent operand to the rest of the
> statement.
>
> Hence if you have:
>
> reg [7:0] a;
>
> ...
>
> a = 2**5;
>
> the subexpression '2**5' would be interpreted by the tool as if it
> were:
>
> 2.0 ** 5.0
>
> the result 32.0 would be generated;
>
> and the tool would then reduce this expression to:
>
> a = 32.0;
>
> Then it would apply the assignement expression rules, where the right
> hand side is converted to something that will fit in the left hand
> side:
>
> As the target 'a' is unsigned 8 bit wide item, the 32.0 would be
> converted to unsigned: 32'h0000_0020;
>
> The low 8 bits would be assigned to a; and a would have the value
> 8'd32.
>
> Similarily in the declaraion the real value generated by the
> exponetion operator would be conferted to a 32 bit signed quantity,
> 32'sd32, which is correct.
>
> OK?
True, if you allow real values to be used in a range specification of
a vector declaration. Looking at the wording for declaring vectors
(section 3.3.1) it doesn't disallow that. It just says the msb and
lsb have to be constants.
At least two major simulators (XL and MTI) forbid using reals in range
specifications. But, the standard, as written, does seem allow it.
I accept your argument about coverting the operands to float, performing
the power operation, then the result will get converted back to integer
upon assignment to an integer thing, or use in an integer context.
I guess I'm saying, why not fold that result conversion back to integer
in as part of the power operation itself when the first operand (both
operands?) is an integer?
This would allow the result of a power operation (when applied to integers)
to be used as an operand to all other operators.
As defined, the result of the power operator can't be applied to any
of the operators listed in Table 11 of section 4.1.1, e.g.
{2**5} // Illegal if 2**5 is real
(2**5) & x // Illegal if 2**5 is real
(2**5) << x // Illegal if 2**5 is real
Dennis
This archive was generated by hypermail 2.1.4
: Mon Jul 08 2002 - 12:55:35 PDT
and
sponsored by Boyd Technology, Inc.