-- Kernel-PC16 prom (revision B)
-- for Rev B&up CP’s
-- last edited by R. Garner on December 12, 1979 11:29 AM
-- File: KernPC16.mesa in [Iris]<Workstation>LH>CPPromsMesa-B.dm
--
and in [Iris]<Workstation>LH>CPProms-B.press

DIRECTORY
ImageDefs: FROM "ImageDefs"
USING [StopMesa],
PromBlowDefs: FROM "PromBlowDefs"
USING [WritePromData, WritePromList];

KernPC16Prom: PROGRAM IMPORTS ImageDefs, PromBlowDefs =
BEGIN OPEN PromBlowDefs;

Size:
CARDINAL = 256;-- number of prom locations
addrWidth:
CARDINAL = 8;-- number of prom address bits
dataWidth:
CARDINAL = 4;-- number of prom output data bits

-- Note: a "n" at the end of a name indicates it is an active low signal, i.e. assigning FALSE means that it represents a true state.

Addr: TYPE = MACHINE DEPENDENT RECORD -- Right-justified
[pad: [0..377B],
null: BOOLEAN,
KernReqn: BOOLEAN,
CSParErr: BOOLEAN,
ExitKerneln: BOOLEAN,
EnterKerneln: BOOLEAN,
IOPWait: BOOLEAN,
CINpc16: BOOLEAN,
pc16n: BOOLEAN];

Output:
TYPE = MACHINE DEPENDENT RECORD -- Left-justified
[KernReqn: BOOLEAN,
null1: BOOLEAN,
pc16n: BOOLEAN,
null2: BOOLEAN,
pad: [0..7777B]];

Prom:
ARRAY [0..Size] OF Output;
A: Addr;
Out: Output;
GenKernPC16Prom: PROCEDURE =
BEGIN
i: CARDINAL;
rq: BOOLEAN;-- temporary
FOR i IN [0..Size) DO
A ← LOOPHOLE[i];
Out.null1 ← Out.null2 ← TRUE;

--
pc16
-- pc16 is invered by CIN←pc16 or else remains the old value. pc16 is not updated if the click is suspended.

Out.pc16n ← IF A.CINpc16 THEN ~A.pc16n ELSE A.pc16n;

--
KernReq’
-- The Kernel is requested to run if there is a parity error, an EnterKernel function (a breakpoint instruction), or IOPWait is true. If one of these is true in c1, the Kernel will run in the next click. However, if it is executed in c2 or c3 (in the emulator, lets suppose), then the emualtor can run for 1 more click before the kernel starts up (unless an IO task overrides it).
-- KernRequests will continue until reset by ExitKernel. The reset is overridden by pending requests. If Exit Kernel is executed in c1, the task to run in the next click will be determined by the pending task requests. Note that ExitKern & EnterKern can not be simultaneously executed since they are both encoded by fY.

rq ← A.CSParErr OR ~A.EnterKerneln OR A.IOPWait;
rq ← IF (~A.ExitKerneln AND ~rq) THEN FALSE ELSE (rq OR ~A.KernReqn);
Out.KernReqn ← ~rq;

Prom[i] ← Out;
ENDLOOP;
END;


GenKernPC16Prom[];
WritePromData["KernPC16Prom-RevB", addrWidth, dataWidth, @Prom[0]];
WritePromList["KernPC16Prom-RevB", addrWidth, dataWidth, @Prom[0]];
ImageDefs.StopMesa[]

END.