在下面的 TikZ 图中,我想绘制与 ALU 引脚对齐的红色箭头,如第二张图所示。我该怎么做?用于生成第一张图片的代码粘贴在第二张图下方。
当然,最大的障碍是知道 ALU 引脚/锚点的名称。请注意,我使用了 1 位加法器(来自 muxdemuxes 类,手册第 174 页) 来表示 ALU。我似乎无法在 Circuitikz 手册中找到引脚/锚点名称。
\documentclass{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\usepackage{flowchart}
\usetikzlibrary{arrows}
\usetikzlibrary {matrix}
\usetikzlibrary{shapes}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{fit}
\usetikzlibrary{shadings}
\begin{document}
\begin{circuitikz}
\node[draw, black, thick,
minimum width =5cm ,
minimum height=5cm, , fill=teal!15] (regbox) at (9,0) {};
\node[black,scale=1.0] at (9,2.2) {\textsf{REGISTER SET}};
\begin{scope}[reg/.style={rectangle, shade,
upper left=gray!30,
draw=black,
ultra thin,
minimum width=1cm,
minimum height=0.5cm}]
\node [matrix] at (9,0)
{
\node {$R_0$} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;& \\
\node {$R_1$} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;& \\
};
\end{scope}
%-------
% ALU
%-------
\node[one bit adder,draw,scale=1.5, fill=pink!35] at (14,0) {};
\node[rotate =90,scale=1.2](alu) at (14.15,0) {\textsf ALU};
\end{circuitikz}
\end{document}
答案1
您正在寻找的手册部分是关于muxdemux
锚点的部分(截至今天为 4.24.2):
(还有更多...)。此外,您可能需要抑制外部引脚(根据您的示例):
\documentclass{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\usepackage{flowchart}
\usetikzlibrary{arrows.meta}% arrows is deprecated
\usetikzlibrary {matrix}
\usetikzlibrary{shapes}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{fit}
\usetikzlibrary{shadings}
\begin{document}
\begin{circuitikz}
\node[draw, black, thick,
minimum width =5cm ,
minimum height=5cm, , fill=teal!15] (regbox) at (9,0) {};
\node[black,scale=1.0] at (9,2.2) {\textsf{REGISTER SET}};
\begin{scope}[reg/.style={rectangle, shade,
upper left=gray!30,
draw=black,
ultra thin,
minimum width=1cm,
minimum height=0.5cm}]
\node [matrix] at (9,0)
{
\node {$R_0$} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;& \\
\node {$R_1$} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;&
\node[reg] at (0,0) {} ;& \\
};
\end{scope}
%-------
% ALU
%-------
%% vvvv give a name to the alu shape node (you named the text...)
\node[one bit adder,draw,scale=1.5, fill=pink!35,
circuitikz/multipoles/external pins width=0](alu) at (14,0) {};
\node[rotate =90,scale=1.2] at (14.15,0) {\textsf ALU};
%% arrow style, probably better in the preamble
\tikzset{red arrow/.style={very thick, -{Straight Barb[]}, red}}
%% using the perpendicular coordinate system here
\draw[ red arrow ] (alu.blpin 1 -| regbox.east) -- (alu.blpin 1);
\draw[ red arrow ] (alu.blpin 2 -| regbox.east) -- (alu.blpin 2);
\draw[ red arrow ] (alu.east) -- ++(1,0);
\end{circuitikz}
\end{document}