comp.lang.ada
 help / color / mirror / Atom feed
* Array slicing question
@ 2014-07-07  7:31 Mike Silva
  2014-07-07  8:04 ` Simon Wright
  2014-07-07 13:34 ` G.B.
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Silva @ 2014-07-07  7:31 UTC (permalink / raw)


I (I being an Ada novice) am still fiddling around with writing 4 bits of LCD display data into a 32-bit GPIO register.  I have this:

   type Bits_1  is mod 2**1 with Size => 1;
   type Bits_32x1 is array (0 .. 31) of Bits_1 with Pack, Size => 32;
   type Bits_8x1 is array (0 .. 7) of Bits_1 with Pack, Size => 8;

and I want to do things like this:

   a32 : Bits_32x1;
   a8  : Bits_8x1;
...
   a32(4..7) := a8(4..7);

This is not allowed, apparently, because a32 and a8 are different types (even though the elements of the arrays are the same type, so I'm a little confused, but OK).

So can I do this?  I'm guessing if Bits_32x1 and Bits_8x1 were both subtypes of the same type, I could do it - is this correct?  But I don't know how to declare such a type, especially given the Pack and Size attributes.

I note that (ref confusion above) I CAN do this:

      for i in 4..7 loop
         gpio32(i) := b8(i);



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

end of thread, other threads:[~2014-07-07 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-07  7:31 Array slicing question Mike Silva
2014-07-07  8:04 ` Simon Wright
2014-07-07 13:34 ` G.B.

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