4

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

  • Can you provide a minimal working example? – Peter Ebelsberger Apr 29 '15 at 13:13
  • Updated the example... – TM90 Apr 29 '15 at 13:17
3
+50

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

  • 1
    If the package author reads this answer: it might be nice to implement \\[<extra-skip-amt>] to make this adjustment easier in the rare case it needs to be done. – Paul Gessler Apr 29 '15 at 15:42
1

I am not sure but is it enough to just add yscale=2 to the relevant line?

 data\_in & 0.1l [[timing/slope=0.7,yscale=1.8]]hhhhllllllhhhhhlllll

This produces:

enter image description here

If the date\_in line shouldn't run into ythe clk line the changing this is yscale=1.8 separates them, but then it is perhaps not quite what you want...

The full code:

\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,yscale=2]]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}
  • I think this is a first approach in the right direction. The main problem now is that the spacing between clk and data_in is not correct... – TM90 Apr 29 '15 at 13:52
  • @TM90 What should the spacing look like? – Andrew Apr 29 '15 at 13:53
  • Basically exactly like the spacings between the other unmodified signals – TM90 Apr 29 '15 at 13:54
0

Distance can be changed by adding this short piece of code to the preamble....

\makeatletter
    \def\tikztiming@rowdist{3}%
\makeatother
  • 2
    But this would apply to every row or am I misunderstanding this solution? – TM90 Apr 29 '15 at 14:06
  • You are absolut right. But in this case the space of each row is identically. Sure, the distance between the rows is unequal... – Peter Ebelsberger Apr 29 '15 at 14:11
  • For me as mentioned the spacing between the signals is important. – TM90 Apr 29 '15 at 14:12
  • You can also do this with \begin{tikztimingtable}[timing/rowdist=3].... The manual suggests that one should be able to add timing/rowdist=3 into the row specifications but this doesn't have any effect:( – Andrew Apr 29 '15 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.