comp.lang.ada
 help / color / mirror / Atom feed
From: Vinzent Hoefler <ada.rocks@jlfencey.com>
Subject: Re: Dynamic discrimants in variant records?
Date: Fri, 20 Jun 2003 09:44:04 +0200
Date: 2003-06-20T09:44:04+02:00	[thread overview]
Message-ID: <bcue32$narjm$1@ID-175126.news.dfncis.de> (raw)
In-Reply-To: 3EF24E74.1080107@spam.com

Jeffrey Carter wrote:

>Vinzent Hoefler wrote:
>> 
[...]
>> 
>> As mentioned, the actual (global) variables of this type are memory
>> mapped registers, so the problem occurs when I want to change a region
>> register dynamically (from a 4K granularity to a 64K for instance). In
>> Ada this would be equivalent to just change some of the discrimants
>> (those are really some bits in the register) and so changing the
>> interpretation of the record.
>
>It works sort of like this:
>
>V : Programmable_Address_Region; -- V is unconstrained
>for V'Address use ...;
>...
>V := (Target => GP_Bus_Memory, Pg_Size => Four_Ki_Byte,
>       Mem_Attr => ..., Sz_St_Addr_4K => ...);
>...
>V := (Target => GP_Bus_Memory, Pg_Size => Sixty_Four_Ki_Byte,
>       Mem_Attr => V.Mem_Attr, Sz_St_Addr_64K => ...);

*aarg* Call me stupid! That's exactly how I thought, it would *not*
work. Well, I didn't actually try... sorry. I suggest, I will read the
complete ARM three times for penalty. Would this be enough? ;)

>However, the only way to change a discriminant of such an object is by 
>assigning an entire new value to it.

No problem, in this case anything else wouldn't make sense. There are
not many bits in the structure that mean the same if the discrimant
bits change.

>If you must use a non-static value for the discriminant, there's a way 
>to do that, too:
>
>declare
>    Temp : Programmable_Address_Region
>           (Target => V.Target, Pg_Size => Sixty_Four_Ki_Byte);
>begin
>    Temp.Mem_Attr := V.Mem_Attr;
>    Temp.Sz_St_Addr_64K := ...;
>    V := Temp;
>end;
>
>Note that none of this code has been compiled.

Of course, I left out too many details. But I'm quite sure it will.


Vinzent.

-- 
Parents strongly cautioned  --  this  posting  is  intended for mature
audiences  over  18.  It  may  contain some material that many parents
would not find suitable for children and may include intense violence,
sexual situations, coarse language and suggestive dialogue.



      reply	other threads:[~2003-06-20  7:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-19  8:44 Dynamic discrimants in variant records? Vinzent Hoefler
2003-06-19 10:37 ` John McCabe
2003-06-19 23:57 ` Jeffrey Carter
2003-06-20  7:44   ` Vinzent Hoefler [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