RE: [vhdl-200x] More operators for integers

From: <whygee@f-cpu.org>
Date: Tue Oct 21 2014 - 10:20:45 PDT
Le 2014-10-21 10:39, Martin.J Thompson a écrit :
> I'm merely wanting to be clear that errors will be raised in the usual
> way and that there is no magic or changes to expected behaviour.  Not
> necessarily that they will get much use, or that every operator *can*
> result in errors, merely that there should be no surprises where
> errors are concerned.
> 
> A "logical operator" example, if you have a +ve integer and "not" it
> (ie flip every bit, resulting in a -ve number) and assign it to a
> natural, or some other subtype without the appropriate negative range,
> you will get an error.

I see where we diverge,
you consider the variables as numbers, as classic VHDL types.
However, the boolean operators consider our variables/data
as a "ordered collection of bits" (at most). One of my usual examples
is bitstream insertion/extraction: you need masks, shifts
and and/or operators. The intermediary data are not real numbers,
just bits waiting to be shuffled around to make sense
for the other parts of the program. If you raise an error
that would apply only on arithmetic numbers, you break
the encoder or decoder.

Let's say I compute a mask and I need to make the
complementary mask (for a MUX-like, or "select" operation).
At one point, my initial mask is 0000...., which excludes all the bits
from one input. When I complement it, I don't expect at all
to get an error. If it was the case, I would have to rewrite
the whole algorithm to avoid the 0 case, which would make it
uselessly complex (and probably slower).

You also raise the issue of the assignments to non-signed numbers.

(BTW here we touch an issue about VHDL : unsigned numbers
are a sub-range of the signed numbers, we lose one MSB...)

The actual error handling should be in the assignment,
not the operation itself. This implies that bool/shift/rot
operations would work only on signed integers. I can live
with that (and all the implied casts) as long as the whole
range of boolean operators is available (for example,
both srl and sra, so *I* can decide how to treat the bits).


I hope that it's clearer why I want to avoid throwing errors.
Restricting boolean use to a certain "safe" type avoids
having to deal with them, I think. What's your opinion ?

> Cheers,
Thanks for your patience,

> Martin
YG

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Oct 21 10:21:01 2014

This archive was generated by hypermail 2.1.8 : Tue Oct 21 2014 - 10:21:53 PDT