OnSameBoard:
PROC [handle: Handle, one, two: DeviceId]
RETURNS [
BOOL] ~ {
RETURN [
(one IN [handle.firstmem .. handle.lastmem] AND two IN [handle.firstmem .. handle.lastmem]) OR
(one IN [handle.firstcache .. handle.lastcache] AND two IN [handle.firstcache .. handle.lastcache]) OR
(one > handle.lastcache AND two > handle.lastcache)];
};
IsBubble:
PROC [handle: Handle, cycle: Cycle]
RETURNS [
BOOL ←
FALSE] ~ {
RETURN [IsUsefulCycle[handle.lastNonDataCycle] AND IsHeaderCycle[cycle] AND NOT OnSameBoard[handle, handle.lastNonDataCycle.master, cycle.master]];
};
Arbitrate:
PROC [handle: Handle]
RETURNS [request: Request] = {
ptr: DeviceId;
Incr:
PROC [val, first, last: DeviceId]
RETURNS[newVal: DeviceId] = {
newVal ← IF val+1>last THEN first ELSE val+1
};
If any high-priority cache requests then select one
ptr ← handle.cacheHPPtr;
WHILE
TRUE
DO
request ← handle.cacheHPRequests[ptr];
IF request#
NIL
AND request.cycles.first.grantLatency >= handle.arbLatency
THEN {
handle.cacheHPPtr ← Incr[ptr, handle.firstcache, handle.lastcache];
handle.cacheHPRequests[ptr] ← NIL;
RETURN;
};
ptr ← Incr[ptr, handle.firstcache, handle.lastcache];
IF ptr=handle.cacheHPPtr THEN EXIT;
ENDLOOP;
If any memory requests then select one
ptr ← handle.memPtr;
WHILE
TRUE
DO
request ← handle.memRequests[ptr];
IF request#
NIL AND request.cycles.first.grantLatency >= handle.arbLatency
THEN {
handle.memPtr ← Incr[ptr, handle.firstmem, handle.lastmem];
handle.memRequests[ptr] ← NIL;
RETURN;
};
ptr ← Incr[ptr, handle.firstmem, handle.lastmem];
IF ptr=handle.memPtr THEN EXIT;
ENDLOOP;
If any displayHP request then select it
request ← handle.displayHPRequest;
IF request#NIL AND request.cycles.first.grantLatency >= handle.arbLatency THEN {handle.displayHPRequest ← NIL; RETURN};
If any low-priority cache requests then select one
ptr ← handle.cacheLPPtr;
WHILE
TRUE
DO
request ← handle.cacheLPRequests[ptr];
IF request#
NIL
AND request.cycles.first.grantLatency >= handle.arbLatency
THEN {
handle.cacheLPPtr ← Incr[ptr, handle.firstcache, handle.lastcache];
handle.cacheLPRequests[ptr] ← NIL;
RETURN;
};
ptr ← Incr[ptr, handle.firstcache, handle.lastcache];
IF ptr=handle.cacheLPPtr THEN EXIT;
ENDLOOP;
If any low-priority display request then select it
request ← handle.displayLPRequest;
IF request#NIL AND request.cycles.first.grantLatency >= handle.arbLatency THEN {handle.displayLPRequest ← NIL; RETURN};
No request found!
request ← MakeRequest[One, MakeNoOp[]];
};