How to specify MOS transitor parameters like length and width?

Hi,

I was able to simulate a schematic using nmos and pmos devices using ngspice but I’m wondering how can I change parameters like l and w (length and width of the channel) per instance ? Ideally, those parameters should be visible next to the transistor symbol.

I would like to be able to do the equivalent to this screenshot (made using gschem)

Screenshot%20from%202018-09-27%2000-02-12

Ronan

I have not seen a MOS transistor symbol with these features (neither in the PSPICE lib nor in the lib offered by nhatkhai in Adding spice components that do not exist in pspice library). If you look at it from the PCB side, the lack of this feature is understandable, because as a user of discrete devices you will probably never stumble over parameters like W and L as user definable entities.

If we want to use eeschema in a more general fashion, as a front-end to ngspice, this feature would be very desirable.

So the question here is: Can we define a symbol within the current eeschema framework that offers text fields to enter W and L and adds them internally to the device instance?

This then should result in a netlist line like
m1 d g s b mosmodel W=xx L=yy

I don’t have an answer to this. If it is not possible, this request should be placed as a feature request to the list https://bugs.launchpad.net/kicad.

1 Like

In addition: ngspice-28 allows adding the instance parameters W and L also to the .model line. Of course then all transistor instances calling this model have the same W and L.

This is an interest specific to IC design (which is my interest).
Adding parameters to a symbol which will be passed (intact or
modified, such as concatenating “W=” and the parsed value of
the W field, to get the “W=xx” result in the m1 device card above.

I could find nothing about this in the EESchema docs or by light
fiddling-around.

Forgive me if I’m not quite understanding the problem here, but I can simulate the below just fine within KiCad/ngspice. Is this not what’s desired?

1 Like

What does the netlist tell you? If the different W and L are appearing on the instance line, the device line, then it is o.k. If W and L are only available in the .model statement, all device using this model will show the same W and L (that one from the .model line). Could you have a look at the netlist?

That is how I do it. 5.x should include the .MODEL … text in the netlist (because of the “.” letter).
However, I think this style vs. the “+pspice” like in 4.0.7 may make it hard/confuse to do ngspice commands that don’t have “.” to started with.

Thanks, Ste,

In IC tools I’m used to seeing the L, W, M values as instance properties

(fill-form fields) besides the modelName. I was not aware that the model

field could also “house” a longer string of args that flow literally to the

netlist line.

Very helpful; “somebody” might want to add a note about this to the

library-element docs, if I didn’t miss one existing. I was thinking I

might need to create my own netlist “template” and a symbol with

the additional fields.

Is there perhaps a deeper reference on netlisting, how params are

passed and how / where evaluated from string to variable / number,

what can and can’t be “digested”, etc.?

@holger
Absolutely. The netlist is correct with different W and L for each M1 and M2. I should’ve been more clear, but I purposely set up that simulation/schematic such that “out_m1” and “out_m2” should produce completely different voltages with the different W and L (which they do).

@dick_freebird
Check out the ngspice-30 manual on page 135 for all the different fields available when calling a MOSFET model: http://ngspice.sourceforge.net/docs/ngspice-30-manual.pdf

This way of specifying W and L is how MOSFETs have always been dealt with since the conception of SPICE. The W and L are similar to how you specify a resistor. The basic resistor “.model” is built in, but you specify an R for it every time you “call it”. Same with MOSFETs, but W and L have defaults (DEFL and DEFW in .options) which are automatically plugged in for you in case you don’t specify their values for a particular instance.

One thing I should note within the .model statement I used, is that typically for IC design you don’t use explicit RS and RD parameters. You should instead specify RSH (sheet resistance) in the .model statement and then define separate NRD and NRS for each MOSFET instance (similar to how you deal with W and L). It then uses these formulas to calculate each RD and RS:
RD = RSH * NRD
RS = RSH * NRS

If you use a lot of instance parameters like these, you can start to see how putting them all on the same line could get sloppy on the schematic. This is why programs like LTspice have multiple “value” lines for their symbols, so you can better manage the clutter of text. I’m not sure if there’s a similar trick in KiCad or not.

1 Like

Duh…I just noticed that my .model statement in the schematic defined W and L which probably confused the crap out of people. I shouldn’t have done that for this example. My bad. Yes, you can define W and L in the model card too, but they will be overridden by the instance values (if they are specified). If not specified in the instance call, then it will fall back to the ones specified in the .model. If not specified in the .model, then it will use DEFL/DEFW as mentioned above. My apologies for the confusion.

Hi, Ste,

I know about SPICE MOSFET device card arguments. My problem

was how to get to what I wanted, through the KiCAD symbol’s limited

param fields. That is what I was on about.

I have encountered different treatment of the resistance and overlap

capacitances by different simulators (width-scaled, or literal). It’s

always good to check this when using models that purport to be

“for a different simulator”.

I know at least you can put all the parameters all in one line of the “Value” of the symbol. Like @Ste had shown. I don’t think KiCad currently support for multi-lines for ease of multi parameters.