From: Mike Silva <mjsilva697@gmail.com>
Subject: Array slicing question
Date: Mon, 7 Jul 2014 00:31:51 -0700 (PDT)
Date: 2014-07-07T00:31:51-07:00 [thread overview]
Message-ID: <91b81cfc-2faa-4cc5-9c9c-0dc663b67a68@googlegroups.com> (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);
next reply other threads:[~2014-07-07 7:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 7:31 Mike Silva [this message]
2014-07-07 8:04 ` Array slicing question Simon Wright
2014-07-07 13:34 ` G.B.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox