TestDrot.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Csaba Gabor August 21, 1987 2:17:27 pm PDT
Bertrand Serlet August 21, 1987 4:32:43 pm PDT
DIRECTORY
Commander, Convert, Core, CoreCreate, CoreDirectory, CoreOps, CoreProperties, Drot, DrotBool, DrotCover, IO, Process, Rope, SymTab, ViewerIO, ViewerTools;
TestDrot: CEDAR MONITOR
IMPORTS Commander, Process
~ BEGIN OPEN DrotBool, DrotCover, Drot;
This test code has to be revisited!!
Debugging Procedures
MakeGenerator: Commander.CommandProc = TRUSTED {Process.Detach[FORK Gen]};
Gen: PUBLIC PROC ~ {
tree: Dag ← MakeNewBoolTree[];
ctcoll: Treeset ← MakeNewCTreeSet[];
gettinginput : BOOLTRUE;
in, out: IO.STREAM;
be: ROPE;
dummy : INT ← 0;
[] ← MakeNewNodeB[tree, NIL, prim, "Gnd"];
[] ← MakeNewNodeB[tree, NIL, prim,"Vdd"];
[in: in, out: out] ← ViewerIO.CreateViewerStreams["Logic Generator"];
AssembleCTree[ctcoll];
IO.PutF[out, "Enter Boolean expressions, <CR> to terminate sequence\n"];
WHILE gettinginput DO
IO.PutF[out, "> "];
ViewerTools.SetSelection[ViewerIO.GetViewerFromStream[in]];
be ← IO.GetLineRope[in];
IF Rope.IsEmpty[be]
THEN EXIT
ELSE IF Rope.Fetch[be,0] = ':
THEN {
be ← Rope.Substr[be,1,Rope.Length[be] - 1];
IF InputOK[be]
THEN AddInputToCover[be,ctcoll]
ELSE IO.PutF[out, " Problem with cover expression. Please enter anew.\n"]}
ELSE IF InputOK[be]
THEN AugmentBoolTreeBySingleExpression[tree, be]
ELSE IO.PutF[out, " Problem with input expression. Please enter anew.\n"];
dummy ← dummy + 1;
ENDLOOP;
FromLogicToCell[tree, ctcoll, out];
dummy ← dummy + 1;
};
FromLogicToCell: PROC [tree: Dag, ctcoll: Treeset, out: IO.STREAM] ~ {
foo: Core.CellType;
FOR ctiter: Dag ← ctcoll^.top, ctiter^.next UNTIL ctiter = NIL DO
RemoveOrs[ctiter];
ENDLOOP;
IO.PutF[out, "Done with first pass\n"];
TwoifyAllTrees[ctcoll];
IO.PutF[out, "Done with second pass\n"];
SimplifyDag[tree];
IO.PutF[out, "Done with third pass\n"];
EstablishLevels[tree];
IO.PutF[out, "Done with fourth pass\n"];
TwoifyTree[tree];
IO.PutF[out, "Done with fifth pass\n"];
ReduceFanout[tree, 4];
IO.PutF[out, "Done with sixth pass\n"];
RemoveOrs[tree];
IO.PutF[out, "Done with seventh pass\n"];
WHILE RemoveAllIdenticalLinks[tree] OR RemoveDuplicateNodes[tree] DO ENDLOOP;
IO.PutF[out, "Done with pass seven and a half\n"];
BufferNecessaryNodes[tree];
ReduceFanout[tree, 4];
KillHangingNodes[tree, FALSE];
IO.PutF[out, "Done with pass seven and three quarters\n"];
ProduceTotalCovering[tree, ctcoll];
IO.PutF[out, "Done with eighth pass\n"];
foo ← FromDagToCellType[tree];
IO.PutF[out, "Done\n"];
};
Disp: PUBLIC PROC [tree: Dag, out: IO.STREAM] ~ {
Given a tree, this will display it on stream out --
iter: Node ← tree^.csucs;
WHILE iter # NIL DO
kiter: Kidptr ← iter^.kidlist;
piter: Kidptr ← iter^.parlist;
IO.PutF[out, "\n%3g: ", IO.int[iter^.number]];
SELECT iter^.type FROM
and => IO.PutF[out," and"];
nand => IO.PutF[out,"nand"];
or => IO.PutF[out," or"];
nor => IO.PutF[out," nor"];
not => IO.PutF[out," not"];
buf => IO.PutF[out," buf"];
ENDCASE => IO.PutF[out,"prim"];
IO.PutF[out, Rope.Concat[" ",Rope.Concat[iter^.inname, Rope.Concat[" ", iter^.varname]]]];
IF iter^.output THEN IO.PutF[out, Rope.Concat["*^*",iter^.outname.first]];
IF iter^.sim THEN IO.PutF[out," Sim "];
IO.PutF[out, " %3g\n", IO.int[iter^.level]];
IO.PutF[out, " Kids: "];
WHILE kiter # NIL DO
IO.PutF[out, "%3g", IO.int[kiter^.child^.number]];
IF kiter^.next # NIL
THEN IO.PutF[out, ","]
ELSE IO.PutF[out, "\n"];
kiter ← kiter^.next;
ENDLOOP;
IO.PutF[out, " Pars: "];
WHILE piter # NIL DO
IO.PutF[out, "%3g", IO.int[piter^.child^.number]];
IF piter^.next # NIL
THEN IO.PutF[out, ","];
piter ← piter^.next;
ENDLOOP;
iter ← iter^.next;
ENDLOOP;
IO.PutF[out,"\n"]
};
Commander.Register[key: "Gen", proc: MakeGenerator, doc: "Standard cells from logic equations"];
END.