2

How do I remove the clk signal in the wave environment?

enter image description here

I still want to keep alle the help lines (i.e. the t0, t1, etc.)

Here's the code:

\documentclass[11pt]{minimal}
\usepackage{tikz}

\newcounter{wavenum}

\setlength{\unitlength}{1cm}
% advance clock one cycle, not to be called directly
\newcommand*{\clki}{
  \draw (t_cur) -- ++(0,.3) -- ++(.5,0) -- ++(0,-.6) -- ++(.5,0) -- ++(0,.3)
    node[time] (t_cur) {};
}

\newcommand*{\bitvector}[3]{
  \draw[fill=#3] (t_cur) -- ++( .1, .3) -- ++(#2-.2,0) -- ++(.1, -.3)
                         -- ++(-.1,-.3) -- ++(.2-#2,0) -- cycle;
  \path (t_cur) -- node[anchor=mid] {#1} ++(#2,0) node[time] (t_cur) {};
}

% \known{val}{length}
\newcommand*{\known}[2]{
    \bitvector{#1}{#2}{white}
}

% \unknown{length}
\newcommand*{\unknown}[2][XXX]{
    \bitvector{#1}{#2}{black!20}
}

% \bit{1 or 0}{length}
\newcommand*{\bit}[2]{
  \draw (t_cur) -- ++(0,.6*#1-.3) -- ++(#2,0) -- ++(0,.3-.6*#1)
    node[time] (t_cur) {};
}

% \unknownbit{length}
\newcommand*{\unknownbit}[1]{
  \draw[ultra thick,black!50] (t_cur) -- ++(#1,0) node[time] (t_cur) {};
}

% \nextwave{name}
\newcommand{\nextwave}[1]{
  \path (0,\value{wavenum}) node[left] {#1} node[time] (t_cur) {};
  \addtocounter{wavenum}{-1}
}

% \clk{name}{period}
\newcommand{\clk}[2]{
    \nextwave{#1}
    \FPeval{\res}{(\wavewidth+1)/#2}
    \FPeval{\reshalf}{#2/2}
    \foreach \t in {1,2,...,\res}{
        \bit{\reshalf}{1}
        \bit{\reshalf}{0}
    }
}

% \begin{wave}[clkname]{num_waves}{clock_cycles}
\newenvironment{wave}[3][clk]{
  \begin{tikzpicture}[draw=black, yscale=.7,xscale=1]
    \tikzstyle{time}=[coordinate]
    \setlength{\unitlength}{1cm}
    \def\wavewidth{#3}
    \setcounter{wavenum}{0}
    \nextwave{#1}
    \foreach \t in {0,1,...,\wavewidth}{
      \draw[dotted] (t_cur) +(0,.5) node[above] {t$_{\t}$} -- ++(0,.4-#2);
      \clki
    }
}{\end{tikzpicture}}

%%% End of timing.sty


\begin{document}

\begin{wave}{4}{9}
\nextwave{handshake\_out\_RPi}
    \bit{0}{1}
    \bit{1}{2}
    \bit{0}{2}
    \bit{1}{3}
    \bit{0}{2}
\nextwave{data\_out\_RPi}
    \bit{0.5}{1}
    \known{}{2}
    \bit{0.5}{2}
    \known{}{3}
    \bit{0.5}{2}    
\nextwave{handshake\_out\_UR5}
    \bit{0}{2}
    \bit{1}{2}
    \bit{0}{3}
    \bit{1}{2}
    \bit{0}{1}
\end{wave}

\end{document}
  • Try to comment %\bit{\reshalf}{1} and %\bit{\reshalf}{0} in the clk definition. – Sigur Apr 24 '15 at 9:43
3

You can do it like this:

  1. Delete clk in \newenvironment{wave}[3][clk], just the word, leave the brackets empty like [] (line 58).

  2. Replace \draw with \path in (line 9).

    \newcommand*{\clki}{ \path (t_cur) -- ++(0,.3) -- ++(.5,0) -- ++(0,-.6) -- ++(.5,0) -- ++(0,.3) node[time] (t_cur) {};}

    Previously it said to add [draw=none] to \draw, corrected thanks to Sigur's suggestion.

  3. Comment this bit (line 47-55):

    \newcommand{\clk}[2]{ \nextwave{#1} \FPeval{\res}{(\wavewidth+1)/#2} \FPeval{\reshalf}{#2/2} \foreach \t in {1,2,...,\res}{ \bit{\reshalf}{1} \bit{\reshalf}{0} } }

figure 1

  • 1
    You can use \path instead of \draw[draw=none] and after, to draw it again, \path[draw]. – Sigur Apr 24 '15 at 10:12
  • @Sigur Awesome :D I'll add that. Thank you. – Alenanno Apr 24 '15 at 10:15
  • @Alenanno thank you! That works perfectly. Now i just have to move the t1, t2, etc. down a bit – Nicolai Anton Lynnerup Apr 24 '15 at 10:23
  • 1
    For others: I edited line 66: \draw[dotted] (t_cur) +(0,.5) node[above] {t$_{\t}$} -- ++(0,.4-#2); to \draw[dotted] (t_cur) +(0,-0.5) node[above] {t$_{\t}$} -- ++(0,.4-#2); – Nicolai Anton Lynnerup Apr 24 '15 at 10:31
  • @NicolaiAntonLynnerup Ah I see you already reached a solution :D – Alenanno Apr 24 '15 at 10:32
3

In case tikz-timing could be considered, the desired diagram could be done with something like

\documentclass[tikz,border=3mm]{standalone}

\usepackage{tikz-timing}
\begin{document}
\begin{tikztimingtable}
handshake\_out\_RPi& 2L 4H 6L 6H 2L\\
data\_out\_RPi & 2Z[black] 4D 4Z[black] 6D 4Z[black]\\
handshake\_out\_UR5 & 4L 4H 6L 4H 2L\\
\extracode
\begin{pgfonlayer}{background}
\vertlines[help lines]{0,2,...,20}
\foreach \i [count=\col from 0] in {0,2,...,20}
    \node[font=\scriptsize] at (\i,2) {$t_{\col}$};
\end{pgfonlayer}
 \end{tikztimingtable}%
 \end{document}

enter image description here

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.