我在芯片中放置了一些门。参见我最后问题。
栅极 N4 与引脚 12 对齐,方式如下:
\path (C.center -| C.bpin 12) node[and port, rotate=90](N4){N4};
N4 垂直居中C.center
但我也需要门 N5 和 N6,它们应该放在 N7 下方或上方。但 N5 应该与引脚 10 对齐,门 N6 应该与引脚 6 对齐。N7 应该与 N5 和 N6 对齐。
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\ctikzset{
logic ports=ieee,
logic ports origin=center, % not needed for IEEE
chips/thickness=4,
}
\begin{tikzpicture}
% when using in a node, you have to prepend "circuitikz/"
\node[dipchip, num pins=16, hide numbers, rotate=90, circuitikz/chips/scale=5](C){};
\path (C.center -| C.bpin 12) node[and port, rotate=90](N4){N4}; %%% gate N4
\draw (C.bpin 12) |- (N4.out);
\path (6,2.5) node[nand port, rotate=90](N5){N5}; %%% gate N5
\draw (C.bpin 10) |- (N5.out);
\path (6,-2.5) node[nor port, rotate=90](N6){N6}; %%% gate N6
\draw (C.bpin 6) |- (N6.in 1);
\path (C.center -| C.bpin 10) node[not port, rotate=90](N7){N7}; %%% gate N7
\draw (N7.in) |- (N6.out);
\draw (N7.out) |- (N5.in 2);
% external numbers
\foreach \pin in {1,...,8} \node[font=\LARGE, below left] at(C.bpin \pin) {\pin};
\foreach \pin in {9,...,16} \node[font=\LARGE, above left] at(C.bpin \pin) {\pin};
\end{tikzpicture}
\end{document}
我怎样才能将门 N6 与引脚 6 对齐而不使其垂直居中?
我需要三个不同的级别,低级别适合 N6,中等级别适合 N7,高级别适合 N5。
答案1
嗯,我不清楚“对齐”是什么意思。你的意思是端口的中心垂直位于引脚上方吗?要连接的引脚垂直位于端口输入引脚上方吗?
无论如何,您可以创建任意数量的对齐“行”。例如,
\path ($(C.north east)!0.5!(C.north)$) coordinate(mid-up);
\path ($(C.north west)!0.5!(C.north)$) coordinate(mid-down);
将在(非旋转)芯片的上部创建两个(不可见的)坐标点,一个位于北和东北中间,另一个位于另一侧对称。
所以:
documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\ctikzset{
logic ports=ieee,
logic ports origin=center, % not needed for IEEE
chips/thickness=4,
}
\begin{tikzpicture}
% when using in a node, you have to prepend "circuitikz/"
\node[dipchip, num pins=16, hide numbers, rotate=90, circuitikz/chips/scale=5](C){};
% create mid-up and mid-down coordinates
% notice that the name of the coordinates do not change with rotation
\path ($(C.north east)!0.5!(C.north)$) coordinate(mid-up);
\path ($(C.north west)!0.5!(C.north)$) coordinate(mid-down);
\path (C.center -| C.bpin 12) node[and port, rotate=90](N4){N4}; %%% gate N4
\draw (C.bpin 12) |- (N4.out);
\path (C.bpin 10 |- mid-up) node[nand port, rotate=90](N5){N5}; %%% gate N5
\draw (C.bpin 10) |- (N5.out);
\path (C.bpin 6 |- mid-down) node[nor port, rotate=90](N6){N6}; %%% gate N6
\draw (C.bpin 6) |- (N6.in 1);
\path (C.center -| C.bpin 10) node[not port, rotate=90](N7){N7}; %%% gate N7
\draw (N7.in) |- (N6.out);
\draw (N7.out) |- (N5.in 2);
% external numbers
\foreach \pin in {1,...,8} \node[font=\LARGE, below left] at(C.bpin \pin) {\pin};
\foreach \pin in {9,...,16} \node[font=\LARGE, above left] at(C.bpin \pin) {\pin};
\end{tikzpicture}
\end{document}
会给你:
为了显示发生了什么,我在这里添加了坐标线(1):
现在,如果您想与引脚对齐,例如以这样的方式使 N6 的输入引脚与引脚 6 的垂直对齐,事情就会变得稍微复杂一些,因为位于中心但在输入引脚高度的端口没有锚点(2)。
因此,我将添加另外几个垂直级别并使用它们,使用in
逻辑端口的锚点(请注意,在这种情况下,您的中心也或多或少位于中心,但这只是偶然的,因为芯片的宽度 --- 旋转时的高度 --- 现在是总数或高度的整数倍,具有您的比例参数)。
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\ctikzset{
logic ports=ieee,
logic ports origin=center, % not needed for IEEE
chips/thickness=4,
}
\begin{tikzpicture}
% when using in a node, you have to prepend "circuitikz/"
\node[dipchip, num pins=16, hide numbers, rotate=90, circuitikz/chips/scale=5](C){};
% create mid-up and mid-down coordinates
% notice that the name of the coordinates do not change with rotation
\path ($(C.north east)!0.5!(C.north)$) coordinate(mid-up);
\path ($(C.north west)!0.5!(C.north)$) coordinate(mid-down);
\path ($(mid-up)!0.5!(C.north)$) coordinate(mid-mid-up);
\path ($(mid-down)!0.5!(C.north west)$) coordinate(mid-mid-down);
\path (C.center -| C.bpin 12) node[and port, rotate=90](N4){N4}; %%% gate N4
\draw (C.bpin 12) |- (N4.out);
\path (C.bpin 10 |- mid-mid-up) node[nand port, rotate=90, anchor=in 2](N5){N5}; %%% gate N5
\draw (C.bpin 10) |- (N5.out);
\path (C.bpin 6 |- mid-mid-down) node[nor port, rotate=90, anchor=in 1](N6){N6}; %%% gate N6
\draw (C.bpin 6) |- (N6.in 1);
\path (C.center -| C.bpin 10) node[not port, rotate=90](N7){N7}; %%% gate N7
\draw (N7.in) |- (N6.out);
\draw (N7.out) |- (N5.in 2);
% external numbers
\foreach \pin in {1,...,8} \node[font=\LARGE, below left] at(C.bpin \pin) {\pin};
\foreach \pin in {9,...,16} \node[font=\LARGE, above left] at(C.bpin \pin) {\pin};
% code for the cord lines:
\def\showcoord(#1){node[circle, red, draw, inner sep=1pt,
pin={[red, overlay, inner sep=0.5pt, font=\small, pin distance=0.1cm,
pin edge={red, overlay}]45:#1}](#1){}}
\path (C.north) \showcoord(C.north) (C.center) \showcoord(C.center);
\draw[dashed, red] (mid-mid-up) \showcoord(mid-mid-up) -- (mid-mid-up -| C.south);
\draw[dashed, red] (mid-mid-down) \showcoord(mid-mid-down) -- (mid-mid-down -| C.south);
\draw[dashed, red] (C.north) -- (C.north -| C.south);
\draw[dashed, red] (C.bpin 6) \showcoord(C.bpin 6) -- (C.bpin 11);
\path (N5.in 2) \showcoord(N5.in 2) (N6.in 1) \showcoord(N6.in 1);
\end{tikzpicture}
\end{document}
没有坐标的话,就是这个:
所以基本上这取决于你真正想要什么。
脚注:
(1)显示坐标的代码:
\def\showcoord(#1){node[circle, red, draw, inner sep=1pt,
pin={[red, overlay, inner sep=0.5pt, font=\small, pin distance=0.1cm,
pin edge={red, overlay}]45:#1}](#1){}}
\path (C.north) \showcoord(C.north) (C.center) \showcoord(C.center);
\draw[dashed, red] (mid-up) \showcoord(mid-up) -- (mid-up -| C.south);
\draw[dashed, red] (mid-down) \showcoord(mid-down) -- (mid-down -| C.south);
\draw[dashed, red] (C.north) -- (C.north -| C.south);
\draw[dashed, red] (C.bpin 6) \showcoord(C.bpin 6) -- (C.bpin 11);
(2)这可能是合理的增强请求,是的......