DIRECTORY FS, HashTable, IO, Rope, ScaldIO; ScaldIOImpl: CEDAR PROGRAM IMPORTS FS, HashTable, IO, Rope EXPORTS ScaldIO = BEGIN OPEN ScaldIO; Handle: TYPE = REF HandleRec; HandleRec: TYPE = RECORD[ stream: Core.STREAM _ NIL, cellTypeIDTab: HashTable.Table _ NIL]; SaveCellType: PUBLIC PROC [cellType: Core.CellType, fileName: ROPE _ NIL] = { h: Handle _ NEW[HandleRec]; IF fileName=NIL THEN fileName _ Rope.Cat[CoreOps.GetCellTypeName[cellType], ".scald"]; h.stream _ FS.StreamOpen[fileName, $create]; h.cellTypeIDTab _ HashTable.Create[]; WriteCellType[h, cellType]; IO.Close[h.stream]; }; RestoreCellType: PUBLIC PROC [cellName: ROPE _ NIL, fileName: ROPE _ NIL] RETURNS [cellType: Core.CellType] = { }; WriteCellType: PUBLIC PROC [h: Handle, cellType: Core.CellType] = { cellTypeID: ROPE; cellType _ CoreOps.ToBasic[cellType]; IF cellType.class#CoreClasses. cellTypeID _ NARROW[HashTable.Fetch[h.cellTypeIDTab, cellType].value]; IF cellTypeID=NIL THEN { WritePublic: PROC [publicWire: Core.Wire, name: ROPE] = { IF publicWire.size=0 THEN { IF parameterCount=0 THEN IO.PutRope[h.stream, "PARAMETER = "] ELSE IO.PutRope[h.stream, ", "]; IO.PutRope[name]; parameterCount _ parameterCount+1; } ELSE FOR i: NAT IN [0..publicWire.size) DO subWire: Core.Wire _ publicWire[i]; subName: ROPE _ CoreOps.GetShortWireName[subWire]; WritePublic[subWire, Rope.Cat[name, "x", IF subName=NIL THEN ? ELSE subName]]; ENDLOOP; }; wireIDTab: HashTable.Table _ HashTable.Create[]; parameterCount: NAT _ 0; IO.PutRope[h.stream, "\nMNAME = "]; cellTypeID _ CoreOps.GetCellTypeName[cellType]; IF NOT HashTable.Insert[h.cellTypeIDTab, cellType, cellTypeID] THEN { }; IO.PutRope[h.stream, cellTypeID]; IO.PutRope[h.stream, ";\n"]; FOR i: NAT IN [0..cellType.public.size) DO subWire: Core.Wire _ cellType.public[i]; WritePublic[subWire, CoreOps.GetShortWireName[subWire]]; ENDLOOP; IF parameterCount>0 THEN IO.PutRope[h.stream, ";\n"]; }; }; END. ΜScaldIOImpl.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Barth, June 17, 1986 6:53:08 pm PDT On write cellTypeIDTab maps REF to ROPE. On read cellTypeIDTab maps ROPE to REF. h: Handle _ NEW[HandleRec]; IF fileName=NIL AND cellName=NIL THEN ERROR; IF fileName=NIL THEN fileName _ Rope.Cat[cellName, ".scald"]; h.stream _ FS.StreamOpen[fileName]; h.cellTypeIDTab _ HashTable.Create[equal: HashTable.RopeEqual, hash: HashTable.HashRope]; h.ropeIDTab _ HashTable.Create[equal: HashTable.RopeEqual, hash: HashTable.HashRope]; h.atomIDTab _ HashTable.Create[equal: HashTable.RopeEqual, hash: HashTable.HashRope]; cellType _ ReadCellType[h]; IO.Close[h.stream]; Recast into record cell type or transistor cell type. Write public wire, assume first levels are named, use x instead of . to seperate the wire levels, e.g. Data[0] becomes Datax0. Write instances Write type name Write public-actual binding IF actual has no name THEN generate a name Κ‚– "cedar" style˜codešœ™Kšœ Οmœ1™