Voltage current measurement in subcircuit

136 views
Skip to first unread message

Jin Yan

unread,
Nov 8, 2022, 7:13:28 PM11/8/22
to xyce-users
Hi,

I have a basic question about how to measure voltage and current inside the subcircuit. I have a very basic inverter and I'd like to measure the voltage at the VDD node and the current flowing from VDD into the PMOS. Can anyone help me how to measure them using .print? If the subcircuit has more levels of hierarchy, what's the best way to do this kind of measurement for the target node at the desired level?

******
.lib sky130.lib.spice ff

.SUBCKT xtor VDD VSS I Z
.OPTIONS DEVICE TEMP=25 TNOM=25
X0 Z I VDD VDD sky130_fd_pr__pfet_01v8_hvt PARAMS: W=1e+06u L=150000u
X1 Z I VSS VSS sky130_fd_pr__nfet_01v8 PARAMS: W=650000u L=150000u
.ENDS

xtop VDD VSS I Z xtor
Vp VDD 0 DC 1.8
Vs VSS 0 DC 0.0
C0 Z 0 C=15f
Vramp1 I 0 PULSE(0 1.8 2e-10 1e-10 1e-11 1e-6 1e-6)
.tran 1e-10 5e-10
.print tran format=csv v(I) v(Z)
.end

jfol...@gmail.com

unread,
Dec 6, 2022, 10:08:08 PM12/6/22
to xyce-users
Hi there, you can do this with the colon notation. For example:

.PRINT TRAN V(XTOP:VDD)

Will print the voltage of the VDD node inside the XTOP instance.

The I() notation only allows you to print the current through a two-terminal device. To measure the current into the terminal of a transistor, you can use the lead abbreviation method or you have to declare a dummy source to use as an ammeter:

.SUBCKT xtor VDD VSS I Z
.OPTIONS DEVICE TEMP=25 TNOM=25
VAMMETER VDD VDD_PMOS 0
X0 Z I  VDD_PMOS    VDD_PMOS   sky130_fd_pr__pfet_01v8_hvt PARAMS: W=1e+06u L=150000u

X1 Z I VSS VSS sky130_fd_pr__nfet_01v8 PARAMS: W=650000u L=150000u
.ENDS


then measure the current:

.PRINT TRAN I(XTOP:VAMMETER)

You can find this information in the .PRINT section of the Xyce Reference Guide under <output variable>.

jfol...@gmail.com

unread,
Dec 6, 2022, 10:15:33 PM12/6/22
to xyce-users

Jin Yan

unread,
Dec 7, 2022, 12:05:25 PM12/7/22
to xyce-users
Thank you so much for the answer and reference! The dummy source approach to measure current is very helpful!

Christos Toitos

unread,
May 26, 2025, 6:31:11 AMMay 26
to xyce-users
This approach requires modifying the schematic by adding a 0V ideal voltage source, and in most simulators you are able to probe the pin of the subcircuit without the need for the voltage source. Is this currently possible in Xyce and if so, what is the notation of probing that current?

Regards,
Christos

xyce-users

unread,
May 26, 2025, 2:18:49 PMMay 26
to xyce-users
Yes, Xyce supports a feature known as "lead currents", which enables the user to request terminal currents from most devices.  For two terminal devices, like a resistor, the syntax on the .PRINT line is very simple.  It is the same as you would use to print a Vsrc current.  For example, ".PRINT DC I(R1)", where R1 is the name of a resistor.

For devices with >2 terminals, the syntax gets a little more complicated, as you have to specify the terminal.  So for example, to get the currents from a BJT device named "Q1", the print line might be: ".PRINT DC ib(q1) ic(q1) ie(q1)", to get the base, collector and emitter currents of "q1" respectively.   This naming convention is the same as can be found in other simulators.  For more details, see the Xyce user and reference guides.

thanks,
Eric

xyce-users

unread,
May 26, 2025, 2:28:26 PMMay 26
to xyce-users

One other thing; for printing out variables that are inside of subcircuits, the default subcircuit separator in Xyce is the colon, like was mentioned earlier in the thread.

We used the colon because many years ago we were emulating spice3, and that is what they used.   We've since learned that most other simulators don't use colons.  Instead, most simulators use the period.

So, for the purposes of compatibility Xyce has an option that allows you to use period separators.  This option can be invoked on the Xyce command line in two ways.  Either:

Xyce -hspice-ext separator <netlist.cir>

or

Xyce -hspice-ext all <netlist.cir>

The first one only turns on the separator flag, the second one turns on a bunch of other hspice syntax choices.

thanks,
Eric
Reply all
Reply to author
Forward
0 new messages