%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % 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;