From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Forcing GNAT to use 32-bit load/store instructions on ARM? Date: Sat, 05 Jul 2014 01:51:09 +0200 Organization: Tidorum Ltd Message-ID: References: <0e0b9ac2-e793-4cc5-8d8d-d3441ca28a58@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net t7fnKObmOJ923zPs/mrpHQ1YyWT9zCx59hwpEgIuQCjhpojLEJ Cancel-Lock: sha1:oSCfa4mqjk+FseuskYp2gvsY9qM= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:20716 Date: 2014-07-05T01:51:09+02:00 List-Id: On 14-07-02 09:30 , Simon Wright wrote: > daniel.dmk@googlemail.com writes: > >> Thanks for this suggestion, I'll define the reserved bits in the >> register, and use static checks to enforce that they are not modified >> from their reset value in the code. > > You could use something like > > type Reserved_Bit is range 0 .. 0 with Size => 1; > type Reserved is array (Natural range <>) of Reserved_Bit > with Component_Size => 1; > > ... > > type T is record > A : Boolean; -- at bit 0 > Res : Reserved (1 .. 6); > B : Boolean; -- at bit 7 > end record with Size => 8; > > (with representation clauses as indicated) That has two potential problems... - First, even if Reserved_Bit is constrained to a single value (0), that does not mean that an uninitialized variable or component of this type will have that value. It will still have to be assigned the value zero, to be sure of having that value. - Second, if you read the value of the control register into a variable of type T, and some of the reserved bits read as 1 (which is not quite possible), these Reserved_Bit components will now, very probably, have an invalid representation, which is a nasty state. For these reasons, I would define Reserved_Bit as range 0 .. 1 and perhaps provide the default value (others => 0) for the Res component. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .