comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Forcing GNAT to use 32-bit load/store instructions on ARM?
Date: Sat, 05 Jul 2014 02:18:22 +0200
Date: 2014-07-05T02:18:22+02:00	[thread overview]
Message-ID: <c1ouibF1sfU1@mid.individual.net> (raw)
In-Reply-To: <c1osvbFuc0jU1@mid.individual.net>

On 14-07-05 01:51 , Niklas Holsti wrote:
> 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
                                                               ^^^
(Delete the word "not", above -- it is quite possible that some reserved
bits read as 1, although they should be written with zero.)

> 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
      .      @       .


      reply	other threads:[~2014-07-05  0:18 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-30 22:11 Forcing GNAT to use 32-bit load/store instructions on ARM? daniel.dmk
2014-06-30 23:41 ` Jeffrey Carter
2014-07-01 12:06   ` Simon Clubley
2014-07-01 15:44     ` Niklas Holsti
2014-07-01 17:26       ` Simon Clubley
2014-07-01 17:18     ` Simon Wright
2014-07-01 19:43       ` Simon Wright
2014-07-01 17:28     ` Jeffrey Carter
2014-07-01  0:55 ` anon
2014-07-01  4:30 ` Niklas Holsti
2014-07-01  8:11 ` Dmitry A. Kazakov
2014-07-01 12:09   ` Simon Clubley
2014-07-01 12:20     ` Dmitry A. Kazakov
2014-07-01 17:00       ` Simon Clubley
2014-07-01 19:36         ` Dmitry A. Kazakov
2014-07-01 20:08           ` Simon Clubley
2014-07-02 22:24             ` Randy Brukardt
2014-07-06 20:40               ` MatthiasR
2014-07-07  0:25                 ` Simon Clubley
2014-07-07 22:38                 ` Randy Brukardt
2014-07-08  6:51                   ` Simon Wright
2014-07-10 11:47                     ` Simon Wright
2014-07-10 13:06                       ` Simon Clubley
2014-07-11 18:05                         ` Simon Wright
2014-07-11 20:22                           ` Simon Clubley
2014-07-08  8:50                   ` Brian Drummond
2014-07-08 12:12                   ` Simon Clubley
2014-07-08 13:26                     ` G.B.
2014-07-08 17:13                       ` Simon Clubley
2014-07-08 15:36                     ` Adam Beneschan
2014-07-08 15:40                       ` Adam Beneschan
2014-07-08 20:34                     ` Randy Brukardt
2014-07-09  7:31                       ` Dmitry A. Kazakov
2014-07-10  0:11                         ` Simon Clubley
2014-07-20 11:35                   ` MatthiasR
2014-07-20 15:49                     ` Simon Clubley
2014-07-26 11:05                       ` MatthiasR
2014-08-10 11:20                         ` MatthiasR
2014-07-01 12:03 ` Simon Clubley
2014-07-01 19:52   ` daniel.dmk
2014-07-01 20:40     ` Simon Clubley
2014-07-01 20:55       ` Simon Clubley
2014-07-01 21:01       ` Niklas Holsti
2014-07-01 21:20         ` Simon Clubley
2014-07-01 22:38           ` Niklas Holsti
2014-07-02 16:49             ` Simon Clubley
2014-07-01 21:55         ` daniel.dmk
2014-07-02  7:30     ` Simon Wright
2014-07-02 18:52       ` daniel.dmk
2014-07-04 23:51       ` Niklas Holsti
2014-07-05  0:18         ` Niklas Holsti [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox