DIRECTORY Convert USING [IntFromRope], CoreRouteFlat, ExprRead USING[ReadFile, FetchRope, FetchBool], FS USING [StreamOpen], IO, Imager USING [Context], Misc USING [Rect], IP, IPCTG, IPConstants, IPParams, IPCTGMaker, IPCoVerifier, IPCoTab, RefStack USING [Ref, Create, Reset, Empty, Push, Pop1, Items, EachItemAction, Size], IPChipRose, IPNetTab, IPTypeTab, IPPortTab, IPToolBox, IPTop, Rope USING [ROPE, Equal, Substr], SymTab; IPTopImpl: CEDAR PROGRAM IMPORTS Convert, FS, ExprRead, IO, IP, IPParams, IPCoTab, IPCTG, IPCTGMaker, IPCoVerifier, IPChipRose, IPPortTab, IPNetTab, IPTypeTab, IPToolBox, RefStack, Rope EXPORTS IPTop = BEGIN OPEN IPTop; CyclicConstraint: PUBLIC ERROR[negCh, posCh: IPCTG.Channel] = CODE; ComponentsOverlapped: PUBLIC ERROR[overlaps: LIST OF Misc.Rect] = CODE; Create: PUBLIC PROC[chipRose: IPChipRose.Ref] RETURNS[Ref] = { types: IPTypeTab.Ref _ IPTypeTab.Create[chipRose]; nets: IPNetTab.Ref _ IPNetTab.Create[chipRose]; ports: IPPortTab.Ref _ IPPortTab.Create[chipRose, nets]; coTab: IPCoTab.Ref _ IPCoTab.Create[chipRose, types, nets]; ctg: IPCTG.Ref _ IPCTG.Create[]; RETURN [NEW[Rep _ [coTab, ports, ctg, types, nets, RefStack.Create[], RefStack.Create[], RefStack.Create[], RefStack.Create[]]]] }; --Create -- Create1: PUBLIC PROC[defaultDir, descFile: Rope.ROPE] RETURNS [Ref] ={ tab: SymTab.Ref _ ExprRead.ReadFile[IPToolBox.ConstructFileName[defaultDir, descFile, "desc"]]; systemName: Rope.ROPE _ ExprRead.FetchRope[tab, "ObjectName", TRUE].val; roseFile: Rope.ROPE _ ExprRead.FetchRope[tab, "ConnectivityFile", TRUE].val; chipFile: Rope.ROPE _ ExprRead.FetchRope[tab, "LibraryFile", TRUE].val; typFile: Rope.ROPE _ ExprRead.FetchRope[tab, "IPTypeFile", TRUE].val; initFile: Rope.ROPE _ ExprRead.FetchRope[tab, "IPInitFile", TRUE].val; readCDFirst: BOOL _ ExprRead.FetchBool[tab, "ReadCDFirst", TRUE].val; chipRose: IPChipRose.Ref _ IPChipRose.CreateFrom[ IPToolBox.ConstructFileName[defaultDir, roseFile, "sch"], IPToolBox.ConstructFileName[defaultDir, chipFile, "dale"], IPToolBox.ConstructFileName[defaultDir, typFile, "typ"], IPToolBox.ConstructFileName[defaultDir, initFile, "init"], readCDFirst]; RETURN[Create[chipRose]]; }; --Create1 CreateFromStructure: PUBLIC PROC[structure: CoreRouteFlat.Structure] RETURNS[Ref] = { types: IPTypeTab.Ref _ IPTypeTab.CreateFromStructure[structure]; nets: IPNetTab.Ref _ IPNetTab.CreateFromStructure[structure]; ports: IPPortTab.Ref _ IPPortTab.CreateFromStructure[structure, nets]; coTab: IPCoTab.Ref _ IPCoTab.CreateFromStructure[structure, types, nets]; ctg: IPCTG.Ref _ IPCTG.Create[]; RETURN [NEW[Rep _ [coTab, ports, ctg, types, nets, RefStack.Create[], RefStack.Create[], RefStack.Create[], RefStack.Create[]]]] }; --CreateFromStructure -- DestroySelf: PUBLIC PROC [top: Ref] ={ IPCTG.DestroySelf[top.ctg]; IPCoTab.DestroySelf[top.coTab]; }; --DestroySelf ReDefineChs: PUBLIC PROC[top: Ref, chWidth: INT _ IPParams.ChDefaultWidth, yPrimary, maxChWidth: BOOL _ FALSE] RETURNS [Ref] ={ cI: IPCoVerifier.Ref _ IPCoVerifier.Create[yPrimary]; ctgMaker: IPCTGMaker.Ref _ IPCTGMaker.Create[]; ctg: IPCTG.Ref; overlaps: LIST OF Misc.Rect; p: IPCoTab.EachComponentAction ={cI.InsertComponent[co]}; --p -- IPCTG.DestroySelf[top.ctg]; -- Release top.ctg-- IPCoTab.Components[top.coTab, p]; IF (overlaps _ cI.Verify) = NIL THEN ctg _ ctgMaker.ConstructCTG[cI, chWidth, yPrimary, maxChWidth].ctg ELSE ERROR ComponentsOverlapped[overlaps]; cI.Destroy; ctgMaker.Destroy; top.ctg _ ctg; top.undoStack.Reset; --undoStack is no longer valid-- top.redoStack.Reset; --redoStack is no longer valid-- top.horOldChs.Reset; --horOldChs is no longer valid-- top.verOldChs.Reset; --verOldChs is no longer valid-- IF top.initialized THEN InitTop[top]; RETURN [top]; }; --ReDefineChs-- ClearChannels: PUBLIC PROC[top: Ref] ={ IPCTG.DestroySelf[top.ctg]; top.ctg _ IPCTG.Create[]; top.undoStack.Reset; --undoStack is no longer valid-- top.redoStack.Reset; --redoStack is no longer valid-- top.horOldChs.Reset; --horOldChs is no longer valid-- top.verOldChs.Reset; --verOldChs is no longer valid-- }; --ClearChannels DescribeSelf: PUBLIC PROC[top: Ref, file: Rope.ROPE] = { stream: IO.STREAM _ FS.StreamOpen[file, $create]; stream.PutF["\nBeginTop"]; stream.PutF["\n%g\n", IO.bool[top.initialized]]; top.ctg.DescribeSelf[stream]; --(1) Print ctg top.nets.DescribeSelf[stream]; --(2) Print nets top.types.DescribeSelf[stream]; --(3) Print types top.ports.DescribeSelf[stream]; --(4) Print ports top.coTab.DescribeSelf[stream]; --(5) Print coTab IF top.southMost = NIL THEN NULL ELSE stream.PutF["\n%g %g %g %g\n --Bounding Channels--", IO.rope[IPCTG.GetName[top.southMost]], IO.rope[IPCTG.GetName[top.eastMost]], IO.rope[IPCTG.GetName[top.northMost]], IO.rope[IPCTG.GetName[top.westMost]]]; stream.PutF["\nEndTop\n"]; stream.Close[]; }; --DescribeSelf-- PaintSelf: PUBLIC PROC[top: Ref, context: Imager.Context, xOffset, yOffset: REAL _ 0.0, scaleFactor: REAL _ 1.0, compStipple: CARDINAL _ IPConstants.White, showChNames, showCompNames, showPinNames: BOOL _ TRUE] ={ top.coTab.PaintSelf[context, xOffset, yOffset, scaleFactor, compStipple, showCompNames, showPinNames]; top.ctg.PaintSelf[context, xOffset, yOffset, scaleFactor, showChNames]; }; --PaintSelf-- ReconstructSelf: PUBLIC PROC[file: Rope.ROPE] RETURNS [top: Ref] = { stream: IO.STREAM _ FS.StreamOpen[file]; id: Rope.ROPE _ stream.GetID; init: BOOL; undoStack: RefStack.Ref _ RefStack.Create[]; redoStack: RefStack.Ref _ RefStack.Create[]; horOldChs: RefStack.Ref _ RefStack.Create[]; verOldChs: RefStack.Ref _ RefStack.Create[]; ctg: IPCTG.Ref; nets: IPNetTab.Ref; ports: IPPortTab.Ref; types: IPTypeTab.Ref; coTab: IPCoTab.Ref; southMost, eastMost, northMost, westMost: IPCTG.Channel _ NIL; IF NOT Rope.Equal[id, "BeginTop"] THEN ERROR IP.Error[callingError, "Bad Input"]; init _ stream.GetBool; IF Rope.Equal[stream.GetID, "BeginCTG"] THEN ctg _ IPCTG.ReconstructSelf[stream] --(1) Get ctg ELSE ERROR IP.Error[callingError, "Bad Input"]; IF Rope.Equal[stream.GetID, "BeginNetTab"] THEN nets _ IPNetTab.ReconstructSelf[stream] -- (2) Get nets ELSE ERROR IP.Error[callingError, "Bad Input"]; IF Rope.Equal[stream.GetID, "BeginTypeTab"] THEN types _ IPTypeTab.ReconstructSelf[stream] -- (3) Get types ELSE ERROR IP.Error[callingError, "Bad Input"]; IF Rope.Equal[stream.GetID, "BeginPortTab"] THEN ports _ IPPortTab.ReconstructSelf[stream, nets] -- (4) Get ports ELSE ERROR IP.Error[callingError, "Bad Input"]; IF Rope.Equal[stream.GetID, "BeginCoTab"] THEN coTab _ IPCoTab.ReconstructSelf[stream, types, nets, ctg] -- (5) Get coTab ELSE ERROR IP.Error[callingError, "Bad Input"]; id _ stream.GetID; IF Rope.Equal[id, "EndTop"] THEN NULL ELSE{ southMost _ IPCTG.GetChannel[ctg, id]; eastMost _ IPCTG.GetChannel[ctg, stream.GetID]; northMost _ IPCTG.GetChannel[ctg, stream.GetID]; westMost _ IPCTG.GetChannel[ctg, stream.GetID]; IF ~ Rope.Equal[stream.GetID, "EndTop"] THEN ERROR IP.Error[callingError, "Bad Input"]; }; top _ NEW[Rep _ [coTab, ports, ctg, types, nets, undoStack, redoStack, horOldChs, verOldChs, init, southMost, eastMost, northMost, westMost]]; IF init THEN InitTop[top]; }; -- ReconstructSelf-- CheckSelf: PUBLIC PROC[top: Ref] ={ oldChsType: IPCTG.ChType _ hor; --First Check horizontal channel-- prevChCount: NAT _ 2; --All old hor/ver channels must have count greater than this-- eachOldCh: RefStack.EachItemAction = { ch: IPCTG.Channel _ NARROW[item]; currentChCount: NAT; IF ch.type # oldChsType THEN ERROR; IF top.ctg.GetChannel[ch.name, FALSE] # NIL THEN ERROR; currentChCount _ Convert.IntFromRope[Rope.Substr[IPCTG.GetName[ch], 1]]; IF prevChCount < currentChCount THEN NULL ELSE ERROR; prevChCount _ currentChCount; }; --eachOldCh-- top.horOldChs.Items[eachOldCh]; oldChsType _ ver; prevChCount _ 2; top.verOldChs.Items[eachOldCh]; IF top.undoStack.Size[] # top.redoStack.Size[] THEN ERROR; --They should match-- BEGIN IF top.ctg.Size[hor] = 0 OR top.ctg.Size[ver] = 0 THEN { IF top.ctg.Size[hor] # top.ctg.Size[ver] THEN ERROR ELSE RETURN}; top.ctg.CheckSelf; top.coTab.CheckSelf; END; BEGIN IF top.southMost = NIL OR top.eastMost = NIL OR top.northMost = NIL OR top.westMost = NIL THEN { IF top.southMost # NIL OR top.eastMost # NIL OR top.northMost # NIL OR top.westMost # NIL THEN ERROR;}; --IF one of them is NIL THEN all must be NIL-- END; };--CheckSelf-- ConstraintChannels: PUBLIC PROC[top: Ref, negCh, posCh: IPCTG.Channel, wt: INT] = { IF ~ top.initialized THEN InitTop[top]; top.ctg.SetExternalConstraint[negCh, posCh, wt ! IPCTG.CyclicConstraints => GOTO reSignal]; top.ctg.ConstrainChannels0[negCh, posCh, wt]; EXITS reSignal => {ERROR CyclicConstraint[negCh, posCh]}}; --ConstraintChannels-- ClearConstraints: PUBLIC PROC[top: Ref, negCh: IPCTG.Channel, posCh: IPCTG.Channel _ NIL] ={ top.ctg.ClearExternalConstraints[negCh, posCh]; top.initialized _ FALSE; }; --ClearConstraints-- ClearAllConstraints: PUBLIC PROC[top: Ref] ={ top.ctg.ClearAllExternalConstraints; top.initialized _ FALSE; }; --ClearAllConstraints-- NoTopology: PUBLIC PROC[top: Ref] RETURNS [BOOL] ={ RETURN [top.ctg.Size[hor] = 0 OR top.ctg.Size[ver] = 0] };--NoTopology Geometrize: PUBLIC PROC [top: Ref, xPosition: INT _ IPParams.ChDefaultPositionX, yPosition: INT _ IPParams.ChDefaultPositionY, horPosSense, verPosSense: BOOL _ TRUE] = { chs: IPCTG.Ref _ top.ctg; p: IPCoTab.EachComponentAction ={IPCoTab.PositionComponent[co, 1, 0, 0, 1]}; IF top.ctg.Size[hor] = 0 OR top.ctg.Size[ver] = 0 THEN RETURN; IF ~ top.initialized THEN InitTop[top]; chs.ComputeGeometry[xPosition, yPosition, horPosSense, verPosSense]; --Compute the geometrical information of the channels -- top.coTab.Components[p]; --compute the position of the boxes wrt. the channels -- InitTop[top] }; -- Geometrize-- XDim: PUBLIC PROC[top: Ref] RETURNS [INT] ={ IF ~ top.initialized THEN InitTop[top]; IF top.eastMost = NIL OR top.westMost = NIL THEN [top.southMost, top.eastMost, top.northMost, top.westMost] _ top.ctg.GetBoundingChannels; RETURN [IPCTG.GetCoord[top.eastMost] - IPCTG.GetCoord[top.westMost]] };--XDim-- YDim: PUBLIC PROC[top: Ref] RETURNS [INT] ={ IF ~ top.initialized THEN InitTop[top]; IF top.southMost = NIL OR top.northMost = NIL THEN [top.southMost, top.eastMost, top.northMost, top.westMost] _ top.ctg.GetBoundingChannels; RETURN [IPCTG.GetCoord[top.northMost] - IPCTG.GetCoord[top.southMost]]};--YDim-- Area: PUBLIC PROC[top: Ref] RETURNS [INT] ={RETURN [XDim[top] * YDim[top]]};--Area-- InitTop: PROC[top: Ref] ={ chs: IPCTG.Ref _ top.ctg; p: IPCoTab.EachComponentAction = {IPCoTab.ConstrainChannels[co, chs]}; top.ctg.RefreshAllConstraints[]; -- Clears all previous constraints top.coTab.Components[p]; --Add the constraints between channels resulting from the components -- chs.AddTopologicalConstraints; -- Add the constraints resulting from the topology of the channel intersection -- chs.AddExternalConstraints; -- Add any user specified constriants -- top.initialized _ TRUE; }; --InitTop-- CreateChannel: PUBLIC PROC[top: Ref, type: IPCTG.ChType, width: INT _ IPParams.ChDefaultWidth, coord: INT _ 0] RETURNS[ch: IPCTG.Channel] ={ top.initialized _ FALSE; SELECT type FROM hor => IF ~ top.horOldChs.Empty THEN { ch _ NARROW[top.horOldChs.Pop1]; IPCTG.SetWidth[ch, width]; IPCTG.SetCoord[ch, coord]; top.ctg.ReActivateChannel[ch]; RETURN [ch]}; ver => IF ~ top.verOldChs.Empty THEN { ch _ NARROW[top.verOldChs.Pop1]; IPCTG.SetWidth[ch, width]; IPCTG.SetCoord[ch, coord]; top.ctg.ReActivateChannel[ch]; RETURN [ch]}; ENDCASE => ERROR; RETURN [top.ctg.CreateChannel[type, width, coord]] };--CreateChannel-- DestroyChannel: PUBLIC PROC[top: Ref, ch: IPCTG.Channel] ={ DeActivateChannel[top, ch]; SELECT IPCTG.GetType[ch] FROM hor => top.horOldChs.Push[ch]; ver => top.verOldChs.Push[ch]; ENDCASE => ERROR; }; --DestroyChannel-- DeActivateChannel: PUBLIC PROC[top: Ref, ch: IPCTG.Channel] = { top.initialized _ FALSE; top.ctg.DeActivateChannel[ch]}; --DeActivateChannel-- ReActivateChannel: PUBLIC PROC[top: Ref, ch: IPCTG.Channel] ={ top.initialized _ FALSE; top.ctg.ReActivateChannel[ch] }; --ReActivateChannel-- END. -- File: IPTopImpl.mesa -- Last Edited by: CSChow, February 1, 1985 8:47:46 am PST Preas, August 26, 1986 7:22:22 pm PDT changed definition for ReDefineChs, CreateChannel November 30, 1987 2:55:20 pm PST --Documentation will come later after consolidating the design -- สฝ˜Jšœ™šœ:™:Icode™%Kšœฯnœ!™R—J™J™AJ˜šฯk ˜ Jšœžœ˜K– "Cedar" stylešœ˜K– "Cedar" stylešœ žœ!˜/Jšžœžœ˜Jšžœ˜K– "Cedar" stylešœžœ ˜Jšœžœ˜J˜Jšžœ˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ žœF˜TJ˜ J˜ J˜ Jšœ ˜ J˜ K– "Cedar" stylešœ˜Jšœžœžœ˜!K– "Cedar" stylešœ˜—J˜šœ žœž˜Jšžœ žœ žœžœa˜ šžœ žœžœ˜!J˜—Jš œžœžœžœ žœ˜Cš œžœžœ žœžœžœ˜GJ˜—šœžœžœžœ ˜>Jšœ2˜2J˜/J˜8Jšœ;˜;Jšœžœžœ ˜ Kšžœžœu˜€Jšœฯc ˜J˜—š œžœžœžœžœ ˜FKšœ_˜_Kšœ>žœ˜HKšœžœ/žœ˜LKšœžœ*žœ˜GKšœžœ)žœ˜EKšœžœ)žœ˜FKšœ žœ*žœ˜Ešœ1˜1Kšœ9˜9Kšœ:˜:Kšœ8˜8Kšœ:˜:Kšœ ˜ —Kšžœ˜KšœŸ ˜ J˜—šœžœžœ%žœ ˜UJšœ@˜@Jšœ=˜=JšœF˜FJšœI˜IJšœžœžœ ˜ Kšžœžœu˜€JšœŸ˜J˜—š œžœžœ˜&Jšžœ˜Jšœ˜JšœŸ ˜J˜—š œžœžœžœ2žœžœžœ ˜K– "Cedar" stylešœ5˜5K– "Cedar" stylešœ/˜/K– "Cedar" stylešœžœ˜K– "Cedar" stylešœ žœžœ ˜K– "Cedar" stylešœ;Ÿ˜AKšžœŸ˜0K– "Cedar" stylešœ!˜!– "Cedar" stylešžœžœ˜ K– "Cedar" stylešžœC˜GK– "Cedar" stylešžœžœ ˜*—K– "Cedar" style˜ K– "Cedar" stylešœ˜K– "Cedar" stylešœ˜K– "Cedar" stylešœŸ ˜6K– "Cedar" stylešœŸ ˜6K– "Cedar" stylešœŸ ˜5K– "Cedar" stylešœŸ ˜5K– "Cedar" stylešžœžœ˜%K– "Cedar" stylešžœ˜ KšœŸ œ˜K– "Cedar" style˜—– "Cedar" styleš œžœžœ ˜'K– "Cedar" stylešžœ˜Kšœ žœ ˜K– "Cedar" stylešœŸ ˜6K– "Cedar" stylešœŸ ˜6K– "Cedar" stylešœŸ ˜5K– "Cedar" stylešœŸ ˜5K– "Cedar" stylešœŸ˜K– "Cedar" style˜—– "Cedar" styleš œžœžœžœ˜8K– "Cedar" stylešœžœžœžœ˜1K– "Cedar" style˜K– "Cedar" stylešœžœ˜0K– "Cedar" stylešœŸ˜.K– "Cedar" stylešœŸ˜/K– "Cedar" stylešœ!Ÿ˜2K– "Cedar" stylešœ Ÿ˜1K– "Cedar" stylešœ Ÿ˜2– "Cedar" styleš žœžœžœžœžœ˜&K– "Cedar" stylešœ8žœžœžœžœžœžœžœžœ˜า—K– "Cedar" style˜K– "Cedar" style˜K– "Cedar" stylešœŸ˜J˜—š œžœžœ6žœžœžœ@žœžœ˜ีJšœf˜fJšœG˜GJšœŸ ˜K– "Cedar" style˜—– "Cedar" styleš œžœžœ žœžœ˜DK– "Cedar" stylešœžœžœžœ˜(K– "Cedar" stylešœ žœ˜K– "Cedar" stylešœžœ˜ K– "Cedar" stylešœ,˜,K– "Cedar" stylešœ,˜,K– "Cedar" stylešœ,˜,K– "Cedar" stylešœ,˜,K– "Cedar" stylešœžœ˜K– "Cedar" stylešœ˜K– "Cedar" style˜Jšœ˜K– "Cedar" stylešœ˜K– "Cedar" stylešœ*žœ žœ˜>K– "Cedar" styleš žœžœžœžœžœ"˜QK– "Cedar" stylešœ˜K– "Cedar" style˜– "Cedar" stylešžœ&˜(K– "Cedar" stylešžœžœŸ ˜7K– "Cedar" stylešžœžœžœ"˜/—– "Cedar" stylešžœ)˜+K– "Cedar" stylešžœ)Ÿ˜˜T•StartOfExpansion4 -- [item: REF ANY] RETURNS [quit: BOOL _ FALSE] -- šœ&˜&Jšœžœ žœ˜!Jšœžœ˜Kšžœžœžœ˜#K– "Cedar" styleš žœžœžœžœžœ˜7K– "Cedar" stylešœ1žœ˜HKš žœžœžœžœžœ˜5Jšœ˜JšœŸ ˜—Jšœ˜Jšœ"˜"Jšœ˜J˜Kšžœ-žœžœŸ˜PJ˜šž˜šžœžœžœ˜9Kš žœ'žœžœžœžœ˜A—Jšœ˜Jšœ˜Jšžœ˜—J˜šž˜šžœžœžœžœžœžœžœžœžœ˜`KšžœžœžœžœžœžœžœžœžœžœŸ.˜–—Kšžœ˜—KšœŸ œ˜J˜—š œžœžœžœžœ˜SKšžœžœžœ˜'Jšœ1žœžœ ˜[Jšœ-˜-šž˜Jšœ žœ#Ÿ˜K—K˜—š œžœžœžœžœ žœ˜\Kšœ/˜/Kšœžœ˜KšœŸ˜K˜—šœžœžœ ˜-Kšœ$˜$Kšœžœ˜KšœŸ˜K˜—š œž œ žœžœ˜3Kšžœžœ˜7KšœŸ ˜J˜—š œžœžœžœ+žœ<žœžœ˜ซJšœžœ˜JšœL˜LKšžœžœžœžœ˜?Kšžœžœžœ˜'JšœEŸ8˜}JšœŸ8˜QJšœ ˜ JšœŸ˜K– "Cedar" style˜—š œžœžœ žœžœ˜,Kšžœžœžœ˜'š žœžœžœžœž˜0KšœY˜Y—Kšžœžœžœ˜DKšœŸœ˜ K˜—š œžœžœ žœžœ˜,Kšžœžœžœ˜'š žœžœžœžœž˜2KšœY˜Y—KšžœžœžœŸœ˜PK˜—šœžœžœ žœžœžœŸœ˜TJ˜—– "Cedar" stylešœžœ ˜Jšœžœ˜JšœF˜FKšœ!Ÿ"˜CJšœŸHœ˜bJšœŸQ˜pJšœŸ(˜DJšœžœ˜JšœŸ ˜K– "Cedar" style˜—– "Cedar" styleš œžœžœžœžœ#žœžœžœ ˜ŒK– "Cedar" stylešœžœ˜– "Cedar" stylešžœž˜šœžœžœ˜&Kšœžœžœ˜K– "Cedar" stylešœžœ˜K– "Cedar" stylešœ˜K– "Cedar" stylešœŸ˜K– "Cedar" style˜—K– "Cedar" stylešžœ˜K– "Cedar" style™——…—/XE-