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
|
% Block diagrams in TeXdraw
% $Id: blockdiagram.tex,v 1.12 2019/03/28 texdraw-V2R0a $
% Copyright (C) 1993-2019 Peter Kabal
% This work is licensed under the Creative Commons Attribution (CC-BY)
% License, any version. To view the licenses, visit
% creativecommons.org/licenses/by or send a letter to
% Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
% Peter Kabal
% Department of Electrical Engineering
% McGill University
% 3480 University
% Montreal, Quebec
% Canada H3A 2A7
% peter dot kabal at mcgill dot ca
% ===============================================================
\input txdtools
% size of sum and product circles
\def\cradius{0.08}
% \bdot
% big dot
\def\bdot{\fcir f:0 r:0.02 }
% centred, stacked items
\def\hcp#1{$\vcenter{\halign{\hss ##\hss\cr #1\crcr}}$}
% left justified, stacked items
\def\hlp#1{$\vcenter{\halign{##\hss\cr #1\crcr}}$}
% right justified, stacked items
\def\hrp#1{$\vcenter{\halign{\hss ##\cr #1\crcr}}$}
% signal labels - Top text, Bottom text, Left text, Right text,
% and Center text
\def\Ttext#1{\bsegment
\textref h:C v:B \htext (0 +0.06){\hcp{#1}}
\esegment}
\def\Btext#1{\bsegment
\textref h:C v:T \htext (0 -0.06){\hcp{#1}}
\esegment}
\def\Ltext#1{\bsegment
\textref h:R v:C \htext (-0.06 0){\hrp{#1}}
\esegment}
\def\Rtext#1{\bsegment
\textref h:L v:C \htext (+0.06 0){\hlp{#1}}
\esegment}
\def\Ctext#1{\bsegment
\textref h:C v:C \htext{\hcp{#1}}
\esegment}
% ruled box (horizontal) with centered label,
% position set to the end of the box
% \Fbox W H text
\def\Fbox#1#2#3{\bsegment
\bsegment
\setsegscale 0.5
\textref h:C v:C \htext (#1 0){\hcp{#3}}
\esegment
\setsegscale 0.5 \lvec (0 #2)
\setsegscale 1
\rlvec (#1 0) \rlvec (0 -#2) \rlvec (-#1 0) \lvec (0 0)
\savepos (#1 0)(*@x *@y)
\esegment
\move (*@x *@y)}
% ruled box (vertical) with centered label, position set to the end of the box
% \Gbox W H text
\def\Gbox#1#2#3{\bsegment
\bsegment
\setsegscale 0.5
\textref h:C v:C \htext (0 #2){\hcp{#3}}
\esegment
\setsegscale 0.5 \lvec (#1 0)
\setsegscale 1
\rlvec (0 #2) \rlvec (-#1 0) \rlvec (0 -#2) \lvec (0 0)
\savepos (0 #2)(*@x *@y)
\esegment
\move (*@x *@y)}
% ruled triangle (horizontal) with centered label,
% position set to the end of the box
% \Ftri W H text
\def\Ftri#1#2#3{\bsegment
\bsegment
\setsegscale 0.3333
\textref h:C v:C \htext (#1 0){\hcp{#3}}
\esegment
\bsegment
\savepos (#1 0)(*@x *@y)
\esegment
\setsegscale 0.5 \lvec (0 #2)
\setsegscale 1 \lvec (#1 0)
\setsegscale 0.5 \lvec (0 -#2) \lvec (0 0)
\esegment
\move (*@x *@y)}
% \pluss
% plus sign
\def\pluss {\bsegment
\setsegscale {\cradius}
\move (-0.5 0) \lvec (+0.5 0)
\move (0 -0.5) \lvec (0 +0.5)
\esegment}
% \minuss
% minus sign
\def\minuss {\bsegment
\setsegscale {\cradius}
\move (-0.5 0) \lvec (+0.5 0)
\esegment}
% \mults
% multiplication sign
\def\mults {\bsegment
\setsegscale {\cradius}
\realmult \cradius {0.354} \tmpa
\move (-0.354 -0.354) \lvec (+0.354 +0.354)
\move (-0.354 +0.354) \lvec (+0.354 -0.354)
\esegment}
% \pcir
% circle of given radius with a plus sign
\def\pcir {\lcir r:{\cradius} \pluss}
% \mcir
% circle of given radius with a multiplication sign
\def\mcir {\lcir r:{\cradius} \mults}
% \putn, \putnne, etc
% places text at an offset from the center of a circle, with
% the position of the text specified in compass directions
\def\puttext (#1 #2)#3{\bsegment
\setsegscale {\cradius}
\textref h:C v:C \htext (#1 #2){#3}
\esegment}
\def\putn #1{\puttext ( 0 +2 ){#1}}
\def\putnne #1{\puttext (+1.2 +1.7){#1}}
\def\putene #1{\puttext (+1.7 +1.2){#1}}
\def\putese #1{\puttext (+1.7 -1.2){#1}}
\def\putsse #1{\puttext (+1.2 -1.7){#1}}
\def\puts #1{\puttext ( 0 -2 ){#1}}
\def\putssw #1{\puttext (-1.2 -1.7){#1}}
\def\putwsw #1{\puttext (-1.7 -1.2){#1}}
\def\putwnw #1{\puttext (-1.7 +1.2){#1}}
\def\putnnw #1{\puttext (-1.2 +1.7){#1}}
% \avectoc
% arrow vector to a circle
\def\avectoc (#1 #2){\currentpos \xa\ya
\cossin ({\xa} \ya)(#1 #2)\cosa\sina
\savepos (#1 #2)(*@x *@y)%
\bsegment
\move (*@x *@y)%
\setsegscale {\cradius}
\rmove ({-\cosa} -\sina)%
\savecurrpos (*@x *@y)%
\esegment
\avec (*@x *@y)%
\move (#1 #2)}
% \avecfrc
% arrow vector from a circle
\def\avecfrc (#1 #2){\currentpos \xa\ya
\cossin ({\xa} \ya)(#1 #2)\cosa\sina
\bsegment
\setsegscale {\cradius}
\move ({\cosa} \sina)%
\savecurrpos (*@x *@y)%
\esegment
\move (*@x *@y)%
\avec (#1 #2)}
% \avecfrctoc
% arrow vector from a circle to a circle
\def\avecfrctoc (#1 #2){\currentpos \xa\ya
\cossin ({\xa} \ya)(#1 #2)\cosa\sina
\bsegment
\setsegscale {\cradius}
\move ({\cosa} \sina)%
\savecurrpos (*@x *@y)%
\esegment
\move (*@x *@y)%
\avectoc (#1 #2)}
% \lvecfrc
% line vector from a circle
\def\lvecfrc (#1 #2){\currentpos \xa\ya
\cossin ({\xa} \ya)(#1 #2)\cosa\sina
\bsegment
\setsegscale {\cradius}
\move ({\cosa} {\sina})%
\savecurrpos (*@x *@y)%
\esegment
\move (*@x *@y)%
\lvec (#1 #2)}
|