我正在尝试使用 circuitikz 包将输入连接到逻辑图中的一个门。
我已经使用各种来源(包括 SE)获得了这一结果,但我想将 B 输入上的第一个点连接到 and2 门输入 2. ANd...然后添加通过 C 输入的交叉点。
我怀疑我遗漏了一些非常简单的东西......
\begin{circuitikz}
\ctikzset{
logic ports=ieee,
logic ports/scale=1,
logic ports/fill=white
}
\draw
(0,2) node (and1) [xshift=1cm,and port] {and1}
(and1.out) node [anchor=south] {\it A.B}
(and1.in 1) node (A1) [anchor=east,xshift=-1cm] {A}
(and1.in 2) node (B1) [anchor=east,xshift=-1cm] {B}
(0,0) node (or1) [xshift=1cm,or port] {or1}
(or1.out) node [anchor=south] {\it B+C}
(or1.in 2) node (C1) [anchor=east, xshift=-1cm] {C}
(0,-2) node (and2) [xshift=1cm,and port] {and2}
(and2.out) node [anchor=south] {\it B.C}
(4,-1) node (and3) [and port] {and3}
(and3.out) node [anchor=north,xshift=0.5cm] {\it BC(B+C)}
(7,1) node (or2) [or port] {or2}
(or2.out) node (Q) [anchor=west] {Q = AB+BC(B+C)}
(A1) -- (and1.in 1)
(B1) -- (and1.in 2)
(C1) -- (or1.in 2)
(B1) -| (or1.in 1)
(C1) -| (and2.in 1)
(B1) -- (and2.in 2)
(and1.out) -| (or2.in 1)
(or1.out) -| (and3.in 1)
(and2.out) -| (and3.in 2)
(and3.out) -| (or2.in 2)
;
\node [xshift=1.25cm] at (B1) {$\bullet$};
\node [xshift=1.25cm] at (C1) {$\bullet$};
\node [xshift=0.7cm] at (B1) {$\bullet$};
\end{circuitikz}
答案1
我的第一个建议是避免交叉 --- 绘制电路时的标准规定,如果没有点,交叉线就不会连接,因此教授和学习标准是很好的。在这种情况下,这很容易:
- 不要直接从
(B1)
到 画(and2.in 2)
,那是对角线; - 使用
circ
节点进行连接(比项目符号更好),并命名有趣的节点; - 使用正交坐标。参见:
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\begin{tikzpicture}[]
\ctikzset{
logic ports=ieee,
logic ports/scale=1,
logic ports/fill=white
}
\draw
(0,2) node (and1) [xshift=1cm,and port] {and1}
(and1.out) node [anchor=south] {\it A.B}
(and1.in 1) node (A1) [anchor=east,xshift=-1cm] {A}
(and1.in 2) node (B1) [anchor=east,xshift=-1cm] {B}
(0,0) node (or1) [xshift=1cm,or port] {or1}
(or1.out) node [anchor=south] {\it B+C}
(or1.in 2) node (C1) [anchor=east, xshift=-1cm] {C}
(0,-2) node (and2) [xshift=1cm,and port] {and2}
(and2.out) node [anchor=south] {\it B.C}
(4,-1) node (and3) [and port] {and3}
(and3.out) node [anchor=north,xshift=0.5cm] {\it BC(B+C)}
(7,1) node (or2) [or port] {or2}
(or2.out) node (Q) [anchor=west] {Q = AB+BC(B+C)}
(A1) -- (and1.in 1)
(B1) -- (and1.in 2)
(C1) -- (or1.in 2)
(B1) -| (or1.in 1)
(C1) -| (and2.in 1)
% (B1) -- (and2.in 2) <<<- removed
(and1.out) -| (or2.in 1)
(or1.out) -| (and3.in 1)
(and2.out) -| (and3.in 2)
(and3.out) -| (or2.in 2)
;
\node [circ, xshift=1.25cm] at (B1) {};
\node [circ, xshift=1.25cm] at (C1) {};
\node [circ, xshift=0.7cm](B1-dot1) at (B1) {};
\draw (B1-dot1) |- (and2.in 2);
\end{tikzpicture}
\end{document}
如果你坚持要穿越,你可以这样做来代替最后的绘制:
% find the crossing between wire C and the vertical of B1-dot
\coordinate (c cross) at (B1-dot1 |- C1);
% plant a jump crossing node there (vertical)
\node [jump crossing, rotate=90](X) at (c cross) {};
% draw the connections, be careful with the rotated anchors
\draw (B1-dot1) -- (X.east) (X.west) |- (and2.in 2);
获得:
C1
请注意,这不是最优的,您还应该从到移除电线or1.in 2
,并用交叉点周围的两个线段替换它X
,但我会把这个交给您;-)
答案2
我用圆圈替换了您的项目符号,并将它们移到了使用它们的线条中。您也可以使用圆圈添加连接,to[short,*-*]
但只能在直线上添加。
\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\ctikzset{
logic ports=ieee,
logic ports/scale=1,
logic ports/fill=white
}
\draw
(0,2) node (and1) [xshift=1cm,and port] {and1}
(and1.out) node [anchor=south] {\it A.B}
(and1.in 1) node (A1) [anchor=east,xshift=-1cm] {A}
(and1.in 2) node (B1) [anchor=east,xshift=-1cm] {B}
(0,0) node (or1) [xshift=1cm,or port] {or1}
(or1.out) node [anchor=south] {\it B+C}
(or1.in 2) node (C1) [anchor=east, xshift=-1cm] {C}
(0,-2) node (and2) [xshift=1cm,and port] {and2}
(and2.out) node [anchor=south] {\it B.C}
(4,-1) node (and3) [and port] {and3}
(and3.out) node [anchor=north,xshift=0.5cm] {\it BC(B+C)}
(7,1) node (or2) [or port] {or2}
(or2.out) node (Q) [anchor=west] {Q = AB+BC(B+C)}
(A1) -- (and1.in 1)
(B1) -- (and1.in 2)
(C1) -- (or1.in 2)
(B1) -| (or1.in 1) node[circ, midway] {}
(C1) -| (and2.in 1) node[circ, midway] {}
(B1) ++(0.7cm,0) node[circ] {} |- (and2.in 2)
(and1.out) -| (or2.in 1)
(or1.out) -| (and3.in 1)
(and2.out) -| (and3.in 2)
(and3.out) -| (or2.in 2)
;
\end{circuitikz}
\end{document}