SCParmsImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Written by: Pradeep Sindhu, October 2, 1986 10:52:55 pm PDT
Pradeep Sindhu, August 13, 1987 5:17:47 pm PDT
DIRECTORY
SCParms, SCUtils, Rope, SCPmCode;
SCParmsImpl: CEDAR PROGRAM
IMPORTS Rope, SCUtils
EXPORTS SCParms
~ BEGIN
ROPE: TYPE = Rope.ROPE;
Independent Parameters
numBitsPerByte: PUBLIC NAT;
numBytesPerWord: PUBLIC NAT;
numWordsPerCycle: PUBLIC NAT ← 2; -- Fixed by the architecture
numCyclesPerLine: PUBLIC NAT;
numMemLines: PUBLIC NAT;
numIOLines: PUBLIC NAT;
numFIFOLines: PUBLIC NAT;
vPagePattern: PUBLIC ROPE;
vBlock0Pattern: PUBLIC ROPE;
vBlock1Pattern: PUBLIC ROPE;
vBlock2Pattern: PUBLIC ROPE;
vBlock3Pattern: PUBLIC ROPE;
vBlock4Pattern: PUBLIC ROPE;
vBlock5Pattern: PUBLIC ROPE;
rPagePattern: PUBLIC ROPE;
rBlock0Pattern: PUBLIC ROPE;
rBlock1Pattern: PUBLIC ROPE;
rBlock2Pattern: PUBLIC ROPE;
rBlock3Pattern: PUBLIC ROPE;
rBlock4Pattern: PUBLIC ROPE;
rBlock5Pattern: PUBLIC ROPE;
Dependent Parameters
numBitsPerWord: PUBLIC NAT;
numBitsPerCycle: PUBLIC NAT;
numBitsPerLine: PUBLIC NAT;
numWordsPerLine: PUBLIC NAT;
logNumWordsPerLine: PUBLIC NAT;
logNumCyclesPerLine: PUBLIC NAT;
numPageBits: PUBLIC NAT;
numBlockBits: PUBLIC NAT;
numDevIdBits: PUBLIC NAT;
numBitsPerHeader: PUBLIC NAT;
Parameter Constraints
numBitsPerWord e 8 (from BCmd+RplySh+M/F+Id=8)
numWordsPerLine e 2 (need to take log and have it be > 0)
numCyclesPerLine e 2 (need to take log and have it be > 0)
numBlockBits e 3 (need 5 IO lines, so block address must be at least 3 bits)
Exported Procs
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];
};
PagePatternHi: PUBLIC PROC [pagePattern: ROPE] RETURNS [ROPE] ~ {
RETURN[Rope.Substr[pagePattern, 0, numPageBits+1-numDevIdBits]];
};
PagePatternLo: PUBLIC PROC [pagePattern: ROPE] RETURNS [ROPE] ~ {
RETURN[Rope.Substr[pagePattern, numPageBits+1-numDevIdBits, numDevIdBits]];
};
END.