绘制黑盒电路

绘制黑盒电路

有没有一种简单的方法可以在乳胶中绘制黑盒电路,我可以将线路连接到输入和输出?任务是绘制一个 4 位 CPU,所以我试图找到一种干净的方法来指定所有内容。

全加器黑盒电路的示例:

全加器黑盒

答案1

只是一个想法。主要问题是调整主节点内的标签位置。

\documentclass[tikz,border=2mm]{standalone}
\usepackage{amsmath}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
    fulladder/.style={draw, minimum size=3cm,
    label={[xshift=8mm]left:$c_\text{out}$},
    label={[yshift=5mm]below:$s$},
    label={[xshift=-6mm]right:$c_\text{in}$},
    label={[yshift=-3mm, anchor=center]65:$b$},
    label={[yshift=-3mm, anchor=center]115:$a$},
    }]

    \node[fulladder] (a) {};
    \node[fulladder, right=1cm of a] (b) {};

    \draw[<-] (a.115) --++(90:0.5cm) node [above] {$a_1$};
    \draw[<-] (a.65) --++(90:0.5cm) node [above] {$b_1$};
    \draw[<-] (b.115) --++(90:0.5cm) node [above] {$a_0$};
    \draw[<-] (b.65) --++(90:0.5cm) node [above] {$b_0$};
    \draw[<-] (b.east) --++(0:0.5cm) node [right] {$0$};
    \draw[<-] (a.east) -- (b.west);
    \draw[->] (a.west) --++(180:0.5cm) node [left] {$c$};
    \draw[->] (a.south) --++(-90:0.5cm) node [below] {$s_1$};
    \draw[->] (b.south) --++(-90:0.5cm) node [below] {$s_0$};

\end{tikzpicture}

\end{document}

在此处输入图片描述

更新:轻松调整标签

我已经学会了如何更好地调整节点内的标签托比昂的回答 如何用 tikz 绘制建筑

先前带有新标签声明的代码可能是:

\documentclass[tikz,border=2mm]{standalone}
\usepackage{amsmath}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
    fulladder/.style={draw, minimum size=3cm,
    label={[anchor=west]left:$c_\text{out}$},
    label={[anchor=south]below:$s$},
    label={[anchor=east]right:$c_\text{in}$},
    label={[anchor=north]65:$b$},
    label={[anchor=north]115:$a\vphantom{b}$},
    }]

    \node[fulladder] (a) {};
    \node[fulladder, right=1cm of a] (b) {};

    \draw[<-] (a.115) --++(90:0.5cm) node [above] {$a_1$};
    \draw[<-] (a.65) --++(90:0.5cm) node [above] {$b_1$};
    \draw[<-] (b.115) --++(90:0.5cm) node [above] {$a_0$};
    \draw[<-] (b.65) --++(90:0.5cm) node [above] {$b_0$};
    \draw[<-] (b.east) --++(0:0.5cm) node [right] {$0$};
    \draw[<-] (a.east) -- (b.west);
    \draw[->] (a.west) --++(180:0.5cm) node [left] {$c$};
    \draw[->] (a.south) --++(-90:0.5cm) node [below] {$s_1$};
    \draw[->] (b.south) --++(-90:0.5cm) node [below] {$s_0$};

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容