DIRECTORY Rope, IO, SymTab, IP, IPParams, IPToolBox, IPBasicOps, IPChipRose, IPTypeTab; IPTypeTabImpl: CEDAR PROGRAM IMPORTS IO, Rope, SymTab, IP, IPParams, IPChipRose, IPToolBox, IPBasicOps EXPORTS IPTypeTab = BEGIN OPEN BO: IPBasicOps, TB: IPToolBox, CR: IPChipRose, IPTypeTab; Create: PUBLIC PROC[chipRose: CR.Ref] RETURNS [Ref] = { tab: SymTab.Ref _ SymTab.Create[]; eachTypeProc: CR.EachTypeAction ={ [] _ tab.Store[type, ToCoType[type, val]]; }; --eachTypeProc chipRose.Types[eachTypeProc]; RETURN [NEW[Rep _ [tab]]]; }; --Create FetchCoType: PUBLIC PROC[typeTab: Ref, name: Rope.ROPE, raiseError: BOOL] RETURNS [CoType] ={ found: BOOL; val: REF; [found, val] _ typeTab.tab.Fetch[name]; IF found THEN RETURN [NARROW[val]]; IF raiseError THEN ERROR IP.Error[missingRegistration, Rope.Cat[name, " is not a type name"]] ELSE RETURN [NIL]; }; --FetchCoType CoTypes: PUBLIC PROC[typeTab: Ref, action: EachCoTypeAction] ={ p: SymTab.EachPairAction = {RETURN[action[NARROW[val]]]};--p [] _ typeTab.tab.Pairs[p]; }; --CoTypes CheckSelf: PUBLIC PROC[typeTab: Ref] ={NULL}; --CheckSelf DescribeSelf: PUBLIC PROC[typeTab: Ref, stream: IO.STREAM, debug: BOOL] ={ pShapeInfo: PROC[shapeInfo: IP.ShapeInfoRec] ={ shape: REF IP.ShapeRep _ shapeInfo.shape; stream.PutF["shape: "]; TB.PutShape[stream, shape]; stream.PutF[" shapeFn: {"]; stream.PutF["} "]; stream.PutF["restriction: {"]; stream.PutF["} "]; }; --pShapeInfo pPin: PROC[pin: Pin] ={ stream.PutF["%g: {", IO.rope[pin.name]]; stream.PutF["physicalPins: "]; TB.PutPhysicalPins[stream, pin.physicalPins]; stream.PutF[" auxInfo: {"]; stream.PutF["} "]; stream.PutF["}\n\t "]; }; --pPin pCoType: EachCoTypeAction ={ stream.PutF["%g: {\n\t" , IO.rope[coType.name]]; stream.PutF["shapeInfo: {"]; pShapeInfo[coType.shapeInfo]; stream.PutF["}\n\t"]; stream.PutF["pins: {\n\t "]; FOR pins: LIST OF Pin _ coType.pins, pins.rest UNTIL pins = NIL DO pPin[pins.first]; ENDLOOP; stream.PutF["}\n\t"]; IF debug THEN { stream.PutF["instances: ("]; FOR l: LIST OF REF IP.ComponentRep _ coType.instances, l.rest UNTIL l = NIL DO stream.PutF[" %g", IO.rope[l.first.name]]; ENDLOOP; stream.PutF[")\n\t"]; }; stream.PutF["}\n"]; }; --pCoType stream.PutF["\nBeginTypeTab"]; stream.PutF["\n%g \t--Number of CoTypes\n", IO.int[typeTab.tab.GetSize[]]]; CoTypes[typeTab, pCoType]; stream.PutF["EndTypeTab\n"]; }; --DescribeSelf ReconstructSelf: PUBLIC PROC[stream: IO.STREAM] RETURNS [Ref] ={ tab: SymTab.Ref _ SymTab.Create[]; THROUGH [0..stream.GetInt) DO name: Rope.ROPE; coType: CoType; [name, coType] _ GetCoType[stream]; [] _ tab.Store[name, coType]; ENDLOOP; IF stream.GetAtom[] # $EndTypeTab THEN ERROR IP.Error; RETURN [NEW[Rep _ [tab]]]; }; --ReconstructSelf ToCoType: PROC[name: Rope.ROPE, crType: REF CR.TypeRec] RETURNS [ct: CoType] ={ pins: LIST OF Pin _ TB.MakeIPPins[crType.pins, crType.origin, crType.shape, IPParams.PinMaxDistFromEdge]; shapeInfo: IP.ShapeInfoRec _ [BO.Copy2Shape[crType.shape], crType.shapeFn, crType. restriction]; RETURN [NEW[CoTypeRep _ [name, NIL, pins, shapeInfo]]] }; --ToCoType GetCoType: PROC[stream: IO.STREAM] RETURNS [Rope.ROPE, CoType] ={ name: Rope.ROPE _ TB.GetIdRope[stream]; pins: LIST OF Pin; shapeInfo: IP.ShapeInfoRec; TB.EnterBlock[stream]; UNTIL TB.ExitBlock[stream] DO token: ATOM _ TB.GetIdAtom[stream]; SELECT token FROM $instances => [] _ stream.GetRefAny[]; --Get instances. NOT used; for show $shapeInfo => shapeInfo _ GetShapeInfo[stream]; -- Get shapeInfo $pins => pins _ GetPins[stream]; -- Get pins ENDCASE => ERROR; ENDLOOP; RETURN[name, NEW[CoTypeRep _ [name, NIL, pins, shapeInfo]]]; }; --GetCoType GetPins: PROC [stream: IO.STREAM] RETURNS [pins: LIST OF REF IP.PinRep _ NIL] = { getPin: PROC RETURNS [pin: Pin] = { getAuxInfo: PROC RETURNS [REF _ NIL] = { TB.EnterBlock[stream]; [] _ TB.ExitBlock[stream] }; --getAuxInfo pin _ NEW[PinRep _ [name: TB.GetIdRope[stream]]]; TB.EnterBlock[stream]; UNTIL TB.ExitBlock[stream] DO SELECT TB.GetIdAtom[stream] FROM $auxInfo => pin.auxInfo _ getAuxInfo[]; $physicalPins => pin.physicalPins _ TB.GetPhysicalPins[stream]; ENDCASE => ERROR; ENDLOOP; }; --getPin TB.EnterBlock[stream]; UNTIL TB.ExitBlock[stream] DO pins _ CONS[getPin[], pins]; ENDLOOP; }; --GetPins GetShapeInfo: PROC [stream: IO.STREAM] RETURNS [IP.ShapeInfoRec] ={ shape: REF IP.ShapeRep _ NIL; shapeFn: REF _ NIL; restriction: REF _ NIL; TB.EnterBlock[stream]; UNTIL TB.ExitBlock[stream] DO SELECT TB.GetIdAtom[stream] FROM $shape => shape _ TB.GetShape[stream]; $shapeFn, $restriction => { TB.EnterBlock[stream]; --GET INFO HERE LATER [] _ TB.ExitBlock[stream];}; ENDCASE => ERROR; ENDLOOP; RETURN [IP.ShapeInfoRec[shape, shapeFn, restriction]] }; --GetShapeInfo GetPin: PUBLIC PROC [coType: CoType, pinName: Rope.ROPE] RETURNS [pin: Pin] ={ FOR l: LIST OF Pin _ coType.pins, l.rest UNTIL l = NIL DO IF Rope.Equal[l.first.name, pinName] THEN {pin _ l.first; EXIT} REPEAT FINISHED => ERROR IP.Error[missingRegistration, Rope.Cat[pinName, " is not a pin in type ", coType.name]]; ENDLOOP; }; --GetPin RemInstance: PUBLIC PROC[coType: CoType, instance: REF IP.ComponentRep] ={ lHd, lTl: LIST OF REF IP.ComponentRep; lHd _ lTl _ CONS[NIL, NIL]; FOR l: LIST OF REF IP.ComponentRep _ coType.instances, l.rest UNTIL l = NIL DO IF l.first = instance THEN {lTl.rest _ l.rest; EXIT} ELSE {lTl.rest _ LIST[l.first]; lTl _ lTl.rest}; REPEAT FINISHED => ERROR IP.Error[callingError, Rope.Cat[instance.name, " is not an instance of type", coType.name]]; ENDLOOP; coType.instances _ lHd.rest; }; --RemInstance MakePhysicalPins: PUBLIC PROC[coType: CoType, pin: Pin, orient: IP.Orientation] RETURNS [phyPins: LIST OF PhysicalPin _ NIL] ={ FOR l: LIST OF PhysicalPin _ pin.physicalPins, l.rest UNTIL l = NIL DO pPin: PhysicalPin _ l.first; phyPins _ CONS[NEW[PhysicalPinRep _ [pPin.coord, pPin.side, pPin.active]], phyPins] ENDLOOP; IF coType.shapeInfo.shape = NIL THEN ERROR IP.Error[callingError, "Not implemented yet"] -- haven't figure out how to handle soft types yet ELSE TB.OrientPhysicalPins[phyPins, coType.shapeInfo.shape.dim^, orient] }; --MakePhysicalPins END. j--File: IPTypeTabImpl.mesa Last Edited by: CSChow, January 27, 1985 0:03:53 am PST --(1) print shape --(2) print shapeFn SHOULD PRINT pShapeInfo.shapeFn HERE --(3) print restriction --SHOULD PRINT pShapeInfo.restriction HERE --SHOULD PRINT pin.auxInfo HERE --(1) print shapeInfo --(2) print pins --(3) print instances --Operation on individual CoType Κ ˜J™J™7J™J™codešΟk ˜ K˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ ˜ —K˜šœœœ˜Kšœœœ-˜IKš œ œœœœ œ˜XK˜K˜š Οnœœœ œœ ˜7Kšœ"˜"šœœ˜"Kšœ*˜*KšœΟc˜—Kšœ˜Kšœœ˜KšœŸ˜ —K˜K˜š ž œœœœœœ ˜]Kšœœ˜ Kšœœ˜ Kšœ'˜'šœ˜ Kšœœœ˜—šœ ˜KšœœœB˜OKšœœœ˜—KšœŸ ˜—K˜šžœœœ+˜?Kšœœœ Ÿ˜