[Tex/LaTex] Tikz Timing change signal height of one signal

tikz-timingtiming-diagrams

I am currently drawing a timing diagramm and need to change the signal heigth of one signal. Is there a mechanism in tikz timing to do so?

This is my timing diagramm/ my minimal example:

\documentclass[12pt,a4paper]{article}
\usepackage{tikz-timing}
\begin{document}
\scalebox{1.5}{%
\begin{tikztimingtable}
    clk & 29{c} \\
    data\_in & 0.1l [[timing/slope=0.7]]hhhhllllllhhhhhlllll 0.4lhhhhlllll\\
    error & lllhhhhhhhhllhhhhhhh hllhhhhhh\\
    error\_reg & lllllhhhhhhhhllhhhhh hhhllhhhh\\
    data & lhhhhhhllllhhhhhhlll lllhhhhll\\
    data\_reg & lllhhhhhhllllhhhhhhl lllllhhhh\\
    early & lllllllllllhhlllllll lllllllll\\
    late & llllllllllllllllllll lllhhllll\\
    \extracode
    \makeatletter
    \begin{pgfonlayer}{background}
        \begin{scope}[gray,semitransparent,semithick]
            \foreach \x in {0.5,...,14.5}
                \draw (\x,1) -- (\x,-14);
            \draw(0,-1.1) -- (16,-1.1);
            \draw(0,-1.9) -- (16,-1.9);
            \node [anchor=south east,inner sep=0pt]
                at (18,-1.4) {\tiny Vrefp};
            \node [anchor= south east,inner sep=0pt]
                at (18,-2.2) {\tiny Vrefn};
        \end{scope}
    \end{pgfonlayer}
\end{tikztimingtable}
}%
\end{document}

The output looks like this, I want the data_in signal twice as high but all other signals should stay as they are:

Resulting output

Best Answer

Here I use y=2\yunit to double the height of the data\_in row as desired.

The tricky part is handling the spacing. The problem is that by the time the next row is created (using the internal representation of rowdist as a skip amount), any key settings done in the previous row are out of scope.

Conversely, by the time the key settings in the current row are executed, the current row has already been placed with the old rowdist, which gives the wrong spacing.

In this solution, I use a global key setting macro \gtikzset as defined in the accepted answer to How to globally tikzset styles. This is used to globally set timing/rowdist=3 at the end of the first row, which causes the second row to be created at the right spot. Then, at the beginning of the second row, I globally reset it to the original value, timing/rowdist=2 which holds for the rest of the table.

Other notes about your code:

  • \vertlines is provided by tikz-timing to place vertical grid lines, it can replace your \foreach loop for those.

  • Instead of manually positioning your annotations, you can use the named nodes provided by tikz-timing so you don't have to update them whenever the drawing changes. So

    \draw(0,-1.1) -- (16,-1.1);
    \draw(0,-1.9) -- (16,-1.9);
    \node [anchor=south east,inner sep=0pt]
        at (18,-1.4) {\tiny Vrefp};
    \node [anchor= south east,inner sep=0pt]
        at (18,-2.2) {\tiny Vrefn};
    

    becomes

    \draw (row2.high start) ++(0,-0.1) -- ++(16,0) node {Vrefp};
    \draw (row2.low start)  ++(0, 0.1) -- ++(16,0) node {Vrefn};
    

    where I have also specified \tiny as the font key within the scope.

Here's the complete code:

\documentclass[tikz]{standalone}
\usepackage{tikz-timing}
\newcommand\gtikzset[1]{%
\begingroup%
 \globaldefs=1\relax%
 \pgfqkeys{/tikz}{#1}%
\endgroup}

\begin{document}
\begin{tikztimingtable}
  clk        & 29{c}@{\gtikzset{timing/rowdist=3}}\\
  data\_in   & @{\gtikzset{timing/rowdist=2}}[y=2\yunit]0.1l 
                 [[timing/slope=0.7]]hhhhllllllhhhhhlllll 0.4lhhhhlllll\\
  error      & lllhhhhhhhhllhhhhhhh hllhhhhhh\\
  error\_reg & lllllhhhhhhhhllhhhhh hhhllhhhh\\
  data       & lhhhhhhllllhhhhhhlll lllhhhhll\\
  data\_reg  & lllhhhhhhllllhhhhhhl lllllhhhh\\
  early      & lllllllllllhhlllllll lllllllll\\
  late       & llllllllllllllllllll lllhhllll\\
  \extracode \background
  \begin{scope}[gray,semitransparent,semithick,node font=\tiny,anchor=west]
    \vertlines{0.5,...,\twidth}
    \draw (row2.high start) ++(0,-0.1) -- ++(16,0) node {Vrefp};
    \draw (row2.low start)  ++(0, 0.1) -- ++(16,0) node {Vrefn};
  \end{scope}
  \endbackground
\end{tikztimingtable}
\end{document}

And the result:

enter image description here

Related Question