如何包含顶部或底部输入,以表示解码器的启用输入

如何包含顶部或底部输入,以表示解码器的启用输入
\documentclass{article}
%decoder
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc,arrows.meta}
\usepackage{circuitikz}
\usetikzlibrary{circuits.logic.IEC,calc}

\begin{document}
\begin{circuitikz}[circuit logic IEC]


\node[and gate,inputs={nnn},and gate IEC symbol={Decoder 3:8},text height=6cm,text width=4cm,
 ] (A) {};

\node[and gate,inputs={nnnnnnnn},and gate IEC symbol={},text height=6cm,text width=4cm, xscale=-1
 ] (B) {};
 \node[and gate,inputs={nn},and gate IEC symbol={},text height=6cm,text width=4cm, yscale=-1
 ] (C) {};
 
\foreach \V/\X in {3/B,2/C,1/D} 
{
  \draw  ([xshift=-10pt]A.input \V) node[left] {$\X$} -- (A.input  \V);
}
\foreach \V/\X in {3/2,2/1,1/0} 
{
  \draw  ([xshift=10pt]A.input \V) node[right] {$\X$} (A.input  \V);
}

%\foreach \T/\S in {1/0000,2/0001,3/0010,4/0011,5/0100,6/0101,7/0110,8/0111,9/1000,10/1001,11/1010,12/1011,13/1100,
%14/1101,15/1110,16/1111} 
%{
%  \draw  ([xshift=-10pt]B.input \T) node[left] {$\S$} -- (B.input  \T);
%}

\foreach \T/\S in {1/Y_0,2/Y_1,3/Y_2,4/Y_3,5/Y_4,6/Y_5,7/Y_6,8/Y_7} 
{
  \draw  ([xshift=-10pt]B.input \T) node[left] {$\S$} -- (B.input  \T);
}

\draw (8,4) node[or port, scale=2, number inputs=5] (or1) {};

% \draw ( $ (A.south east)!.888!(A.north east) $ ) -| (myor1.in 1) {};
% \draw ( $ (A.south east)!.777!(A.north east) $ ) -| (myor1.in 2) {};

\draw (or1.in 1)  node [anchor=east] {$Y_0$}
(or1.in 2)  node [anchor=east] {$Y_6$}
(or1.in 3)  node [anchor=east] {$Y_8$}
(or1.in 4)  node [anchor=east] {$Y_{11}$}
(or1.in 5)  node [anchor=east] {$Y_{13}$}
(or1.out)   node [anchor=west] {$f_1$};

\draw (8,1) node[or port, scale=2, number inputs=5] (or2) {};

% \draw ( $ (A.south east)!.888!(A.north east) $ ) -| (myor2.in 1) {};
% \draw ( $ (A.south east)!.777!(A.north east) $ ) -| (myor2.in 2) {};

\draw (or2.in 1)  node [anchor=east] {$Y_1$}
(or2.in 2)  node [anchor=east] {$Y_5$}
(or2.in 3)  node [anchor=east] {$Y_9$}
(or2.in 4)  node [anchor=east] {$Y_{10}$}
(or2.in 5)  node [anchor=east] {$Y_{14}$}
(or2.out)   node [anchor=west] {$f_2$};

\draw (8,-2) node[or port, scale=2, number inputs=5] (or3) {};

% \draw ( $ (A.south east)!.888!(A.north east) $ ) -| (myor2.in 1) {};
% \draw ( $ (A.south east)!.777!(A.north east) $ ) -| (myor2.in 2) {};

\draw (or3.in 1)  node [anchor=east] {$Y_4$}
(or3.in 2)  node [anchor=east] {$Y_7$}
(or3.in 3)  node [anchor=east] {$Y_8$}
(or3.in 4)  node [anchor=east] {$Y_{11}$}
(or3.in 5)  node [anchor=east] {$Y_{15}$}
(or3.out)   node [anchor=west] {$f_3$};
\end{circuitikz}
\end{document}

我得到了什么 我想要的例子

答案1

除非你完全清楚自己在做什么,否则永远不要混淆 Ti 的内部电路库Z circuitikz;它有记录在手册的开头

您可以使用muxdemux中的(高度可配置)组件获得一个非常相似的解码器circuitikz。请参阅此处的示例,其中注释解释了您可以找到的键的值在手册中

\documentclass[border=10pt]{standalone}
\usepackage{circuitikz}
% define the component
\tikzset{my3to8/.style={
        muxdemux, muxdemux def={
            Lh=8, Rh=8, w=6, % both left and right size =8 units, wide top
            NT=1, NB=0, % one terminal on the top, none bottom
            NR=8, % 8 pins on the right
            % we will define 9 pins on the left, to have them
            % centered, but we will draw just the central three
            NL=9,
        },
        draw only left pins = {4-6},
    }
}
\begin{document}
\begin{tikzpicture}[]
    \draw (0,0) node[my3to8](D){\tiny\ttfamily 3:8 decoder};
    % left labels
    \foreach \i [count=\iz from 0] in {1,...,8} {
        \node[left, font=\tiny\ttfamily] at (D.brpin \i) {\iz};
        \node[right, font=\tiny\ttfamily] at (D.rpin \i) {Y\iz};
    }
    % right labels
    \foreach \i/\lab [count=\iz from 0] in {4/d,5/c,6/b} {
        \node[right, font=\tiny\ttfamily] at (D.blpin \i) {\iz};
        \node[left, font=\tiny\ttfamily] at (D.lpin \i) {\lab};
    }
    % top label
    \node [below, font=\tiny\ttfamily] at (D.btpin 1) {EN}; 
    \node [above, font=\tiny\ttfamily] at (D.tpin 1) {a'}; 
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容