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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a05:6214:1634:: with SMTP id e20mr9591644qvw.205.1579983986490; Sat, 25 Jan 2020 12:26:26 -0800 (PST) X-Received: by 2002:a9d:73ca:: with SMTP id m10mr7551985otk.312.1579983986179; Sat, 25 Jan 2020 12:26:26 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!g89no10490554qtd.0!news-out.google.com!w29ni408qtc.0!nntp.google.com!g89no10490546qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 25 Jan 2020 12:26:21 -0800 (PST) In-Reply-To: <01f6b6cc-9ce6-43b8-9c67-5595fa960381@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=146.5.17.67; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.17.67 References: <01f6b6cc-9ce6-43b8-9c67-5595fa960381@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7ac9e461-6e59-4a81-9e47-98d2e6f0d59a@googlegroups.com> Subject: Re: Creating several types from a base type and conversion From: Shark8 Injection-Date: Sat, 25 Jan 2020 20:26:26 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:57944 Date: 2020-01-25T12:26:21-08:00 List-Id: On Saturday, January 25, 2020 at 3:37:17 AM UTC-7, Ken Roberts wrote: > It might be that I can only really concentrate on learning Ada on my week= ends (thursday night -> saturday) subject to $HoneyDoList. >=20 > Needless to say, I'm not always the brightest nowadays between age and fr= ee time without some extra help, so sorry for seeming a little dense right = now. That's fine; we all know life happens. >=20 > Here's the computer representation as expressed in documentation and how = I'm used to working on the hardware: >=20 > 30-bit words (both memory storage and hardware registers) >=20 > Bit Number : 29 28 .. 01 00 > MSBit on left, LSBit on right Isn't MSB on left, rather arbitrary? (eg "Your left or mine?") What really matters is that you're consistent. > Instruction format: >=20 > Bit number: | 29 .. 24 | 23 .. 21 | 20 .. 18 | 17 .. 15 | 14 .. 0 | > Field : | Op code | J | K | B | Y | >=20 > Op code : Instruction > j : Skip next instruction modification > k : Source or destination of data > b : Index register to use to modify Y > y : Constant or memory address I would recommend that you use a proper enumeration for your op-codes, and = a full record for your instruction. The enumeration can help by making use = of the required case-coverage (absent an OTHERS option) for case-statements= and discriminated-records; the record is an excellent way to "keep things = together" and organize things. =E2=80=94 If you *do* use a record for the i= nstruction-type, consider a record discriminated on the op-code enumeration= . >=20 > Based on Niklas Holsti's recommendation, it looks like the following woul= d be what I want to do: >=20 > >=20 > with Interfaces; > package core is >=20 > subtype Word is Interfaces.Unsigned_32 with range 0 .. 2**30 - 1; >=20 > subtype D_Word is Interfaces.Unsigned_64 with record > Ru : Word; > Rl : Word; > end record >=20 > for D_Word use record > Ru : at 0 use 59 .. 30; > Rl : at 0 use 29 .. 0; > end record >=20 > -- NOTE: I_Word is basically read-only > -- The only use is to make it easier to break down Word into > -- the fields to interpret the instruction and will not change > -- during the instruction execution cycle >=20 > I_Word is Word with record > -- Not sure how to define this part yet > -- See below for breakdown of bits-to-fields > end record >=20 > for I_Word use record > f : at 0 range 29 .. 24; > j : at 0 range 23 .. 21; > k : at 0 range 20 .. 18; > b : at 0 range 17 .. 15; > y : at 0 range 14 .. 00; > end record >=20 > end package core; >=20 > I_Word's syntax is off you can only do "Type X is new Y with record ..." fo= r tagged types. =E2=80=94 in order to make it work as you have it laid out = you're going to need the appropriate sized types to occupy those locations. > -- Circular left shift register > procedure shift_left_logical (R : <> Word'Class,=20 > Count : in Integer) is You can only use S'Class on tagged types; while you /could/ have your word-= types as tagged-types, it's probably a really bad idea considering you indi= cate you want to model the bits. (Tagged-types have a tag which would throw= off your record's bit-layouts.) >=20 > Thanks for all of your help - I wish I could catch on a little quicker, b= ut age and $DayJob (plus $HoneyDoList) make learning a new language a littl= e challenging lately. Again, it's fine.