LichenPads.Mesa
Last tweaked by Mike Spreitzer on May 6, 1989 9:04:40 am PDT
DIRECTORY AbSets, BiRelBasics, BiRels, FS, IntStuff, IO, LichenDataOps, LichenDataStructure, LichenIntBasics, Rope, SetBasics;
LichenPads: CEDAR PROGRAM
IMPORTS AbSets, BiRels, FS, IO, LichenDataOps, LichenDataStructure
EXPORTS LichenDataOps, LichenDataStructure
=
BEGIN OPEN IS:IntStuff, LIB:LichenIntBasics, LIB, LichenDataStructure, LichenDataOps, Sets:AbSets;
ReadSteppyNameSet: PUBLIC PROC [fileName: ROPE] RETURNS [found: BOOL, set: Set] ~ {
in: IO.STREAM ~ FS.StreamOpen[fileName !FS.Error => GOTO DontExist];
found ← TRUE;
set ← Sets.CreateHashSet[steppyNameSpace];
DO
[] ← in.SkipWhitespace[];
IF in.EndOf[] THEN EXIT;
{asRope: ROPE ~ in.GetRopeLiteral[];
steppy: SteppyName ~ ParseSteppyName[asRope];
[] ← set.AddElt[SnV[steppy]];
}ENDLOOP;
in.Close[];
RETURN;
EXITS DontExist => {found ← FALSE; set ← nilSet}};
ExtractNamed: PUBLIC PROC [ct: CellType, names: Set] RETURNS [newPorts: Set] ~ {
wires: Set ~ ct.fullName[w].Image[names, rightToLeft].CreateHashCopy[];
IF wires.Size # names.Size THEN ERROR;
newPorts ← FullySfwdlyExportWires[ct, wires];
RETURN};
ExtractPads: PUBLIC PROC [d: Design, log: IO.STREAMNIL] RETURNS [exCells: BiRel, newPorts: Set] ~ {
ct: CellType ~ d.root;
padTypeNames: Set ~ Sets.RopesMatching[["pad*", FALSE, star]];
padTypes: Set ~ d.ctName.Image[padTypeNames, rightToLeft].CreateHashCopy[];
pads: Set ~ d.ciType.Image[padTypes, rightToLeft].Intersection[ct.Subcells].CreateHashCopy[];
ex: BiRel ~ d.ciType.Intersection[BiRels.CreateProduct[[pads, padTypes]]];
wires: Set ~ d.iwConns.Image[pads].CreateHashCopy[];
exCells ← ct.fullName[i].Invert.Compose[ex.Compose[d.ctName, [TRUE, FALSE]], [FALSE, TRUE]].CreateHashCopy[mappable: ALL[TRUE]];
newPorts ← FullySfwdlyExportWires[ct, wires];
DeleteInsts[d, pads, TRUE, TRUE, log];
RETURN};
END.