From: Bill Findlay <yaldnif.w@blueyonder.co.uk>
Subject: Aspects, rep specs, shifts, conditional expressions, expression functions
Date: Thu, 22 Dec 2011 04:19:47 +0000
Date: 2011-12-22T04:19:47+00:00 [thread overview]
Message-ID: <CB186063.D1C0%yaldnif.w@blueyonder.co.uk> (raw)
The topics listed in the subject have been controversial recently.
I wonder what people think of my first attempt at an Ada 2012 package,
which seems to use them all, in what I hope is a judicious mix?
----
with Unchecked_Conversion;
with KDF9.CPU;
package KDF9.K5_stuff is
-- PHU, the Program Hold-Up register is internal to I/O Control.
-- A subset is exposed to Director by means of the K5 order.
-- It has one element for each of the 4 program priority levels.
type blockage is (buffer_busy, locked_out) with Size => 1;
type group_address is mod 1024 with Size => 10;
type PHU_store (hold_up : one_bit := 0;
reason : blockage := buffer_busy) is
record
case hold_up is
when 0 =>
null;
when 1 =>
case reason is
when buffer_busy =>
buffer_nr : buffer_number;
when locked_out =>
group_nr : group_address;
end case;
end case;
end record;
PHU : array (priority) of PHU_store;
type PHU_subset is
record
hold_up : one_bit;
reason : blockage;
parameter : buffer_number;
end record
with Size => 6, Bit_Order => Low_Order_First;
for PHU_subset use
record
hold_up at 0 range 5 .. 5;
reason at 0 range 4 .. 4;
parameter at 0 range 0 .. 3;
end record;
type PHU_as_6_bits is mod 2**6 with Size => 6;
function as_6_bits is
new Unchecked_Conversion(Source => PHU_subset,
Target => PHU_as_6_bits);
function K5_word (short_PHU : PHU_subset) return word is
(word(as_6_bits(short_PHU)));
function short_PHU (p : priority) return word is
(K5_word((
hold_up => PHU(p).hold_up,
reason => (
if PHU(p).hold_up = 0 then
buffer_busy -- A non-significant 0 bit.
else
PHU(p).reason
),
parameter => (
if PHU(p).hold_up = 0 then
0
elsif PHU(p).reason = buffer_busy then
PHU(p).buffer_nr
else
buffer_number(PHU(p).group_nr mod 2**4)
)
))
);
-- A K5_operand is a KDF9 word, D00-D47, with the content:
-- short_PHU(0) in D00 .. D05
-- short_PHU(1) in D06 .. D11
-- short_PHU(2) in D12 .. D17
-- short_PHU(3) in D18 .. D23
function K5_operand return word is
(
KDF9.CPU.shift_word_left(short_PHU(0), 47-05) or
KDF9.CPU.shift_word_left(short_PHU(1), 47-11) or
KDF9.CPU.shift_word_left(short_PHU(2), 47-17) or
KDF9.CPU.shift_word_left(short_PHU(3), 47-23)
);
end KDF9.K5_stuff;
--
Bill Findlay
with blueyonder.co.uk;
use surname & forename;
next reply other threads:[~2011-12-22 4:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-22 4:19 Bill Findlay [this message]
2011-12-23 1:01 ` Aspects, rep specs, shifts, conditional expressions, expression functions Randy Brukardt
2011-12-23 17:50 ` Bill Findlay
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox