TRTest.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Last Edited by: Gasbarro December 10, 1987 11:34:50 am PST
DIRECTORY
Atom, Basics, BitOps, CD, CDCommandOps, CDIO, CDOps, CDProperties, CDSequencer, CDViewer, CommandTool, Core, CoreCDUser, CoreFlat, IO, FS, Ports, Rope, Rosemary, RosemaryUser, Sinix, Sisyph;
TRTest: CEDAR PROGRAM
IMPORTS Atom, Basics, BitOps, CDCommandOps, CDIO, CDOps, CDProperties, CDViewer, CommandTool, CoreCDUser, CoreFlat, IO, FS, Ports, Rope, Rosemary, RosemaryUser, Sisyph
~ BEGIN
CompData, Write, Start, Reset, CK, DecompData, Vdd, Gnd: NAT;
ROPE: TYPE = Core.ROPE;
Port: TYPE = Ports.Port;
Quad: TYPE = BitOps.BitQWord;
qZero: Quad = BitOps.BitQWordZero;
REProc:
TYPE = RosemaryUser.TestEvalProc;
--PROC [memory: BOOL ← TRUE, clockEval: BOOL ← FALSE]--
TProc:
TYPE =
PROC [h: Handle,
Eval: REProc];
SHIFT: PROC [value: WORD, count: INTEGER] RETURNS [WORD] = Basics.BITSHIFT;
BITAND: Basics.BitOp = Basics.BITAND;
BITNOT: PROC [WORD] RETURNS [WORD] = Basics.BITNOT;
Log2: PROC [n: INT] RETURNS [INT] = BitOps.Log2;
logOn: BOOL ← TRUE;
cutSet : LIST OF ROPE ← LIST["Logic", "LogicMacro", "DPMacro", "FSM"];
design: CD.Design ← NIL;
Handle: TYPE = REF HandleRec;
HandleRec:
TYPE =
RECORD[
tester: RosemaryUser.Tester ← NIL,
rootCT: Core.CellType ← NIL,
testFlatCell: CoreFlat.FlatCellType ← NIL,
testPort: Ports.Port ← NIL,
port: Port ← NIL
];
SimpleTest: RosemaryUser.TestProc = {
h: Handle ← NEW[HandleRec];
FindDesign[];
h.port ← p;
InitPortIndicies[cellType];
Load[h, Eval];
Go[h, Eval];
};
inFile: ROPE ← "AChip3.force.bin";
loadSize: NAT ← 127;
Load: TProc ~ {
ENABLE Rosemary.Stop => IF reason = $BoolWireHasX THEN RESUME;
GetData:
PROC
RETURNS [q: Quad, done:
BOOL ← FALSE] ~ {
q ← ALL[0];
FOR i:
NAT
IN [0..4)
DO
q ← BitOps.ICIQ[LOOPHOLE[IO.GetHWord[compStream ! IO.EndOfStream => GOTO eof]], q, i*10, 10, 40]
REPEAT
eof => done ← TRUE;
ENDLOOP;
};
p: Port ← h.port;
done: BOOL ← FALSE;
compStream: IO.STREAM ← FS.StreamOpen[fileName: Rope.Concat[inFile, ".com"], accessOptions: $read, wDir: CommandTool.CurrentWorkingDirectory[], streamOptions: FS.binaryStreamOptions];
p[Reset].b ← TRUE;
p[Start].b ← TRUE;
p[Write].b ← FALSE;
Cycle[h, Eval];
p[Start].b ← FALSE;
Cycle[h, Eval];
p[Write].b ← TRUE;
FOR i:
NAT
IN [0..loadSize)
DO
[p[CompData].q, done] ← GetData[];
Cycle[h, Eval];
IF done THEN EXIT;
ENDLOOP;
p[Write].b ← FALSE;
p[Reset].b ← FALSE;
Cycle[h, Eval, 4];
};
Go: TProc ~ {
p: Port ← h.port;
sourceStream: IO.STREAM ← FS.StreamOpen[fileName: inFile, accessOptions: $read, wDir: CommandTool.CurrentWorkingDirectory[], streamOptions: FS.binaryStreamOptions];
p[DecompData].d ← expect;
DO
p[DecompData].lc ← LOOPHOLE[IO.GetHWord[sourceStream ! IO.EndOfStream => EXIT], CARDINAL];
Cycle[h, Eval];
ENDLOOP;
};
Cycle:
PROC [h: Handle,
Eval: REProc, n:
CARDINAL ← 1] ~ {
p: Port ← h.port;
THROUGH [0..n)
DO
Eval[TRUE, FALSE, FALSE]; --ignore errors before clock rises
p[CK].b ← TRUE;
Eval[TRUE, TRUE, FALSE]; --ignore errors during clockEval
Eval[TRUE, FALSE, TRUE];
p[CK].b ← FALSE;
Eval[TRUE, TRUE, TRUE];
ENDLOOP;
};
CDExtract:
PROC [comm: CDSequencer.Command] = {
design ← comm.design;
DoExtract[];
};
Extract:
PROC [fileName:
ROPE ←
NIL, wDir:
ROPE] ~ {
FindDesign[fileName, wDir];
DoExtract[];
};
DoExtract:
PROC ~ {
ct: Core.CellType ← NIL;
ct ← Sisyph.ExtractSchematicByName["Decompressor.sch", Sisyph.Create[design]];
CDProperties.PutDesignProp[design, $TestarossaCellType, ct];
};
FindDesign:
PROC [fileName:
ROPE ←
NIL, wDir:
ROPE ←
NIL] ~ {
IF design=NIL THEN design ← NARROW[Atom.GetProp[$Testarossa, $Design]];
IF design=NIL THEN design ← CDViewer.FindDesign["Testarossa"];
IF design=
NIL
THEN {
design ← CDIO.ReadDesign[fileName, NIL, wDir];
CDOps.SetMutability[design];
Viewer[];
};
Atom.PutProp[$Testarossa, $Design, design];
};
Viewer:
PROC ~ {
[] ← CDViewer.CreateViewer[design];
};
StartTest:
PROC ~ {
RosemaryUser.StartTest[NARROW[CDProperties.GetDesignProp[design, $TestarossaTester], RosemaryUser.Tester]];
};
InitPortIndicies:
PROC [ct: Core.CellType] ~ {
[CompData, Write, Start, Reset, CK, DecompData] ← Ports.PortIndexes[ct.public, "CompData", "Write", "Start", "Reset", "CK", "DecompData"];
Vdd ← Ports.PortIndex[ct.public, "Vdd"];
Gnd ← Ports.PortIndex[ct.public, "Gnd"];
};
Simulate:
PROC = {
tester: RosemaryUser.Tester ← NIL;
ct: Core.CellType ← NIL;
IF design=NIL THEN ERROR;
ct ← NARROW[CDProperties.GetDesignProp[design, $TestarossaCellType]];
InitPortIndicies[ct];
Ports.ITDList[ct.public, LIST[CompData, Write, Start, Reset, CK], force];
Ports.ITDList[ct.public, LIST[DecompData], none];
Ports.IPList[ct.public, LIST[CompData], q];
Ports.IPList[ct.public, LIST[DecompData], lc];
[] ← Rosemary.SetFixedWire[ct.public[Vdd], H];
[] ← Rosemary.SetFixedWire[ct.public[Gnd], L];
tester ← RosemaryUser.TestProcedureViewer[cellType: ct, testButtons: LIST["SimpleTest"], name: "Testarossa Tester", displayWires: RosemaryUser.DisplayPortLeafWires[ct], cutSet: CoreFlat.CreateCutSet[labels: cutSet], recordDeltas: logOn];
CDProperties.PutDesignProp[design, $TestarossaTester, tester];
CoreCDUser.SetDesignRootCellType[design, ct];
CoreCDUser.SetRootCellTypeDecoration[ct, Sisyph.mode.decoration];
};
RosemaryUser.RegisterTestProc["SimpleTest", SimpleTest];
CDCommandOps.RegisterWithMenu[
menu: $ProgramMenu,
entry: "Extract TR",
doc: "",
proc: CDExtract
];
END.