Set:
PUBLIC
PROC [NumBitsPerByte, NumBytesPerWord, NumCyclesPerLine, NumMemLines, NumIOLines, NumFIFOLines:
NAT]
RETURNS [
NAT] ~ {
temp: NAT;
numBitsPerByte ← NumBitsPerByte;
numBytesPerWord ← NumBytesPerWord;
numCyclesPerLine ← NumCyclesPerLine;
numMemLines ← NumMemLines;
numIOLines ← NumIOLines;
numFIFOLines ← NumFIFOLines;
numBitsPerWord ← numBitsPerByte*numBytesPerWord;
numBitsPerCycle ← numBitsPerWord*numWordsPerCycle;
numBitsPerLine ← numBitsPerCycle*numCyclesPerLine;
numWordsPerLine ← numWordsPerCycle*numCyclesPerLine;
logNumWordsPerLine ← SCUtils.Log2[numWordsPerLine];
logNumCyclesPerLine ← SCUtils.Log2[numCyclesPerLine];
numPageBits ← (22*(numBitsPerWord-logNumWordsPerLine))/32;
numBlockBits ← numBitsPerWord-numPageBits-logNumWordsPerLine;
Exchange numBlock and numPage bits if numBlock bits is too small
BEGIN
IF numBlockBits < 3 THEN {temp ← numBlockBits; numBlockBits ← numPageBits; numPageBits ← temp};
IF numBlockBits < 3 THEN ERROR;
END;
numDevIdBits ← IF (numBitsPerWord-7) < 10 THEN (numBitsPerWord-7) ELSE 10;
numBitsPerHeader ← 7+numDevIdBits+numBitsPerWord;
Initialize the virtual page and block patterns
BEGIN
vPagePattern ← "1"; -- IO bit
FOR i:
NAT
IN [0..numPageBits)
DO
vPagePattern ← Rope.Cat[vPagePattern, "0"];
ENDLOOP;
vBlock0Pattern ← vBlock1Pattern ← vBlock2Pattern ← vBlock3Pattern ← vBlock4Pattern ← vBlock5Pattern ← "";
FOR i:
NAT
IN [0..numBlockBits-3)
DO
vBlock0Pattern ← Rope.Cat[vBlock0Pattern, "0"];
vBlock1Pattern ← Rope.Cat[vBlock1Pattern, "0"];
vBlock2Pattern ← Rope.Cat[vBlock2Pattern, "0"];
vBlock3Pattern ← Rope.Cat[vBlock3Pattern, "0"];
vBlock4Pattern ← Rope.Cat[vBlock4Pattern, "0"];
vBlock5Pattern ← Rope.Cat[vBlock5Pattern, "0"];
ENDLOOP;
vBlock0Pattern ← Rope.Cat[vBlock0Pattern, "000"];
vBlock1Pattern ← Rope.Cat[vBlock1Pattern, "001"];
vBlock2Pattern ← Rope.Cat[vBlock2Pattern, "010"];
vBlock3Pattern ← Rope.Cat[vBlock3Pattern, "011"];
vBlock4Pattern ← Rope.Cat[vBlock4Pattern, "100"];
vBlock5Pattern ← Rope.Cat[vBlock5Pattern, "101"];
END;
Initialize the real page and block patterns
BEGIN
rPagePattern ← "1"; -- IO bit
FOR i:
NAT
IN [0..numPageBits-numDevIdBits-1)
DO
rPagePattern ← Rope.Cat[rPagePattern, "0"];
ENDLOOP;
rPagePattern ← Rope.Cat[rPagePattern, "1"]; -- 1 bit for DeviceType
DeviceId bits must be X since they are matched outside the array
FOR i:
NAT
IN [numPageBits-numDevIdBits..numPageBits)
DO
rPagePattern ← Rope.Cat[rPagePattern, "X"];
ENDLOOP;
rBlock0Pattern ← rBlock1Pattern ← rBlock2Pattern ← rBlock3Pattern ← rBlock4Pattern ← rBlock5Pattern ← "";
FOR i:
NAT
IN [0..numBlockBits-3)
DO
rBlock0Pattern ← Rope.Cat[rBlock0Pattern, "0"];
rBlock1Pattern ← Rope.Cat[rBlock1Pattern, "0"];
rBlock2Pattern ← Rope.Cat[rBlock2Pattern, "0"];
rBlock3Pattern ← Rope.Cat[rBlock3Pattern, "0"];
rBlock4Pattern ← Rope.Cat[rBlock4Pattern, "0"];
rBlock5Pattern ← Rope.Cat[rBlock5Pattern, "0"];
ENDLOOP;
rBlock0Pattern ← Rope.Cat[rBlock0Pattern, "000"];
rBlock1Pattern ← Rope.Cat[rBlock1Pattern, "001"];
rBlock2Pattern ← Rope.Cat[rBlock2Pattern, "010"];
rBlock3Pattern ← Rope.Cat[rBlock3Pattern, "011"];
rBlock4Pattern ← Rope.Cat[rBlock4Pattern, "100"];
rBlock5Pattern ← Rope.Cat[rBlock5Pattern, "101"];
END;
RETURN[NumBitsPerByte*NumBytesPerWord*NumCyclesPerLine*NumMemLines*NumIOLines*NumFIFOLines];
};