<> <> <> DIRECTORY Build, Globals, IO, Model, Parse, Printout, Rope; PrintoutImpl: CEDAR PROGRAM IMPORTS Build, Globals, IO, Model, Rope, Parse EXPORTS Printout = BEGIN OPEN Printout; Units: PUBLIC REAL _ 2.0; <> <> threshold: REAL; nDups: INT; FetRope: PUBLIC PROC[fet: Globals.Fet, globalVars: Globals.GlobalVars] RETURNS [rope: Rope.ROPE] = BEGIN rope _ IO.PutFR["g=%s, s=%s, d=%s", IO.rope[Build.RopeFromNode[fet.gate, globalVars]], IO.rope[Build.RopeFromNode[fet.source, globalVars]], IO.rope[Build.RopeFromNode[fet.drain, globalVars]]]; RETURN [rope]; END; NodeRope: PUBLIC PROC[node: Globals.Node, globalVars: Globals.GlobalVars] RETURNS [rope: Rope.ROPE] = BEGIN x,y: REAL; p: Globals.Pointer; terminal: Rope.ROPE; f: Globals.Fet; <> p _ node.firstPointer; IF p = NIL THEN BEGIN RETURN [Build.RopeFromNode[node, globalVars]]; END ELSE BEGIN FOR i:INT IN [0..10) DO f _ p.fet; IF node = f.gate THEN EXIT; IF p.next = NIL THEN EXIT; p _ p.next; ENDLOOP; x _ f.x/Units; y _ f.y/Units; IF node = f.gate THEN terminal _ "gate" ELSE IF node = f.drain THEN terminal _ "drain" ELSE IF node = f.source THEN terminal _ "source" ELSE BEGIN IO.PutF[Globals.StdOut, "Crystal bug: node %s doesn't connect right!\n", IO.rope[Build.RopeFromNode[node, globalVars]]]; RETURN ["??"]; END; rope _ IO.PutFR["%s (see %s at %f,%f)", IO.rope[Build.RopeFromNode[node, globalVars]], IO.rope[terminal], IO.real[x], IO.real[y]]; RETURN [rope]; END; END; PrintCap: PUBLIC Globals.CmdProc = BEGIN ParseOK: BOOLEAN; <> node: Globals.Node; nDups _ 0; threshold _ 0.0; <> WHILE args # NIL DO IF Rope.Fetch[args.rope, 0] # '- THEN EXIT; IF Rope.Length[args.rope] # 2 THEN BEGIN IO.PutF[Globals.StdOut, "Bad switch: %s\n", IO.rope[args.rope]]; args _ args.next; LOOP; END; SELECT Rope.Fetch[args.rope, 1] FROM 't => BEGIN [ParseOK, threshold] _ Parse.Real[args.next]; IF ParseOK THEN args _ args.next ELSE IO.PutF[Globals.StdOut, "No threshold value given, using 0.\n"]; END; ENDCASE => IO.PutF[Globals.StdOut, "Bad switch: %s\n", IO.rope[args.rope]]; args _ args.next; ENDLOOP; <> nDups _ 0; <> <> <> WHILE args # NIL DO <> node _ Build.NodeFromRope[args.rope, globalVars]; IO.PutF[Globals.StdOut, "%.3f pf capacitance at %s.\n", IO.real[node.cap], IO.rope[NodeRope[node, globalVars]]]; args _ args.next; ENDLOOP; IF nDups > 0 THEN IO.PutF[Globals.StdOut, "%d duplicates not printed.\n", IO.int[nDups]]; END; <> <> <> <> <= threshold THEN BEGIN>> <> <> <> <> <> <> <> <> <> <> <> PrintRes: PUBLIC Globals.CmdProc = BEGIN ParseOK: BOOLEAN; <> node: Globals.Node; nDups _ 0; threshold _ 0.0; <> WHILE args # NIL DO IF Rope.Fetch[args.rope, 0] # '- THEN EXIT; IF Rope.Length[args.rope] # 2 THEN BEGIN IO.PutF[Globals.StdOut, "Bad switch: %s\n", IO.rope[args.rope]]; args _ args.next; LOOP; END; SELECT Rope.Fetch[args.rope, 1] FROM 't => BEGIN [ParseOK, threshold] _ Parse.Real[args.next]; IF ParseOK THEN args _ args.next ELSE IO.PutF[Globals.StdOut, "No threshold value given, using 0.\n"]; END; ENDCASE => IO.PutF[Globals.StdOut, "Bad switch: %s\n", IO.rope[args.rope]]; args _ args.next; ENDLOOP; <> <> nDups _ 0; <> <> <> WHILE args # NIL DO node _ Build.NodeFromRope[args.rope, globalVars]; IO.PutF[Globals.StdOut, "%.3f ohms resistance at %s.\n", IO.real[node.res], IO.rope[NodeRope[node, globalVars]]]; <> args _ args.next; ENDLOOP; IF nDups > 0 THEN IO.PutF[Globals.StdOut, "%d duplicates not printed.\n", IO.int[nDups]]; END; <> <> <> <> <= threshold THEN>> <> <> <> <> <> <> <> <> <> <> <> PrintFets: PUBLIC Globals.CmdProc = BEGIN <> <> <> WHILE args # NIL DO <> FetProc[Build.NodeFromRope[args.rope, globalVars], globalVars]; args _ args.next; ENDLOOP; END; FetProc: PROC[node: Globals.Node, globalVars: Globals.GlobalVars] = BEGIN pointer: Globals.Pointer; fet: Globals.Fet; fp: Globals.FlowPtr; FOR pointer _ node.firstPointer, pointer.next UNTIL pointer = NIL DO fet _ pointer.fet; IF fet.gate = node THEN BEGIN IO.PutF[Globals.StdOut, "%s, type=%s, aspect=%.3f, area=%.3f\n", IO.rope[FetRope[fet, globalVars]], IO.rope[Model.TypeTable[fet.type].name], IO.real[fet.aspect], IO.real[fet.area/(Units*Units)]]; IO.PutRope[Globals.StdOut, " Flags:"]; IF fet.flowFromSource THEN IO.PutRope[Globals.StdOut, " fromSource"]; IF fet.flowFromDrain THEN IO.PutRope[Globals.StdOut, " fromDrain"]; IF fet.forcedOn THEN IO.PutRope[Globals.StdOut, " forcedOn"]; IF fet.forcedOff THEN IO.PutRope[Globals.StdOut, " forcedOff"]; IF fet.on0 THEN IO.PutRope[Globals.StdOut, " on0"]; IF fet.on1 THEN IO.PutRope[Globals.StdOut, " on1"]; IF fet.onAlways THEN IO.PutRope[Globals.StdOut, " onAlways"]; IF fet.noSourceInfo THEN IO.PutRope[Globals.StdOut, " noSourceInfo"]; IF fet.noDrainInfo THEN IO.PutRope[Globals.StdOut, " noDrainInfo"]; IF fet.firstFlow # NIL THEN IO.PutRope[Globals.StdOut, " Flow:"]; FOR fp _ fet.firstFlow, fp.next UNTIL fp = NIL DO IF fp.source THEN IO.PutF[Globals.StdOut, " s=%s", IO.rope[fp.flow.name]]; IF fp.drain THEN IO.PutF[Globals.StdOut, " d=%s", IO.rope[fp.flow.name]]; ENDLOOP; IO.PutRope[Globals.StdOut, "\n"]; END; ENDLOOP; END; PrintNodes: PUBLIC Globals.CmdProc = BEGIN <> <> WHILE args # NIL DO <> NodeProc[Build.NodeFromRope[args.rope, globalVars], globalVars]; args _ args.next; ENDLOOP; END; NodeProc: PROC[node: Globals.Node, globalVars: Globals.GlobalVars] = BEGIN IO.PutF[Globals.StdOut, "%s:", IO.rope[Build.RopeFromNode[node, globalVars]]]; IF node.always0 THEN IO.PutRope[Globals.StdOut, " always 0"]; IF node.always1 THEN IO.PutRope[Globals.StdOut, " always 1"]; IF node.input THEN IO.PutRope[Globals.StdOut, " input"]; IF node.output THEN IO.PutRope[Globals.StdOut, " output"]; IF node.precharged THEN IO.PutRope[Globals.StdOut, " precharged"]; IF node.bus THEN IO.PutRope[Globals.StdOut, " bus"]; IF node.dynamic THEN IO.PutRope[Globals.StdOut, " dynamic"]; IF node.inPath THEN IO.PutRope[Globals.StdOut, " inPath"]; IF node.ratioError THEN IO.PutRope[Globals.StdOut, " ratioError"]; IF node.watched THEN IO.PutRope[Globals.StdOut, " watched"]; IO.PutF[Globals.StdOut, " capacitance = %.5f, resistance = %.1f,", IO.real[node.cap], IO.real[node.res]]; IO.PutF[Globals.StdOut, " rise time = %.1f, fall time = %.1f\n", IO.real[node.hiTime], IO.real[node.loTime]]; END; END.