PROGRAM sjrc(input,output);

{A program to calculate the widths of 15 Enh MOSFETS designed
 to produce a linear voltage output in the range 0-1V.  Each
 MOSFET has its drain tied to Vdd (5V) and its source tied to
 the analogue output (V). The gate is driven below threshold
 (input 0) or to 5V (input 1).                               }

VAR     V : real;   {The desired output voltage}
      rho : real;   {Width/Length of the MOSFET current source}
        W : real;   {Width in microns of the MOSFET}
     Wcum : real;   {Cumulative Width, in microns, so far}
   lambda : real;   {currently 3u}
        L : real;   {channel Length - currently 6u}
      Vth : real;   {Threshold voltage - nominally 0.75V}
        K : real;   {Transconductance in A/V**2}
        n : integer;
BEGIN
  lambda := 3;
  L := 6;
  Vth := 0.75;
  Wcum := 0.0;      {cumulative width so far...}
  K := 30E-6;       {transconductance}
  FOR n := 1 TO 15 DO
    BEGIN
      V := n / 15;  {desired output voltage}
      {now solve Schichman-Hodges}
      rho := V * 2.0  / (75.0 * K * Sqr(5.0 - Vth - V));
      W := rho * L / lambda;     {target width in microns}
      writeln('M',n:1,'  17 ',n:1,'  18  16  MENH2 L=',L:4:1,
      {and the increment, in multiples of lambda, required to
       achieve the target width}
              'U  W=',ROUND(W-Wcum)*3-3:1,'U');
      Wcum := W;
    END;
END.
