summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/loggates/loggates.sty
blob: 7c5299182b96dfdf85661257501db6ae6297dd89 (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Nico Verwer",
%%%     version         = "1.1",
%%%     date            = "8 April 1992",
%%%     filename        = "loggates.sty",
%%%     address         = "Dept. of Computer Science
%%%                        Rijksuniversiteit te Utrecht
%%%                        P.O. box 80.089
%%%                        3508 TB Utrecht
%%%                        the Netherlands",
%%%     telephone       = "+31 30 533921",
%%%     FAX             = "+31 30 513791",
%%%     email           = "nico@cs.ruu.nl (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "TeX, LaTeX, logical gates symbols",
%%%     supported       = "yes",
%%%     docstring       = "This file accompanies the file loggates.mf
%%%                        which contains Metafont definitions of
%%%                        symbols for drawing digital circuit diagrams.
%%%                        It defines macros to draw all possible 
%%%                        gates in all directions.
%%%                        If you use this file with plain TeX, you may
%%%                        want to call it loggates.tex. Since it uses @
%%%                        as a character, it must be a style file in
%%%                        LaTeX.
%%%                        The next version of this file will include
%%%                        an interface with the XY-pic package for
%%%                        drawing diagrams.",
%%%  }
%%% ====================================================================
%
\font\loggates=loggates
%
\def\BusWidth{{\loggates\char0}}         % '/' for bus width notation
%
% Defintions for gates. All the gates that may have more than one
% input (AND, NAND, OR, NOR, XOR, NXOR) may be followed by a single
% digit from 2 to 5, to indicate the number of inputs.
% On the OR-like gates, this will draw short input lines; for the
% AND-like gates it has no effect.
%
\def\ANDr{\gdef\@gate{\char1}\@NIN}      % AND gate facing right
\def\ANDd{\gdef\@gate{\char2}\@NIN}      %                 down
\def\ANDl{\gdef\@gate{\char3}\@NIN}      %                 left
\def\ANDu{\gdef\@gate{\char4}\@NIN}      %                 up
\def\NANDr{\gdef\@gate{\char5}\@NIN}     % NAND gate facing right
\def\NANDd{\gdef\@gate{\char6}\@NIN}     %           etcetera...
\def\NANDl{\gdef\@gate{\char7}\@NIN}
\def\NANDu{\gdef\@gate{\char8}\@NIN}
\def\ORr{\gdef\@gate{\char9}\@INr}       % OR gate 
\def\ORd{\gdef\@gate{\char10}\@INd}
\def\ORl{\gdef\@gate{\char11}\@INl}
\def\ORu{\gdef\@gate{\char12}\@INu}
\def\NORr{\gdef\@gate{\char13}\@INr}     % NOR gate
\def\NORd{\gdef\@gate{\char14}\@INd}
\def\NORl{\gdef\@gate{\char15}\@INl}
\def\NORu{\gdef\@gate{\char16}\@INu}
\def\BUFr{{\loggates\char17}}            % Buffer
\def\BUFd{{\loggates\char18}}
\def\BUFl{{\loggates\char19}}
\def\BUFu{{\loggates\char20}}
\def\INVr{{\loggates\char21}}            % Inverter
\def\INVd{{\loggates\char22}}
\def\INVl{{\loggates\char23}}
\def\INVu{{\loggates\char24}}
\def\XORr{\gdef\@gate{\char25}\@INr}     % XOR gate
\def\XORd{\gdef\@gate{\char26}\@INd}
\def\XORl{\gdef\@gate{\char27}\@INl}
\def\XORu{\gdef\@gate{\char28}\@INu}
\def\NXORr{\gdef\@gate{\char29}\@INr}    % NXOR gate, a.k.a. comparator
\def\NXORd{\gdef\@gate{\char30}\@INd}
\def\NXORl{\gdef\@gate{\char31}\@INl}
\def\NXORu{\gdef\@gate{\char32}\@INu}
%
% In order to connect input lines we define some  skips.
%
\newskip\INmskip\setbox0=\hbox{{\loggates\char35}}\INmskip\ht0%
\def\deflgskip#1#2{\setbox0=\hbox{{\loggates\char#2}}%
                   \global\newskip#1\global#1\ht0%
                   \global\advance #1 by-\INmskip}
\deflgskip\INuskip{33}
\deflgskip\INlskip{34}
\deflgskip\INumskip{36}
\deflgskip\INlmskip{37}
\deflgskip\INmuskip{38}
\deflgskip\INmlskip{39}
\INmskip 0pt
%
% The following definitions are internal to loggates, and should not
% normally be used.
%
\def\@gobble#1{} %Not strictly necessary in LaTeX...
\def\@NIN{\futurelet\next\@@NIN}
\def\@@NIN{\let\@next\@gobble%
           {\loggates\@gate}%
           \ifx\next2\else\ifx\next3\else\ifx\next4\else\ifx\next5%
           \else\let\@next\relax\fi\fi\fi\fi\@next}
\def\@INr{\futurelet\next\@@INr}
\def\@@INr{\let\@next\@gobble%
        \ifx\next2{\loggates\char33\char34\@gate}%
        \else\ifx\next3{\loggates\char33\char34\char35\@gate}%
        \else\ifx\next4{\loggates\char33\char34\char38\char39\@gate}%
        \else\ifx\next5{\loggates\char33\char34\char35\char36\char37\@gate}%
        \else{\loggates\@gate}\let\@next\relax\fi\fi\fi\fi\@next}
\def\@INd{\futurelet\next\@@INd}
\def\@@INd{\let\@next\@gobble%
        \def\@up##1{\setbox0=\hbox{\@gate}\raise\ht0\hbox{\loggates##1}}%
        \ifx\next2%
          \hbox{\loggates\@up{\char40\char41}\@gate}%
        \else\ifx\next3%
          \hbox{\loggates\@up{\char40\char41\char42}\@gate}%
        \else\ifx\next4%
          \hbox{\loggates\@up{\char40\char41\char45\char46}\@gate}%
        \else\ifx\next5%
          \hbox{\loggates\@up{\char40\char41\char42\char43\char44}\@gate}%
        \else%
          \hbox{\loggates\@gate}\let\@next\relax\fi\fi\fi\fi\@next}
\def\@INl{\futurelet\next\@@INl}
\def\@@INl{\let\@next\@gobble%
        \def\@up##1{\setbox0=\hbox{\@gate}\raise\ht0\hbox{\loggates##1}}%
        \ifx\next2%
          \hbox{\loggates\@gate\@up{\char47\char48}}%
        \else\ifx\next3%
          \hbox{\loggates\@gate\@up{\char47\char48\char49}}%
        \else\ifx\next4%
          \hbox{\loggates\@gate\@up{\char47\char48\char52\char53}}%
        \else\ifx\next5%
          \hbox{\loggates\@gate\@up{\char47\char48\char49\char50\char51}}%
        \else%
          \hbox{\loggates\@gate}\let\@next\relax\fi\fi\fi\fi\@next}
\def\@INu{\futurelet\next\@@INu}
\def\@@INu{\let\@next\@gobble%
        \ifx\next2{\loggates\@gate\char54\char55}%
        \else\ifx\next3{\loggates\@gate\char54\char55\char56}%
        \else\ifx\next4{\loggates\@gate\char54\char55\char59\char60}%
        \else\ifx\next5{\loggates\@gate\char54\char55\char56\char57\char58}%
        \else{\loggates\@gate}\let\@next\relax\fi\fi\fi\fi\@next}