From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,19502ac20a7b16de X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-20 00:45:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!213.200.246.247!not-for-mail From: Vinzent Hoefler Newsgroups: comp.lang.ada Subject: Re: Dynamic discrimants in variant records? Date: Fri, 20 Jun 2003 09:44:04 +0200 Organization: JeLlyFish software Message-ID: References: <3EF24E74.1080107@spam.com> NNTP-Posting-Host: 213.200.246.247 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: fu-berlin.de 1056095138 24473206 213.200.246.247 (16 [175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:39482 Date: 2003-06-20T09:44:04+02:00 List-Id: Jeffrey Carter wrote: >Vinzent Hoefler wrote: >>=20 [...] >>=20 >> 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 :=3D (Target =3D> GP_Bus_Memory, Pg_Size =3D> Four_Ki_Byte, > Mem_Attr =3D> ..., Sz_St_Addr_4K =3D> ...); >... >V :=3D (Target =3D> GP_Bus_Memory, Pg_Size =3D> Sixty_Four_Ki_Byte, > Mem_Attr =3D> V.Mem_Attr, Sz_St_Addr_64K =3D> ...); *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=20 >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=20 >to do that, too: > >declare > Temp : Programmable_Address_Region > (Target =3D> V.Target, Pg_Size =3D> Sixty_Four_Ki_Byte); >begin > Temp.Mem_Attr :=3D V.Mem_Attr; > Temp.Sz_St_Addr_64K :=3D ...; > V :=3D 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. --=20 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.