<> <> <> <<>> <> <> <<>> DIRECTORY CD USING [Design], CDEnvironment USING [StuffToCommandTool], CDViewer USING [FindDesign], Core USING [Wire, Wires], CoreCreate USING [Range, Seq], CoreOps USING [SetShortWireName], ProcessProps USING [GetProp], Rope USING [ROPE]; IOBridge: CEDAR PROGRAM IMPORTS CDEnvironment, CDViewer, CoreCreate, CoreOps, ProcessProps ~ BEGIN <> CacheType: INT _ 001H; -- Constant defined in DynaBus protocol, Appendix B IOWRQ: INT _ 012H; -- Constant defined by the DynaBus protocol BIOWRQ: INT _ 014H; -- Constant defined by the DynaBus protocol ByteType: INT _ 02H; -- Constant defined by the IOBridge specs WordType: INT _ 03H; -- Constant defined by the IOBridge specs LongType: INT _ 04H; -- Constant defined by the IOBridge specs IOType: INT _ 02H; -- Constant defined by the IOBridge specs <> Fields: TYPE ~ LIST OF Field; Field: TYPE ~ REF FieldRep; FieldRep: TYPE ~ RECORD [name: Rope.ROPE, size: NAT]; -- size 0 means field is atomic wire Fld: PROC [name: Rope.ROPE, size: NAT _ 0] RETURNS [Field] ~ INLINE { RETURN [NEW[FieldRep _ [name, size]]] }; BusStructure: PROC [name: Rope.ROPE, size: NAT, fields: Fields] RETURNS [public: Core.Wires] ~ { bus: Core.Wire _ CoreCreate.Seq[name, size]; base: NAT _ 0; public _ LIST [bus]; WHILE fields#NIL DO f : Field = fields.first; IF f.size=0 THEN { -- Extraction of an atomic field public _ CONS [CoreOps.SetShortWireName[bus[base], f.name], public]; base _ base+1; } ELSE { -- Extraction of a regular field public _ CONS [CoreCreate.Range[bus, base, f.size, f.name], public]; base _ base+f.size; }; fields _ fields.rest; ENDLOOP; IF size#base THEN ERROR; -- the sum of field sizes is not equal to the bus size! }; Request: PROC [] RETURNS [public: Core.Wires] ~ { public _ BusStructure[name: "Request", size: 81, fields: LIST[ Fld["Cmd", 5], Fld["Mode"], Fld["IORange"], Fld["DeviceID", 10], Fld["Address", 32], Fld["Data", 32]]]; }; RequestH: PROC [] RETURNS [public: Core.Wires] ~ { public _ BusStructure[name: "RequestH", size: 49, fields: LIST[ Fld["Cmd", 5], Fld["Mode"], Fld["IORange"], Fld["DeviceID", 10], Fld["Address", 32]]]; }; Header: PROC [] RETURNS [public: Core.Wires] ~ { public _ BusStructure[name: "Header", size: 64, fields: LIST[ Fld["Cmd", 5], Fld["ModeError"], Fld["Shared"], Fld["DeviceID", 10], Fld["Address", 47]]]; }; IOAddress: PROC [] RETURNS [public: Core.Wires] ~ { public _ BusStructure[name: "IOA", size: 47, fields: LIST[ Fld["ZA", 15], Fld["Addr", 32]]]; }; IOLargeAddr: PROC [] RETURNS [public: Core.Wires] ~ { public _ BusStructure[name: "IOLarge", size: 32, fields: LIST[ Fld["DevT", 4], Fld["DevN", 4], Fld["DevSA", 24]]]; }; IOMediumAddr: PROC [] RETURNS [public: Core.Wires] ~ { public _ BusStructure[name: "IOMedium", size: 32, fields: LIST[ Fld["DevT", 8], Fld["DevN", 8], Fld["DevSA", 16]]]; }; IOSmallAddr: PROC [] RETURNS [public: Core.Wires] ~ { public _ BusStructure[name: "IOSmall", size: 32, fields: LIST[ Fld["DevT", 12], Fld["DevN", 10], Fld["DevSA", 10]]]; }; <> GetDesign: PROC [] RETURNS [design: CD.Design] ~ { design _ CDViewer.FindDesign["IOBridge"]; IF design=NIL THEN { [] _ CDEnvironment.StuffToCommandTool["CDRead +R -P +X -S IOBridge", NARROW[ProcessProps.GetProp[$WorkingDirectory], Rope.ROPE]]; design _ CDViewer.FindDesign["IOBridge"]; }; IF design=NIL THEN ERROR; -- don't bother ... }; END.