summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/loggates/lgdoc.tex
blob: 14aff48e98cba15e106bfd27d2a9e5c002e48d90 (plain)
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
% Documentation for the loggates font.
% By Nico Verwer (nico@cs.ruu.nl), April 8, 1992
% After you have created the font (e.g. loggates.300pk and
% loggates.tfm), make sure that TeX and your dvi-driver can find
% these files.

\documentstyle[loggates]{article}

% This file uses XY-pic, but you may do without.
% If you don't have XY-pic, delete the following line:
\input{xypic}

\ifx\xypicloaded\undefined% Test if XY-pic is used.
 \def\XY{\leavevmode\hbox{X\kern-.3em\lower.4ex\hbox{Y\kern-.15em}}}%
\else\objectmargin{0pt}\fi
\newcommand{\XYpicOnly}[1]{\ifx\xypicloaded\undefined%
                            \begin{quote}
                               \em Something which uses \XY -pic
                                   should be here.
                            \end{quote}%
                           \else #1 \fi}

\setlength{\fboxsep}{0pt}

\begin{document}

The \verb"loggates" font contains symbols for drawing digital logic
circuits.
It includes AND, OR, NAND, NOR, XOR, and NXOR (comparator) gates, 
inverters and buffers, and special characters to make input lines.
Eventually, I'd like to use this font in a package for drawing circuit
diagrams, based on the \XY -pic package by Kristoffer~H.~Rose.
\footnote{\XY-pic can be obtained by FTP from \verb"diku.dk".}
The package as it stands now is nice, but not really impressive, but
that will hopefully improve.

The font for drawing digital logic circuits was originally conceived by Rick
Simpson, and published in UKTeX 1988, issue 30.
\footnote{Milstd can be obtained by FTP from \verb"kth.se".}
It was called milstd then (the font follows MIL-STD 806).
The milstd font encouraged me to try to extend it; some gates (XOR,
NXOR) were missing, and there were problems with connecting input lines
(cf.\ the input line extenders below).
I also made some changes to the metafont code, which make it easier to
modify (imho), and made better bounding boxes.
The result is \verb"loggates.mf".

The file \verb"loggates.sty" is a \LaTeX\ style file which facilitates
using the font.
It defines commands for all of the gates, in all four directions (right,
down, left, up).
These names of these commands consist of the name of the gate,
followed by a letter for the direction
(\verb"r", \verb"d", \verb"l", \verb"u").
For instance, \verb"\ANDr" and \verb"\XORu" give:
\begin{quote}
\ANDr \ \ \ \XORu
\end{quote}

The gates are set in a very tight bounding box:
\begin{quote}
\fbox{\INVl} \ \ \ \fbox{\NXORd}
\end{quote}
The reference point is in the lower left corner.
This facilitates the use of \XY-pic, which makes a line disappear when
it enters the bounding box.
Note that \XY-pic centers boxes vertically, so in a diagram the
reference point seems to be in the middle-left:
\XYpicOnly{
$$\diagram
{} \rline|>{\bullet} & \text{\fbox{\NANDr}} \rline & 
\enddiagram$$
}

In circuit diagrams, gates have inputs. Inputs for AND-like gates are
easy: just draw a line to the gate symbol.
The input side of an OR-like gate is not straight, so the input line
should extend into the bounding box.
The \verb"loggates" font has characters for these `input line
extenders', which go from the bounding box just up to the front of the
gate.
There are input line extenders for gates with 2, 3, 4, and 5 inputs.
These extenders are added by appendding a single digit (2, 3, 4, or 5) to
the gate command.
Thus, \verb"\ORr3", \verb"\NXORd4", and \verb"\ANDl5" give
\begin{quote}
\ORr3 \ \ \ \NXORd4 \ \ \ \ANDl5
\end{quote}
Of course, AND gates don't need these extenders, but I added the
optional digit for compatibility.

The font can already be used with \XY-pic, but I'd like to do more
things automatically, like the placement of connections.
Here is a (nonsense) example of how to use \verb"loggates" with
\XY-pic:
\XYpicOnly{
$$\diagram
\rrline<\INuskip> & \rline<\INlskip> & \text{\NANDr2} \rrline & \bullet
    \xline '[1,0]+<0pt,1em> '[1,-2]+<0pt,-1em> 
           '[2,-2]+<0pt,\INmskip> &
\\
 & & & &
\\
\rrline<\INlskip> \rrline<\INuskip> & \rline<\INmskip> &
    \text{\NORr3} \rrline & \bullet 
    \xline '[-1,0]+<0pt,-1em> '[-1,-2]+<0pt,1em> 
           '[-2,-2]+<0pt,\INlskip> &
\enddiagram$$
}
If the lines in this diagram don't connect perfectly, this is probably
caused by an imperfection in your dvi-driver.

I make no claims whatsoever about the usefulness of loggates.
Consider this as an alpha-test version; I hope to release improved
versions `real soon'.
If you have ideas of how to use \XY-pic for drawing diagrams,
or suggestions for features and improvements,
please mail to \verb"nico@cs.ruu.nl".
\end{document}