DIRECTORY BSimModel, FS USING [StreamOpen], IO USING [Backup, char, Close, GetChar, GetLineRope, GetReal, Put, PutF, real, RIS, rope, STREAM], Rope USING [Cat, Equal, Fetch, Find, Length, ROPE, Substr]; BSimModelImplInput: CEDAR PROGRAM IMPORTS FS, IO, Rope EXPORTS BSimModel = BEGIN ReadProcessFile: PUBLIC PROC [ fileName: Rope.ROPE ] RETURNS [ p: REF BSimModel.ProcessParams ] = { s: IO.STREAM = FS.StreamOpen[fileName]; ReadReal: PROC [ s: IO.STREAM ] RETURNS [ r: REAL ] = BEGIN DO SELECT (c _ s.GetChar[]) FROM ',, ' , '/, '\n => NULL; ENDCASE => {s.Backup[c]; RETURN[s.GetReal[]]}; ENDLOOP; END; c: CHAR; p _ NEW[BSimModel.ProcessParams]; p.info _ NIL; WHILE (c _ s.GetChar[]) = '* DO line: Rope.ROPE = s.GetLineRope[]; eqPos: INT = line.Find["="]; p.info _ Rope.Cat[p.info, "*", line, "\n"]; IF line.Length>1 AND line.Fetch[0]#' AND eqPos>0 THEN { label: Rope.ROPE = line.Substr[len: eqPos]; rest: IO.STREAM = IO.RIS[line.Substr[start: eqPos+1]]; SELECT TRUE FROM label.Equal["W/L", FALSE] => { p.dutW _ ReadReal[rest]; p.dutL _ ReadReal[rest]}; label.Equal["BetaFudgeFactor", FALSE] => p.betaFudgeFactor _ ReadReal[rest]; ENDCASE => NULL; }; ENDLOOP; s.Backup[c]; FOR i: INT IN [0..BSimModel.nBasicBSimParams) DO FOR j: INT IN [1..6] DO p.params[i][j] _ ReadReal[s]; ENDLOOP; ENDLOOP; p.toxMicrons _ ReadReal[s]; p.tempC _ ReadReal[s]; p.vddVolts _ ReadReal[s]; s.Close[]; }; WriteProcessFile: PUBLIC PROC [ fileName: Rope.ROPE, p: REF BSimModel.ProcessParams ] = { s: IO.STREAM = FS.StreamOpen[fileName, $create]; s.Put[IO.rope[p.info]]; FOR i: INT IN [0..BSimModel.nBasicBSimParams) DO FOR j: INT IN [1..6] DO s.Put[IO.real[p.params[i][j]], IO.char[IF j<6 THEN ', ELSE '\n]]; ENDLOOP; ENDLOOP; s.PutF["%g,%g,%g\n", IO.real[p.toxMicrons], IO.real[p.tempC], IO.real[p.vddVolts]]; s.Close[]; }; END. |File: [Cherry]Cedar5.1>System>BSimModelImplInput.mesa Last Edited by: McCreight, April 11, 1985 7:04:21 pm PST Ê8˜Jšœ<™