Debian Codegraph @

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

raw
1 .PS
2 # `Alogix.m4'
3 log_init
4
5 # A modest expression in default form
6 A: Autologix(
7 Nand(And(Or(A,C),Or(B,~C),Or(~A,B,C)),Ck);
8 Nand(~A,B)@with .n at last [].s+(0,-2bp__))
9 move left 10bp__ from A.InCk
10 "\sl Out1" at A.Out1 ljust
11 "\sl Out2" at A.Out2 ljust
12 foreach_(`v_', `"$v_$" at A.In`'v_ above ', A,B,C,Ck)
13 `"\shortstack[l]{
14 \tt Autologix( \\ \tt \quad
15 Nand(And(Or(A,C),Or(B,\~{}C),Or(\~{}A,B,C)),Ck);\\ \tt \quad
16 Nand(\~{}A,B))@with .n at last [].s+(0,-2bp\_\_))}"'\
17 wid 288bp__ ht 32bp__ with .nw at A.sw+(0,-0.10)
18
19 # Draw a tree of gates only. The ~ has been
20 # replaced by NOT gates.
21 definergbcolor(lightblue,0.72,0.72,0.9)
22 G: Autologix(Or(And(B,Not(C)),And(Not(A),B,C)),N,shaded "lightblue") \
23 with .sw at A.e+(1.3,-0.5)
24 "{\sl G.Out}" at G.Out above ljust
25 `"\shortstack[l]{\tt G: Autologix( \\ \tt \
26 Or(And(B,Not(C)),And(Not(A),B,C)),N,\\ \tt \
27 shaded \"lightblue\")}"' wid 242pt__ ht 20pt__ at G.s+(0,-0.3)
28 for_(1,4,1,`"{\sf\small\sl G.In`'m4x}" at G.In`'m4x rjust')
29 "{\sf\small\sl G.In5}" at G.In5+(0,-1.5bp__) rjust
30
31 # Here is how to include an arbitrary circuit
32 # (an SR-flipflop, for example)
33 # that is not one of the standard gates.
34 # First, define the circuit with a name ending
35 # in _gate. Put its inputs named In1, In2, ...
36 # on the left and the output Out on the right.
37 define(`SR_gate',`[ v = 2*L_unit
38 S: NOR_gate
39 line right_ 4*L_unit from S.Out
40 Out: Here
41 R: NOR_gate at S+(0,-10*L_unit)
42 TS: S.In2-(v,0)
43 TR: (TS,R.In1)
44 dot(at S.Out+(v,0))
45 line down v*3/2 then to TR+(0,v) then to TR then to R.In1
46 line from R.Out right v then up v*3/2 then to TS+(0,-v) \
47 then to TS then to S.In2
48 In1: S.In1
49 In2: R.In2 ]')
50 # Now define the function by which the circuit
51 # will be invoked using the built-in _AutoGate:
52 define(`SRff',`_AutoGate(SR,$@)')
53 #
54 # You are done. Here is an example using SRff:
55 G: [
56 F: Autologix(SRff(And(x,y),Nand(x,y)),LRV)
57
58 "$x$" at F.Inx rjust
59 "$y$" at F.Iny rjust
60 "\sl Out" at F.Out ljust
61 ] with .sw at A.n+(0.5,-0.25)
62 `"{\tt Autologix(SRff(And(x,y),Nand(x,y)),LRV)}"' wid 253pt__ ht 7pt__ \
63 with .w at last [].sw+(0,-10pt__)
64
65 undefine(`moreexamples')
66 #efine(`moreexamples')
67
68 ifdef(`moreexamples',`
69 Q1: Autologix(Nor(Nor(A,And(B,C)),Nand(Not(B),D))) \
70 with .nw at A.sw+(0,-61bp__)
71 foreach_(`x',`"\sf x" at last [].In`'x above',A,B,C,D)
72
73 `"\shortstack[l]{%
74 \tt Q1: Autologix(Nor(Nor(A,And(B,C)),Nand(Not(B),D)),<options>)\\
75 \tt Loopover\_(`x',`\"\sf x\" at last [].In`'x above',A,B,C,D)}"' \
76 wid 350bp__ ht 20bp__ with .nw at Q1.sw+(0,-10pt__)
77
78 Q2: Autologix(Nor(Nor(A,And(B,~C)),Nand(Not(B),D)),V) \
79 with .nw at last "".sw+(0,-14bp__)
80 foreach_(`x',`"\sf x" at last [].In`'x above',A,B,C,D)
81 "\sf V" at last [].se above rjust
82
83 Q3: Autologix(Nor(Nor(A,And(B,C)),Nand(Not(B),D)),R) \
84 with .nw at last [].sw+(0,-0.2)
85 foreach_(`x',`"\sf x" at last [].In`'x above',A,B,C,D)
86 "\sf R" at last [].se above rjust
87
88 Q4: Autologix(Nor(Nor(A,And(B,C)),Nand(Not(B),D)),RV) \
89 with .nw at last [].sw+(0,-0.2)
90 foreach_(`x',`"\sf x" at last [].In`'x above',A,B,C,D)
91 "\sf RV" at last [].se above rjust
92
93 Autologix(Nor(Nor(A,And(B,C)),Nand(Not(B),D)),LRV) \
94 with .Out at Q4.Out+(3.5,0)
95 foreach_(`x',`"\sf x" at last [].In`'x rjust',A,B,C,D)
96 "\sf LRV" at last [].se above rjust
97
98 Autologix(Nor(Nor(A,And(B,C)),Nand(Not(B),D)),LR;offset=-L_unit*1.5) \
99 with .Out at Q3.Out+(3.5,0)
100 foreach_(`x',`"\sf x" at last [].In`'x rjust',A,B,C,D)
101 "\sf LR" at last [].se above rjust
102
103 Autologix(Nor(Nor(A,And(B,~C)),Nand(Not(B),D)),LV;offset=L_unit*2) \
104 with .Out at Q2.Out+(3.5,0)
105 foreach_(`x',`"\sf x" at last [].In`'x rjust',A,B,C,D)
106 "\sf LV" at last [].se above rjust
107
108 Autologix(Nor(Nor(A,And(B,C)),Nand(Not(B),D)),L) \
109 with .Out at Q1.Out+(3.5,0)
110 foreach_(`x',`"\sf x" at last [].In`'x rjust',A,B,C,D)
111 "\sf L" at last [].se above rjust
112 ')
113
114 .PE