Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/XOR.m4

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