1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
\section{Flip Flops}
The syntax for all logical base circuits is
\begin{verbatim}
logic[<options>](<originX,originY>){Label}
\end{verbatim}
\noindent where the options and the origin are optional. If they are missing,
then the default options, described in the next section and the default
origin $(0,0)$ is used. The origin specifies the lower left corner
of the logical circuit.
\begin{verbatim}
logic{Demo}
logic[logicType=and]{Demo}
logic(0,0){Demo}
logic[logicType=and](0,0){Demo}
\end{verbatim}
The above four ,,different`` calls of the \verb|logic| macro give the
same output, because they are equivalent.
\subsection{The Options}
\begin{description}
\item[\HLTTc{logicShowNode} (boolean):] (\emph{default:~false})
\item[\HLTTc{logicShowDot} (boolean):] (\emph{default:~false})
\item[\HLTTc{logicNodestyle} (command):] (\emph{default:~\textbackslash footnotesize})
\item[\HLTTc{logicSymbolstyle} (command):] (\emph{default:~\textbackslash large})
\item[\HLTTc{logicSymbolpos} (value):] (\emph{default:~0.5})
\item[\HLTTc{logicLabelstyle} (command):] (\emph{default:~\textbackslash small})
\item[\HLTTc{logicType} (string):] (\emph{default:~and})
\item[\HLTTc{logicChangeLR} (boolean):] (\emph{default:~false})
\item[\HLTTc{logicWidth} (length):] (\emph{default:~1.5})
\item[\HLTTc{logicHeight} (length):] (\emph{default:~2.5})
\item[\HLTTc{logicWireLength} (length):] (\emph{default:~0.5})
\item[\HLTTc{logicNInput} (number):] (\emph{default:~2})
\item[\HLTTc{logicJInput} (number):] (\emph{default:~2})
\item[\HLTTc{logicKInput} (number):] (\emph{default:~2})
\end{description}
\subsection{Basic Logical Circuits}
At least the basic objects require a unique label name, otherwise it is
not sure, that all nodes will work well. The label may contain any
alphanumerical character and most of all symbols. But it is save
using only combinations of letters and digits. For example:
\begin{verbatim}
And0
a0
a123
12
NOT123a
\end{verbatim}
\verb|A_1| is not a good choice, the underscore may causes some
problems.
\subsubsection{And}
\psset{subgriddiv=0,griddots=5,gridlabels=7pt}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-1,0)(3,3)
\psgrid
\logic{AND1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[/HLCBWz&logicChangeLR"=true]{AND2}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](4,6)
\begin{pspicture}(-0.5,0)(4,5)
\psgrid
\logic[/HLCBWz&logicShowNode"=true,%
/HLCBWz&logicWidth"=2,%
/HLCBWz&logicHeight"=4,%
/HLCBWz&logicNInput"=6,%
logicChangeLR=true](1,1){AND3}
\end{pspicture}
\end{PSideBySideExample}
\subsubsection{NotAnd}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=/HLCBWz&nand",%
logicShowNode=true]{NAND1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=nand,%
logicChangeLR=true]{NAND2}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](4,6)
\begin{pspicture}(4,5)
\psgrid
\logic[logicType=nand,%
logicShowNode=true,%
logicWidth=2,%
logicHeight=4,%
/HLCBWz&logicNInput"=6,%
logicChangeLR=true](1,1){NAND3}
\end{pspicture}
\end{PSideBySideExample}
\subsubsection{Or}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=/HLCBWz&or",%
logicShowNode=true]{OR1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=or,%
logicChangeLR=true]{OR2}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](4,6)
\begin{pspicture}(4,5)
\psgrid
\logic[logicType=or,%
logicShowNode=true,%
logicWidth=2,%
logicHeight=4,%
logicNInput=6,%
logicChangeLR=true](1,1){OR3}
\end{pspicture}
\end{PSideBySideExample}
\subsubsection{Not Or}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=/HLCBWz&nor",%
logicShowNode=true]{NOR1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=nor,%
logicChangeLR=true]{NOR2}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](4,6)
\begin{pspicture}(4,5)
\psgrid
\logic[logicType=nor,%
logicShowNode=true,%
logicWidth=2,%
logicHeight=4,%
logicNInput=6,%
logicChangeLR=true](1,1){NOR3}
\end{pspicture}
\end{PSideBySideExample}
\subsubsection{Not}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=/HLCBWz¬",%
logicShowNode=true]{NOT1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=not,%
logicChangeLR=true]{NOT2}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](4,6)
\begin{pspicture}(4,5)
\psgrid
\logic[logicType=not,%
logicShowNode=true,%
logicWidth=2,%
logicHeight=4,%
logicChangeLR=true](1,1){NOT3}
\end{pspicture}
\end{PSideBySideExample}
\subsubsection{Exclusive OR}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=/HLCBWz&exor",%
logicShowNode=true]{ExOR1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=exor,%
logicChangeLR=true]{ExOR2}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](4,6)
\begin{pspicture}(4,5)
\psgrid
\logic[logicType=exor,%
logicShowNode=true,%
logicNInput=6,%
logicWidth=2,%
logicHeight=4,%
logicChangeLR=true](1,1){ExOR3}
\end{pspicture}
\end{PSideBySideExample}
\subsubsection{Exclusive NOR}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=/HLCBWz&exnor",%
logicShowNode=true]{ExNOR1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,3)
\logic[logicType=exnor,%
logicChangeLR=true]{ExNOR2}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](4,6)
\begin{pspicture}(4,5)
\psgrid
\logic[logicType=exnor,%
logicShowNode=true,%
logicNInput=6,%
logicWidth=2,%
logicHeight=4,%
logicChangeLR=true](1,1){ExNOR3}
\end{pspicture}
\end{PSideBySideExample}
\subsection{RS Flip Flop}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,4.5)
\begin{pspicture}(-1,-1)(3,3)
\logic[logicShowNode=true,%
logicType=/HLCBWz&RS"]{RS1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,4.5)
\begin{pspicture}(-1,-1)(3,3)
\logic[logicShowNode=true,%
logicType=RS,%
logicChangeLR=true]{RS2}
\end{pspicture}
\end{PSideBySideExample}
\subsection{D Flip Flop}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,4.5)
\begin{pspicture}(-1,-1)(3,3)
\logic[logicShowNode=true,%
logicType=/HLCBWz&D"]{D1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,4.5)
\begin{pspicture}(-1,-1)(3,3)
\logic[logicShowNode=true,%
logicType=D,%
logicChangeLR=true]{D2}
\end{pspicture}
\end{PSideBySideExample}
\subsection{JK Flip Flop}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,4.5)
\begin{pspicture}(-1,-1)(3,3)
\logic[logicShowNode=true,%
logicType=/HLCBWz&JK",%
/HLCBWz&logicKInput"=2,%
/HLCBWz&logicJInput"=2]{JK1}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](3,4.5)
\begin{pspicture}(-1,-1)(3,3)
\logic[logicShowNode=true,%
logicType=JK,%
logicKInput=2, logicJInput=4,%
logicChangeLR=true]{JK2}
\end{pspicture}
\end{PSideBySideExample}
\subsection{Other Options}
\begin{PSideBySideExample}[xrightmargin=3.5cm](3,3)
\begin{pspicture}(-0.5,0)(3,2.5)
\logic[/HLCBWz&logicShowDot"=true]{A0}
\end{pspicture}
\end{PSideBySideExample}
\begin{PSideBySideExample}[xrightmargin=4.5cm](4,3)
\begin{pspicture}(-1,0)(3,2.5)
\logic[/HLCBWz&logicWireLength"=1,%
logicShowDot=true]{A1}
\end{pspicture}
\end{PSideBySideExample}
\bigskip
The unit of \verb|logicWireLength| is the same than the actual one for pstricks, set by
the \verb|unit| option.
\subsection{The Node Names}
Every logic circuit is defined with its name, which should be a unique one.
If we have the following NAND circuit, then \verb|pst-circ| defines the nodes
\begin{verbatim}
NAND11, NAND12, NAND13, NAND14, NAND1Q
\end{verbatim}
\noindent If there exists an inverted output, like for alle Flip Flops,
then the negated one gets the appendix \verb|neg| to the node name. For
example:
\begin{verbatim}
NAND1Q, NAND1Qneg
\end{verbatim}
\begin{PSideBySideExample}[xrightmargin=3cm](3,3.5)
\begin{pspicture}(-0.5,0)(2.5,3)
\logic[/HLCBWz&logicShowNode"=true,%
/HLCBWz&logicLabelstyle"=\footnotesize,%
/HLCBWz&logicType"=nand,%
/HLCBWz&logicNInput"=4]{NAND1}
\multido{\n=1+1}{4}{%
\pscircle*[linecolor=red](NAND1\n){2pt}%
}
\pscircle*[linecolor=blue](NAND1Q){2pt}
\end{pspicture}
\end{PSideBySideExample}
\vspace{0.5cm}
Now it is possible to draw a line from the output to the input
\begin{verbatim}
\ncbar[angleA=0,angleB=180]{<Node A>}{<Node B>}
\end{verbatim}
It may be easier to print a grid since the drawing phase and then comment it out if
all is finished.
\bigskip
\begin{PSideBySideExample}[xrightmargin=3.5cm](3,3.5)
\begin{pspicture}(-1,-1)(2.5,3)
\logic[/HLCBWz&logicShowNode"=true,%
logicLabelstyle=\footnotesize,%
logicType=nand,%
/HLCBWz&logicWireLength"=1,%
/HLCBWz&logicNInput"=4]{NAND1}
\pnode(-0.5,0|NAND11){tempA}
\pnode(2,0|NAND1Q){tempB}
\end{pspicture}
\ncbar[angleA=-90,angleB=0,arm=0.75,%
arrows=*-*, dotsize=0.15]{tempA}{tempB}
\end{PSideBySideExample}
\subsection{Examples}
\begin{CenterExample}
\begin{pspicture}(-1,0)(5,5)
\psgrid
\psset{logicType=nor, logicLabelstyle=\normalsize,%
logicWidth=1, logicHeight=1.5, dotsize=0.15}
\logic(1.5,0){nor1}
\logic(1.5,3){nor2}
\psline(nor2Q)(4,0|nor2Q)
\uput[0](4,0|nor2Q){$Q$}
\psline(nor1Q)(4,0|nor1Q)
\uput[0](4,0|nor1Q){$\overline{Q}$}
\psline{*-}(3.50,0|nor2Q)(3.5,2.5)(1.5,2.5)
(0.5,1.75)(0.5,0|nor12)(nor12)
\psline{*-}(3.50,0|nor1Q)(3.5,2)(1.5,2)
(0.5,2.5)(0.5,0|nor21)(nor21)
\psline(0,0|nor11)(nor11)\uput[180](0,0|nor11){R}
\psline(0,0|nor22)(nor22)\uput[180](0,0|nor22){S}
\end{pspicture}
\end{CenterExample}
\bigskip
\begin{CenterExample}
\begin{pspicture}(-4,0)(5,7)
\psgrid
\psset{logicWidth=1, logicHeight=2, dotsize=0.15}
\logic[logicWireLength=0](-2,0){A0}
\logic[logicWireLength=0](-2,5){A1}
\ncbar[angleA=-180,angleB=-180,arm=0.5]{A11}{A02}
\psline[dotsize=0.15]{-*}(-3.5,3.5)(-2.5,3.5)
\uput[180](-3.5,3.5){$T$}
\psline(-3.5,0.5)(A01)\uput[180](-3.5,0.5){$S$}
\psline(-3.5,6.5)(A12)\uput[180](-3.5,6.5){$R$}
\psset{logicType=nor, logicLabelstyle=\normalsize}
\logic(1,0.5){nor1}
\logic(1,4.5){nor2}
\psline(nor2Q)(4,0|nor2Q)
\uput[0](4,0|nor2Q){$Q$}
\psline(nor1Q)(4,0|nor1Q)
\uput[0](4,0|nor1Q){$\overline{Q}$}
\psline{*-}(3,0|nor2Q)(3,4)(1,4)(0,3)(0,0|nor12)(nor12)
\psline{*-}(3,0|nor1Q)(3,3)(1,3)(0,4)(0,0|nor21)(nor21)
\psline(A0Q)(nor11)
\psline(A1Q)(nor22)
\end{pspicture}
\end{CenterExample}
\end{document}
|