comp.lang.ada
 help / color / mirror / Atom feed
* Comments requested for a couple of Ada-Comments submissions
@ 2014-07-11  0:02 Simon Clubley
  2014-07-11  0:30 ` Jeffrey Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Simon Clubley @ 2014-07-11  0:02 UTC (permalink / raw)


Hello,

Since it's my first time sending anything to Ada-Comments, I was hoping
for feedback before I submit them. I'm looking for things like style,
content, unclear language, etc. Among other things, I don't want to
waste Randy's time if I've missed something obvious. :-)

The two issues are below and thanks for any feedback,

Simon.

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

However, sometimes there is a requirement to be able to update a
subset of those bitfields as an atomic operation while preserving
the contents of the other bitfields in the record.

In Ada, the only way to do this (apart from C style bitmasks on a
integer variable) is to read the device register into a temporary
instance of the record type, modify the temporary variable and
write the temporary variable back to the device register.

This, to put it mildly, is ugly.

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.

Thanks,

Simon.

-----------------------------------------------------------------------------
Issue 2: Does Atomic apply to record components ?

!topic		Does Atomic on a record apply to it's components ?
!reference	Ada 2012 RMC.6(15)
!from		Simon Clubley 2014-07-10
!keywords	Atomic update record components

C.6(15) states:

For an atomic object (including an atomic component) all reads and
updates of the object as a whole are indivisible.

Scenario:

Consider a 32 bit record marked as Atomic. This record consists of
multiple bitfields and is used to model the bitfields in a 32 bit
memory mapped device register. The hardware requires the device
register to be read from and written to in units of 32 bits.

Now consider the following statement:

	Device_Register.bitfield := 1;

When this specific bitfield in the record, say 4 bits wide, is written
to, does the Atomic attribute on the record require the register to
be accessed in units of 32 bits or is the compiler permitted to
generate code to access, say, 8 bits of the register only ?

There are conflicting opinions in comp.lang.ada. The words "as a whole"
in C.6(15) were used to justify the position that access to this single
bitfield is not required to be in units of the record size which on the
surface seemed reasonable.

However, other opinions are that C.6(15) does apply when accessing this
single bitfield.

Which opinion is correct ?

I would like C.6(15) to apply, but I am more interested in obtaining a
firm decision so that we actually know one way or another.

You should be aware that generated code posted in comp.lang.ada shows
that for a ARM target, ldrb/strb (ie: byte level access) was used instead
of ldr/str (ie: 32 bit level access) when the bitfield was within the
first 8 bits of the register. This broke the hardware requirement this
register be accessed in units of 32 bits.

Thank you,

Simon.
-----------------------------------------------------------------------------

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2014-07-12  5:52 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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