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

From: Jones, Andy D <andy.d.jones@lmco.com>
Date: Fri Jul 11 2014 - 14:34:38 PDT
I favor (4): we specify the behavior for all integer values of modulus (do the operation on the "base" type, and then modulo that to get the result.) Ada has the logical operators defined, and there are arithmetic definitions for the shift operators, whether they are efficiently realizable in HW or not.

Synthesis tools are free to implement what they can. If they can tell a non-power-of-two modulo is just a single, conditional subtraction, say in a counter, they can choose to implement that, or not.

We still need to decide whether we are talking about modular types, or modular subtypes of integer base types. I am comfortable with subtypes (evaluate the expression using the base type, and perform the modulo on assignment/association). If someone needs the effects of different, intermediate moduli, then they can always break the expression up into separate expressions assigned to separate objects of the desired moduli.

Among subtypes, I still favor a resolved subtype (extended to variables) approach. It has a smaller impact on the language, while still providing the needed functionality.

If we wanted modular types, we would probably need generic packages that defined the operators, etc. along with the new types, with the modulus passed in as a generic. However, that still leaves us without a clean way to interoperate between types of different moduli. That's ultimately why I like a subtype implementation, resolved or otherwise.

Andy





-----Original Message-----
From: owner-vhdl-200x@eda.org [mailto:owner-vhdl-200x@eda.org] On Behalf Of Brian Drummond
Sent: Friday, July 11, 2014 12:08 PM
To: vhdl-200x@eda.org
Subject: EXTERNAL: Re: [vhdl-200x] Modular types

On Fri, 2014-07-11 at 18:41 +0200, tgingold@free.fr wrote:
> > But if we are providing boolean and shift operators for the special 
> > case of modulo 2**n, then we have to do one of:
> > 
> > 1) restrict modular types to mod 2**n. Prohibits other legitimate 
> > uses.
> > IMO : Just No.
> 
> Why not.

Because I have no desire to prohibit legitimate uses of modular types, such as wrapround counters, where modulus need not be 2**n.

> > 2) Define boolean and shift only for mod 2**n and prohibit for other 
> > cases. Ugly irregular language feature. IMO : No.
> 
> That's my preferred choice.  There is no obvious definition of 
> logicals and shift operators for not mod 2**n types.  So I suppose 
> nobody would use them (and we could revisit this issue at a later revision).
> 
> We have many irregular rules (shift operators are only predefined for 
> one-dimensional array of BIT and BOOLEAN); and I fear that any 
> definition of shift and logical operator for no mod 2**n would be 
> ugly.

Interesting. It's not my first choice, but if the details turn out to be so ugly, I could be persuaded to support (2).

> > 5) Split modular types into two  : power of two, and other. IMO : 
> > too much complexity
> 
> We could split modular types into two using the same syntax 
> (enumerated types are also split into two: characters ones and the others).
> No complexity here.
in other words, this option would reduce to (2).
> 
> Strongly in favour of 2) after the Ada experience.

I'm interested : what about the Ada logical operators (there are no shift operators) on modular types is problematic in practice? 

The semantics struck me as a bit odd, but I presumed that was academic since I didn't think anyone actually used them! 

Is it a matter of the implementation burden, or are there practical drawbacks too?

- Brian



--
This message has been scanned for viruses and dangerous content by MailScanner, 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 Fri Jul 11 14:35:21 2014

This archive was generated by hypermail 2.1.8 : Fri Jul 11 2014 - 14:35:48 PDT