IFUSrcImpl.mesa
Copyright c 1985 by Xerox Corporation. All rights reserved.
Last Edited by Curry, October 10, 1986 8:30:16 am PDT
Don Curry November 2, 1986 9:21:54 pm PST
DIRECTORY Atom, CD, Commander, CommandTool, Core, CoreFrame, CoreGlue, CoreName, CoreXform, DragOpsCross, IFUCoreData, IFUSrc, IO, PW, PWC, Process, Rope;
IFUSrcImpl: CEDAR PROGRAM
IMPORTS Commander, CommandTool, CoreFrame, CoreGlue, CoreName, CoreXform, IFUCoreData, IFUSrc, IO, PW, PWC, Process, Rope
EXPORTS IFUSrc =
BEGIN
ROPE: TYPE = Core.ROPE;
Rollback: PUBLIC SIGNAL[name: ROPE] = CODE;
ifuContext: PUBLIC CoreName.Context ← CoreName.NewContext[];
dShIn:   PUBLIC ROPE ← CoreName.RopeNm["DShIn"];
dShLeftOut:  PUBLIC ROPE ← CoreName.RopeNm["DShLeftOut"];
dShRightOut: PUBLIC ROPE ← CoreName.RopeNm["DShRightOut"];
dShOut:   PUBLIC ROPE ← CoreName.RopeNm["DShOut"];
ProcRegToList: PUBLIC PROC [reg: DragOpsCross.ProcessorRegister] RETURNS[LIST OF REF] =
{val: CARDINALLOOPHOLE[reg]; RETURN[CardToList[val, 8]]};
CardToList: PUBLIC PROC [val, size: CARDINAL] RETURNS[new: LIST OF REF] = {
new ← NIL;
THROUGH [0..size) DO
new ← CONS[(IF (val MOD 2)=1 THEN "VDD" ELSE "GND"), new];
val ← val/2;
ENDLOOP};
TestSwitching: PROC RETURNS[cellType: Core.CellType] = {
cellType ← IFUCoreData.CellProc[
subClass: "SwitchBox",
name:  "TestSwitching",
top:  "(A.)",
bot:  "(NIL A.)",
xform:  CoreXform.GenXform[LIST[ [2, 0] ]] ]};
TranslateCellName: PROC[name: ROPE] RETURNS[cell: Core.CellType] = {
cell ← SELECT CoreName.RopeNm[name] FROM
CoreName.RopeNm[ "Complete"  ] => IFUSrc.Complete[],
CoreName.RopeNm[ "PadTop"   ] => IFUSrc.PadTop[],
CoreName.RopeNm[ "PadHeart"  ] => IFUSrc.PadHeart[],
CoreName.RopeNm[ "PadBot"   ] => IFUSrc.PadBot[],
CoreName.RopeNm[ "PadLt"   ] => IFUSrc.PadLt[],
CoreName.RopeNm[ "Heart"   ] => IFUSrc.Heart[],
CoreName.RopeNm[ "PadRt"   ] => IFUSrc.PadRt[],
CoreName.RopeNm[ "LeftColumn" ] => IFUSrc.LeftColumn[],
CoreName.RopeNm[ "DataColumn" ] => IFUSrc.DataColumn[],
CoreName.RopeNm[ "RightColumn" ] => IFUSrc.RightColumn[],
CoreName.RopeNm[ "FetchIndexing" ] => IFUSrc.FetchIndexing[],
CoreName.RopeNm[ "FetchControler" ] => IFUSrc.FetchControler
["testing", dShLeftOut].cellType,
CoreName.RopeNm[ "LtDrPadIO"  ] => IFUSrc.LtDrPadIO["testing"].cellType,
CoreName.RopeNm[ "StackControler" ] => IFUSrc.StackControler["testing"].cellType,
CoreName.RopeNm[ "Interlock"  ] => IFUSrc.Interlock[dShIn].cellType,
CoreName.RopeNm[ "MainPipeControl" ] => IFUSrc.MainPipeControl["testing"].cellType,
CoreName.RopeNm[ "StackIndexing" ] => IFUSrc.StackIndexing[],
CoreName.RopeNm[ "InstrDecode" ] => IFUSrc.InstrDecode
["testing", dShRightOut].cellType,
CoreName.RopeNm[ "RtDrPadIO"  ] => IFUSrc.RtDrPadIO[dShLeftOut].cellType,
CoreName.RopeNm[ "Fetch"   ] => IFUSrc.Fetch[],
CoreName.RopeNm[ "FetchBuf"  ] => IFUSrc.FetchBuf[],
CoreName.RopeNm[ "XaForm"   ] => IFUSrc.XaForm[],
CoreName.RopeNm[ "PCFormTop"  ] => IFUSrc.PCFormTop[],
CoreName.RopeNm[ "PCFormBot"  ] => IFUSrc.PCFormBot[],
CoreName.RopeNm[ "StackBuf"  ] => IFUSrc.StackBuf[],
CoreName.RopeNm[ "LSForm"   ] => IFUSrc.LSForm[],
CoreName.RopeNm[ "ABForm"  ] => IFUSrc.ABForm[],
CoreName.RopeNm[ "ControlPipe"  ] => IFUSrc.ControlPipe[],
ENDCASE          => NIL};
ifuBotPadRoute: ROPE ← CoreName.RopeNm["IFUBotPadRoute"];
IFUBuildRun: Commander.CommandProc = {
AppendListItemsToLine: PROC[lst: LIST OF ROPE, line: ROPENIL] RETURNS[ROPE] = {
FOR lst ← lst, lst.rest WHILE lst#NIL DO line ← Rope.Cat[line, " ", lst.first] ENDLOOP;
RETURN[line]};
RollBackBuild: PROC[lst: LIST OF ROPE] = { -- you will never get out of here alive
line: ROPE ← AppendListItemsToLine[lst, "RollBackAnd IFUPack; IFUBuild "];
log.Close[]; [ ] ← CommandTool.DoCommand[line, cmd]};
log: IO.STREAM  ← CoreFrame.GetLog[];
list: LIST OF ROPE ← CommandTool.ParseToList[cmd].list;
Process.SetPriority[Process.priorityBackground];
DO
ENABLE {
IFUSrc.Rollback => {
SELECT CoreName.RopeNm[name] FROM
ENDCASE   => GOTO RollBackAndRepeat};
CoreGlue.RouteCheckPointWritten => {
SELECT CoreName.RopeNm[name] FROM
ifuBotPadRoute => GOTO RollBackAndRepeat;
ENDCASE   => RESUME} };
cell: Core.CellType ← NIL;
IF list=NIL THEN GOTO Done;
IF Rope.Equal[list.first, "RB", FALSE] THEN RollBackBuild[list.rest];
IF Rope.Equal[list.first, "FINISH", FALSE] THEN {
[ ] ← CommandTool.DoCommand[AppendListItemsToLine[list.rest], cmd];
GOTO Done};
cell ← TranslateCellName[ list.first];
IF cell=NIL THEN cmd.err.PutF["Unknown name: %g\n", IO.rope[list.first]];
list ← list.rest;
REPEAT
Done     => {log.Close[]; RETURN[$Done, "\nIFUBuild Complete\n"]};
RollBackAndRepeat =>
{log.PutRope["\n *** RollbackAnd REPEAT ***\n"]; RollBackBuild[list]}
ENDLOOP};
IFUPlotRun: Commander.CommandProc = {
cell:  Core.CellType ← NIL;
line:  ROPE    ← "RollBackAnd IFUPlot";
list:  LIST OF ROPE ← CommandTool.ParseToList[cmd].list;
FOR list ← list, list.rest WHILE list#NIL DO
[ ] ← CommandTool.DoCommand[IO.PutFR
["CDPlot -n /Indigo/Dragon/IFUModules/%g.dale", IO.rope[list.first]], cmd];
[ ] ← CommandTool.DoCommand[IO.PutFR
["Copy /Indigo/Dragon/IFUModules/%g.pd ← PD/Plot1.pd", IO.rope[list.first]], cmd];
[ ] ← CommandTool.DoCommand[IO.PutFR
["PeachPrint -n /Indigo/Dragon/IFUModules/%g.pd", IO.rope[list.first]], cmd];
ENDLOOP;
RETURN[$Done, "\nIFUPlot Complete\n"]};
RunCTSoft: Commander.CommandProc = {
log:   IO.STREAM  ← CoreFrame.GetLog[];
nofArgs:  INT    ← CommandTool.NumArgs[cmd];
top:   Core.CellType ← NIL;
recCell:  Core.CellType ← NIL;
obj:   CD.Object  ← NIL;
cleanUp:  BOOL    ← FALSE;
status:   CoreGlue.Status;
build:   LIST OF ROPE;
list:   LIST OF ROPE;
comlist:  LIST OF ROPE ← CommandTool.ParseToList[cmd].list;
FOR list ← comlist, list.rest WHILE list#NIL DO
Next: PROC RETURNS[next: ROPE] =
{IF list.rest=NIL THEN ERROR; list ← list.rest; next ← list.first};
SELECT list.first.Fetch[0] FROM
'- => SELECT list.first.Fetch[1] FROM
'B, 'b  => build  ← CONS[Next[], build];
'C, 'c  => cleanUp ← TRUE;
ENDCASE;
ENDCASE => build  ← CONS[list.first, build];
ENDLOOP;
IF build.rest # NIL THEN RETURN
[$Failure, "\nWhat did you hope to accomplish with multiple frame names?\n"];
IF build.first=NIL THEN build ← CONS["Complete", build];
top ← NARROW[Atom.GetProp[$IFUFrames, build.first]];
top ← IFUSrc.FetchControler[];
top ← TestSwitching[];
top ← IFUSrc.ABForm[];
CoreFrame.Expand[hard, top];
status  ← CoreGlue.RouteHard[top]; IF status#complete2 THEN Signal[];
obj  ← PWC.Layout[top];
[]   ← PW.Draw[obj] };
IF status#complete2 THEN RETURN[$Failure, "Routing Errors"];
IF CoreConnect.Connect[top]#TRUE  THEN RETURN[$Failure, "Connection Errors"];
top  ← CoreOps.Recast[top];
CoreOps.PrintCellType[top, log];
};
Signal: SIGNAL = CODE;
Commander.Register[proc: IFUBuildRun,  key: "IFUBuild"];
Commander.Register[proc: IFUPlotRun,  key: "IFUPlot"];
Commander.Register[proc: RunCTSoft,   key: "IFUSrc"];
Process.SetPriority[Process.priorityBackground]
END.