1
\$\begingroup\$

I am trying to simulate a circuit using .subckt directive in Ngspice-26 to define NAND GATE and NOT gate.

I have two separate subckt files for inv and nand as inv.txt and nand.txt which I include in my main file. When I run the below mentioned code using source file_name.cir in Ngspice, I get the following promt in Ngspice terminal.

Warning: unknown device type: n
Error: too few nodes:  numparm__________00000013 

I read about it and there was some bug in NgSpice but was fixed in updated version 26 of Ngspice. Also another point to be noted was that this error occurred only when nand subckt is used and doesn't give error when only inv is used. Also the warning is says about a device type n which I haven't used in my cir file anywhere. Please tell me if I am doing something wrong.

This part of code is the main .cir file.

** DUT Test for NAND **
.include nand.txt
.include inv.txt
.include models.txt

.PARAM Len = 0.4um 
.param nWid = 0.60um 
.PARAM pWid = 1.55826um 
.PARAM vdd = 3.3
.global vdd

vdd vdd 0 vdd
vs  6 0 vdd

xinv1 1 2 inv
xinv2 2 3 inv

xnand1 3 6 4 nand

xinv3 4 5 inv
xinv4 4 5 inv
xinv5 4 5 inv
xinv6 4 5 inv

c1 5 0 0.1pF

vin 1 0 dc PULSE(0 3.3V 0 0.1ps 0.1ps 4ns 12ns)
.tran 0.05ps 8ns
.control
run

plot v(3) 'vdd - v(4)'
.endc
.end

Following is the code for subckt file for nand gate

* Subcircuit for Minimum sized NAND Gate

* CONNECTIONS:   IN1
*                | IN2
*                | | OUTPUT
*                | | |
.SUBCKT nand     1 2 3

*Specifying NMOS in this manner-
*name drain gate source body modelname as in model file

m1 node1 1 0 0 cmosn L=Len W=nWid AD='2*nWid*Len' AS='2*nWid*Len' PD='2*(nWid+2*Len)' PS='2*(nWid+2*Len)' 
m2 3 2 node1 0 cmosn L=Len W=nWid AD='2*nWid*Len' AS='2*nWid*Len' PD='2*(nWid+2*Len)' PS='2*(nWid+2*Len)' 

m3 3 1 vdd vdd cmosp L=Len W=pWid AD='2*pWid*Len' AS='2*pWid*Len' PD='2*(pWid+2*Len)' PS='2*(pWid+2*Len)
'
m4 3 2 vdd vdd cmosp L=Len W=pWid AD='2*pWid*Len' AS='2*pWid*Len' PD='2*(pWid+2*Len)' PS='2*(pWid+2*Len)
' 
.ends nand

Following is the code for subckt file for inverter

* Subcircuit for Minimum sized inverter

* CONNECTIONS:   INPUT
*                | OUTPUT
*                | | 
*                | | 
.SUBCKT inv      1 3 

*Specifying NMOS in this manner-
*name drain gate source body modelname as in model file

m1 3 1  0   0 cmosn L=Len W=nWid AD='2*nWid*Len' AS='2*nWid*Len' PD='2*(nWid+2*Len)' PS='2*(nWid+2*Len)' 
m2 3 1  vdd vdd cmosp L=Len W=pWid AD='2*pWid*Len' AS='2*pWid*Len' PD='2*(pWid+2*Len)' PS='2*(pWid+2*Len)' 
.ends inv

Link to models.txt file here Link to inv.txt file here.

Link to nand.txt file, replace inv.txt in above with nand.txt

\$\endgroup\$
1
\$\begingroup\$

Syntax error. Closing single quotes on lines 16 and 18 should not be on a new line. Always keep a * on empty lines between code.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks a lot. The problem was in definition of m3 and m4 in nand.txt, apparently the single quote shifted to the next line due to some formatting in text editor. Thanks a lot again. \$\endgroup\$ – Shashank Gangrade Oct 7 '15 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.