Re: EXTERNAL: Re: [vhdl-200x] Standard Package enhancements

From: Daniel Kho <daniel.kho@gmail.com>
Date: Sat Apr 18 2015 - 00:35:09 PDT
Yes, the fixed/float types shows some good ways for using negative indices.
I may have gotten some inspiration from those packages.

I use normal vector types (like std_ulogic_vector, unsigned, signed) for
mathematical operations as well, for cases when I feel fixed / floating
types are not necessary. So, I feel it makes sense for us to extend the
ranges to support negative indices for these.

In many cases, it is just used to show more clarity to the code. For
example, index 0 may indicate the current data sample being processed,
while negative indices may indicate previous samples, and positive indices
may indicate the "future" or next samples from the current data being
processed. In a buffer containing all the samples that need processing, the
middle location of the array will be the current sample being processed,
while to the left of that, will indicate previous samples, and to the
right, the next samples.

It will be intuitive to write:
    sample(0) <= sample(-1) xor sample(1);    -- or any other math operation
instead of figuring out the middle index of the array buffer and use that
index as the index to process the current sample. In an array of 9 samples
for example, index 5 will be the middle index, so we had to write the
following if negative indices were not supported:
    sample(5) <= sample(4) xor sample(6);

While both expressions boil down to the same thing, the first expression
looks clearer and more intuitive in showing the intention of the algorithm.

-Daniel

On 17 April 2015 at 21:56, Jennings, Kevin <Kevin.Jennings@burroughs.com>
wrote:

> *From:* owner-vhdl-200x@eda.org [mailto:owner-vhdl-200x@eda.org] *On
> Behalf Of *Martin.J Thompson
> *Sent:* Friday, April 17, 2015 3:36 AM
> *To:* vhdl-200x@eda.org
> *Subject:* RE: EXTERNAL: Re: [vhdl-200x] Standard Package enhancements
>
>
>
> <snip>
>
>
>
> I’m also not sure what the benefit of negative indices is – the use of
> them for fixed and floating types struck me as an elegant use, but I’m not
> sure how that kind of use extends to vectors of non-bit types?
>
>
>
> KJ:  But it doesn’t sound like you were sure of the benefits of negative
> indices for bit types either until you saw and appreciated it for
> fixed/float types.
>
>
>
> Kevin
>
> --
> 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 Sat Apr 18 00:35:50 2015

This archive was generated by hypermail 2.1.8 : Sat Apr 18 2015 - 00:36:40 PDT