Re: [vhdl-200x] RE: Modular types

From: <whygee@f-cpu.org>
Date: Wed Jul 30 2014 - 23:54:44 PDT
Hello,

Le 2014-07-31 07:55, Brent Hayhoe a écrit :
> I am in agreement with most of this proposal. However, I feel we are
> getting confused between defining a modular integer type and its
> implementation within a compiler.

for me it's not confusion, it's also about what goal we are pursuing.
Trying to make VHDL too abstract can lead to too much inefficiencies.

> Integers, as a VHDL type, have no comprehension of shift functions or
> logical functions. These imply vectors, or how we would naturally
> implement integers. They do have mathematical equivalents, e.g. shift
> -> 2**(±N) assuming we are mapping to a binary vector such as
> UNSIGNED.

But then, what else do you want to map integers too ?
what other representation might eventually be used in practice ?
Ternary was briefly experimented with by Russians with no real impact.
Everybody and their dog use binary.

> As such they should be added as overloads to the Numeric_Std and
> Numeric_Bit packages.

Can you elaborate ?
(no pun intended)

> Now, most explanations of modular types start with the analogy to time
> - hours, minutes, and seconds and that they are examples of modulo 12
> types  i.e:
> 
>     1, 2, 3,....11, 12.
> 
> and then they very quickly normalize this type to:
> 
>     0, 1, 2,....10, 11.
> 
> and then start explaining modular types.

normalisation is a matter of convention, people are used
to use "12" for "0"...

> In fact there are many (infinite) subtypes of this range length that
> are of a modulo 12 subtype.
> 
> So in order to perform the arithmetic in normal INTEGER, we will need
> to first normalize any modular types and caste to INTEGER:
> 
>     int_object = INTEGER(mod_object - MOD_TYPE'low)    ....... or do 
> we???

the modular type should be stored as a normalised (mod'ed) integer.
so you don't need to compute the subtraction.

I probably missed discussions about the range of modulo types,
and I'm not even sure that they are a subtype of integers so do we have 
a 'low ?

> and then after performing the integer calculation, the resolution
> function will need to convert it back to its modulo type and
> reverse-normalize at the assignment point:
> 
>     mod_object = MOD_TYPE(int_object mod MOD_TYPE'length) + 
> MOD_TYPE'low
> 
> That is my concept of how we should handle modular type arithmetic.

This is the principle, yes.

Now, we wouldn't need modular types if the "pure math integer" approach
of VHDL was enough. And we must not forget that VHDL is not a math or 
calculus
language but a circuit description language, and our circuits are made 
of bits :-)

> Regards,
> 
> Brent.
YG

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Jul 30 23:55:04 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 30 2014 - 23:55:19 PDT