| 1 |
.PS |
| 2 |
# `XORDPV.m4' |
| 3 |
# Realizations of the XOR function |
| 4 |
log_init |
| 5 |
scale = 2.54 |
| 6 |
|
| 7 |
define(`gatelineth',1.6) # gate line thickness |
| 8 |
define(`lineth',0.8) # connection thickness |
| 9 |
|
| 10 |
define(`labels',` |
| 11 |
"svg_it(A)" at last [].InA above wid 0.25 |
| 12 |
"svg_it(B)" at last [].InB above wid 0.25 |
| 13 |
"svg_it(A) O`'svg_sup(+,100,0,-1.4ex) svg_it(B)" at last [].Out ljust wid 1.2 |
| 14 |
#"svg_it(A) svg_font(Latin,,,"O")`'svg_sup(+,100,0,-1.4ex) svg_it(B)" at last [].Out ljust |
| 15 |
') |
| 16 |
|
| 17 |
# single gate |
| 18 |
XOR: Autologix(Xor(A,B)) |
| 19 |
labels |
| 20 |
|
| 21 |
# canonical form |
| 22 |
Autologix(Or(And(A,Not(B)),And(Not(A),B))) \ |
| 23 |
with .nw at last [].sw+(0,-1) |
| 24 |
labels |
| 25 |
|
| 26 |
# mixed gates |
| 27 |
Autologix(And(Nand(A,B),Or(A,B))) \ |
| 28 |
with .nw at last [].nw+(8,0) |
| 29 |
labels |
| 30 |
|
| 31 |
# nand realization |
| 32 |
Autologix(Nand(Nand(Nand(A,A),B),Nand(Nand(B,B),A))) \ |
| 33 |
with .nw at 2nd last [].sw+(0,-1) |
| 34 |
labels |
| 35 |
|
| 36 |
# nor realization |
| 37 |
Autologix(Nor(Nor(Nor(A,A),Nor(B,B)),Nor(A,B))) \ |
| 38 |
with .nw at last [].nw+(8,0) |
| 39 |
labels |
| 40 |
|
| 41 |
# These functions contain topologies in common so write a macro |
| 42 |
define(`customAB', |
| 43 |
`S: Autologix(N`$1'(N`$1'(A,B1),N`$1'(B1,B)),N) with .Out at Here |
| 44 |
line thick lineth from S.In2 to S.In3; InAB: dot(at last line.c) |
| 45 |
line thick lineth from InAB left 2*L_unit |
| 46 |
TN: Autologix(N`$1'(A,B)) with .Out at Here |
| 47 |
line thick lineth from TN.InA up 3*L_unit; InA: Here |
| 48 |
line thick lineth from TN.InB up 3*L_unit; InB: Here |
| 49 |
line thick lineth from S.In4 to (InB,S.In4) then to (InB,TN.In2); dot |
| 50 |
line thick lineth from S.In1 to (InA,S.In1); dot') |
| 51 |
|
| 52 |
[ customAB(and) |
| 53 |
Out: S.Out |
| 54 |
] with .nw at 2nd last [].sw+(0,-1) |
| 55 |
labels |
| 56 |
|
| 57 |
[ linethick = gatelineth |
| 58 |
H: NOR_gate(2); linethick = lineth |
| 59 |
L:dot(at H.w-(2*L_unit,0)) |
| 60 |
line from H.In1 to (L,H.In1) then to (L,H.In2) then to H.In2 |
| 61 |
line from L left 2*L_unit |
| 62 |
customAB(or) |
| 63 |
Out: H.Out |
| 64 |
] with .nw at last [].nw+(8,0) |
| 65 |
labels |
| 66 |
|
| 67 |
.PE |