我正在尝试在 TikZ/ 中绘制类似的东西CircuiTikZ。软件包文档似乎保存得很好,内容很丰富,但只有几个完整的示例(而是分成需要您自己整理的小块)。不过,我对 TikZ 还很陌生,所以对我来说还不太明白。
答案1
\documentclass[a4paper]{article}
\usepackage[dvipsnames]{xcolor}
\usepackage[siunitx, RPvoltages]{circuitikz}
\usetikzlibrary{circuits.logic.US} % TiKZ Library for US Logic Circuits.
\usetikzlibrary{positioning, arrows.meta, calc}
\begin{document}
\def\L{-2cm}
\begin{circuitikz}[circuit logic US, every circuit symbol/.style={ultra thick},line width=1.5pt]
\foreach \i [evaluate=\i as \k using int(\i-1)] in {1,2,3,...,8} {
\node [and gate,
inputs={nnnn},
]
(and\i) at (0,\i*\L) {};
\draw (and\i)--++(1,0) node[label={right:\bfseries\texttt Y\k}] {};
}
\node [and gate,inputs={nnn},
below left=0.2cm and 4.5cm of and2 ]
(andL) {};
\foreach \i [evaluate=\i as \k using int(\i-5)] in {6,7,8} {
\node [not gate,
left=2cm of and\i.input 4 ]
(not\k) {};
}
\foreach \i [evaluate=\i as \k using int(\i+3)] in {1,2,3} {
\node [not gate,
left=4cm of not\i]
(not\k) {};
}
\node [not gate,
left=1.5cm of andL.input 2]
(not7) {};
\node [not gate,
above=1cm of not7]
(not8) {};
\node [buffer gate,
below=1cm of not7]
(buffer) {};
\foreach \i/\j in {6/A2,5/A1,4/A0,7/E2,8/E1} {
\draw (not\i)--++(-1,0) node[label={left:\bfseries\texttt \j}] {};
}
\draw (buffer)--++(-1,0) node[label={left:\bfseries\texttt E3}] {};
\draw (andL.input 1)-- ++(left:7mm) |- (not8);
\draw (andL.input 2)-- ++(left:7mm) |- (not7);
\draw (andL.input 3)-- ++(left:7mm) |- (buffer);
\foreach \i [evaluate=\i as \k using int(\i-3)]in {6,5,4} {
\draw (not\i)--(not\k);
}
\draw [red] (and1.input 4) --
++(left:3mm) coordinate(redwire)
|- (and2.input 4) to [short, -*]
++(left:3mm) |- (and3.input 4) to [short, -*]
++(left:3mm) |- (and4.input 4) to [short, -*]
++(left:3mm) |- (and5.input 4) to [short, -*]
++(left:3mm) |- (and6.input 4) to [short, -*]
++(left:3mm) |- (and7.input 4) to [short, -*]
++(left:3mm) |- (and8.input 1);
\draw [blue] (and5.input 3) --
++(left:6mm) coordinate(bluewire)
|- (and6.input 2) to [short, -*]
++(left:6mm) |- (and7.input 2) to [short, -*]
++(left:6mm) |- (and8.input 4) ;
\draw [green] (and3.input 2) --
++(left:9mm) coordinate(greenwire)
|- (and4.input 2) to [short, -*]
++(left:9mm) |- (and7.input 3) to [short, -*]
++(left:9mm) |- (and8.input 2) ;
\draw [brown] (and2.input 1) to [short, -*]
++(left:12mm) coordinate(brownwire)
|- (and4.input 1) to [short, -*]
++(left:12mm) |- (and6.input 3) to [short, -*]
++(left:12mm) |- (and8.input 3);
\draw let \p1=(brownwire),
\p2=(not1.output) in
(not1.output) to [short,-*]
++($(\x1,0)-(\x2,0)$);
\draw let \p1=(greenwire),
\p2=(not2.output) in
(not2.output) to [short,-*]
++($(\x1,0)-(\x2,0)$);
\draw let \p1=(bluewire),
\p2=(not3.output) in
(not3.output) to [short,-*]
++($(\x1,0)-(\x2,0)$);
\draw let \p1=(redwire),
\p2=(andL.output) in
(andL.output) to [short,-*]
++($(\x1,0)-(\x2,0)$);
\draw (not3.input) to [short,-*]
++(left:3mm) coordinate(not3)
(not2.input) to [short,-*]
++(left:6mm) coordinate(not2)
(not1.input) to [short,-*]
++(left:9mm) coordinate(not1)
to [short,-*]
++(left:3mm) coordinate(not11);
\draw[blue](not11) |- (and7.input 1);
\foreach \i/\k in {1/not1,2/not2,3/not3} {
\draw[red] (and1.input \i) -| (\k);
}
\foreach \i/\k in {not2/and2.input 2, not3/and2.input 3} {
\draw[brown] let \p1=(\i),
\p2=(\k) in (\k) to [short,-*]
++($(\x1,0)-(\x2,0)$);
}
\foreach \i/\k in {not1/and3.input 1, not3/and3.input 3} {
\draw[green] let \p1=(\i),
\p2=(\k) in (\k) to [short,-*]
++($(\x1,0)-(\x2,0)$);
}
\foreach \i/\k in {not3/and4.input 3} {
\draw[NavyBlue] let \p1=(\i),
\p2=(\k) in (\k) to [short,-*]
++($(\x1,0)-(\x2,0)$);
}
\foreach \i/\k in {not1/and5.input 1, not2/and5.input 2} {
\draw[blue] let \p1=(\i),
\p2=(\k) in (\k) to [short,-*]
++($(\x1,0)-(\x2,0)$);
}
\foreach \i/\k in {not2/and6.input 1} {
\draw[SeaGreen] let \p1=(\i),
\p2=(\k) in (\k) to [short,-*]
++($(\x1,0)-(\x2,0)$);
}
\end{circuitikz}
\end{document}