2.6.3. TikZ-Timing

CTAN Package

TikZ-Timing Package

Documentation

TikZ-Timing User Guide

Git Repository

TikZ-Timing Master Branch

TikZ-Timing is a TikZ extension with macros and an environment to generate timing diagrams (digital waveforms) without much effort.

tikztiming/pcinst-tick.tex 1, in Figure 2.16.

\begin{tikztimingtable}

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% My Customized Styles
%%

\tikzset{% Environment Config
    timing/nodes/advanced,
    timing/dslope=0.1,
    timing/.style={x=5ex,y=2ex},
    x=5ex,
    timing/rowdist=3ex,
    timing/name/.style={font=\sffamily\scriptsize},
    timing/d/text/.style={font=\sffamily\tiny},
}

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Drawing
%%

\textcolor{black}{Instruction} & [black]
    Z 2D{push}      4D{mov}       4D{sub}       4D{movl}      4D{mov}       2D{leave}     2D{ret}       2D{...}       \\ %
\textcolor{black}{PC Address} & [black]
    Z 2D{8394}      4D{8395}      4D{8397}      4D{839a}      4D{83a1}      2D{83a4}      2D{83a5}      2D{...}       \\ %
\textcolor{red}{Instruction tick} & [red]
    S O{A}{G} 2{S}  O{A}{G} 4{S}  O{A}{G} 4{S}  O{A}{G} 4{S}  O{A}{G} 4{S}  O{A}{G} 2{S}  O{A}{G} 2{S}  O{A}{G} 2{S}  \\ %
\textcolor{brown}{Clock} & [brown]
    Z 2{C}          4{C}          4{C}          4{C}          4{C}          2{C}          2{C}          2{C}          \\ %
%
% there must NOT be an uncommented line before \extracode!
%
\extracode
    \tablerules
%%  \tablegrid

\begin{pgfonlayer}{background}
    \begin{scope}[semitransparent ,semithick]
        \vertlines[darkgray,dotted]{1.0,3.0,...,23.0}
        \vertlines[gray,dotted]{2.0,4.0,...,24.0}
    \end{scope}
\end{pgfonlayer}

%%
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{tikztimingtable}

%Local variables:
% coding: utf-8
% mode: text
% mode: rst
% End:
% vim: fileencoding=utf-8 filetype=tex :

Figure 2.16 Program counter and instruction tick

tikztiming/divider-line.tex 2, in Figure 2.17.

\begin{tikztimingtable}[timing/wscale=2]

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% My Customized Styles
%%

\def\strut{\large\vphantom{/}}

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Drawing
%%

%      section A
\\  % empty line for time scale
RefClock\_150MHz & h19{c}                                  \\
%      section B
                 & \divider{Transceiver Interface}         \\
PowerDown        & [very thick,violet]lN(BA1)h5HhN(BA2)l3L \\
PowerDownDone    & [very thick,orange]3LN(BB1)3H3HN(BB2)1L \\
%      section C
                 & \divider{Synchronized Interface}        \\
CC\_PowerDown    & [thick,orange]2LN(CA1)6HN(CA2)2L        \\
%
% there must NOT be an uncommented line before \extracode!
%
\extracode
    \makeatletter
    \tableheader{Signal Name}{Waveform}\tablerules
    \tablerules
    % time scale
    \pgfmathsetmacro\twidthnew{\twidth/2}
    \pgfmathsetmacro\nrowsnew{76}
    \draw[->,thick] (0,0) -- +(\twidth+1,0);
    \foreach \n in {0,1,...,\twidthnew}
        \pgfmathsetmacro\nnew{int(\n*2)}
        \draw(\nnew,-0.2) -- +(0,.4) node[above,inner sep=2pt] {\scalebox{0.75}{\n}};
    % interconnection
    \draw[blue,->](BA1)to[out=0,in=180](CA1);
    \draw[blue,->](CA1)to[out=0,in=180](BB1);
    \draw[blue,->](BA2)to[out=0,in=180](CA2);
    \draw[blue,->](CA2)to[out=0,in=180](BB2);
    % table grid
    \begin{background}[lightgray!50,semitransparent,semithick]
        \horlines{1,...,8}
        \vertlines{0,2,...,6,8,10,...,\twidth}
    \end{background}
    % draw dividers
    \dividers
    
%%
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{tikztimingtable}

%Local variables:
% coding: utf-8
% mode: text
% mode: rst
% End:
% vim: fileencoding=utf-8 filetype=tex :

Figure 2.17 Signal interconnections and dividers

tikztiming/colored-cells.tex 3, in Figure 2.18.

\begin{tikztimingtable}

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% My Customized Styles
%%

\tikzset{% Environment Config
    scale=2.5,
    timing/slope=0.1,
    timing/rowdist=3ex,
}

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Drawing
%%

\textnormal{SPI Select} & 1U 24L    U{ } \\
\textnormal{SPI Clock}  & 3U 16{C} 7U{ } \\
\textnormal{SPI Data}   & 3U [fill=yellow]2D{B0}2D{B1}2D{B2}2D{B3}2D{B4}2D{B5}2D{B6}2D{B7}
                             [fill=gray]7U{ } \\
\textnormal{UART Data}  & 1U [fill=green]2D{Start}
                             [fill=yellow]2D{B0}2D{B1}2D{B2}2D{B3}2D{B4}2D{B5}2D{B6}2D{B7}
                             [fill=magenta!60]2D{Parity}
                             [fill=red!70]2D{Stop}2D{Stop}
                             [fill=gray]U{ } \\
%
% there must NOT be an uncommented line before \extracode!
%
\extracode
    % interconnection
    % table grid
    \begin{pgfonlayer}{background}
        \vertlines[help lines,red]{1,3,5,...,13,15,17,...,\twidth}
    \end{pgfonlayer}
    \tablegrid[fill=red,green!25,step=1]

%%
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{tikztimingtable}

%Local variables:
% coding: utf-8
% mode: text
% mode: rst
% End:
% vim: fileencoding=utf-8 filetype=tex :

Figure 2.18 SPI vs. UART with arbitrary colored data cells

tikztiming/spi-opmodes.tex 4, in Figure 2.19.

\begin{tikztimingtable}

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% My Customized Styles
%%

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Drawing
%%

CPOL =0  & LL 15{ T} LL \\
CPOL =1  & HH 15{ T} HH \\
         &  H 17L H \\
Cycle \# & U R     [fill=red!25]8{2 Q}    [fill=gray]2U \\
    MISO & D{z} R  [fill=yellow!25]8{2 Q} [fill=white]2D{z} \\
    MOSI & D{z} R  [fill=yellow!25]8{2 Q} [fill=white]2D{z} \\
Cycle \# & UU R    [fill=blue!25]8{2 Q}   [fill=gray]U \\
    MISO & D{z}U R [fill=yellow!25]8{2 Q} [fill=white]D{z} \\
    MOSI & D{z}U R [fill=yellow!25]8{2 Q} [fill=white]D{z} \\
\extracode
   % Add vertical lines in two colors
    \begin{pgfonlayer}{background}
        \begin{scope}[semitransparent,semithick]
            \vertlines[red!50]{2.1,4.1,...,17.1}
            \vertlines[blue!50]{3.1,5.1,...,17.1}
        \end{scope}
    \end{pgfonlayer}
    % Add big group labels
    \begin{scope}[font =\sffamily \Large ,shift={(-6em,-0.5)},anchor=east]
        \node at (0,0){SCK};
        \node at (0,-3){SS};
        \node at (1ex,-8){CPHA=0}; 
        \node at (1ex,-14){CPHA =1};
        \end{scope}

%%
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{tikztimingtable}

%Local variables:
% coding: utf-8
% mode: text
% mode: rst
% End:
% vim: fileencoding=utf-8 filetype=tex :

Figure 2.19 Serial Peripheral Interface operating modes

tikztiming/pci-read-irqack.tex, in Figure 2.20.

PCI timing diagrams with reference to version 2.2 of the PCI specification 5.

\begin{tikztimingtable}[timing/wscale=2]

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% My Customized Styles
%%

\tikzset{% Environment Config
    timing/dslope=0.1,
    timing/.style={x=2ex,y=2ex},
    x=2ex,
    timing/rowdist=3ex,
    timing/name/.style={font=\sffamily\scriptsize},
    timing/nodes/advanced,
}

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Drawing
%%

\busref{CLK}         & l 17{c}
                       N(C1);[thin,dotted,black!25]8{0.25t};N(C2)
                       10{c} \\
\busref*{FRAME}      & 2u 12l 2h 2u
                       N(F1);[thin,dotted,black!25]8{0.25t};N(F2)
                       u 0.5h2l 4.5h 2u \\
\busref[31::0]{AD}   & 2u 2d{addr} 2u{} 2d{$d_1$} 2d{$d_1 '$} 2d{$d_2$} 4d{$d_3$} 2u
                       N(A1);[thin,dotted,black!25]8{0.25t};N(A2)
                       1.5u 2x 2.5u 2d{$v_i$} 2u \\
\busref*[3::0]{C/BE} & 2u 2d{0010} 12d{BE\#} 2u
                       N(B1);[thin,dotted,black!25]8{0.25t};N(B2)
                       1.5u 2d{0000} 4.5d{\busref*{BE}} 2u \\
\busref*{IRDY}       & 4u 8l 2h2l2h
                       N(I1);[thin,dotted,black!25]8{0.25t};N(B2)
                       3.5u 4.5l 2h \\
\busref*{TRDY}       & 4u HLH 6l 2h
                       N(T1);[thin,dotted,black!25]8{0.25t};N(T2)
                       3.5u 2.5h 2l 2h \\
\busref*{DEVSEL}     & 4u 12l 2h
                       N(D1);[thin,dotted,black!25]8{0.25t};N(D2)
                       5u 0.5h2.5l 0.5h 1.5u \\
%
% there must NOT be an uncommented line before \extracode!
%
\extracode
    \tablerules
%%  \tablegrid
    \begin{pgfonlayer}{background}
        \begin{scope}[semitransparent,semithick]
            \vertlines[darkgray,dotted]{1,3,...,17}
            \vertlines[darkgray,dotted]{21,23,...,\twidth}
        \end{scope}
    \end{pgfonlayer}

%%
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{tikztimingtable}

%Local variables:
% coding: utf-8
% mode: text
% mode: rst
% End:
% vim: fileencoding=utf-8 filetype=tex :

Figure 2.20 PCI Read and Interrupt Acknowledge

tikztiming/gn4124-pdwreq.tex, in Figure 2.21.

Packet decoder timing diagram with reference to the Gennum GN4124 to Wishbone bridge user guide 6.

\begin{tikztimingtable}

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% My Customized Styles
%%

\tikzset{% Environment Config
    timing/dslope=0.1,
}

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Drawing
%%

lclk                 & H29{C}                                \\
pd\_csr\_sel         & 2L 0.1HN(B0)1.9H 0.1LN(C0)9.9L 0.1HN(B1)1.9H 0.1LN(C1)13.9L   \\
pd\_data [31:0]      & 2U N(A0) 2D{A0} 10U 2D{H1} 2D{D1} N(D1) 12U  \\
pd\_data [63:32]     & 2D{H0} 2D{D0} N(D0) 10U N(A1) 2D{A1} 14U          \\
wb\_adr\_o           & 4D{0} N(E0) 4D{A0} 10D{0} N(E1) 4D{A1} 8D{0} \\
wb\_dat\_o           & 4D{0} N(F0) 4D{D0} 10D{0} N(F1) 4D{D1} 8D{0}      \\
%
% there must NOT be an uncommented line before \extracode!
%
\extracode
    \draw[orange,semithick,->](A0) .. controls +(left:0.5cm)  and +(left:0.5cm) .. (B0);
    \draw[orange,semithick,->](C0) .. controls +(right:0.5cm) and +(left:0.5cm) .. (D0);
    \draw[orange,semithick,->](D0) .. controls +(right:0.5cm) and +(left:0.5cm) .. (E0);
    \draw[orange,semithick,->](D0) .. controls +(right:0.5cm) and +(left:0.5cm) .. (F0);
    \draw[orange,semithick,->](A1) .. controls +(left:0.5cm)  and +(left:0.5cm) .. (B1);
    \draw[orange,semithick,->](C1) .. controls +(right:0.5cm) and +(left:0.5cm) .. (D1);
    \draw[orange,semithick,->](D1) .. controls +(right:0.5cm) and +(left:0.5cm) .. (E1);
    \draw[orange,semithick,->](D1) .. controls +(right:0.5cm) and +(left:0.5cm) .. (F1);
    \begin{pgfonlayer}{background}
        \begin{scope}[gray,semitransparent,semithick]
            \vertlines {2,4,...,29}
        \end{scope}
    \end{pgfonlayer}

%%
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{tikztimingtable}

%Local variables:
% coding: utf-8
% mode: text
% mode: rst
% End:
% vim: fileencoding=utf-8 filetype=tex :

Figure 2.21 GN4124 Packet Decoder Write Request

Footnotes

1

Indication of provenance: StackExchange (TeX): a/30906 (sdaau and Count Zero)

2

Indication of provenance: StackExchange (TeX): a/236091 (Symbol 1)

3

Indication of provenance: StackExchange (TeX): a/255027 (Gonzalo Medina)

4

Indication of provenance: StackExchange (TeX): a/290027 (Habi)

5

Indication of provenance: https://nathantypanski.com/blog/2014-10-29-tikz-timing.html

6

Indication of provenance: https://github.com/terpstra/gn4124-core/