EU.rose
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last edited by: Monier, May 10, 1984 7:23:23 pm PDT
Last edited by: McCreight, March 11, 1986 12:22:37 pm PST
Last edited by: Curry, September 5, 1985 11:21:43 pm PDT
Last edited by: Herrmann, September 5, 1985 2:50:49 pm PDT
Louis Monier January 28, 1986 12:22:46 pm PST
??? shows something that has to be discussed and fixed
Directory Rope, DragOpsCross, LizardRosemary;
TranslationNeeds Dragon;
Imports Atom, Basics, ClusterParams, DragonRosemary, DragonRoseExtras, IO, BitOps, RoseEvents, RoseRun, RoseTypes, RoseVectors, DragOpsCrossUtils, ViewerIO;
Cedar
fieldAdr:  INTEGER = DragOpsCross.ProcessorRegister[euField].ORD;
marAdr:  INTEGER = DragOpsCross.ProcessorRegister[euMAR].ORD;
Remark: PROC [ message: Rope.ROPE ] = {RoseRun.DisableableStop[Remark, message]};
FieldOp: PROC[aluLeft, aluRight, fieldDesc: Dragon.HexWord]
RETURNS [result:Dragon.HexWord] =
BEGIN OPEN DragOpsCross, DragOpsCrossUtils;
fd: FieldDescriptor = CardToFieldDescriptor[fieldDesc MOD 65536];
Left: Word = CardToWord[aluLeft];
Right: Word = CardToWord[aluRight];
out: Word;
From here on, the code is copied from LizardHeartImpl, which in turn purports to be identical to the manual.
shifter: Word = DoubleWordShiftLeft[Left, Right, fd.shift];
The shifter output has the input double word shifted left by fd.shift bits
mask: Word ← SingleWordShiftRight[OnesWord, 32-fd.mask];
The default mask has fd.mask 1s right-justified in the word
IF fd.insert THEN mask ← DragAnd[mask, SingleWordShiftLeft[OnesWord, fd.shift]];
fd.insert => clear rightmost fd.shift bits of the mask
out ← DragAnd[mask, shifter];
1 bits in the mask select the shifter output
IF fd.insert THEN out ← DragOr[out, DragAnd[DragNot[mask], Right]];
fd.backR => 0 bits in the mask select bits from Right to OR in to the result
result ← WordToCard[out];
END;
Returns a+b+carry and c32, where a and b are considered to be signed numbers
DoubleADD: PROC[al, bl: Dragon.HexWord, carry: BOOL]
RETURNS [sl: Dragon.HexWord, c32: BOOL] = {
Xor: PROC[x, y: BOOL] RETURNS [z: BOOL] =
{RETURN[(x AND NOT y) OR (y AND NOT x)]};
ai, bi: BOOL;
s: BOOLFALSE;
c: BOOL ← carry;
i: INTEGER;
sum: BitOps.BitDWord ← [0,0];
FOR i IN [1..32]
DO
ai ← EBFL[al, 32-i];
bi ← EBFL[bl, 32-i];
s ← Xor[ai, Xor[bi, c]];
c ← (ai AND bi) OR (bi AND c) OR (ai AND c);
sum ← BitOps.IBID[s, sum, 32, 32-i];
ENDLOOP;
RETURN[DragonRoseExtras.LFD[sum], c]};
DoubleNOT: PROC[a: Dragon.HexWord] RETURNS [c: Dragon.HexWord] = {
c ← LOOPHOLE[Basics.DoubleNot[LOOPHOLE[a]]]
};
WordOp: PROC[op:{or, and, xor}, left, right:Dragon.HexWord ← 0]
RETURNS[result:Dragon.HexWord] = {
RETURN[DragonRoseExtras.LFD[SELECT op FROM
or    => BitOps.DOR [DragonRoseExtras.LTD[left], DragonRoseExtras.LTD[right]],
and   => BitOps.DAND [DragonRoseExtras.LTD[left], DragonRoseExtras.LTD[right]],
xor   => BitOps.DXOR [DragonRoseExtras.LTD[left], DragonRoseExtras.LTD[right]],
ENDCASE => ERROR]] };
ELispFL: PROC[word: Dragon.HexWord] RETURNS[[0..7]] = {
RETURN[ BitOps.ECFD[DragonRoseExtras.LTD[word], 32, 0, 3]] };
EBFL: PROC[word: Dragon.HexWord, index: CARDINAL] RETURNS[BOOL] = {
RETURN[ BitOps.EBFD[DragonRoseExtras.LTD[word], 32, index]] };
DblShiftRt: PROC[msb: BOOL, ltIn, rtIn: Dragon.HexWord]
RETURNS[ltOut, rtOut: Dragon.HexWord] =
{rtOut ← ShiftRt[EBFL[ltIn, 31], rtIn]; ltOut ← ShiftRt[msb, ltIn]};
ShiftRt: PROC[msb: BOOL, w: Dragon.HexWord] RETURNS[r: Dragon.HexWord] =
{r𡤍ragonRoseExtras.LFD[BitOps.IBID[msb, BitOps.MDTD[DragonRoseExtras.LTD[w],32,0,31,[0,0],32,1,31],32,0]]};
DblShiftLt: PROC[ltIn, rtIn: Dragon.HexWord, lsb: BOOL]
RETURNS[cry: BOOL, ltOut, rtOut: Dragon.HexWord] =
{cry ← EBFL[ltIn,0]; ltOut ← ShiftLt[ltIn, EBFL[rtIn, 0]]; rtOut ← ShiftLt[rtIn, lsb]};
ShiftLt: PROC[w: Dragon.HexWord, lsb: BOOL] RETURNS[r: Dragon.HexWord] =
{r𡤍ragonRoseExtras.LFD[BitOps.IBID[lsb, BitOps.MDTD[DragonRoseExtras.LTD[w],32,1,31,[0,0],32,0,31],32,31]]};
vectorStream: IO.STREAMNIL;
SeeSettle: PROC [event: ATOM, watched, watcherData, arg: REF ANY] --RoseEvents.NotifyProc-- = {
cell: RoseTypes.Cell = NARROW[watcherData];
IF ClusterParams.clusterPanel.enaEULog THEN {
IF vectorStream = NIL THEN {
vectorStream ← ViewerIO.CreateViewerStreams["EU Vectors"].out;
RoseVectors.WriteHeader[vectorStream, cell];
};
RoseVectors.WriteVector[vectorStream, cell];
}
};
;
CELLTYPE "EUCompute"
PORTS [
Signal names obey the following convention: If a signal x is computed during PhA and remains valid throughout the following PhB, it is denoted as xAB. If x is computed during PhA and can change during the following PhB (as, for example, in precharged logic), it is denoted as xA. In this latter case, a client wanting to use x during PhB must receive it in his own latch open during PhA. xBA and xB are defined symmetrically. Positive logic is assumed (dragon.Asserted = TRUE = 1 = more positive logic voltage); negative-logic signals have an extra "N" at or very near the beginning of the signal name (e.g., DPNPErrorB for PBus Negative-TRUE Parity Error).
P Interface
DPData=INT[32], -- address/data to cache/FP during PhA, data to/from cache/FP during PhB
DPRejectB<BOOL, -- received during PhB
Timing and housekeeping interface
PhA, PhB<BOOL,
ResetAB<BOOL, -- not needed by the EU
Vdd, Gnd, PadVdd, PadGnd<BOOL,
I interface
KBus= INT[32],
PhiB: a, b, and c ram addresses are multiplexed on KBus. a=[0..7], b=[8..15], c=[16..23], cIsField=[24], EUAluLeftSrc1BA=[25..26], EUAluRightSrc1BA=[27..29], EUStore2ASrc1BA=[30..31].
PhiA: data moves from EU -> IFU iff cAdr = euToKBus during the previous PhiB, otherwise IFU may be using bus to pass data to EU or control to FP.
The following signals change during 1B and are stable during 2A.
EUAluLeftSrc1BA < EnumType["Dragon.ALULeftSources"],
EUAluRightSrc1BA < EnumType["Dragon.ALURightSources"],
EUStore2ASrc1BA < EnumType["Dragon.Store2ASources"],
EUSt3AisCBus2BA < BOOL, -- multiplexor control to store3AB
EURes3BisPBus3AB < BOOL, -- multiplexor control to cBusResult3BA
EUWriteToPBus3AB < BOOL, -- Tells EU to drive PBus on 3B. Used for Store instructions, and issued every instruction following a DPrejectB.
EUAluOp2AB  < EnumType["Dragon.ALUOps"],
EUCondSel2AB  < EnumType["Dragon.CondSelects"],
EUCondition2B > BOOL,
Serial debugging interface
All the following signals change during PhA and PhB, giving an entire clock cycle for them to change, are sampled during PhB, and are applied to the data path during the following PhA. All signals are not used !!! JH
DShiftAB  < BOOL, -- shift the shift register by 1 bit if ~DNSelectAB
DExecuteAB < BOOL, -- interpret the content of the shift register if ~DNSelectAB
DNSelectAB < BOOL, -- if high, hold but don't Execute or Shift
DHoldAB  < BOOL, -- must be high before testing
DDataInAB < BOOL, -- sampled 1 full cycle after a PhB that DShiftAB is Asserted
DDataOutAB = BOOL, -- changes in PhA after a PhB that DShiftAB is Asserted
Extra signals to the logger
CBusResult3BA > INT[32],
ALULeft2AB  > INT[32],
ALURight2AB > INT[32],
Store2AB   > INT[32]
]
Initializer
RoseEvents.AddWatcher[
event: $Settled,
watcher: [SeeSettle, cell],
watched: cell.sim];
State
Pipeline registers
aluLeft, aluRight, aluOut: Dragon.HexWord,
result2BA, result3AB, cBusResult3BA: Dragon.HexWord,
store2AB, store2BA, store3AB: Dragon.HexWord,
RAM, RAM addresses and various aliased registers
The RAM is organised as follows (Ref DragOpsCross):
registers 0 through 127 constitute the stack
128: euJunk i.e. no write
129: euToKBus, write result to KBus
130: euMAR
131: euField
132 through 143 are constants registers
144 through 159 are auxilliary registers
Any aAdr larger than 160 is illegal
aAdr, bAdr, cAdr: Dragon.HexByte,
cIsField: BOOL,
EUAluLeftSrc1BA: Dragon.ALULeftSources,
EUAluRightSrc1BA: Dragon.ALURightSources,
EUStore2ASrc1BA: Dragon.Store2ASources,
ram: ARRAY Dragon.HexByte OF Dragon.HexWord,
field: Dragon.HexWord, -- a copy is kept as RAM[fieldAdr], another copy is in the field unit. Any write is performed to both physical locations, any read is from the most convenient location.
Bits and pieces for the ALU and the Field Unit
carryAB, carryBA: BOOL, -- carryBA is the output of the adder modified by the opcode of the previous operation and latched if no trap; carryAB is a copy of carryBA if there is no reject or trap.
conditionB: BOOL,
Other pieces from the Control pipeline
rejectBA: BOOL -- a copy of DPRejectB stable during PhiA
EvalSimple
drive[DPData] ← ignore;
drive[KBus] ← ignore;
PhiA phase. Note that rejectBA alone inhibits almost any state change during PhiA
IF PhA THEN {
cReg: DragOpsCross.ProcessorRegister;
DragonRosemary.Assert[aAdr>=0 AND aAdr<164];
No simultaneous bypass control signals on
IF NOT (rejectBA OR EUCondition2B) THEN {carryAB ← carryBA};
IF NOT rejectBA THEN {
SELECT EUAluLeftSrc1BA FROM
aBus  => aluLeft ← (SELECT aAdr FROM
DragOpsCross.ProcessorRegister[euConstant].ORD => 0,
ENDCASE => ram[aAdr] -- watch out for illegal addresses
);
rBus  => aluLeft ← result2BA;
cBus  => aluLeft ← cBusResult3BA;
ENDCASE => DragonRosemary.Assert[FALSE];
SELECT EUAluRightSrc1BA FROM
bBus  => aluRight ← (SELECT bAdr FROM
DragOpsCross.ProcessorRegister[euConstant].ORD => 0,
ENDCASE => ram[bAdr] -- watch out for illegal addresses
);
rBus  => aluRight ← result2BA;
cBus  => aluRight ← cBusResult3BA;
kBus  => aluRight ← DragonRoseExtras.LFD[KBus];
fCtlReg => aluRight ← field;
ENDCASE => DragonRosemary.Assert[FALSE];
SELECT EUStore2ASrc1BA FROM
bBus  => store2AB ← (SELECT bAdr FROM
DragOpsCross.ProcessorRegister[euConstant].ORD => 0,
ENDCASE => ram[bAdr] -- watch out for illegal addresses
);
cBus  => store2AB ← cBusResult3BA;
rBus  => store2AB ← result2BA;
ENDCASE => DragonRosemary.Assert[FALSE];
result3AB ← result2BA;
Always send address to Cache during PhiA
drive[DPData] ← drive;
DPData ← DragonRoseExtras.LTD[result2BA];
store3AB ← SELECT EUSt3AisCBus2BA FROM
TRUE  => cBusResult3BA,
ENDCASE => store2BA;
IF NOT rejectBA AND cIsField THEN field ← cBusResult3BA;
ALULeft2AB ← DragonRoseExtras.LTD[aluLeft];
ALURight2AB ← DragonRoseExtras.LTD[aluRight];
Store2AB ← DragonRoseExtras.LTD[store2AB];
};
-- On every PhA with RejectBA the faulty address is saved in ram[euMAR]; the EU generates the appropriate cAdr when RejectBA is sensed, so the rule is: we always write into the register file! (Q: what about euToKBus? LMM)
SELECT (cReg ← VAL[cAdr]) FROM
IN [euStack .. euJunk), euMAR, IN [euField .. euBogus) =>
ram[cAdr] ← cBusResult3BA;
euJunk => NULL;
euToKBus => {    -- don't mind reject???
drive[KBus] ← drive;
KBus ← DragonRoseExtras.LTD[cBusResult3BA];
};
ENDCASE => DragonRosemary.Assert[FALSE, "EU cAdr out of range"];
};
PhiB phase. Most of the computations take place during PhiB
IF PhB THEN {
c32, cx: BOOL;
rejectBA ← DPRejectB;
DPRejectB is valid at the end of PhiB but bogus during PhiA, so it must be latched at the end of PhiB. A current problem is that the source for cBusResult3BA depends upon DPRejectB, and the choice is made during the same PhiB as it is received. So this statement has to be first.
Updating the RAM addresses
aAdr ← BitOps.ECFD[KBus, 32, Dragon.aRegKBusPos, 8];
bAdr ← BitOps.ECFD[KBus, 32, Dragon.bRegKBusPos, 8];
cAdr ← IF rejectBA THEN DragOpsCross.ProcessorRegister[euMAR].ORD
ELSE BitOps.ECFD[KBus, 32, Dragon.cRegKBusPos, 8];
cIsField ← BitOps.EBFD[KBus, 32, 24];
EUAluLeftSrc1BA ← VAL[BitOps.ECFD[KBus, 32, 25, 2]];
EUAluRightSrc1BA ← VAL[BitOps.ECFD[KBus, 32, 27, 3]];
EUStore2ASrc1BA ← VAL[BitOps.ECFD[KBus, 32, 30, 2]];
PBus: notice that in case of reject during a store, we keep sending the data even though it is useless
DragonRosemary.Assert[NOT (EUWriteToPBus3AB AND EURes3BisPBus3AB)];
SELECT TRUE FROM
EUWriteToPBus3AB => { -- store in progress
drive[DPData] ← drive;
DPData   ← DragonRoseExtras.LTD[store3AB]; -- send data to Cache (Store)
cBusResult3BA ← result3AB};
save the address in cBusResult3BA, done normally since NOT EURes3BisPBus3AB;
ENDCASE => { -- either a fetch, an op, or a move in progress
IF rejectBA -- Fetch with reject => save address in cBusResult3BA and don't listen to IFU
THEN cBusResult3BA ← result3AB
ELSE -- Fetch without reject -- IF EURes3BisPBus3AB
THEN {
cBusResult3BA ← DragonRoseExtras.LFD[DPData];}
ELSE cBusResult3BA ← result3AB}; -- op or move ;
Data pipe
store2BA ← store2AB;
Alu and Field Unit computation
Set Default values of state
carryBA  ← carryAB;
SELECT EUAluOp2AB FROM
SAdd => {
[aluOut, c32] ← DoubleADD[aluLeft, aluRight, carryAB];
result2BA ← aluOut;
carryBA ← FALSE};
SSub => {
[aluOut, cx] ← DoubleADD[aluLeft, DoubleNOT[aluRight], NOT carryAB];
c32 ← NOT cx;
result2BA ← aluOut;
carryBA ← FALSE};
UAdd => {
[aluOut, c32] ← DoubleADD[aluLeft, aluRight, carryAB];
result2BA ← aluOut;
carryBA ← c32};
USub => {
[aluOut, cx] ← DoubleADD[aluLeft, DoubleNOT[aluRight], NOT carryAB];
c32 ← NOT cx;
result2BA ← aluOut;
carryBA ← c32};
VAdd, VAdd2 => {
[aluOut, c32] ← DoubleADD[aluLeft, aluRight, FALSE];
result2BA ← aluOut};
VSub => {
[aluOut, cx] ← DoubleADD[aluLeft, DoubleNOT[aluRight], TRUE];
c32 ← NOT cx;
result2BA ← aluOut};
LAdd => {
[aluOut, c32] ← DoubleADD[aluLeft, aluRight, FALSE];
result2BA ← aluOut;
carryBA ← FALSE};
LSub => {
[aluOut, cx] ← DoubleADD[aluLeft, DoubleNOT[aluRight], TRUE];
c32 ← NOT cx;
result2BA ← aluOut;
carryBA ← FALSE};
FOP => {
result2BA ← aluOut ← FieldOp[aluLeft, store2AB, aluRight]};
And => {
result2BA ← aluOut ← WordOp[and, aluLeft, aluRight]};
Or => {
result2BA ← aluOut ← WordOp[or, aluLeft, aluRight]};
Xor => {
result2BA ← aluOut ← WordOp[xor, aluLeft, aluRight]};
BndChk => {
[aluOut, cx] ← DoubleADD[aluLeft, DoubleNOT[aluRight], TRUE];
c32 ← NOT cx;
result2BA ← aluLeft};
ENDCASE => ERROR Stop["Invalid ALU Operation"];
Condition and trap generation
conditionB ← SELECT EUCondSel2AB FROM
False  => FALSE,
EZ   => aluOut=0, -- aluOut=0
LZ   => (c32 # (EBFL[aluLeft, 0] # EBFL[aluRight, 0])), -- VSub<0
LE   => (aluOut=0) OR (c32 # (EBFL[aluLeft, 0] # EBFL[aluRight, 0])), -- VSub<=0,
AddressCheckFault => aluOut < DragOpsCross.KernalLimit,
NE  => aluOut#0, -- aluOut#0
GE   => NOT (c32 # (EBFL[aluLeft, 0] # EBFL[aluRight, 0])), -- VSub>=0
GZ   => NOT ((aluOut=0) OR (c32 # (EBFL[aluLeft, 0] # EBFL[aluRight, 0]))), -- VSub>0
OvFl  => ((c32 # EBFL[aluOut, 0]) # (EBFL[aluLeft, 0] # EBFL[aluRight, 0])),
BC   => NOT c32,
IL   => (ELispFL[aluLeft] IN (0..7) ) OR
    (ELispFL[aluRight] IN (0..7) ) OR
    (ELispFL[aluOut] IN (0..7) ),
NotBC  => c32,
NotIL  => NOT ((ELispFL[aluLeft] IN (0..7) ) OR
    (ELispFL[aluRight] IN (0..7) ) OR
    (ELispFL[aluOut] IN (0..7) )),
ModeFault => TRUE,
ENDCASE => ERROR Stop["Invalid EUCondition2B Code"];
EUCondition2B ← conditionB;
CBusResult3BA ← DragonRoseExtras.LTD[cBusResult3BA];
};
ENDCELLTYPE;
EULogger: LAMBDA [logRef: |REF IO.STREAM|] RETURN CELLTYPE AutoName
PORTS [
KBus    < INT[32],
ALULeft2AB  < INT[32],
ALURight2AB < INT[32],
Store2AB   < INT[32],
CBusResult3BA < INT[32],
DPRejectB  < BOOL,
ResetAB   < BOOL,
PhA, PhB  < BOOL
]
State
phALast: BOOL,
cAdr3BA: DragOpsCross.ProcessorRegister
EvalSimple
IF ResetAB THEN Atom.PutProp[$Cluster, $RegStores, NIL];
IF PhA AND NOT phALast THEN {
phALast ← TRUE;
SELECT cAdr3BA FROM
euJunk, euBogus => NULL;
ENDCASE => Atom.PutProp[$Cluster, $RegStores,
CONS[
NEW[LizardRosemary.RegStoreRec ← [
instr: ClusterParams.clusterPanel.instrCount,
reg: cAdr3BA,
data: DragonRoseExtras.LFD[CBusResult3BA]]],
NARROW[Atom.GetProp[$Cluster, $RegStores], LIST OF REF ANY]]];
};
IF PhB THEN {
phALast ← FALSE;
cAdr3BA ← IF DPRejectB THEN euBogus ELSE VAL[BitOps.ECFD[KBus, 32, Dragon.cRegKBusPos, 8]];
};
ENDCELLTYPE;
EU: LAMBDA [logRef: |REF IO.STREAM|] RETURN CELLTYPE AutoName
PORTS [
P Interface
DPData=INT[32], -- address/data to cache/FP during PhA, data to/from cache/FP during PhB
DPRejectB<BOOL, -- received during PhB
DPFaultB<EnumType["Dragon.PBusFaults"], -- received during PhB, together with the last DPRejectB of a sequence. On the next PhA, the EU still freezes, but saves the Fault address in RAM. No instruction following a faulty Cache access should modify the carry!
Timing and housekeeping interface
PhA, PhB<BOOL,
ResetAB<BOOL,
Vdd, Gnd, PadVdd, PadGnd<BOOL,
I interface
KBus= INT[32],
PhiB: a, b, and c ram addresses are multiplexed on KBus. a=[0..7], b=[8..15], c=[16..23], cIsField=[24], EUAluLeftSrc1BA=[25..26], EUAluRightSrc1BA=[27..29], EUStore2ASrc1BA=[30..31].
PhiA: data moves from EU -> IFU iff cAdr in [ifuXBus..ifuLast] during the previous PhiB, otherwise IFU may be using bus to pass data to EU or control to FP.
The following signals change during 1B and are stable during 2A.
EUAluLeftSrc1BA < EnumType["Dragon.ALULeftSources"],
EUAluRightSrc1BA < EnumType["Dragon.ALURightSources"],
EUStore2ASrc1BA < EnumType["Dragon.Store2ASources"],
EUSt3AisCBus2BA < BOOL, -- multiplexor control to store3AB
EURes3BisPBus3AB < BOOL, -- multiplexor control to cBusResult3BA
EUWriteToPBus3AB < BOOL, -- Tells EU to drive PBus on 3B. Used for Store instructions, and issued every instruction following an DPrejectB. This is not necessary, but so far OK and simple.
EUAluOp2AB  < EnumType["Dragon.ALUOps"],
EUCondSel2AB  < EnumType["Dragon.CondSelects"],
EUCondition2B > BOOL, -- latched to hide precharge in the carry propagator etc
Serial debugging interface
All the following signals change during PhA and PhB, giving an entire clock cycle for them to change, are sampled during PhB, and are applied to the data path during the following PhA. All signals are not used !!! JH
DShiftAB  < BOOL, -- shift the shift register by 1 bit if ~DNSelectAB
DExecuteAB < BOOL, -- interpret the content of the shift register if ~DNSelectAB
DNSelectAB < BOOL, -- if high, hold but don't Execute or Shift
DHoldAB  < BOOL, -- must be high before testing
DDataInAB < BOOL, -- sampled 1 full cycle after a PhB that DShiftAB is Asserted
DDataOutAB = BOOL -- changes in PhA after a PhB that DShiftAB is Asserted
]
Expand
ALULeft2AB  : INT[32];
ALURight2AB : INT[32];
Store2AB   : INT[32];
CBusResult3BA : INT[32];
compute: EUCompute[];
logger: EULogger[logRef: logRef][]
ENDCELLTYPE