Pspice Subcircuit implementation

Thread Starter

BATFISH55

Joined Feb 18, 2013
2
Hey there!

I'm a 3rd year EE major, and I'm trying to learn how to properly implement a subcircuit. At several points in a circuit sim, I need to invert a signal, so I coded up a simple CMOS inverter which works fine in its own simulation, but when I try to use reference it as a subcircuit, I get a weird error.

First, the code:


VDD 1 0 5
VCLOCK 2 0 PULSE (0 5 .5m 1N 1N .5m 1m)
;START INVERTER SUBCIRCUIT
.SUBCKT ZINV 101 102 105 100
; VDD VIN VOUT GND
VDDI 101 100
MPI 101 102 103 101 PFETI
.MODEL PFETI PMOS (L=3U W=6U KP=34.6U GAMMA=-.37 LAMBDA=.06 RD=1 RS=1
+VTO=-1 TOX=.04U CBD=2F CBS=2F CJ=200U CGBO=200P CGSO=40P CGDO=40P)
MNI 103 102 100 100 NFETI
.MODEL NFETI NMOS (L=3U W=6U KP=69U GAMMA=.37 LAMBDA=.06 RD=1 RS=1
+VTO=1 TOX=.04U CBD=2F CBS=2F CJ=200U CGBO=200P CGSO=40P CGDO=40P)
RINI 102 104 1k
VINI 104 100
ROUTI 103 105 1k
VOUTI 105 100
.ENDS ZINV
RIN 1 5 1K
X2 1 5 3 0 ZINV
ROUT 3 0 1K
.TRAN 0 5m 50U
.PROBE
.END

Now, the error:

ERROR -- Voltage source and/or inductor loop involving X2.VDDI
You may break the loop by adding a series resistance


First, I wasn't sure if there would be node-naming collisions for node labels within the subcircuit as outside, so I just started numbering subcircuit nodes in the 100s.
Second, based on the error, I added those resistors both inside and outside the subcircuit, but that didn't work either.

Since the CMOS code works fine on its own, it MUST be something to do with how I'm calling it....

Help!
 

WBahn

Joined Mar 31, 2012
30,072
Hey there!

I'm a 3rd year EE major, and I'm trying to learn how to properly implement a subcircuit. At several points in a circuit sim, I need to invert a signal, so I coded up a simple CMOS inverter which works fine in its own simulation, but when I try to use reference it as a subcircuit, I get a weird error.
You do have not one, but three voltage sources in your subcircuit? You don't give any value for any of them and I'm not sure how the simulator treats that -- it may default to 0V.

But your first one in the subcircuit is between nodes 101 and 100, which are your first and fourth ports. When you instantiate the inverter, these are connected to nodes 1 and 0 of the main circuit. But what else does your main circuit have between nodes 1 and 0? How about VDD?

A CMOS inverter is an extremely simple circuit -- one PFET and one NFET. Nothing else. Nada. Zip.
 

Thread Starter

BATFISH55

Joined Feb 18, 2013
2
Ah. When not using subcircuits, I've found that Pspice doesn't like floating nodes, that's why I entered sources into the subcircuit.

I deleted those 'internal' sources, and all is well.

Thanks much!
 
Top