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

From: Jones, Andy D <>
Date: Sat Jun 28 2014 - 09:55:14 PDT
From: [] On Behalf Of
 > Well, resolution function applies only on signals.

Have you tried it, or are you relying on the LRM's silence WRT the effects of resolution functions on variables? I have not tried it yet. (I will soon). 

Note that the LRM specifies that not just subtypes, but objects themselves (constants, ports, signals and [gasp!] variables) are all declared with a subtype_indication, which is defined as including an optional resolution_indication. Therefore, the LRM actually, explicitly supports associating a resolution function directly with a variable. It just remains silent on the effect (is or should the resolution function be called to determine the updated value for an object other than a port/signal). 

Clearly the LRM is ambiguous on this (one way or the other) and should be corrected!

> You can't achieve modulo arithmetic with resolution function.
> If you write 17 ** 16, you get a value for a modulo type, but a overflow on integer types.

This same behavior is also true if you use an Ada modular type, and exceed the implementation's range for Ada integers. Can you imagine what it would mean if the language had to support an arbitrarily large, pre-modulo value (e.g. integer'high ** integer'high)?

What is different is that Ada modular types perform the modulo operation after each operation in an expression, rather than on the results of the expression being assigned to the object, as with a resolution function. For complex expressions, this might cause overflows with a resolved subtype which would not have occurred with a modular type.

However, we must address the pitiful range of integer, regardless of whether or how we address modulo behavior for them.

Even if we have to revise the LRM to employ resolution functions on variables, they would be a much cleaner, simpler and easier to use solution than modular types. I am all for borrowing things from Ada if we need them, unless there is an alternative that fits better with VHDL. 

Given that resolution functions can be deployed through subtypes, such a modular implementation retains the spirit of Ada modular types, with more flexibility and compatibility. 

If we revise the LRM in this regard, we can also provide for more flexibility in the resolution_indication, including the specification of an optional association list (for parameters or generics) with the resolution_function_name, to simplify the specification of multiple subtypes or objects with different modulus values.

And, with resolution functions, we are not limited to modulo arithmetic on integers, but can explore similar "auto-resizing" effects on fixed point and other types.



This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Sat Jun 28 09:55:27 2014

This archive was generated by hypermail 2.1.8 : Sat Jun 28 2014 - 09:56:04 PDT