circuitikz
有一种op amp
组件类型有两个输入、输出和up
端口down
,通常用于电源轨。还有一种buffer
组件类型(我认为是它tikz
自己提供的,而不是circuitikz
库提供的),它有一个输入和一个输出,没有垂直端口。
我正在寻找一个具有一个输入、一个输出和垂直端口的缓冲器/放大器,用作控制引脚。我的用例是跟踪保持(又称采样保持)放大器符号,但三态缓冲器也很常见,并且需要控制输入。
好的,该图使用了双输入 SHA。但我相信您可以想象单输入版本应该是什么样子(基本上,我试图制作一个隐藏所有复杂性的单个符号,用于高级框图)。
它的扩展库是否tikz
提供了这样的功能?如果没有,我该如何正确地将垂直线与缓冲区的边缘对齐?
答案1
声明新的节点形状有点麻烦,但你会习惯的。以下是两个新的电路形状tri state buffer active low
和tri state buffer active high
,它们的行为类似于buffer gate
和not gate
,但提供了新的锚点control
。这允许你绘制如下:
使用这个:
\begin{tikzpicture}[circuit logic US, on grid]
\node (i) {x};
\node (buf) [right of=i, tri state buffer active high] {};
\node (ctrl) [above=of buf] {c};
\node (o) [right of=buf] {y};
\draw (i) -- (buf.input)
(ctrl) -- (buf.control)
(buf.output) -- (o);
\end{tikzpicture}%
\begin{tikzpicture}[circuit logic US, on grid]
\node (i) {x};
\node (buf) [right of=i, tri state buffer active low] {};
\node (ctrl) [above=1 of buf] {c};
\node (o) [right of=buf] {y};
\draw (i) -- (buf.input)
(ctrl) -- (buf.control)
(buf.output) -- (o);
\end{tikzpicture}%
完整代码:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, circuits.logic.US}
\makeatletter%
%
%
\pgfdeclareshape{tri state buffer active high}{
\inheritsavedanchors[from=buffer gate US]
\inheritanchorborder[from=buffer gate US]
\inheritanchor[from=buffer gate US]{center}
\inheritanchor[from=buffer gate US]{base}
\inheritanchor[from=buffer gate US]{base west}
\inheritanchor[from=buffer gate US]{base east}
\inheritanchor[from=buffer gate US]{mid}
\inheritanchor[from=buffer gate US]{mid west}
\inheritanchor[from=buffer gate US]{mid east}
\inheritanchor[from=buffer gate US]{north}
\inheritanchor[from=buffer gate US]{north west}
\inheritanchor[from=buffer gate US]{north east}
\inheritanchor[from=buffer gate US]{south}
\inheritanchor[from=buffer gate US]{south east}
\inheritanchor[from=buffer gate US]{south west}
\inheritanchor[from=buffer gate US]{west}
\inheritanchor[from=buffer gate US]{east}
\inheritanchor[from=buffer gate US]{input}
\inheritanchor[from=buffer gate US]{output}
\anchor{control}{%
\dimensions
\pgfpointintersectionoflines{\csname pgf@anchor@buffer gate US@north west\endcsname}{\tipanchor}{\centerpoint}{\centerpoint\advance\pgf@y1pt}%
}%
\backgroundpath{%
\dimensions%
\pgf@xc\halfwidth%
\pgf@yc\halfheight%
\advance\pgf@xc-\outerxsep%
\advance\pgf@yc-\outerysep%
{%
\pgftransformshift{\centerpoint}%
\pgfpathmoveto{\tipanchor}%
\pgfpathlineto{\pgfqpoint{-.833333\pgf@xc}{1.166666\pgf@yc}}%
\pgfpathlineto{\pgfqpoint{-.833333\pgf@xc}{-1.166666\pgf@yc}}%
\pgfpathclose%
%
% Draw the input.
%
\expandafter\ifx\expandafter\pgf@lib@sh@itext\csname input-1\endcsname%
{%
\pgfpathcircle{%
\pgf@xa\halfside%
\[email protected]\pgf@xa%
\advance\[email protected]\pgflinewidth%
\advance\pgf@x-\invertedradius%
\pgf@y0pt%
}{+\invertedradius}%
}%
\fi%
}%
}%
}
\pgfdeclareshape{tri state buffer active low}{
\inheritsavedanchors[from=buffer gate US]
\inheritanchorborder[from=buffer gate US]
\inheritanchor[from=buffer gate US]{center}
\inheritanchor[from=buffer gate US]{base}
\inheritanchor[from=buffer gate US]{base west}
\inheritanchor[from=buffer gate US]{base east}
\inheritanchor[from=buffer gate US]{mid}
\inheritanchor[from=buffer gate US]{mid west}
\inheritanchor[from=buffer gate US]{mid east}
\inheritanchor[from=buffer gate US]{north}
\inheritanchor[from=buffer gate US]{north west}
\inheritanchor[from=buffer gate US]{north east}
\inheritanchor[from=buffer gate US]{south}
\inheritanchor[from=buffer gate US]{south east}
\inheritanchor[from=buffer gate US]{south west}
\inheritanchor[from=buffer gate US]{west}
\inheritanchor[from=buffer gate US]{east}
\inheritanchor[from=buffer gate US]{input}
\inheritanchor[from=buffer gate US]{output}
\anchor{control}{%
\dimensions
\tipanchor%
\pgf@xa\pgf@x%
\pgf@ya\pgf@y%
\csname pgf@anchor@buffer gate US@north west\endcsname%
\advance\pgf@xa-\pgf@x%
\advance\pgf@ya-\pgf@y%
\pgfpointintersectionoflines{\csname pgf@anchor@buffer gate US@north west\endcsname}{\tipanchor}{\centerpoint}{\centerpoint\advance\pgf@y2pt}%
\pgfmathparse{sqrt(\pgf@xa^2+\pgf@ya^2)/\pgf@xa*\invertedradius}
\advance\pgf@y\pgfmathresult pt
\advance\pgf@y\invertedradius
}%
\backgroundpath{%
\dimensions%
\pgf@xc\halfwidth%
\pgf@yc\halfheight%
\advance\pgf@xc-\outerxsep%
\advance\pgf@yc-\outerysep%
{%
\pgftransformshift{\centerpoint}%
\pgfpathmoveto{\tipanchor}%
\pgfpathlineto{\pgfqpoint{-.833333\pgf@xc}{1.166666\pgf@yc}}%
\pgfpathlineto{\pgfqpoint{-.833333\pgf@xc}{-1.166666\pgf@yc}}%
\pgfpathclose%
%
% Draw the input.
%
\pgfpathcircle{%
\tipanchor%
\pgf@xa\pgf@x%
\pgf@ya\pgf@y%
\csname pgf@anchor@buffer gate US@north west\endcsname%
\advance\pgf@xa-\pgf@x%
\advance\pgf@ya-\pgf@y%
\pgfpointintersectionoflines{\csname pgf@anchor@buffer gate US@north west\endcsname}{\tipanchor}{\centerpoint}{\centerpoint\advance\pgf@y1pt}%
\pgfmathparse{sqrt(\pgf@xa^2+\pgf@ya^2)/\pgf@xa*\invertedradius}
\advance\pgf@y\pgfmathresult pt
}{+\invertedradius}%
\expandafter\ifx\expandafter\pgf@lib@sh@itext\csname input-1\endcsname%
{%
\pgfpathcircle{%
\pgf@xa\halfside%
\[email protected]\pgf@xa%
\advance\[email protected]\pgflinewidth%
\advance\pgf@x-\invertedradius%
\pgf@y0pt%
}{+\invertedradius}%
}%
\fi%
}%
}%
}
\tikzset{
circuit declare symbol=tri state buffer active low,
set tri state buffer active low graphic={draw, shape=tri state buffer active low, minimum size=5mm},
circuit declare symbol=tri state buffer active high,
set tri state buffer active high graphic={draw,shape=tri state buffer active high,minimum size=5mm}
}
\begin{document}
%
\begin{tikzpicture}[circuit logic US, on grid]
\node (i) {x};
\node (buf) [right of=i, tri state buffer active high] {};
\node (ctrl) [above=of buf] {c};
\node (o) [right of=buf] {y};
\draw (i) -- (buf.input)
(ctrl) -- (buf.control)
(buf.output) -- (o);
\end{tikzpicture}%
\begin{tikzpicture}[circuit logic US, on grid]
\node (i) {x};
\node (buf) [right of=i, tri state buffer active low] {};
\node (ctrl) [above=1 of buf] {c};
\node (o) [right of=buf] {y};
\draw (i) -- (buf.input)
(ctrl) -- (buf.control)
(buf.output) -- (o);
\end{tikzpicture}%
\end{document}
答案2
如果您仅使用高电平有效三态缓冲器,这里有一个简单的解决方案:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.gates.logic.US}
\begin{document}
\begin{tikzpicture}
\node (A) at (0,0) {$A$};
\node (E) at (0,0.5) {$E$};
\node (Y) at (2,0) {$Y$};
\node[buffer gate US, draw, logic gate inputs=n] at (1,0) (TS) {};
\draw (A) -- (TS.input);
\draw (E) -| (TS.north);
\draw (TS.output) -- (Y);
\end{tikzpicture}
\end{document}