Editing Ocs package

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 469: Line 469:


==== Build the AND gate circuit structure parsing an IFF netlist ====
==== Build the AND gate circuit structure parsing an IFF netlist ====
To parse an IFF format netlist of the CMOS AND gate we can use the following command


{{Code|Load the AND circuit structure parsing an IFF netlist |<syntaxhighlight lang="octave" style="font-size:13px">
{{Code|Load the AND circuit structure parsing an IFF netlist |<syntaxhighlight lang="octave" style="font-size:13px">
Line 476: Line 474:
</syntaxhighlight>
</syntaxhighlight>
}}
}}
The IFF netlist consists of the .cir file named "and.cir" shown below


{{Code|IFF netlist for the AND gate (.cir file)|<syntaxhighlight lang="text" style="font-size:13px">
{{Code|IFF netlist for the AND gate (.cir file)|<syntaxhighlight lang="text" style="font-size:13px">
Line 525: Line 521:
</syntaxhighlight>
</syntaxhighlight>
}}
}}
and of the .nms file named "and.nms shown below


{{Code|IFF netlist for the AND gate (.nms file)|<syntaxhighlight lang="text" style="font-size:13px">
{{Code|IFF netlist for the AND gate (.nms file)|<syntaxhighlight lang="text" style="font-size:13px">
Line 539: Line 533:
</syntaxhighlight>
</syntaxhighlight>
}}
}}
{{Code|Model evaluator file for simple MOSFET models |<syntaxhighlight lang="octave" style="font-size:13px">
function [a,b,c] = Mnmosfet (string, parameters, parameternames, extvar, intvar, t) 
 
  switch string
    case 'simple',
     
      rd = 1e6;
     
      for ii=1:length(parameternames)
        eval([parameternames{ii} "=",...
              num2str(parameters(ii)) " ;"])   
      endfor
     
      vg  = extvar(1);
      vs  = extvar(2);
      vd  = extvar(3);
      vb  = extvar(4);
     
      vgs  = vg-vs;
      vds  = vd-vs;
     
      if (vgs < Vth)
       
       
        gm = 0;
        gd = 1/rd;
        id = vds*gd;
       
      elseif ((vgs-Vth)>=(vds))&(vds>=0)
       
        id = k*((vgs-Vth)*vds-(vds^2)/2)+vds/rd;
        gm = k*vds;
        gd = k*(vgs-Vth-vds)+1/rd;
       
      elseif ((vgs-Vth)>=(vds))&(vds<0)
       
        gm = 0;
        gd = 1/rd;
        id = vds*gd;
       
      else # (i.e. if 0 <= vgs-vth <= vds)
       
        id = k*(vgs-Vth)^2/2+vds/rd;
        gm = k*(vgs-Vth);
        gd = 1/rd;
       
      endif
     
      a = zeros(4);
     
      b = [ 0    0        0  0;
          -gm  (gm+gd)  -gd  0;
            gm  -(gm+gd)    gd  0;
            0    0        0  0];
     
      c = [0 -id id 0]';
      break;
    otherwise
      error(["Mnmosfet: unknown option " string]);
     
  endswitch
endfunction
</syntaxhighlight>
}}


==== Build the AND gate circuit structure parsing a .spc file ====
==== Build the AND gate circuit structure parsing a .spc file ====
Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: