Unit Test for 2-input NOR Digital Device-SR latch
.options timeint reltol=1.0e-3.tran 1ns 2us
* Sources.param V_LO=0 V_REF=0 V_HI=10;V1 5 0 PULSE ({V_LO} {V_HI} 20ns 20ns 20ns 40ns 250ns) ;SET;V2 4 0 PULSE ({V_LO} {V_HI} 150ns 20ns 20ns 40ns 250ns) ;RESETV1 5 0 {V_LO};setV2 4 0 {V_LO};reset
;first prn with 5 high / 4 low -> v(9) low, v(10) high;second prn with 5 low / 4 high -> v(9) high, v(10) low;third prn with 5 low / 4 low ->
* Output
.print tran PRECISION=4 WIDTH=10 v(5) v(4) v(9) v(10) ; S R Q Q' ?
* Set SR Latch default parameters:.param R1HI=5 R1LO=200 R0HI=200 R0LO=5 RIN=1000 R1=100.param SW=5.e-9 CAPOUT=1.e-12 CAPIN=1.e-12
* Digital power nodeVdd 1 0 10V
U1 NOR(2) 1 0 5 10 9 DMODU2 NOR(2) 1 0 4 9 10 DMOD
;R1 9 0 100K
.model DMOD DIG ( CLO=CAPOUT CHI=CAPOUT+ S0RLO=R0LO S0RHI=R0HI S0TSW=SW+ S0VLO=0 S0VHI=2+ S1RLO=R1LO S1RHI=R1HI S1TSW=SW+ S1VLO=8 S1VHI=12+ RLOAD=RIN CLOAD=CAPIN+ DELAY=20ns )
.end
Unit Test for NOR-basd latch, using the switch device
.options timeint reltol=1.0e-3
.tran 1ns 2us
* Sources
.param V_LO=0 V_REF=0 V_HI=10
V1 s 0 PULSE ({V_LO} {V_HI} 20ns 20ns 20ns 40ns 250ns) ;SET
V2 r 0 PULSE ({V_LO} {V_HI} 150ns 20ns 20ns 40ns 250ns) ;RESET
*V1 s 0 {V_LO};set
*V2 r 0 {V_LO};reset
*first prn with 5 high / 4 low -> v(9) low, v(10) high
*second prn with 5 low / 4 high -> v(9) high, v(10) low
*third prn with 5 low / 4 low ->
* Output
.print tran v(s) v(r) v(q) v(qp)
* S R Q QP
* Set SR Latch default parameters:
.param R1HI=5 R1LO=200 R0HI=200 R0LO=5 RIN=1000 R1=100
.param SW=5.e-9 CAPOUT=1.e-12 CAPIN=1.e-12
* Digital power node
Vdd 10 0 10V
.param Rstd=1MEG
.param Cstd=0.01pf
XLATCH1 s r q qp 10 NORLATCH
Rq q 0 {Rstd}
Rqp qp 0 {Rstd}
* NOR-LATCH subcircuit
* S R Q QP VCC
.subckt norlatch S R Q QP VCC
XNOR1 S Q2 QP VCC NOR
R1 QP QP2 {Rstd}
C1 QP2 0 {Cstd}
XNOR2 R QP2 Q VCC NOR
R2 Q Q2 {Rstd}
C2 Q2 0 {Cstd}
.ends
.SUBCKT NOR 1 2 3 4
* TERMINALS A B OUT VCC
RL 3 4 500
S1 3 0 1 0 SW
S2 3 0 2 0 SW
.ENDS
.MODEL SW VSWITCH(VON=2.6 VOFF=2.4 RON=10 ROFF=1MEG)
.end