///sloop/ReadConnectionImpl.mesa
Last Edited by: Preas, August 28, 1984 4:10:50 pm PDT
Last Edited by: CSChow, January 31, 1985 6:08:50 am PST
run by typing run PopupMenuImpl TerminalIOImpl ReadConnectionImpl
Read Connectivity data
DIRECTORY IO USING [STREAM, GetRefAny, SkipWhitespace, EndOf],
FS,
TerminalIO USING [PutRope],
Rope USING [ROPE, Cat],
ReadConnection;
ReadConnectionImpl: CEDAR PROGRAM
IMPORTS IO, FS, TerminalIO, Rope
EXPORTS ReadConnection =
BEGIN
OPEN ReadConnection;
ReadConct: PUBLIC PROCEDURE [file: Rope.ROPE,
EnumHeader: EnumHeaderProc,
EnumPorts: EnumPortsProc,
EnumNets: EnumNetsProc,
EnumPortNets: EnumPortNetsProc,
EnumComps: EnumCompsProc] =
BEGIN
from: IO.STREAMFS.StreamOpen[file];
DO
item: LORA;
[] ← IO.SkipWhitespace[from];
IF from.EndOf[] THEN EXIT;
item ← NARROW[from.GetRefAny[]];
SELECT item.first FROM
$CellTypeName => BEGIN
cellTypeName: Rope.ROPE;
cellTypeName ← NARROW[item.rest.first];
EnumHeader["CellTypeName", cellTypeName];
IF item.rest.rest # NIL THEN
TerminalIO.PutRope[Rope.Cat["Data following CellTypeName ignored: cellTypeName = ", cellTypeName, "\n"]];
END;
$CreatingUser => BEGIN
userName: Rope.ROPE;
userName ← NARROW[item.rest.first];
EnumHeader["CreatingUser", userName];
IF item.rest.rest # NIL THEN
TerminalIO.PutRope[Rope.Cat["Data following CreatingUser ignored: CreatingUser = ", userName, "\n"]];
END;
$CreationTime => BEGIN
creationTime: Rope.ROPE;
creationTime ← NARROW[item.rest.first];
EnumHeader["CreationTime", creationTime];
IF item.rest.rest # NIL THEN
TerminalIO.PutRope[Rope.Cat["Data following CreationTime ignored: creationTime = ", creationTime, "\n"]];
END;
$CreationSite => BEGIN
creationSite: Rope.ROPE;
creationSite ← NARROW[item.rest.first];
EnumHeader["CreationSite", creationSite];
IF item.rest.rest # NIL THEN
TerminalIO.PutRope[Rope.Cat["Data following CreationSite ignored: creationSite = ", creationSite, "\n"]];
END;
$Version => BEGIN
versionSpec: Rope.ROPE;
versionSpec ← NARROW[item.rest.first];
EnumHeader["VersionSpec", versionSpec];
IF item.rest.rest # NIL THEN
TerminalIO.PutRope[Rope.Cat["Data following VersionSpec ignored: versionSpec = ", versionSpec, "\n"]];
END;
$DerivingProgram => BEGIN
END;
$Source => BEGIN
END;
$CellTypeEquivalentClass => BEGIN
equivalenceClass: Rope.ROPE;
equivalenceClass ← NARROW[item.rest.first];
EnumHeader["CellTypeEquivalentClass", equivalenceClass];
IF item.rest.rest # NIL THEN
TerminalIO.PutRope[Rope.Cat["Data following CellTypeEquivalentClass ignored: CellTypeEquivalentClass = ", equivalenceClass, "\n"]];
END;
$Ports => BEGIN
portIndex: CARDINAL ← 0;
portList: LIST OF portEc ← NIL;
FOR portSpec: LORA ← item.rest, portSpec.rest WHILE portSpec # NIL DO
equivClass: Rope.ROPENIL;
direction: Direction ← Unknown;
pair: LORANARROW[portSpec.first];
portName: Rope.ROPENARROW[pair.first];
FOR portAssertion: LORA ← pair.rest, portAssertion.rest
WHILE portAssertion # NIL DO
assertion: LORANARROW[portAssertion.first];
IF assertion.first = $EC THEN equivClass ← NARROW[assertion.rest.first]
ELSE IF assertion.first = $IN THEN direction ← Input
ELSE IF assertion.first = $OUT THEN direction ← Output
ELSE IF assertion.first = $BIDIR THEN direction ← InputOutput;
ENDLOOP;
portIndex ← portIndex + 1;
portList ← CONS[portEc[portIndex, portName, equivClass, direction], portList];
ENDLOOP;
EnumPorts[portList];
END;
$InsidesUnspecified => BEGIN
EnumHeader["InsidesUnspecified"];
END;
$PrivateFollows => BEGIN
EnumHeader["PrivateFollows"];
END;
$N => BEGIN
netName: Rope.ROPENARROW[item.rest.first];
generation: Generation ← Unknown;
FOR netAssertion: LORANARROW[item.rest.rest], netAssertion.rest
WHILE netAssertion # NIL DO
assertion: LORANARROW[netAssertion.first];
IF assertion.first = $G THEN
BEGIN
IF assertion.rest.first = $D THEN generation ← Designer
ELSE IF assertion.rest.first = $P THEN generation ← Program;
END;
ENDLOOP;
EnumNets[netName, generation];
END;
$PN => BEGIN
portName, netName: Rope.ROPE;
portName ← NARROW[item.rest.first];
netName ← NARROW[item.rest.rest.first];
EnumPortNets[portName, netName];
IF item.rest.rest.rest # NIL THEN
TerminalIO.PutRope[Rope.Cat["Data following portName/netName ignored: portName = ", portName, " netName = ", netName, "\n"]];
END;
$CI => BEGIN
instName, typeName: Rope.ROPE;
pinIndex: CARDINAL ← 1;
cicList: LORA;
pnList: LIST OF pinNet ← NIL;
instName ← NARROW[item.rest.first];
typeName ← NARROW[item.rest.rest.first];
--This is a kludgy fix. A better solution would be to redesign the interface
--CSChow: January 31, 1985 6:03:07 am PST
cicList ← NARROW[item.rest.rest.rest];
UNTIL NARROW[cicList.first, LORA].first = $CIC DO
cicList ← cicList.rest;
IF cicList = NIL THEN EXIT;
ENDLOOP;
IF cicList # NIL THEN
BEGIN
FOR con: LORANARROW[cicList.first, LORA].rest, con.rest WHILE con # NIL DO
pair: LORANARROW[con.first];
pinName: Rope.ROPENARROW[pair.first];
netName: Rope.ROPENARROW[pair.rest.first];
pnList ← CONS[pinNet[pinIndex, pinName, netName], pnList];
pinIndex ← pinIndex + 1;
ENDLOOP;
EnumComps[instName, typeName, pnList];
END
ELSE
TerminalIO.PutRope[Rope.Cat["No CIC data: instName = ", instName, " typeName = ", typeName, "\n"]];
END;
$Leaf => ERROR;
ENDCASE => ERROR;
ENDLOOP;
FS.Close[from];
END;
EchoHeader: PUBLIC EnumHeaderProc =
BEGIN
TerminalIO.PutRope[Rope.Cat["(", key]];
IF val1 # NIL THEN TerminalIO.PutRope[Rope.Cat[" """, val1, """"]];
IF val2 # NIL THEN TerminalIO.PutRope[Rope.Cat[" """, val2, """"]];
TerminalIO.PutRope[")\n"];
END;
EchoPorts: PUBLIC EnumPortsProc =
PROCEDURE [portList: LIST OF portEc]
BEGIN
TerminalIO.PutRope["(Ports"];
FOR pList: LIST OF portEc ← portList, pList.rest WHILE pList # NIL DO
TerminalIO.PutRope[Rope.Cat["\n (""", pList.first.portName, """"]];
IF pList.first.ecName # NIL THEN
TerminalIO.PutRope[Rope.Cat[" (EC """, pList.first.ecName, """)"]];
IF pList.first.portDir = Input THEN
TerminalIO.PutRope[" (IN)"]
ELSE IF pList.first.portDir = Output THEN
TerminalIO.PutRope[" (OUT)"]
ELSE IF pList.first.portDir = InputOutput THEN
TerminalIO.PutRope[" (BIDIR)"];
TerminalIO.PutRope[")"];
ENDLOOP;
TerminalIO.PutRope[")\n"];
END;
EchoNets: PUBLIC EnumNetsProc =
BEGIN
TerminalIO.PutRope[Rope.Cat["(N """, netName, """ "]];
IF generation = Designer THEN TerminalIO.PutRope["(G D)"]
ELSE IF generation = Program THEN TerminalIO.PutRope["(G P)"];
TerminalIO.PutRope[")\n"];
END;
EchoPortNets: PUBLIC EnumPortNetsProc =
BEGIN
TerminalIO.PutRope[Rope.Cat["(PN """, portName, """ """, netName, """)\n"]];
END;
EchoComps: PUBLIC EnumCompsProc =
BEGIN
-- TerminalIO.PutRope[Rope.Cat[Rope.Cat["(CI """, instName, """ """], Rope.Cat[typeName, """", "\n"]];
-- TerminalIO.PutRope[" (CIC"]];
FOR pnList: LIST OF pinNet ← pinNetList, pnList.rest WHILE pnList # NIL DO
TerminalIO.PutRope[Rope.Cat[" (""", pnList.first.pinName, """ """, pnList.first.netName, """)\n"]];
ENDLOOP;
TerminalIO.PutRope["))"];
END;
ReadConct[file: "///mouse/ShiftCap-9.sch",
EnumHeader: EchoHeader,
EnumPorts: EchoPorts,
EnumNets: EchoNets,
EnumPortNets: EchoPortNets,
EnumComps: EchoComps];
-- ReadConct[file: "///sloop/TSArbiter-1.sch",
-- EnumHeader: EchoHeader,
-- EnumPorts: EchoPorts,
-- EnumNets: EchoNets,
-- EnumPortNets: EchoPortNets,
-- EnumComps: EchoComps];
END.