.include "/mit/6.004/jsim/nominal.jsim" .include "/mit/6.004/jsim/lab2checkoff.jsim" .subckt ORGATE a b o Xnor a b nor1 NORGATE Xnot nor1 o NOTGATE .ends .subckt NORGATE a b o M1 midtop a vdd vdd PENH sw=8 sl=1 M2 o b midtop vdd PENH sw=8 sl=1 M3 o a 0 0 NENH sw=8 sl=1 M4 o b 0 0 NENH sw=8 sl=1 .ends .subckt XORGATE a b o Xnand a b nor1 NORGATE M1 midtop a vdd vdd PENH sw=4 sl=1 M2 o nor1 midtop vdd PENH sw=4 sl=1 M3 midbot b 0 0 NENH sw=2 sl=1 M4 o a midbot 0 NENH sw=2 sl=1 M5 midtop b vdd vdd PENH sw=4 sl=1 M6 o nor1 0 0 NENH sw=2 sl=1 .ends .subckt NOTGATE a o M1 o a 0 0 NENH sw=2 sl=1 M2 o a vdd vdd PENH sw=4 sl=1 .ends .subckt ANDGATE a b o M1 mid a vdd 0 NENH sw=2 sl=1 M2 o2 b mid 0 NENH sw=2 sl=1 M3 o2 a 0 vdd PENH sw=4 sl=1 M4 o2 b 0 vdd PENH sw=4 sl=1 Xnot1 o2 o1 NOTGATE Xnot2 o1 o NOTGATE .ends .subckt FA a b c0 s c1 XXOR1 a b xout XORGATE XXOR2 xout c0 s XORGATE XOR1 a b oout ORGATE XAND1 c0 oout aaut ANDGATE XAND2 a b aout ANDGATE XOR2 aaut aout c1 ORGATE .ends .subckt adder4 a3 a2 a1 a0 b3 b2 b1 b0 s4 s3 s2 s1 s0 Xbit0 a0 b0 0 s0 c0 FA Xbit1 a1 b1 c0 s1 c1 FA Xbit2 a2 b2 c1 s2 c2 FA Xbit3 a3 b3 c2 s3 s4 FA .ends .plot Xtest.s0 .plot Xtest.c0 .plot Xtest.a0 .plot Xtest.b0