summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/loggates/loggates.mf
blob: 73d5083de85b432d3d482453b423839fbc5f65ff (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
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%    Loggates.mf --- special characters for drawing digital
%    electronic circuits with logical gates.
%
%    Version history:
%    -  "milstd" font by Rick Simpson, font for logical gates
%       as in MIL-STD 806.
%       (published in UKTeX 1988, issue 30 (23 Sept. 1988).)
%    -  Extended version, 30 March 1992, by Nico Verwer,
%       now called loggates.mf. Added XOR, NXOR and OR-input
%       lines, supported in loggates.sty.
%
%    To create the "loggates" font, use the command:
%       makefont loggates
%    or:  
%       mf '\mode=localfont; mag=magstepX ; input' loggates.mf
%    for X = 0, 0.5, 1, 2, 3, 4, 5.
%
%    To use the characters in a PLAIN TeX document:
%       \font\loggates=loggates         % define the font
%            . . .
%       {\loggates\char0}               % typeset the character
%
%    To use the characters in a LaTeX document:
%        \newfont{\loggates}{loggates}   % define the font
%             . . .
%        {\loggates\char0}               % typeset the character
%
%    The file loggates.sty contains definitions that make this 
%    font easy to use.
%

mode_setup;
font_identifier "LOGGATES";
font_size 10pt#;
gatew = 1.2pt;
linew = 0.4pt;

picture pic;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       Slanting line at 45-degree angle for marking
%       busses in logic diagrams.

slwd#:=7pt#;
define_pixels(slwd);

beginchar(0,slwd#,slwd#,0);  "Slanted line for buss widths";

x1 = 0;
y1 = 0;

x2 = slwd;
y2 = slwd;

pickup pencircle scaled gatew;
draw z1--z2;

labels (1,2);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       AND gate, facing to the right
%

gateunit# := 6pt#;

gatea# := 2   * gateunit#;
gateb# := 4   * gateunit#;
gatec# := 2.5 * gateunit#;
gated# := 2   * gateunit#;

define_pixels(gatea,gateb,gatec,gated);

w_and# := gatec#+gated#;
h_and# := gateb#;
define_pixels(w_and,h_and);

beginchar(1,w_and#,h_and#,0);  "AND gate, right";

x1 = x2 = 0;
x3 = x5 = gatec;
x4 = gatec + gated;

y1 = y5 = 0;
y2 = y3 = gateb;
y4 = gatea;

pickup pencircle scaled gatew;
draw z1--z2--z3{right}..z4..{left}z5--z1;

pic := currentpicture;

labels (range 1 thru 5);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       AND gate, facing down
%

beginchar(2,h_and#,w_and#,0);  "AND gate, down";

currentpicture := pic rotated 270 shifted (0,w_and);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       AND gate, facing to the left
%

beginchar(3,w_and#,h_and#,0);  "AND gate, right";

currentpicture := pic rotated 180 shifted(w_and,h_and);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       AND gate, facing up
%

beginchar(4,h_and#,w_and#,0);  "AND gate, up";

currentpicture := pic rotated 90 shifted(h_and,0);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NAND gate, facing to the right
%

gatee# := gateunit#;

define_pixels(gatee);

w_nand# := gatec#+gated#+gatee#;
h_nand# := gateb#;
define_pixels(w_nand,h_nand);

beginchar(5,w_nand#,h_nand#,0);  "NAND gate, right";

x1 = x2 = 0;
x3 = x5 = gatec;
x4 = gatec + gated;
x6 = x4 + gatee/2;

y1 = y5 = 0;
y2 = y3 = gateb;
y4 = gatea;
y6 = y4;

pickup pencircle scaled gatew;
draw z1--z2--z3{right}..z4..{left}z5--z1;
draw fullcircle scaled gatee shifted(z6);

pic := currentpicture;

labels (range 1 thru 6);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NAND gate, facing down
%

beginchar(6,h_nand#,w_nand#,0);  "NAND gate, down";

currentpicture := pic rotated 270 shifted (0,w_nand);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NAND gate, facing to the left
%

beginchar(7,w_nand#,h_nand#,0);  "NAND gate, left";

currentpicture := pic rotated 180 shifted(w_nand,h_nand);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NAND gate, facing up
%

beginchar(8,h_nand#,w_nand#,0);  "NAND gate, up";

currentpicture := pic rotated 90 shifted(h_nand,0);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       OR gate, facing to the right
%

gatef# := .75 * gateunit#;
gateg# := 1.5 * gateunit#;
gateh# := 3   * gateunit#;

define_pixels(gatef,gateg,gateh);

w_or# := gateg#+gateh#;
h_or# := gateb#;
define_pixels(w_or,h_or);

beginchar(9,w_or#,h_or#,0);  "OR gate, right";

x1 = x2 = 0;
x3 = x5 = gateg;
x4 = gateg + gateh;
x6 = gatef;

y1 = y5 = 0;
y2 = y3 = gateb;
y4 = y6 = gatea;

pickup pencircle scaled gatew;
draw z1..z6..z2;
draw z2--z3;
draw z3{right}..{(1,-2)}z4;
draw z4{-1,-2}..z5{left};
draw z5--z1;

pic := currentpicture;

labels (range 1 thru 6);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       OR gate, facing down
%

beginchar(10,h_or#,w_or#,0);  "OR gate, down";

currentpicture := pic rotated 270 shifted (0,w_or);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       OR gate, facing to the left
%

beginchar(11,w_or#,h_or#,0);  "OR gate, left";

currentpicture := pic rotated 180 shifted(w_or,h_or);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       OR gate, facing up
%

beginchar(12,h_or#,w_or#,0);  "OR gate, up";

currentpicture := pic rotated 90 shifted(h_or,0);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NOR gate, facing to the right
%

w_nor# := gateg#+gateh#+gatee#;
h_nor# := gateb#;
define_pixels(w_nor,h_nor);

beginchar(13,w_nor#,h_nor#,0);  "NOR gate, right";

x1 = x2 = 0;
x3 = x5 = gateg;
x4 = gateg + gateh;
x6 = gatef;
x7 = x4 + gatee/2;

y1 = y5 = 0;
y2 = y3 = gateb;
y4 = y6 = gatea;
y7 = y4;

pickup pencircle scaled gatew;
draw z1..z6..z2;
draw z2--z3;
draw z3{right}..{(1,-2)}z4;
draw z4{-1,-2}..z5{left};
draw z5--z1;
draw fullcircle scaled gatee shifted (z7);

pic := currentpicture;

labels (range 1 thru 7);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NOR gate, facing down
%

beginchar(14,h_nor#,w_nor#,0);  "NOR gate, down";

currentpicture := pic rotated 270 shifted (0,w_nor);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NOR gate, facing to the left
%

beginchar(15,w_nor#,h_nor#,0);  "NOR gate, left";

currentpicture := pic rotated 180 shifted(w_nor,h_nor);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NOR gate, facing up
%

beginchar(16,h_nor#,w_nor#,0);  "NOR gate, up";

currentpicture := pic rotated 90 shifted(h_nor,0);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       Buffer, facing to the right
%

gatei# := 3    * gateunit#;
gatej# := .866 * gatei#;
gatek# := 1.5  * gateunit#;

define_pixels(gatei,gatej,gatek);

w_buf# := gatej#;
h_buf# := gatei#;
define_pixels(w_buf,h_buf);

beginchar(17,w_buf#,h_buf#,0);  "Buffer, right";

x1 = x2 = 0;
x3 = gatej;

y1 = 0;
y2 = gatei;
y3 = gatek;

pickup pencircle scaled gatew;
draw z1--z2--z3--z1;

pic := currentpicture;

labels (range 1 thru 3);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       Buffer, facing down
%

beginchar(18,h_buf#,w_buf#,0);  "Buffer, down";

currentpicture := pic rotated 270 shifted (0,w_buf);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       Buffer, facing to the left
%

beginchar(19,w_buf#,h_buf#,0);  "Buffer, left";

currentpicture := pic rotated 180 shifted(w_buf,h_buf);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       Buffer, facing up
%

beginchar(20,h_buf#,w_buf#,0);  "Buffer, up";

currentpicture := pic rotated 90 shifted(h_buf,0);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       Inverter, facing to the right
%

w_inv# := gatej#+gatee#;
h_inv# := gatei#;
define_pixels(w_inv,h_inv);

beginchar(21,w_inv#,h_inv#,0);  "Inverter, right";

x1 = x2 = 0;
x3 = gatej;
x4 = x3 + gatee/2;

y1 = 0;
y2 = gatei;
y3 = y4 = gatek;


pickup pencircle scaled gatew;
draw z1--z2--z3--z1;
draw fullcircle scaled gatee shifted (z4);

pic := currentpicture;

labels (range 1 thru 4);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       Inverter, facing down
%

beginchar(22,h_inv#,w_inv#,0);  "Inverter, down";

currentpicture := pic rotated 270 shifted (0,w_inv);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       Inverter, facing to the left
%

beginchar(23,w_inv#,h_inv#,0);  "Inverter, left";

currentpicture := pic rotated 180 shifted(w_inv,h_inv);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       Inverter, facing up
%

beginchar(24,h_inv#,w_inv#,0);  "Inverter, up";

currentpicture := pic rotated 90 shifted(h_inv,0);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       XOR gate, facing to the right
%

w_xor# := gatef#+gateg#+gateh#;
h_xor# := gateb#;
define_pixels(w_xor,h_xor);

beginchar(25,w_xor#,h_xor#,0);  "XOR gate, right";

x1 = x2 = 0 + gatef;
x3 = x5 = gateg + gatef;
x4 = gateg + gateh + gatef;
x6 = gatef + gatef;
x7 = x8 = 0;
x9 = 0 + gatef;

y1 = y5 = 0;
y2 = y3 = gateb;
y4 = y6 = gatea;
y7 = 0;
y8 = gateb;
y9 = gatea;

pickup pencircle scaled gatew;
draw z1..z6..z2;
draw z2--z3;
draw z3{right}..{(1,-2)}z4;
draw z4{-1,-2}..z5{left};
draw z5--z1;
draw z8..z9..z7;

pic := currentpicture;

labels (range 1 thru 9);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       XOR gate, facing down
%

beginchar(26,h_xor#,w_xor#,0);  "XOR gate, down";

currentpicture := pic rotated 270 shifted (0,w_xor);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       XOR gate, facing to the left
%

beginchar(27,w_xor#,h_xor#,0);  "XOR gate, left";

currentpicture := pic rotated 180 shifted(w_xor,h_xor);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       XOR gate, facing up
%

beginchar(28,h_xor#,w_xor#,0);  "XOR gate, up";

currentpicture := pic rotated 90 shifted(h_xor,0);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NXOR gate (a.k.a. comparator), facing to the right
%

w_nxor# := gatef#+gateg#+gateh#+gatee#;
h_nxor# := gateb#;
define_pixels(w_nxor,h_nxor);

beginchar(29,w_nxor#,h_nxor#,0);  "NXOR gate, right";

x1 = x2 = 0 + gatef;
x3 = x5 = gateg + gatef;
x4 = gateg + gateh + gatef;
x6 = gatef + gatef;
x7 = x8 = 0;
x9 = 0 + gatef;
x10 = x4 + gatee/2;

y1 = y5 = 0;
y2 = y3 = gateb;
y4 = y6 = gatea;
y7 = 0;
y8 = gateb;
y9 = gatea;
y10 = y4;

pickup pencircle scaled gatew;
draw z1..z6..z2;
draw z2--z3;
draw z3{right}..{(1,-2)}z4;
draw z4{-1,-2}..z5{left};
draw z5--z1;
draw z8..z9..z7;
draw fullcircle scaled gatee shifted (z10);

pic := currentpicture;

labels (range 1 thru 10);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NXOR gate, facing down
%

beginchar(30,h_nxor#,w_nxor#,0);  "NXOR gate, down";

currentpicture := pic rotated 270 shifted (0,w_nxor);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NXOR gate, facing to the left
%

beginchar(31,w_nxor#,h_nxor#,0);  "NXOR gate, left";

currentpicture := pic rotated 180 shifted(w_nxor,h_nxor);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       NXOR gate, facing up
%

beginchar(32,h_nxor#,w_nxor#,0);  "NXOR gate, up";

currentpicture := pic rotated 90 shifted(h_nxor,0);

endchar;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%      lines to connect inputs of OR-like gates
%      N.B.: right/down facing inputs come before the gate,
%      left/up facing inputs after the gate!
%      The left/down lines have to be shifted by TeX, since 
%      this shift cannot be determined in advance for down-
%      facing lines.
%      Only the right-facing lines have a height, which should
%      be used to determine the exact place where connections
%      should enter the gate.
%

linea# := 0.2 * gateb#;
lineb# := 0.25 * (gateb# - (2 * linea#));
linec# := 0.3333 * (gateb# - (2 * linea#));

lineea# := 0.5 * gatef#;
lineeb# := 0.75 * gatef#;
lineec# := 0.87 * gatef#;
lineed# := 0.95 * gatef#;

define_pixels(linea,lineb,linec,lineea,lineeb,lineec,lineed);

beginchar(33,0,gateb#-linea#,0); "upper input facing right";
x1 = 0;
x2 = lineea;
y1 = y2 = gateb - linea;
pickup pencircle scaled linew;
draw z1--z2;
pic := currentpicture;
labels (range 1 thru 2);
endchar;
beginchar(40,0,0,0); "upper input facing down";
currentpicture := pic rotated 270;
endchar;
beginchar(47,0,0,0); "upper input facing left";
currentpicture := pic rotated 180;
endchar;
beginchar(54,0,0,0); "upper input facing up";
currentpicture := pic rotated 90;
endchar;

beginchar(34,0,linea#,0); "lower input facing right";
x1 = 0;
x2 = lineea;
y1 = y2 = linea;
pickup pencircle scaled linew;
draw z1--z2;
pic := currentpicture;
labels (range 1 thru 2);
endchar;
beginchar(41,0,0,0); "lower input facing down";
currentpicture := pic rotated 270;
endchar;
beginchar(48,0,0,0); "lower input facing left";
currentpicture := pic rotated 180;
endchar;
beginchar(55,0,0,0); "lower input facing up";
currentpicture := pic rotated 90;
endchar;

beginchar(35,0,linea#+(2*lineb#),0); "middle input facing right";
x1 = 0;
x2 = lineed;
y1 = y2 = linea + (2 * lineb);
pickup pencircle scaled linew;
draw z1--z2;
pic := currentpicture;
labels (range 1 thru 2);
endchar;
beginchar(42,0,0,0); "middle input facing down";
currentpicture := pic rotated 270;
endchar;
beginchar(49,0,0,0); "middle input facing left";
currentpicture := pic rotated 180;
endchar;
beginchar(56,0,0,0); "middle input facing up";
currentpicture := pic rotated 90;
endchar;

beginchar(36,0,gateb#-linea#-lineb#,0); "upper-middle input facing right";
x1 = 0;
x2 = lineeb;
y1 = y2 = gateb - linea - lineb;
pickup pencircle scaled linew;
draw z1--z2;
pic := currentpicture;
labels (range 1 thru 2);
endchar;
beginchar(43,0,0,0); "upper-middle input facing down";
currentpicture := pic rotated 270;
endchar;
beginchar(50,0,0,0); "upper-middle input facing left";
currentpicture := pic rotated 180;
endchar;
beginchar(57,0,0,0); "upper-middle input facing up";
currentpicture := pic rotated 90;
endchar;

beginchar(37,0,linea#+lineb#,0); "lower-middle input facing right";
x1 = 0;
x2 = lineeb;
y1 = y2 = linea + lineb;
pickup pencircle scaled linew;
draw z1--z2;
pic := currentpicture;
labels (range 1 thru 2);
endchar;
beginchar(44,0,0,0); "lower-middle input facing down";
currentpicture := pic rotated 270;
endchar;
beginchar(51,0,0,0); "lower-middle input facing left";
currentpicture := pic rotated 180;
endchar;
beginchar(58,0,0,0); "lower-middle input facing up";
currentpicture := pic rotated 90;
endchar;

beginchar(38,0,gateb#-linea#-linec#,0); "next-to-upper input facing right";
x1 = 0;
x2 = lineec;
y1 = y2 = gateb - linea - linec;
pickup pencircle scaled linew;
draw z1--z2;
pic := currentpicture;
labels (range 1 thru 2);
endchar;
beginchar(45,0,0,0); "next-to-upper input facing down";
currentpicture := pic rotated 270;
endchar;
beginchar(52,0,0,0); "next-to-upper input facing left";
currentpicture := pic rotated 180;
endchar;
beginchar(59,0,0,0); "next-to-upper input facing up";
currentpicture := pic rotated 90;
endchar;

beginchar(39,0,linea#+linec#,0); "next-to-lower input facing right";
x1 = 0;
x2 = lineec;
y1 = y2 = linea + linec;
pickup pencircle scaled linew;
draw z1--z2;
pic := currentpicture;
labels (range 1 thru 2);
endchar;
beginchar(46,0,0,0); "next-to-lower input facing down";
currentpicture := pic rotated 270;
endchar;
beginchar(53,0,0,0); "next-to-lower input facing left";
currentpicture := pic rotated 180;
endchar;
beginchar(60,0,0,0); "next-to-lower input facing up";
currentpicture := pic rotated 90;
endchar;

end;