comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <OneWingedShark@gmail.com>
Subject: Comments requested for a couple of Ada-Comments submissions
Date: Thu, 10 Jul 2014 22:56:36 -0600
Date: 2014-07-10T22:56:36-06:00	[thread overview]
Message-ID: <58Kvv.9105$Zt3.1101@fx02.iad> (raw)
In-Reply-To: <lpn9ic$acs$1@dont-email.me>

On 10-Jul-14 18:02, Simon Clubley wrote:
> -----------------------------------------------------------------------------
> Issue 1: Partial Aggregate notation
>
> !topic	Updating multiple record bitfields as an atomic operation
> !reference	Ada 2012 RM{clause unsure}
> !from		Simon Clubley 2014-07-10
> !keywords	bitfields records device registers atomic updating
>
> Ada can model the bitfields in a device register as a record type
> containing those bitfields and can map an instance of that record
> type to the address of that device register.
>
> A far better approach would be a new partial aggregate syntax in which
> the list of bitfields to be modified would be listed along with their
> new values.
>
> The compiler would then generate a Read-Modify-Write sequence and, as
> the operation would be on the record as a whole, C.6(15) would be
> guaranteed to apply when Atomic is used and there would be one single
> read of the device register and a single write to the device register.
>
> One suggested syntax would be:
>
> 	A := (A changing C => D, E => F);
>
> or
>
> 	A := (A updating C => D, E => F);
>
> where A is a record and C and E are record components. When this syntax
> discussion took place in comp.lang.ada one suggestion was "overriding"
> but I didn't like that because that keyword made it seem as if A was
> the one doing the overriding, not the later C and E references.
>
> I do think we need a new keyword because we are talking about adding
> a subset update capability to Ada and that new usage should stand
> out in any code.

I don't really like the new keyword idea.
One way to do this would be to perhaps have an aspect say, "Atomic_At" 
whose value would be a list of components to group for reads and writes:

Type Some_Register_1 is record
    f1 : Bits(1..4);
    f2 : Bits(1..4);
    f3 : Bits(1..8);
end record
with Atomic_At => (f1, f2) and (f3);

--or--
Type Some_Register_2 is Array(1..16) of Boolean
with Pack, Atomic_At => (1..4) and (5..8) and (9..16);

-- or, if the above suggestion is syntactically impossible to handle we 
could use ((Some_Register_1.f1, Some_Register_1.f2), 
(Some_Register_1.f3)) & (Some_Register_2(1..4), Some_Register_2(5..8), 
Some_Register_2(9..16)), respectively.


Just an idea.




  parent reply	other threads:[~2014-07-11  4:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11  0:02 Comments requested for a couple of Ada-Comments submissions Simon Clubley
2014-07-11  0:30 ` Jeffrey Carter
2014-07-11  4:16   ` Randy Brukardt
2014-07-11 16:04     ` Niklas Holsti
2014-07-11 16:24       ` Dan'l Miller
2014-07-11 20:02       ` Simon Clubley
2014-07-12  5:52         ` Niklas Holsti
2014-07-11  4:26 ` Randy Brukardt
2014-07-11  7:05   ` Simon Clubley
2014-07-11  4:56 ` Shark8 [this message]
2014-07-11 15:35   ` Adam Beneschan
2014-07-11 17:26     ` Niklas Holsti
2014-07-11 17:55       ` Adam Beneschan
2014-07-11 18:00         ` Simon Wright
2014-07-11 19:07           ` Georg Bauhaus
2014-07-11 19:10           ` Dmitry A. Kazakov
2014-07-11 19:16             ` Niklas Holsti
2014-07-11 19:35               ` Dmitry A. Kazakov
2014-07-11 21:24             ` Randy Brukardt
2014-07-11 21:46               ` Shark8
2014-07-11 19:30       ` Simon Clubley
replies disabled

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