Tristan, You can write your own resolution function, and declare a resolved subtype using it. The function takes an unconstrained array of integers (the driven values), and returns a value of the same type or subtype thereof. subtype nat4 is integer range 0 to 3; function modular4(arg: integer_vector) return nat4 is variable temp : integer := integer'low; begin for I in arg'range loop temp := maximum(temp, arg(i)); end loop; return temp mod 4; end function modular4; subtype mod4 is modular4 integer; signal mysig : mod4; mysig <= 5; -- takes the value (5 mod 4) = 1 In your counter-example, if s were of the resolved subtype mod4, then s could not have had the value integer'high in the first place, so s + 1 could not exceed integer'high, and there would be no error. However, s <= integer'high + 1 would generate an error in the "+" function, and without functions knowing the subtype for the return value from the context, so would any other solution that is interoperable with standard integers. Andy D Jones Electrical Engineering Lockheed Martin Missiles and Fire Control Dallas TX -----Original Message----- From: owner-vhdl-200x@eda.org [mailto:owner-vhdl-200x@eda.org] On Behalf Of tgingold@free.fr Sent: Wednesday, October 22, 2014 10:53 PM To: vhdl-200x@eda.org Subject: {Spam?} Re: EXTERNAL: [vhdl-200x] A compromise about modular type, boolean operations, integers... > There is still another alternative: > > For signals, we can create modular integers today, using a resolution > function. Not, that's not correct. Whatever the resolution function resolv in that excerpt, you cannot have a modular behaviour: signal s : resolv integer; .. s <= s + 1; when 's' has the integer'last value, you will get an error. And that error occurs in the '+'. If you don't agree with that, please provide a counter-case. Tristan. -- 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 Wed Oct 22 21:39:31 2014
This archive was generated by hypermail 2.1.8 : Wed Oct 22 2014 - 21:39:44 PDT