
내 강의를 위한 타이밍 다이어그램을 준비하는 데 있어 tikz-timing을 좋아합니다. 하지만 내가 찾지 못한 한 가지는 타이밍 다이어그램에 번호가 매겨진 시간 축을 추가하는 방법입니다. 이는 테스트벤치 설계의 기본 사항을 보여주고 Verilog 소스의 선으로 다이어그램의 대응 관계를 표시하려는 경우에 유용합니다. TikZ 오버레이가 작동할 수 있다고 생각하지만 저는 그다지 전문가가 아니며 숫자가 자동으로 추가되는 것을 선호합니다. 나는 수직 도움말 라인을 사용하고 있으므로 어떻게든 그 위나 아래에 숫자를 추가하는 것이 좋을 것입니다.
답변1
에서 제공하는 전용 매크로는 없지만 tikz-timing
, 제공된 크기 매크로와 노드를 사용하여 이러한 레이블이 지정된 축을 그리는 것이 가능합니다.
행 수는 로 주어지며 \nrows
가장 넓은 행은 으로 제공됩니다 \twidth
. 행은 라는 노드로도 제공되며 row<number>
마지막 행 노드에도 이름이 지정됩니다 last row
. 추가 자료를 그리려면 extracode
아래 예와 같이 마지막 행 뒤의 환경에 그리기 코드를 배치하세요. tikz-timing
자세한 내용은 설명서를 참조하세요 .
\documentclass[border=2mm]{standalone}
\usepackage{tikz-timing}
\begin{document}
\begin{tikztimingtable}
clk & 20{C} \\
sig & 5{HLZD{}} \\
\begin{extracode}
\begin{background}
\vertlines[help lines]{}
\horlines[help lines]{}
\show\horlines
\draw [->,>=latex] (0,-\nrows-1) -- (\twidth+1,-\nrows-1);
\foreach \n in {0,1,...,\twidth}
\draw (\n,-\nrows-1+.1) -- +(0,-.2)
node [below,inner sep=2pt] {\scalebox{.75}{\tiny\n}};
\end{background}
%\tablegrid
\end{extracode}
\end{tikztimingtable}%
\end{document}
이것이 더 자주 필요한 경우 자체 매크로를 정의할 수 있습니다.
\documentclass[border=2mm,png]{standalone}
\usepackage{tikz-timing}
\newcommand{\timingaxis}[1][]{%
\begin{scope}[#1]
\draw [timing/table/axis] (0,-\nrows-1) -- (\twidth+1,-\nrows-1);
\foreach \n in {0,1,...,\twidth} {
\draw [timing/table/axis ticks]
(\n,-\nrows-1+.1) -- +(0,-.2)
node [below,inner sep=2pt] {\scalebox{.75}{\tiny\n}};
}
\end{scope}
}
\tikzset{%
timing/table/axis/.style={->,>=latex},
timing/table/axis ticks/.style={},
}
\begin{document}
\begin{tikztimingtable}
clk & 20{C} \\
sig & 5{HLZD{}} \\
\begin{extracode}
\timingaxis\relax
\end{extracode}
\end{tikztimingtable}%
\end{document}
답변2
pgfplots
다음은 환경 을 사용하는 또 다른 가능한 방법입니다 axis
. 그것은 다음과 같이 보일 것입니다 :
... 이 MWE를 사용하여:
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{tikz-timing}
\usetikzlibrary{intersections} %% named intersections
\usetikzlibrary{fit}
\usetikzlibrary{calc}
\makeatletter
% http://tex.stackexchange.com/questions/33703/extract-x-y-
\newcommand{\gettikzxy}[3]{%
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\edef#2{\the\pgf@x}%
\edef#3{\the\pgf@y}%
}
\makeatother
\begin{document}
\begin{tikzpicture}[timing/picture]%,timing/nodes/advanced]
\begin{axis}[clip=false,ymin = 0, ymax = 2, xmin = 0, xmax = 5]
%\addplot [] node [] (origin) at (0,0) {}; %no
\addplot [] coordinates {(0,0)};
\node[] (refsize) at ({axis cs:1,1}) {};
\pgfplotsextra{ % must have, else \gettikzxy will not work!
\gettikzxy{(refsize)}{\rx}{\ry}
% re-convert \rx back to length, so can scale it directly in style= below:
\newlength{\trx}
\setlength{\trx}{\rx}
\typeout{rx \rx - \the\trx, ry \ry}
\timing[very thick,style={x=0.5\trx,y=\ry},name=tgraph1] at ({axis cs:1,0.5}) { HLHLHL };
% debug:
% add frame border around tgraph1
\node[fit=(tgraph1), draw, color=gray] {};
% indicate origin of tgraph1 (is lower left corner):
\node[fill,circle,color=gray] at (tgraph1.origin) {};
} % end \pgfplotsextra
\end{axis}
\end{tikzpicture}
\end{document}
그래프의 단위를 그래프에 표시된 단위로 조정하려면 약간의 산술 연산을 수행해야 합니다 \timing
. 위의 예는 픽셀 단위로 완벽하게 정렬되지 않을 수도 있지만 적어도 모든 것이 보이지는 않습니다. 설정이 너무 어렵다...