0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ngspice tips switchを使ってみる

Last updated at Posted at 2025-09-01

普段使っているhspiceにはいわゆる機械式Switchのelementはないので、switchが必要な時はVCR(Voltage Controlled Resistor)のG素子を使っているのだが、ngspiceはG素子にVCRが無いようなので、switchを使ってみる。(これも実態はVCR)
ngspiceでsw(voltage controlled switch)を使ってみた例は以下。

*
*
.option method=gear tnom=25
*.option autostop
*
.param vdd=1.8
.param vss=0.0

vvcc vcc 0 dc vdd
vgnd vdd 0 dc vss

vin n00 0 dc vdd
sw1 n00 n01 ctrl0 0 switch1 on
r1 n01 0 10K

vsw ctrl0 0 pwl(0n vss 1n vss 2n vdd 3n vdd 4n vdd 5n vss 10n vss)

.print tran v(ctr0) v(n00) v(n01)
.print tran i(r1)

.model switch1 SW vt='0.5*vdd' vh='0.2*vdd'

.temp 25
.tran 1p 10n

.control
run
plot v(n00) v(n01) v(ctrl0)
write outputfile.raw v(n00) v(n01) v(ctrl0)
.endc

.end

switch modelのvhの意味が分からなかったので、適当に0.2vddとしたところ、このような波形になったので、VH/VLに対するSwitching点の指定のようだ。(vdd0.2とvdd*0.8でhysterisis)
image.png

ちなみにhspiceではこんな感じ

略
.param vdd=0.75
.param vss=0.0
略
vcc vcc 0 dc vdd
vss vss 0 dc vss
略
gsw a b VCR pwl(1) ctrl vss vss,10G vdd,1p
略
vctrl ctrl vss pwl(0n vdd 12n vdd 12.1n vss 15n vss)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?