From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Creating several types from a base type and conversion
Date: Sat, 25 Jan 2020 12:26:21 -0800 (PST)
Date: 2020-01-25T12:26:21-08:00 [thread overview]
Message-ID: <7ac9e461-6e59-4a81-9e47-98d2e6f0d59a@googlegroups.com> (raw)
In-Reply-To: <01f6b6cc-9ce6-43b8-9c67-5595fa960381@googlegroups.com>
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 weekends (thursday night -> saturday) subject to $HoneyDoList.
>
> Needless to say, I'm not always the brightest nowadays between age and free time without some extra help, so sorry for seeming a little dense right now.
That's fine; we all know life happens.
>
> Here's the computer representation as expressed in documentation and how I'm used to working on the hardware:
>
> 30-bit words (both memory storage and hardware registers)
>
> 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:
>
> Bit number: | 29 .. 24 | 23 .. 21 | 20 .. 18 | 17 .. 15 | 14 .. 0 |
> Field : | Op code | J | K | B | Y |
>
> 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. — If you *do* use a record for the instruction-type, consider a record discriminated on the op-code enumeration.
>
> Based on Niklas Holsti's recommendation, it looks like the following would be what I want to do:
>
> <code>
>
> with Interfaces;
> package core is
>
> subtype Word is Interfaces.Unsigned_32 with range 0 .. 2**30 - 1;
>
> subtype D_Word is Interfaces.Unsigned_64 with record
> Ru : Word;
> Rl : Word;
> end record
>
> for D_Word use record
> Ru : at 0 use 59 .. 30;
> Rl : at 0 use 29 .. 0;
> end record
>
> -- 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
>
> I_Word is Word with record
> -- Not sure how to define this part yet
> -- See below for breakdown of bits-to-fields
> end record
>
> 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
>
> end package core;
>
> </code>
I_Word's syntax is off you can only do "Type X is new Y with record ..." for tagged types. — 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,
> 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 indicate you want to model the bits. (Tagged-types have a tag which would throw off your record's bit-layouts.)
>
> Thanks for all of your help - I wish I could catch on a little quicker, but age and $DayJob (plus $HoneyDoList) make learning a new language a little challenging lately.
Again, it's fine.
next prev parent reply other threads:[~2020-01-25 20:26 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-18 7:32 Creating several types from a base type and conversion Ken Roberts
2020-01-18 12:16 ` Simon Wright
2020-01-18 12:49 ` Ken Roberts
2020-01-18 14:56 ` Bill Findlay
2020-01-18 16:13 ` Jeffrey R. Carter
2020-01-18 18:20 ` Bill Findlay
2020-01-18 18:32 ` Jeffrey R. Carter
2020-01-18 20:34 ` Simon Wright
2020-01-20 16:38 ` Bill Findlay
2020-01-18 22:20 ` Ken Roberts
2020-01-18 15:09 ` Simon Wright
2020-01-18 22:16 ` Ken Roberts
2020-01-18 22:35 ` Simon Wright
2020-01-18 23:03 ` Ken Roberts
2020-01-18 23:38 ` Simon Wright
2020-01-19 0:12 ` Ken Roberts
2020-01-19 9:37 ` Simon Wright
2020-01-19 11:48 ` AdaMagica
2020-01-19 14:51 ` Simon Wright
2020-01-19 15:24 ` Niklas Holsti
2020-01-19 16:11 ` Optikos
2020-01-19 0:33 ` Ken Roberts
2020-01-19 0:07 ` Niklas Holsti
2020-01-18 15:47 ` Simon Wright
2020-01-21 21:35 ` Shark8
2020-01-21 23:06 ` Niklas Holsti
2020-01-22 1:08 ` Ken Roberts
2020-01-22 14:18 ` Ken Roberts
2020-01-22 8:37 ` Simon Wright
2020-01-22 14:32 ` Shark8
2020-01-22 15:40 ` Simon Wright
2020-01-18 14:17 ` Optikos
2020-01-18 17:57 ` Niklas Holsti
2020-01-18 22:59 ` Ken Roberts
2020-01-19 0:30 ` Niklas Holsti
2020-01-19 1:07 ` Ken Roberts
2020-01-19 3:37 ` Ken Roberts
2020-01-23 21:39 ` Optikos
2020-01-24 9:35 ` Ken Roberts
2020-01-24 10:04 ` AdaMagica
2020-01-24 12:38 ` Optikos
2020-01-24 15:01 ` Ken Roberts
2020-01-24 15:22 ` Simon Wright
2020-01-24 15:40 ` Ken Roberts
2020-01-24 15:54 ` Simon Wright
2020-01-25 10:37 ` Ken Roberts
2020-01-25 10:44 ` Ken Roberts
2020-01-25 20:26 ` Shark8 [this message]
2020-01-27 14:10 ` Ken Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox