%%
%% This is file `tikz-timing.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tikz-timing.dtx  (with options: `tikz-timing.sty')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from tikz-timing.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file tikz-timing.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% Copyright (C) 2009-2012 by Martin Scharrer <martin@scharrer-online.de>
%% ----------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Martin Scharrer.
%%
%% This work consists of the files tikz-timing.dtx and tikz-timing.ins
%% and the derived filebase tikz-timing*.sty.
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{tikz-timing}[%
    2017/12/20
    v0.7f
    Digital Timing Diagrams using TikZ]
\RequirePackage{tikz}

\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\usetikzlibrary{decorations.pathmorphing}
\ifx\collect@body\@undefined
  \IfFileExists{environ.sty}
    {\RequirePackage{environ}}
    {\RequirePackage{amsmath}}
\fi
\def\tikztimingwidth{0.0}
\newcount\tikztiming@numint
\newcount\tikztiming@numfrac
\def\tikztiming@wscale{1.0}%
\def\tikztimingsetwscale#1{%
  \pgfmathparse{#1}%
  \let\tikztiming@wscale\pgfmathresult
}
\def\tikztiming@num{0.0}%
\let\tikztiming@back\empty
\newlength\tikztiming@xunit
\newlength\tikztiming@yunit
\def\tikztiming@@xunit{1.6ex}%
\def\tikztiming@@yunit{1.6ex}%
\setlength{\tikztiming@xunit}{\tikztiming@@xunit}%
\setlength{\tikztiming@yunit}{\tikztiming@@yunit}%

\def\tikztiming@setnum#1{%
  \pgfmathparse{#1}%
  \global\let\tikztiming@num\pgfmathresult
}

\newcount\tikztiming@debug

\def\tikztiming@xsep{0pt}
\def\tikztiming@ysep{0pt}

\newcounter{tikztiming@nrows}%
\def\tikztiming@rowdist{2}%
\def\tikztiming@coldist{1}%

\def\tikztiming@prefix{tikztiming@trans@}%
\def\tikztiming@ttt#1#2#3{#1#2#3}%
\def\tikztiming@pfxtr{%
  \tikztiming@prefix\expandafter\tikztiming@ttt
}

\def\timingwidth{1}%
\def\timingheight{1}%

\tikzset{%
  timing/.style={/tikz,
    line cap=round, line join=round,
    timing/adjust@xy,
    every path/.append code={\tikz@expandcount=\tikztiming@expandcount\relax},
  },%
}
\tikzset{%
  timing/.cd,
  adjust@xy/.style={%
    /utils/exec={%
      \tikz@textfont
      \let\@tempa\fsize
      \let\fsize\@tempdima
      \fsize=\f@size pt\relax
      \pgfmathsetlength{\tikztiming@xunit}{\tikztiming@@xunit}%
      \pgfmathsetlength{\tikztiming@yunit}{\tikztiming@@yunit}%
      \let\fsize\@tempa
    },%
    /tikz/x=\tikztiming@xunit, /tikz/y=\tikztiming@yunit,
  },
  expand count/.store in={\tikztiming@expandcount},
  expand count=1000,
  unit/.style={%
    /utils/exec={%
      \def\tikztiming@@xunit{#1}%
      \let\tikztiming@@yunit\tikztiming@@xunit
    },%
    /tikz/timing/adjust@xy,%
  },
  xunit/.style={%
    /utils/exec={%
      \def\tikztiming@@xunit{#1}%
    },%
    /tikz/timing/adjust@xy,%
  },
  yunit/.style={%
    /utils/exec={%
      \def\tikztiming@@yunit{#1}%
    },%
    /tikz/timing/adjust@xy,%
  },
  font/.style={%
    /tikz/font={#1},
    /tikz/timing/adjust@xy
  },%
  initchar/.value required,
  initchar/.code={\uppercase{\gdef\tikztiming@lastchar{#1}}},
  metachar/.code={\tikztimingmetachar#1},
  grid/.style={timing,help lines},
  @grid/.code={\texttiminggrid},
  draw grid/.style={%
    timing/before text/.append style={timing/@grid},%
    timing/before/.append style={timing/@grid}%
  },
  no grid/.style={timing/@grid/.code={}},
  before/.code={},
  after/.code={},
  before text/.code={\texttimingbefore},
  after text/.code={\texttimingafter},
  picture/.style={timing,line width=0.15ex},
  intext/.style={timing,line width=0.15ex},
  inline node/.style={shape=coordinate},
  inline node/from char/.store in=\tikztiming@node@fromchar,
  inline node/to char/.store in=\tikztiming@node@tochar,
  table/.style={font=\sffamily,timing,line width=0.15ex},
  before table/.code={},
  after table/.code={},
  coord/.style={coordinate},
  save/.style={coordinate},
  restore/.style={/utils/exec={\expandafter\tikzset\expandafter{\tikztiming@saved@options}}},
  option/.style={/utils/exec={\g@addto@macro\tikztiming@saved@options{#1,}},#1},
  nooptions/.style={/utils/exec={\gdef\tikztiming@saved@options{}}},
  popoptions/.style={/utils/exec={\tikztiming@popoptions}},
  pushoptions/.style={/utils/exec={\tikztiming@pushoptions}},
  name/.style={inner sep=0pt,outer sep=0pt,minimum size=0pt},
  text format/.store in=\tikztiming@textformat,
  @/.style={},
  every char/.style={},
  every bg/.style={},
  D/.style={timing/d},
  D/text/.style={timing/d/text},
  D/background/.style={timing/d/background},
  D@edge@/.style={timing/d@edge@},
  D@edge@/text/.style={timing/d@edge@/text},
  D@edge@/background/.style={timing/d@edge@/background},
  U/.style={timing/u},
  U/text/.style={timing/u/text},
  U/background/.style={timing/u/background},
  U@edge@/.style={timing/u@edge@},
  U@edge@/text/.style={timing/u@edge@/text},
  U@edge@/background/.style={timing/u@edge@/background},
  H/.style={timing/h},
  L/.style={timing/l},
  E/.style={timing/e},
  E/background/.style={timing/e/background},
  M/decoration/.style={timing/m/decoration},
  M/base/.style={timing/m/base},
  M/.style={timing/m},
  G/.style={timing/g},
  Z/.style={timing/z},
  T/.style={timing/t},
  C/.style={timing/c},
  X/.style={timing/x},
  d/.style={},
  d/text/.style={timing,scale=0.6,font=\sffamily},
  d/background/.style={draw=none},
  d@edge@/.style={timing/d},
  d@edge@/text/.style={timing/d/text},
  d@edge@/background/.style={timing/d/background},
  u/.style={},
  u/background/.style={draw=none,fill=gray},
  u@edge@/.style={timing/u},
  u@edge@/text/.style={timing/u/text},
  u@edge@/background/.style={timing/u/background},
  h/.style={},
  l/.style={},
  e/.style={},
  e/background/.style={draw=none},
  m/decoration/.style={decorate,%
    decoration={zigzag,segment length=.25\tikztiming@xunit,
    amplitude=.225\tikztiming@yunit}},
  m/base/.style={black!40!brown},
  m/.style={timing/m/base,timing/m/decoration},
  g/.style={decorate=false},
  z/.style={blue},
  t/.style={},
  c/.style={timing/lslope=0.0},
  x/.style={red},
  table/grid/.style={timing/grid},
  table/lines/.style={},
  table/rules/.style={line width=0.08em,line cap=butt},
  table/midrules/.style={line width=0.05em,line cap=butt},
  table/header/.style={timing/name},
  table/label header/.style={},
  table/row header/.style={},
  slope/.code={%
    \tikztimingsetslope{#1}%
    \tikztimingsetdslope{2*#1}%
    \tikztimingsetzslope{#1/2}%
  },
  lslope/.code={\tikztimingsetslope{#1}},
  dslope/.code={\tikztimingsetdslope{#1}},
  zslope/.code={\tikztimingsetzslope{#1}},
  wscale/.code={\tikztimingsetwscale{#1}},
  coldist/.store in=\tikztiming@coldist,
  rowdist/.store in=\tikztiming@rowdist,
  outer xsep/.store in=\tikztiming@xsep,
  outer ysep/.store in=\tikztiming@ysep,
  outer sep/.style={/tikz/timing/outer xsep=#1,/tikz/timing/outer ysep=#1},
  %
  debug/level/.code={\tikztiming@debug=#1\relax},
  debug/level/.value required,
  debug/scope/.style={font=\sffamily\tiny,gray},
  debug/node/.style={above,inner sep=2pt},
  debug/nodes/.style={%
    /tikz/timing/after table/.append code={\tikztiming@marknodes{\tikztiming@namednodes}},
    /tikz/timing/after text/.append code={\tikztiming@marknodes{\tikztiming@namednodes}}
  },
  debug/markcmd/.store in={\tikztiming@markcmd},
}
\tikzset{timing/inline node/.cd,
  from char={}, to char={}
}
\def\texttimingbefore{}
\def\texttimingafter{}
\def\texttiminggrid{%
  \draw[xstep={\timingwidth/2.},ystep={\timingheight/2.},timing/grid] (0,0) grid
  (\timingwidth*\tikztimingwidth,\timingheight);
}
\DeclareRobustCommand*\texttiming[2][]{%
  \begingroup
    \let\tikztiming@lastchar\empty
    \let\tikztiming@settings\empty
    \tikzset{timing/before/.append style={timing/before text}}%
    \tikzset{timing/after/.prefix style={timing/after text}}%
    \ifx\relax#1\relax\else
      \tikztiming@testoptarg#1\relax\relax%
    \fi
    \begin{tikzpicture}[timing/intext,baseline={(0,0)}]
      \tikztiming@picinit
      \def\@tempa{\expandafter\timing\expandafter[\tikztiming@settings] at (0,0)}%
      \expandafter\@tempa\expandafter{\expandafter[\tikztiming@lastchar]#2};%
    \end{tikzpicture}%
  \endgroup
}
\def\tikztiming@testoptarg#1#2\relax{%
  \ifx\relax#2\relax
    \uppercase{\def\tikztiming@lastchar{#1}}%
  \else
    \def\tikztiming@settings{#1#2}%
  \fi
}
\def\tikztiming@picinit{%
    \global\let\tikztiming@namednodes\empty
}
\let\tikztiming@namednodes\empty
\def\tikztiming@init{%
    \def\tikztiming@lastchar{@}%
    \def\tikztiming@num{0}%
    \let\tikztiming@currentchar\empty
    \let\tikztiming@settings\empty
    \let\tikztiming@fromchar\empty
    \let\tikztiming@tochar\empty
    \let\setwscale\tikztimingsetwscale
    \def\wscale{\tikztiming@wscale}%
    \let\xunit\tikztiming@xunit
    \let\yunit\tikztiming@yunit
    \def\slope{\timingslope}%
    \def\lslope{\timingslope}%
    \def\zslope{\timingzslope}%
    \def\dslope{\timingdslope}%
    \gdef\tikztiming@saved@settings{}%
    \gdef\tikztiming@saved@options{}%
    \gdef\tikztiming@oldnodecenter@{}%
    \def\tikztimingwidth{0.0}%
    \setcounter{tikztimingtrans}{-1}%
    \setcounter{tikztimingtranspos}{0}%
    \tikztiming@initstr{%
      \useasboundingbox (0,0) rectangle (\tikztimingwidth,\timingheight);
      \draw [timing/every char] (0,0)
        coordinate (timing@refa)
        coordinate (timing@ref)  at (0,\timingheight/2)
        coordinate (timing@refb) at (0,\timingheight)
        coordinate (timing/start)
        coordinate (timing/start base)
    }%
}
\def\tikz@timing{%
  \@ifnextchar{[}%
    {\tikz@timing@}%
    {\tikz@timing@[]}%
}
\g@addto@macro\tikz@installcommands{%
  \let\tikz@origtiming=\timing%
  \let\timing=\tikz@timing%
}
\g@addto@macro\tikz@uninstallcommands{%
  \let\timing=\tikz@origtiming%
}
\def\tikz@timing@[#1]{%
  \@ifnextchar{a}%
    {\tikz@timing@at{#1}}%
    {\PackageWarning{tikz-timing}{The \string\timing\space command awaits now an
    `at' before the coordinate, like the \string\node\space command is doing.
    Please update your source code to ensure compatibility with newer
    versions}{}{}{}%
     \@ifnextchar{+}%
      {\tikz@timing@@{#1}}%
      {\@ifnextchar(%)
        {\tikz@timing@@{#1}}%
        {\tikz@timing@@{#1}++(0,0)}%
      }%
    }%
}
\def\tikz@timing@at#1at#2(#3){%
  \tikz@timing@@@{#1}{#2(#3)}%
}
\def\tikz@timing@@#1#2(#3){%
  \tikz@timing@@@{#1}{#2(#3)}%
}
\def\tikz@timing@@@#1#2#3{%
  \begingroup
    \tikztiming@init
    \let\tikz@alias=\pgfutil@empty%
    \begin{scope}[shift={#2},timing,#1]%
      \@ifnextchar{[}%
        {\tikz@timing@@@init}%
        {\tikz@timing@@@init[]}%
      #3\relax
      \tikzset{timing/before}%
      \tikztiming@str;%
      \path let \p1 = (timing/end top), \p2 = (timing/end base),
                \p3 = (timing/end), \p4 = (timing/start) in
          [/utils/exec={%
            \xdef\tikztiming@northeast{\noexpand\pgfpoint{.5*\pgf@pt@aa*\x1}{.5*\pgf@pt@bb*\y1}}%
            \xdef\tikztiming@startpoint{\noexpand\pgfpoint{\pgf@pt@aa*(\x4-.5*\x1)}{\pgf@pt@bb*(\y4-.5*\y1)}}%
            \xdef\tikztiming@endpoint{\noexpand\pgfpoint{\pgf@pt@aa*(\x3-.5*\x1)}{\pgf@pt@bb*(\y3-.5*\y1)}}%
          }];
      \node [shape=tikztiming@shape,anchor=origin,#1] at (0,0) {};
      \tikzset{timing/after}%
    \end{scope}%
  \endgroup
  \tikz@timing@@@end
}
\def\tikz@timing@@@end{%
  \@ifnextchar{;}%
    {\@gobble}%
    {\PackageError{tikz-package}{Can not parse timing path}{}}%
}
\def\tikz@timing@@@init[#1]{%
  \begingroup
  \ifx\relax#1\relax\else
    \uppercase{\def\tikztiming@lastchar{#1}}%
  \fi
  \@ifundefined{tikztiming@initcode@\tikztiming@lastchar}%
    {}%
    {\@nameuse{tikztiming@initcode@\tikztiming@lastchar}}%
  \if @\tikztiming@lastchar\relax\else
  \tikztiming@iftrans{@\tikztiming@lastchar}%
    {\tikztiming@nameaddtostr{@}{\tikztiming@lastchar}{}}%
    {\PackageWarning{tikz-timing}{Start value for timing character
    '\tikztiming@lastchar' is not defined and will be ignored!}{}{}{}}%
  \fi
  \tikztiming@parser
}
\def\tikztiming@trans@#1#2#3#4{%
    \unexpanded\expandafter\expandafter\expandafter{%
        \csname\tikztiming@prefix #2#3#4\endcsname{#1}{#2}{#3}{#4}
    }%
}
\def\tikztiming@beforenextcode@D@edge@{%
  \if D\tikztiming@currentchar\else
    \gdef\tikztiming@lastchar{D}%
  \fi
}
\def\tikztiming@beforenextcode@U@edge@{%
  \if U\tikztiming@currentchar\else
    \gdef\tikztiming@lastchar{U}%
  \fi
}
\def\tikztiming@initcode@{%
  \gdef\tikztiming@lastchar{@}%
}
\def\tikztiming@initcode@D{%
  \gdef\tikztiming@lastchar{D@edge@}%
}
\def\tikztiming@initcode@U{%
  \gdef\tikztiming@lastchar{U@edge@}%
}
\def\tikztiming@parser{%
  \@ifnextchar\relax
    {\tikztiming@parser@end}%
    {\tikztiming@testfornum}%
}
\def\tikztiming@eaddto#1#2{%
  \begingroup
    \tikztiming@internaldefs
    \@temptokena\expandafter{#1}%
    \xdef#1{%
      \the\@temptokena
      #2%
    }%
  \endgroup
}
\iftrue
\long\def\tikztiming@initstr{%
    \def\tikztiming@str
}
\def\tikztiming@eaddtostr{%
  \tikztiming@eaddto\tikztiming@str
}
\def\tikztiming@addtostr{%
  \g@addto@macro\tikztiming@str
}
\else
\def\tikztiming@file{\jobname.ttg}
\newwrite\tikztiming@fh
\def\tikztiming@str{%
    \tikztiming@addtostr{;}%
    \immediate\closeout\tikztiming@fh
    \begingroup
    \makeatletter
    \@@input\tikztiming@file\relax
    \endgroup
    \@ifnextchar;{\@gobble}{}%
}
\long\def\tikztiming@initstr{%
    \immediate\openout\tikztiming@fh= \tikztiming@file\relax
    \tikztiming@addtostr
}
\long\def\tikztiming@eaddtostr#1{%
  \begingroup
    \tikztiming@internaldefs
    \let\par\empty
    \immediate\write\tikztiming@fh{#1}%
  \endgroup
}
\long\def\tikztiming@addtostr#1{%
  \begingroup
    \tikztiming@internaldefs
    \let\par\empty
    \immediate\write\tikztiming@fh{\unexpanded{#1}}%
  \endgroup
}
\fi
\def\tikztiming@makeglobal#1{%
  \global\let#1#1\relax\relax
}
\def\tikztiming@trans{}%
\def\tikztiming@iftrans#1{%
  \tikztiming@iftrans@#1\empty\empty\empty\relax
}
\def\tikztiming@iftrans@#1#2#3#4\relax{%
  \begingroup
  \xdef\tikztiming@trans{#1#2}%
  \ifx\tikztiming@trans\empty
    \gdef\tikztiming@trans{{@}{}{@}}%
  \else
    \global\let\tikztiming@trans\relax
    % Use triple macros before double macros
    \@ifundefined{tikztiming@triple@#2}%
      {\@ifundefined{\tikztiming@prefix#1#2}%
        {}%
        {\xdef\tikztiming@trans{{#1}{#2}{}}}%
      }%
      {%
      \@ifundefined{\tikztiming@prefix#1#2#3}%
        {}%
        {\xdef\tikztiming@trans{{#1}{#2}{#3}}}%
      }%
    % If both do not exist, search for aliases:
    \ifx\tikztiming@trans\relax
      \@ifundefined{tikztiming@alias@#1}%
        {\edef\chara{{#1}}}%
        {\edef\chara{{#1},{\csname tikztiming@alias@#1\endcsname}}}%
      \@ifundefined{tikztiming@alias@#2}%
        {\edef\charb{{#2}}}%
        {\edef\charb{{#2},{\csname tikztiming@alias@#2\endcsname}}}%
      \@ifundefined{tikztiming@triple@#2}%
        {\def\charc{\empty}}%
        {%
         \@ifundefined{tikztiming@alias@#3}%
           {\edef\charc{{#3},}}%
           {\edef\charc{{#3},{\csname tikztiming@alias@#3\endcsname},}}%
        }%
      \ifx\charb\empty
        \def\charb{\empty}%
      \fi
      \let\tikztiming@next\relax
      \foreach \b in \charb {%
        \foreach \a in \chara {%
          \foreach \c in \charc {%
            %\message{ ^^J Testing: \a\b\c ^^J}%
            \@ifundefined{\tikztiming@prefix\a\b\c}%
              {}{%
                \xdef\tikztiming@trans{{#1}{#2}{#3}}%
                \expandafter\tikztimingcpy\expandafter
                  {\tikztiming@trans}{\a\b\c}%
                \ifnum\tikztiming@debug>0
                  \message{^^J DEBUG: '#1#2#3' = '\a\b\c' ^^J}%
                \fi
                \expandafter\tikztiming@makeglobal
                \csname\tikztiming@pfxtr\tikztiming@trans\endcsname
                \ifnum\tikztiming@debug>1
                  \ifnum\tikztiming@debug>2
                    \expandafter\show\csname\tikztiming@pfxtr\tikztiming@trans\endcsname
                  \else
                    \message{^^J\tikztiming@trans:
                    \expandafter\meaning\csname\tikztiming@pfxtr\tikztiming@trans\endcsname^^J}%
                    \message{^^J\a\b\c:
                    \expandafter\meaning\csname\tikztiming@prefix\a\b\c\endcsname^^J}%
                  \fi
                \fi
                \global\let\tikztiming@next\breakforeach
              }%
            \tikztiming@next
          }%
          \tikztiming@next
        }%
        \tikztiming@next
      }%
    \fi
  \fi
  \endgroup
  \ifx\tikztiming@trans\relax
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi
}
\def\tikztiming@nameaddtostr#1#2#3{%
  \tikztiming@iftrans{{#1}{#2}{#3}}%
   {%
     %\edef\@tempa{\noexpand\tikztiming@trans@{\tikztiming@num}\tikztiming@trans}%
     %\expandafter\tikztiming@addtostr
     %\expandafter{\@tempa}%
     \edef\@tempa{\noexpand\tikztiming@trans@{\tikztiming@num}\tikztiming@trans}%
     %\tikztiming@eaddtostr{\@percentchar\space {#1}{#2}{#3}}%
     \tikztiming@eaddtostr{\@tempa}%
     %\tikztiming@eaddtostr{\tikztiming@trans@{\tikztiming@num}\tikztiming@trans}%
   }%
   {\PackageWarning{tikz-timing}{No transitions '#1#2' (or '#1#2#3') defined!}}%
}
\def\tikztiming@output@addcode#1{%
  \g@addto@macro\tikztiming@output@bufcode{\unexpanded{ #1 }}%
}
\def\tikztiming@output@eaddcode#1{%
  \g@addto@macro\tikztiming@output@bufcode{ #1 }%
}
\def\tikztiming@output@Eaddcode{%
  \tikztiming@eaddto\tikztiming@output@bufcode%
}
\def\tikztiming@output@bufchara{}%
\def\tikztiming@output@bufcharb{}%
\def\tikztiming@output@bufnum{0}%
\def\tikztiming@output@bufcode{}%
\def\tikztiming@output@nextchar{}%
\def\tikztiming@output#1#2{%
  \edef\tikztiming@fromchar{#1}%
  \edef\tikztiming@tochar{#2}%
  \ifx\relax#2\relax
    %\tikztiming@output@codeflush
    \tikztiming@nameaddtostr{}{#1}{}%
  \else
    \ifcase0%
      \ifx\tikztiming@output@bufchara\empty
        \ifx\tikztiming@output@bufcharb\empty
          1%
        \fi
      \fi\relax
      % not empty
      \edef\tikztiming@output@currentchar{#2}%
      \ifcase0%
       \ifx\tikztiming@output@bufcode\empty% Stop combining if code was inserted
        \expandafter\ifx\csname tikztiming@nocombine@#2\endcsname\relax
         \ifx\tikztiming@output@currentchar\tikztiming@output@bufcharb
           2%
         \fi
        \fi
       \else
         1%
       \fi
      \relax
        \edef\tikztiming@output@nextchar{#2}%
        \tikztiming@output@flush
        \xdef\tikztiming@output@bufchara{#1}%
        \xdef\tikztiming@output@bufcharb{#2}%
      \or
        \edef\tikztiming@output@nextchar{#2}%
        \tikztiming@output@flush
        \xdef\tikztiming@output@bufchara{#1}%
        \xdef\tikztiming@output@bufcharb{#2}%
      \or
        \pgfmathparse{\tikztiming@output@bufnum + \tikztiming@num}%
        \global\let\tikztiming@output@bufnum\pgfmathresult
      \fi
    \else % empty
      \tikztiming@output@codeflush
      \xdef\tikztiming@output@bufchara{#1}%
      \xdef\tikztiming@output@bufcharb{#2}%
      \global\let\tikztiming@output@bufnum\tikztiming@num
    \fi
  \fi
}
\def\tikztiming@output@flush{%
  \tikztiming@output@charflush
  \tikztiming@output@codeflush
}
\def\tikztiming@output@codeflush{%
  \ifx\tikztiming@output@bufcode\empty\else
    \tikztiming@eaddtostr{\tikztiming@output@bufcode}%
    \global\let\tikztiming@output@bufcode\empty%
  \fi
}
\def\tikztiming@output@charflush{%
  \begingroup
    \let\tikztiming@num\tikztiming@output@bufnum
    \tikztiming@nameaddtostr
      {\tikztiming@output@bufchara}%
      {\tikztiming@output@bufcharb}%
      {\tikztiming@output@nextchar}%
  \endgroup%
  \gdef\tikztiming@output@nextchar{}%
  \gdef\tikztiming@output@bufchara{}%
  \gdef\tikztiming@output@bufcharb{}%
  \global\let\tikztiming@output@bufnum\tikztiming@num
}
\newcommand\tikztiming@nameedef[4]{%
  \def\@gtempa##1{#4}%
  \begingroup
    \tikztiming@internaldefs
    \xdef\@gtempa##1##2##3##4{\@gtempa{\width}}%
  \endgroup
  \expandafter\let\csname\tikztiming@prefix#1#2#3\endcsname\@gtempa
  \let\@gtempa\empty
}
\newcommand\tikztiming@namelet[2]{%
  \ifcase0%
    \@ifundefined{\tikztiming@prefix#2}%
      {\@ifundefined{\tikztiming@prefix#1}%
        {0}{1}%
      }%
      {1}%
    \relax
  \else
    \expandafter\let
    \csname\tikztiming@prefix#1\expandafter\endcsname
    \csname\tikztiming@prefix#2\endcsname
  \fi
}
\def\tikztiming@parser@end{%
  \def\tikztiming@output@nextchar{@}%
  \let\tikztiming@fromchar\tikztiming@tochar
  \edef\tikztiming@tochar{@}%
  \tikztiming@output@flush
  \global\let\tikztimingwidth\tikztimingwidth
  \tikztiming@addtostr{ coordinate (timing/end)
    let \p1 = (timing/start base), \p2 = (timing/end), \p3 = (0,1) in
      coordinate (timing/end base) at (\x2,\y1)
      coordinate (timing/end top)  at (\x2,\y1+\y3)
  }%
  \endgroup
  \tikztiming@endhook%
}
\let\tikztiming@endhook\relax
\def\tikztiming@parser@#1{%
  \ifx\relax#1\empty
    \expandafter\tikztiming@parser@end
  \else
    \tikztiming@iflower{#1}%
      {\tikztiming@setnum{\tikztiming@num/2}}%
      {}%
    \ifx\tikztiming@back\empty\else
      \tikztiming@setnum{\tikztiming@num - \tikztiming@back}%
      \global\let\tikztiming@back\empty
    \fi
    \pgfmathparse{\tikztimingwidth + \tikztiming@num}%
    \global\let\tikztimingwidth\pgfmathresult
    \uppercase{\gdef\tikztiming@currentchar{#1}}%
    \@nameuse{tikztiming@beforenextcode@\tikztiming@lastchar}%
    \@nameuse{tikztiming@beforecode@\tikztiming@currentchar}%
    \tikztiming@output{\tikztiming@lastchar}{\tikztiming@currentchar}%
    \global\let\tikztiming@lastchar\tikztiming@currentchar
    \@nameuse{tikztiming@aftercode@\tikztiming@currentchar}%
    \expandafter\lowercase\expandafter{%
      \expandafter\def\expandafter\@tempa
      \expandafter{\tikztiming@currentchar}%
    }%
    \pgfkeysifdefined{/tikz/timing/\@tempa/text/.@cmd}%
      {\expandafter\expandafter\expandafter\tikztiming@testfortext}%
      {\expandafter\expandafter\expandafter\tikztiming@parser}%
  \fi
}
\def\tikztiming@testfortext{%
  \@ifnextchar\bgroup
    {\tikztiming@handletext}%
    {\tikztiming@parser}%
}
\def\tikztiming@handletext#1{%
  \@ifnextchar\relax
    {\def\tikztiming@output@nextchar{@}\tikztiming@handletext@{#1}}%
    {\def\tikztiming@output@nextchar{Z}\tikztiming@handletext@{#1}}%
}
\def\tikztiming@handletext@#1{%
  \@ifnextchar{[}%
    {\tikztiming@handletext@@}%
    {\tikztiming@handletext@@[]}%
  #1\tikztiming@endoftext
}
\def\tikztiming@handletext@@[#1]#2\tikztiming@endoftext{%
  \@ifnextchar{\relax}%
    {\def\tikztiming@output@nextchar{@}%
     \tikztiming@handletext@@@{#1}{#2}}%
    {\tikztiming@handletext@@@{#1}{#2}}%
}
\def\tikztiming@handletext@@@#1#2{%
  \expandafter\lowercase\expandafter{%
    \expandafter\def\expandafter\@tempa
    \expandafter{\tikztiming@currentchar}%
  }%
  \edef\@tempa{node [timing/\@tempa/text,}%
  \expandafter\tikztiming@output@addcode\expandafter{%
    \@tempa
    #1] at ($ (timing@dstart) !.5! (timing@dend) $)
    {\tikztiming@textformat{#2}}
  }%
  \ifcase0%
    \if @\tikztiming@output@bufchara
      1%
    \else
      \ifx\tikztiming@output@bufchara\tikztiming@currentchar
        1%
      \fi
    \fi
  \relax
  \else
  \fi
  \xdef\tikztiming@output@bufcharb{\tikztiming@currentchar @edge@}%
  \xdef\tikztiming@lastchar{\tikztiming@currentchar @edge@}%
  \tikztiming@parser
}
\let\tikztiming@textformat\empty
\def\tikztiming@defcode#1{%
  \@namedef{tikztiming@code@\meaning#1}%
}
\tikztiming@defcode{@}#1{%
  #1\relax
  \tikztiming@parser
}
\begingroup
  \expandafter\let\expandafter\temp
    \csname tikztiming@code@\meaning @\endcsname
  \makeatother
  \expandafter\global\expandafter\let
    \csname tikztiming@code@\meaning @\endcsname\temp
\endgroup
\tikztiming@defcode$#1${%
  \pgfmathparse{#1}%
  \expandafter
  \tikztiming@parser\pgfmathresult
}
\tikztiming@defcode{,}{%
  \tikztiming@output@eaddcode{%
    \newdraw [timing/every char]
  }%
  \tikztiming@parser
}
\tikztiming@defcode{;}{%
  \endgroup\begingroup
  \tikztiming@output@eaddcode{%
    \newdrawns [timing/every char]
  }%
  \tikztiming@parser
}
\tikztiming@defcode{N}{%
  \@ifnextchar[%]
    {\tikztiming@addnode@getoptions}%
    {\tikztiming@addnode@getoptions[]}%
}
\tikztiming@defcode{n}{%
  \@ifnextchar[%]
    {\tikztiming@addnode@getoptions}%
    {\tikztiming@addnode@getoptions[]}%
}
\tikztiming@defcode{B}{%
  \pgfmathparse{\tikztiming@back+\tikztiming@num}%
  \global\let\tikztiming@back\pgfmathresult
  \tikztiming@parser
}
\tikztiming@defcode{b}{%
  \pgfmathparse{\tikztiming@back+\tikztiming@num/2}%
  \global\let\tikztiming@back\pgfmathresult
  \tikztiming@parser
}
\tikztiming@defcode{F}{%
  \pgfmathparse{\tikztiming@back-\tikztiming@num}%
  \global\let\tikztiming@back\pgfmathresult
  \tikztiming@parser
}
\tikztiming@defcode{f}{%
  \pgfmathparse{\tikztiming@back-\tikztiming@num/2}%
  \global\let\tikztiming@back\pgfmathresult
  \tikztiming@parser
}
\tikztiming@defcode[{%}]{
  \@ifnextchar[%]
    {\tikztiming@bothoption}%
    {\@ifnextchar{!}%
      {\tikztiming@parseroption}%
      {\@ifnextchar{|}%
        {\tikztiming@onceoption}%
        {\tikztiming@addoption}%
      }%
    }%
}
\def\tikztiming@parseroption!#1!]{%
  \pgfqkeys{/tikz/timing}{#1}%
  \tikztiming@parser
}
\def\tikztiming@addoption#1]{%
  \tikztiming@output@addcode{ [timing/option={#1}] }%
  \tikztiming@parser
}
\def\tikztiming@bothoption[#1]]{%
  \tikzset{#1}%[
  \tikztiming@addoption{#1}]%
}
\def\tikztiming@onceoption|#1|]{%
  \tikztiming@output@addcode{ [#1] }%
  \tikztiming@parser
}
\tikztiming@defcode{\bgroup}{%
  \tikztiming@output@eaddcode{%
    [timing/pushoptions]
    \newdraw [timing/every char]
  }%
  \tikztiming@parser
}
\tikztiming@defcode{\egroup}{%
  \tikztiming@output@eaddcode{%
    [timing/popoptions]
    \newdraw [timing/every char]
  }%
  \tikztiming@parser
}
\def\tikztiming@popoptions{%
  \expandafter\tikztiming@popoptions@\tikztiming@optionstack\relax
}
\def\tikztiming@optionstack{{}}
\def\tikztiming@popoptions@#1#2\relax{%
  \gdef\tikztiming@saved@options{#1}%
  \gdef\tikztiming@optionstack{#2}%
  \ifx\tikztiming@optionstack\empty
    \gdef\tikztiming@optionstack{{}}%
  \fi
}
\def\tikztiming@pushoptions{%
  \expandafter\expandafter\expandafter\gdef
  \expandafter\expandafter\expandafter\tikztiming@optionstack
  \expandafter\expandafter\expandafter{%
  \expandafter\expandafter\expandafter{\expandafter\tikztiming@saved@options\expandafter}\tikztiming@optionstack}%
}
\def\tikztiming@addnode@getoptions[#1]{%
  \@ifnextchar(%)
    {\tikztiming@addnode@getname{#1}}%
    {\tikztiming@addnode@getname{#1}()}%
}
\def\tikztiming@addnode@getname#1(#2){%
  \@ifnextchar\bgroup
    {\tikztiming@addnode@{#1}{#2}}%
    {\tikztiming@addnode@{#1}{#2}{}}%
}
\def\tikztiming@addnode@#1#2#3{%
  \def\@tempa{#2}%
  \ifx\@tempa\empty
    \def\@tempa{ node [timing/inline node,%
      timing/inline node/from char={\tikztiming@fromchar},%
      timing/inline node/to char={\tikztiming@tochar},%
      \unexpanded{#1}] }%
    \def\@tempb{}%
  \else
    \def\@tempa{ node [timing/inline node,%
      timing/inline node/from char={\tikztiming@fromchar},%
      timing/inline node/to char={\tikztiming@tochar},%
      \unexpanded{#1}] (\unexpanded{#2}) }%
    \xdef\tikztiming@namednodes{\tikztiming@namednodes,#2}%
  \fi
  \expandafter\tikztiming@output@eaddcode\expandafter{\@tempa \unexpanded{{#3}}}%
  \tikztiming@parser
}
\newcommand*\tikztiming@marknodes[2][]{%
  \scope[timing/debug/scope,#1]
    \edef\@tempa{floor((\noexpand\y1-\tikztiming@xunit) / \tikztiming@rowdist\tikztiming@xunit) * \tikztiming@rowdist\tikztiming@xunit}%
    \foreach \N in #2 {%
      \ifx\N\empty\else
        \tikztiming@markcmd
        \path let \p1=(\N) in
          node [timing/debug/node] at ($ (\x1,\noexpand\@tempa) + (0,1) $) {\N};
      \fi
    }%
  \endscope
}
\def\tikztiming@markcmd{ \draw (\N) circle (1pt); }%
\newcommand*\tikztiming@mark@nodes[2][]{%
  \begingroup
    \def\@tempa{#2}%
    \ifx\@tempa\empty \let\@tempa\tikztiming@namednodes \fi
    \ifx\@tempa\space \let\@tempa\tikztiming@namednodes \fi
    \def\@tempb{\tikztiming@marknodes[#1]}%
    \expandafter\@tempb\expandafter{\expandafter{\@tempa}}%
  \endgroup
}
\def\tikztiming@testforcode{%
  \@ifnextchar{!}%
    {\tikztiming@testforcode@}%
    {\@ifundefined{tikztiming@code@\meaning\@let@token}%
      {\tikztiming@parser@}%
      {\expandafter\afterassignment
       \csname tikztiming@code@\meaning\@let@token\endcsname
       \let\@let@token=%
      }%
    }%
}
\def\tikztiming@testforcode@#1{%
  \@ifnextchar\bgroup
    {\tikztiming@handlecode}%
    {%
      \PackageWarning{tikz-timing}{Missing braces after '!' character. Ignoring
      this character}{}{}{}%
      \tikztiming@parser
    }%
}
\def\tikztiming@handlecode#1{%
  \tikztiming@output@addcode{ #1 }%
  \tikztiming@parser
}
\def\tikztiming@testfornum{%
  \global\let\tikztiming@num\tikztiming@wscale
  \let\tikztiming@numchars\empty
  \tikztiming@numfrac0\relax
  \afterassignment
  \tikztiming@testfornum@
  \tikztiming@numint0%
}
\def\tikztiming@testfornumfrac{%
  \afterassignment
  \tikztiming@testfornum@@@
  \tikztiming@numfrac1%
}
\def\tikztiming@numloop{%
  \ifnum\tikztiming@numint>0%
    \toks@\expandafter{\tikztiming@numchars}%
    \xdef\tikztiming@numchars{%
      \the\toks@
      \the\@temptokena
    }%
    \advance\tikztiming@numint by -1\relax
    \expandafter\tikztiming@numloop
  \fi
}
\def\tikztiming@testfornum@{%
  \ifx0\@let@token
    \let\tikztiming@next\tikztiming@testfornum@@
  \else
  \ifnum0<\tikztiming@numint
    \let\tikztiming@next\tikztiming@testfornum@@
  \else
    \def\tikztiming@next{%
      \@ifnextchar{.}%
        {\expandafter\tikztiming@testfornumfrac\@gobble}%
        {%
          \tikztiming@numint1\relax
          \tikztiming@numfrac0\relax
          \global\let\tikztiming@num\tikztiming@wscale
          \if@tikztiming@metachar
            {\def\@tempa{\expandafter\expandafter\expandafter
             \tikztiming@parser
             \csname tikztiming@metachar@\meaning\@let@token\endcsname{1}}%
             \expandafter\@tempa\@gobble
            }%
            {\tikztiming@testforcode}%
        }%
    }%
  \fi\fi
  \tikztiming@next
}
\def\tikztiming@testfornum@@{%
  \@ifnextchar{.}%
    {\expandafter\tikztiming@testfornumfrac\@gobble}%
    {\tikztiming@testfornum@@@}%
}
\def\tikztiming@testfornum@@@{%
  \edef\tikztiming@num{\the\tikztiming@numint.\expandafter\@gobble\the\tikztiming@numfrac}%
  \tikztiming@setnum{\tikztiming@wscale * \tikztiming@num}%
  \@ifnextchar\bgroup
    {%
      \expandafter\tikztiming@numfrac\expandafter0\expandafter
      \@gobble\the\tikztiming@numfrac\relax
      \ifnum0=\tikztiming@numfrac\else
        \pgfmathparse{round(\tikztiming@num)}%
        \PackageWarning{tikz-timing}%
          {Can not repeat group by a non-integer factor!^^J%
           Rounding '\tikztiming@num' to '\pgfmathresult'.}{}{}{}%
        \global\let\tikztiming@num\pgfmathresult
      \fi
      \tikztiming@testfornum@@@@
    }%
    {%
      \if@tikztiming@metachar
        {\def\@tempa{\expandafter\expandafter\expandafter
        \tikztiming@parser
        \csname tikztiming@metachar@\meaning\@let@token\expandafter\endcsname
        \expandafter{\tikztiming@num}}%
        \expandafter\@tempa\@gobble
        }%
        {\tikztiming@testforcode}%
    }%
}
\def\tikztiming@testfornum@@@@#1{%
  \begingroup
    \@temptokena{#1}%
    \tikztiming@numloop%
  \endgroup
  \tikztiming@numint1\relax
  \tikztiming@numfrac0\relax
  \expandafter\tikztiming@parser\tikztiming@numchars
}
\def\tikztimingmetachar#1{%
  \@ifnextchar{[}%]
    {\tikztiming@metachar{#1}}%
    {\tikztiming@metachar{#1}[]}%
}
\def\tikztiming@metachar#1[#2]#3{%
  \ifx\relax#3\relax
    \expandafter\let\csname tikztiming@metachar@\meaning#1\endcsname\@undefined
  \else
    \@namedef{tikztiming@metachar@\meaning#1}{}%
    \ifx\relax#2\relax
      \expandafter\renewcommand\expandafter*%
      \csname tikztiming@metachar@\meaning#1\expandafter
      \endcsname\expandafter[1]{##1{#3}}%
    \else
      \expandafter\renewcommand\expandafter*%
      \csname tikztiming@metachar@\meaning#1\expandafter
      \endcsname\expandafter[#2]{#3}%
    \fi
  \fi
  \ifnum\tikztiming@debug=-1
    \message{^^J Defined meta-char '#1' as:
      \expandafter\meaning\csname tikztiming@metachar@\meaning#1\endcsname ^^J}%
  \fi
}
\def\if@tikztiming@metachar#1#2{%
  \@ifundefined{tikztiming@metachar@\meaning\@let@token}{#2}{#1}%
}
\newcounter{tikztimingrows}
\def\abc{\tracingassigns=1}
\newenvironment{tikztimingtable}[1][]{%
  \begingroup
  \setcounter{tikztiming@nrows}{0}%
  \def\tikztiming@maxwidth{0.0}%
  \let\extracode\tikztiming@extracode
  \let\endextracode\tikztiming@endextracode
  \let\tablegrid\tikztiming@tablegrid
  \let\fulltablegrid\tikztiming@fulltablegrid
  \let\horlines\tikztiming@horlines
  \let\vertlines\tikztiming@vertlines
  \let\marknodes\tikztiming@mark@nodes
  \def\background{\pgfonlayer{background}\scope}%
  \def\endbackground{\endscope\endpgfonlayer}%
  \def\tablerules{\tikztiming@tablerules}%
  \def\tableheader{\tikztiming@tableheader}%
  \def\rowdist{\tikztiming@rowdist}%
  \def\coldist{\tikztiming@coldist}%
  \def\nrows{\the\c@tikztiming@nrows}%
  \def\twidth{\tikztiming@maxwidth}%
  \tikzpicture[timing/table,#1]%
    \coordinate (@last row)  at (0,\rowdist);
    \coordinate (label@header)   at ($ -1*(\tikztiming@coldist,0) + 1.5*(0,\tikztiming@rowdist) $);
    \coordinate (diagram@header) at ($                              1.5*(0,\tikztiming@rowdist) $);
    \coordinate (timing@table@bottom right) at (0,0);
    \coordinate (timing@table@bottom left)  at ($ -1*(\tikztiming@coldist,0) $);
    \tikztiming@picinit
    \tikzset{timing/before table}%
    \tikztimingtable@checkrow
}{%
  \tikzset{timing/after table}%
  \endtikzpicture
  \endgroup
}
\def\tikztiming@extracode{%
  \path
    let
      \p1 = (row1.north west),
      \p2 = (timing@table@bottom right),
      \p3 = (\x2-\x1,\y1-\y2),
      \p4 = (\pgf@pt@aa * \x3, \pgf@pt@bb * \y3)
    in
      node [shape=rectangle,anchor=north west,
            minimum width=\x4,minimum height=\y4,
            inner sep=0pt,outer sep=0pt]
        at (\x1,\y1) (all rows) {}
    ;
  \path
    let
      \p0 = ($ -1*(\tikztiming@coldist,0) + (0,1) $),
      \p1 = (label1.north east),
      \p2 = (timing@table@bottom left),
      \p3 = (\x0-\x2,\y1-\y2),
      \p4 = (\pgf@pt@aa * \x3, \pgf@pt@bb * \y3)
    in
      node [shape=rectangle,anchor=north east,
            minimum width=\x4,minimum height=\y4,
            inner sep=0pt,outer sep=0pt]
        at (\x1,\y1) (all labels) {}
    ;
   \@ifnextchar[{\tikztiming@oset}{}%
}
\def\tikztiming@endextracode{%
}%
\def\tikztimingtable@checkrow{%
  \@ifnextchar\end
    {\tikztimingtable@chkendec}%
    {\ifx\@let@token\extracode
       \let\tikztiming@next\empty
     \else
       \ifx\@let@token\begin
         \def\tikztiming@next{\tikztimingtable@chkbegec}%
       \else
         \def\tikztiming@next{\tikztimingtable@row}%
       \fi
     \fi
     \tikztiming@next
    }%
}
\def\tikztimingtable@chkbegec\begin#1{
  \begingroup
  \def\@tempa{#1}%
  \def\@tempb{extracode}%
  \ifx\@tempa\@tempb
    \endgroup
    \def\tikztiming@next{\begin{extracode}}%
  \else
    \endgroup
    \def\tikztiming@next{\tikztimingtable@row\begin{#1}}%
  \fi
  \tikztiming@next
}
\def\tikztimingtable@chkendec\end#1{
  \begingroup
  \def\@tempa{#1}%
  \def\@tempb{extracode}%
  \ifx\@tempa\@tempb
    \endgroup
    \def\tikztiming@next{\end{extracode}\tikztimingtable@row}%
  \else
    \endgroup
    \def\tikztiming@next{\end{#1}}%
  \fi
  \tikztiming@next
}
\def\tikztiming@oset[#1]{%
  \let\tikz@options\pgfutil@empty
  \tikzset{#1}%
  \tikz@options
}
\def\tikztiming@emptycell{%
  \@gobble{tikztiming@emptycell}%
}
\long\def\tikztimingtable@row#1\\{%
  \tikztimingtable@row@#1&\tikztiming@emptycell&\\
}
\long\def\tikztimingtable@row@#1&#2&#3\\{%
  \ifx\\#3\\\else
    \begingroup
      \def\@tempa{\tikztiming@emptycell&}%
      \def\@tempb{#3}%
      \ifx\@tempa\@tempb\else
        \PackageWarning{tikz-timing}{%
          To many columns in tikztimingtable row! Only two are allowed%
        }{}{}{}%
      \fi
    \endgroup
  \fi
  \ifx\tikztiming@emptycell#2%
    \def\tikztiming@next{\tikztimingtable@row@@{#1}{}}%
  \else
    \def\tikztiming@next{\tikztimingtable@row@@{#1}{#2}}%
  \fi
  \tikztiming@next
}%
\long\def\tikztimingtable@row@@#1#2{%
  \addtocounter{tikztiming@nrows}{1}%
  \coordinate (@last row) at ($ (@last row) - (0,\tikztiming@rowdist) $);
  \node [anchor=base east,timing/name,alias=last label] (label\the\c@tikztiming@nrows)
    at ($ (@last row) - (\tikztiming@coldist,0) $) {\ignorespaces #1\unskip\strut};
  \path let \p1 = (timing@table@bottom left), \p2 = (last label.south west) in
    coordinate (timing@table@bottom left) at ({min(\x1,\x2)},\y2);
  %
  \@ifnextchar{[}%
    {\tikztiming@tabletiming}%
    {\tikztiming@tabletiming[]}%
  #2\relax
  \path let \p1 = (timing@table@bottom right), \p2 = (timing/end base) in
    coordinate (timing@table@bottom right) at ({max(\x1,\x2)},\y2);
  %
  \pgfmathparse{max(\tikztiming@maxwidth,\tikztimingwidth)}%
  \let\tikztiming@maxwidth\pgfmathresult
  \tikztimingtable@checkrow
}

\def\tikztiming@tabletiming[#1]#2\relax{%
  \let\tikztiming@lastchar\empty
  \let\tikztiming@settings\empty
  \ifx\relax#1\relax\else
    \tikztiming@testoptarg#1\relax\relax
  \fi
  \ifx\tikztiming@lastchar\empty
    \def\tikztiming@lastchar{@}%
  \fi
  \edef\@tempa{\noexpand\timing
    [name=row\the\c@tikztiming@nrows,alias=last row,%
     \expandafter\unexpanded\expandafter{\tikztiming@settings}] at (@last row)}%
  \expandafter\@tempa\expandafter{\expandafter[\tikztiming@lastchar]#2};
}

\newcommand*\tikztiming@fulltablegrid[1][]{%
  \begin{pgfonlayer}{background}
    \scope[xstep={\timingwidth/2.},ystep={\timingheight/2.},
      shift={(all rows.south west)},timing/table/grid,#1]
      \draw (0,0) grid ($ (all rows.north east) - (all rows.south west) $);
   \endscope
  \end{pgfonlayer}
}
\def\tikztiming@tablegrid{%
  \@ifnextchar{*}%
    {\tikztiming@tablegrid@{row\row.high end}}%
    {\tikztiming@tablegrid@{all rows.north east}}%
}
\def\tikztiming@tablegrid@#1{%
  \@ifnextchar{[}%]
    {\tikztiming@tablegrid@@{#1}}%
    {\tikztiming@tablegrid@@{#1}[]}%
}
\def\tikztiming@tablegrid@@#1[#2]{%
  \begin{pgfonlayer}{background}
    \scope[xstep={\timingwidth/2.},ystep={\timingheight/2.},timing/table/grid,#2]
      \foreach \row in {1,...,\nrows} {%
        \draw {[shift={(row\row.low start)}]
          let \p1 = (#1) in (0,0) grid (\x1,1)};
      }%
    \endscope
  \end{pgfonlayer}
}
\def\tikztiming@tableheader{%
  \@ifnextchar[%]
    {\tikztiming@tableheader@}%
    {\tikztiming@tableheader@@{}[]}%
}
\def\tikztiming@tableheader@[#1]{%
  \@ifnextchar[%]
    {\tikztiming@tableheader@@{#1}}%
    {\tikztiming@tableheader@@{#1}[]}%
}
\def\tikztiming@tableheader@@#1[#2]#3{%
  \@ifnextchar[%]
    {\tikztiming@tableheader@@@{#1}{#2}{#3}}%
    {\tikztiming@tableheader@@@{#1}{#2}{#3}[]}%
}
\def\tikztiming@tableheader@@@#1#2#3[#4]#5{%
  \path
    let
        \p1 = (label@header),
        \p2 = (all labels.east),
        \p3 = (all labels.west)
     in
        (\x2,\y1) -- node [pos=0,anchor=base east,timing/table/header,timing/table/label header,#1,#2]
          (label header)   {\ignorespaces #3\unskip\strut} (\x3,\y1)
     ;
  \path
    let
        \p4 = (diagram@header),
        \p5 = (all rows.west),
        \p6 = (all rows.east)
     in
        (\x5,\y4) -- node [pos=0,anchor=base west,timing/table/header,timing/table/row header,#1,#4]
          (row header) {\ignorespaces #5\unskip\strut} (\x6,\y4)
     ;
  \tikztiming@tableheadtrue
}
\newif\iftikztiming@tablehead
\newcommand*\tikztiming@tablerules[1][]{%
  \begin{scope}[#1]
    \coordinate (NW) at (current bounding box.north west);
    \coordinate (SE) at (current bounding box.south east);
    %
    \draw [timing/table/rules]
    let
      \p1 = (NW),
      \p2 = (SE),
      \p3 = (@last row),
      \p4 = (0,\rowdist)
    in
      ($ (\x1-\tabcolsep,\y3) - (0,.5*\y4) $) --
      ($ (\x2+\tabcolsep,\y3) - (0,.5*\y4) $)
     \iftikztiming@tablehead
      (\x1-\tabcolsep,2.5*\y4) -- (\x2+\tabcolsep,2.5*\y4)
     \fi
    ;
    \draw
     \iftikztiming@tablehead [timing/table/midrules] \else [timing/table/rules] \fi
    let
      \p1 = (NW),
      \p2 = (SE)
    in
      (\x1-\tabcolsep,\rowdist) -- (\x2+\tabcolsep,\rowdist)
    ;
  \end{scope}
}
\newcommand*\tikztiming@horlines[2][]{%
  \begingroup
    \def\list{#2}%
    \ifx\list\empty
      \def\list{1,2,...,\nrows}%
    \fi
    \foreach \row in \list {%
      \draw [timing/table/lines,#1] let
        \p1 = (all rows.south east),
        \p2 = (0,\rowdist)
      in
        ($ (0,\y2) -  (0,\row * \y2) $) -- +(\x1,0);
    }%
  \endgroup
}
\newcommand*\tikztiming@vertlines[2][]{%
  \begingroup
    \def\list{#2}%
    \ifx\list\empty
      \def\list{0,1,...,\twidth}%
    \fi
    \draw [timing/table/lines,#1] let
        \p1 = ($ (all rows.south east) - (0,2) $)
      in
        \foreach \clk in \list {
          (\clk,+1.5) -- +(0,\y1)
        }
    ;
  \endgroup
}
\pgfdeclareshape{tikztiming@shape}{%
  \savedanchor\northeast{\tikztiming@northeast}%
  \savedanchor\startpoint{\tikztiming@startpoint}%
  \savedanchor\endpoint{\tikztiming@endpoint}%
  \anchor{center}{\pgfpointorigin}%
  \anchor{start}{\startpoint}%
  \anchor{end}{\endpoint}%
  %
  \anchor{origin}{\northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }%
  \anchor{east}{\northeast \pgf@y=0pt }%
  \anchor{west}{\northeast \pgf@y=0pt \pgf@x=-\pgf@x }%
  \anchor{north}{\northeast \pgf@x=0pt }%
  \anchor{north west}{\northeast \pgf@x=-\pgf@x }%
  \anchor{north east}{\northeast}
  \anchor{high mid}{\northeast \pgf@x=0pt }%
  \anchor{high start}{\northeast \pgf@x=-\pgf@x }%
  \anchor{high end}{\northeast}
  \anchor{south}{\northeast \pgf@x=0pt \pgf@y=-\pgf@y }%
  \anchor{south west}{\northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }%
  \anchor{south east}{\northeast \pgf@y=-\pgf@y }%
  \anchor{low mid}{\northeast \pgf@x=0pt \pgf@y=-\pgf@y }%
  \anchor{low start}{\northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }%
  \anchor{low end}{\northeast \pgf@y=-\pgf@y }%
  \anchor{mid}{\pgfpointorigin}%
  \anchor{mid east}{\northeast \pgf@y=0pt }%
  \anchor{mid west}{\northeast \pgf@y=0pt \pgf@x=-\pgf@x }%
  \anchor{mid end}{\northeast \pgf@y=0pt }%
  \anchor{mid start}{\northeast \pgf@y=0pt \pgf@x=-\pgf@x }%
  \anchor{base}{\northeast \pgf@x=0pt \pgf@y=-\pgf@y }%
  \anchor{base west}{\northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }%
  \anchor{base east}{\northeast \pgf@y=-\pgf@y }%
  \anchorborder{%
    \@tempdima=\pgf@x
    \@tempdimb=\pgf@y
    \pgfpointborderrectangle{\pgfpoint{\@tempdima}{\@tempdimb}}{\northeast}%
  }%
}
\gdef\tikztiming@oldnodecenter@{}%
\tikzset{timing/old@node@center/.code={\xdef\tikztiming@oldnodecenter@{%
  ++($ (0,0) - #1 $)
  [timing/no@old@node@center]}}%
}%
\tikzset{timing/no@old@node@center/.code={\gdef\tikztiming@oldnodecenter@{}}}%

\def\tikztiming@oldnodecenter#1{%
  [timing/old@node@center={#1}]
  ++#1
}

\def\tikztiming@iflower#1{%
  \begingroup
  \edef\@tempa{`#1}%
  \ifnum\@tempa=\lccode\@tempa
    \endgroup
    \expandafter
    \@firstoftwo
  \else
    \endgroup
    \expandafter
    \@secondoftwo
  \fi
}
\def\tikztiming@internaldefs{%
  \let\draw\relax
  \let\path\relax
  \let\p\relax
  \let\x\relax
  \let\y\relax
  \let\n\relax
  \let\tikztiming@oldnodecenter\relax
  \let\tikztiming@oldnodecenter@\relax
  \def\width{####1*\noexpand\timingwidth}%
  \def\fwidth{\noexpand\timingwidth}%
  \def\height{\noexpand\timingheight}%
  \def\slope{\noexpand\timingslope}%
  \def\zslope{\noexpand\timingzslope}%
  \def\dslope{\noexpand\timingdslope}%
  \def\gslope{0}%
  \def\style{timing/every char,timing/####3}%
  \def\bgstyle{draw=none,timing/every bg,timing/####3/background}%
  \def\nstyle{timing/every char,timing/####4}%
  \def\newdraw{\tikztiming@newdraw}%
  \def\newdrawns{\tikztiming@newdraw@nosave}%
  \def\code##1{ [/utils/exec={\unexpanded{##1}}] }%
}

\def\tikztimingsetslope#1{%
  \pgfmathparse{min(1.0,{max(0.0,#1)})}%
  \let\tikztiming@slope\pgfmathresult
  \edef\timingslope{\tikztiming@slope*\noexpand\timingwidth}%
}
\def\tikztimingsetdslope#1{%
  \pgfmathparse{min(1.0,{max(0.0,#1)})}%
  \let\tikztiming@dslope\pgfmathresult
  \edef\timingdslope{\tikztiming@dslope*\noexpand\timingwidth}%
}
\def\tikztimingsetzslope#1{%
  \pgfmathparse{min(1.0,{max(0.0,#1)})}%
  \let\tikztiming@zslope\pgfmathresult
  \edef\timingzslope{\tikztiming@zslope*\noexpand\timingwidth}%
}
\tikztimingsetslope{0.10}%
\tikztimingsetdslope{0.20}%
\tikztimingsetzslope{0.05}%
\def\tikztiminguse#1#2{%
  \@nameuse{\tikztiming@prefix#1}{#2}{##2}{##3}{##4}%
}
\def\tikztimingdef#1{%
  \tikztimingdef@#1\empty\empty\relax
}
\def\tikztimingdef@#1#2#3\relax#4{%
  \ifx\empty#2\empty
    \tikztiming@nameedef{}{#1}{}{#4}%
  \else
    \tikztiming@nameedef{#1}{#2}{#3}{#4}%
  \fi
}
\def\tikztimingcpy#1#2{%
  \begingroup
  \edef\tikztimingcpy@a{#1}%
  \edef\tikztimingcpy@b{#2}%
  \ifx\tikztimingcpy@a\tikztimingcpy@b
    \endgroup
    %\message{^^J Copy macro '#2' to '#1' skipped.^^J}%
  \else
    \endgroup
    \@ifundefined{\tikztiming@pfxtr#2\empty\empty\empty}%
      {\ifnum\tikztiming@debug>0\relax
        \message{^^J Copy macro '#2' to '#1' failed.^^J}\fi}%
      {\ifnum\tikztiming@debug>0\relax
        \message{^^J Copy macro '#2' to '#1'.^^J}\fi
        \expandafter\let
        \csname\tikztiming@pfxtr#1\empty\empty\empty\expandafter\endcsname
        \csname\tikztiming@pfxtr#2\empty\empty\empty\endcsname
      }%
  \fi
}
\def\tikztiminglet#1#2{%
  \tikztiming@namelet{#1}{#2}%
}
\def\tikztiming@chars#1{}
\def\tikztiming@ifcharexists#1{%
  \def\tikztiming@ifcharexists@##1,#1,##2\relax{%
    \ifx\relax##2\relax%
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
  }%
  \expandafter\tikztiming@ifcharexists@
  \expandafter,\tikztiming@chars,#1,\relax%
}
\def\tikztiming@addchar#1{%
  \tikztiming@ifcharexists{#1}{%
    \edef\tikztiming@chars{\tikztiming@chars,#1}%
  }{}%
}
\def\tikztimingchar#1{%
  \uppercase{%
  \tikztiming@addchar{#1}%
  \tikztimingchar@{#1}}%
}
\@namedef{\tikztiming@prefix @@}#1#2#3#4{ coordinate (timing/start)}%
\def\tikztimingchar@#1#2#3{%
  \tikztiming@nameedef{@}{#1}{}{#2 coordinate (timing/start) #3}%
  \tikztimingdef{{#1}{#1}}{#3}%
}
\def\tikztimingecopy#1#2{%
  \@namedef{tikztiming@alias@#1}{#2}%
  \tikztiming@addchar{#1}%
  \expandafter\let
  \csname tikztiming@triple@#1\expandafter\endcsname
  \csname tikztiming@triple@#2\endcsname
  \expandafter\let
  \csname tikztiming@nocombine@#1\expandafter\endcsname
  \csname tikztiming@nocombine@#2\endcsname
}
\def\tikztiming@setref#1#2{%
  coordinate (#1) coordinate (#1) at ([shift={(#2)}]#1)
}
\def\tikztiming@newdraw{%
  node [timing/save] (timing@save) {};%
  \draw [timing/restore] (timing@save) ++(0,0)
}

\def\tikztiming@newdraw@nosave{%
  node [timing/coord] (timing@save) {};%
  \draw [timing/nooptions] (timing@save) ++(0,0)
}
\def\tikztiming@baseline{%
  node [timing/save] (timing@save) {};%
  \draw [timing/restore] let \p1 = (timing@save) in (\x1,0) ++(0,0)
}
\def\tikztiming@chars{H,L,Z,X,M,D,U,T,C}%
\tikztiming@defcode{S}{%
  \pgfmathparse{\tikztimingwidth + \tikztiming@num}%
  \global\let\tikztimingwidth\pgfmathresult
  \tikztiming@output@Eaddcode{%
    coordinate (timing@ref)  at ($ (timing@ref)  + (\tikztiming@num,0) $)
    coordinate (timing@refa) at ($ (timing@refa) + (\tikztiming@num,0) $)
    coordinate (timing@refb) at ($ (timing@refb) + (\tikztiming@num,0) $)
    ++(\tikztiming@num,0)
  }%
  \tikztiming@parser
}

\tikztiming@defcode{s}{%
  \pgfmathparse{\tikztimingwidth + \tikztiming@num/2}%
  \global\let\tikztimingwidth\pgfmathresult
  \tikztiming@output@Eaddcode{%
    coordinate (timing@ref)  at ($ (timing@ref)  + (\tikztiming@num/2,0) $)
    coordinate (timing@refa) at ($ (timing@refa) + (\tikztiming@num/2,0) $)
    coordinate (timing@refb) at ($ (timing@refb) + (\tikztiming@num/2,0) $)
    ++(\tikztiming@num/2,0)
  }%
  \tikztiming@parser
}
\tikztiming@defcode{G}{%
  \tikztiming@output@addcode{%
    \tikztiming@glitch
  }%
  \tikztiming@parser
}

\tikztiming@defcode{g}{%
  \tikztiming@output@addcode{%
    \tikztiming@glitch
  }%
  \tikztiming@parser
}

\def\tikztiming@glitch{%
  {[timing/every char,timing/g] let \p1 = +(0,0) in (\x1,0) -- (\x1,\timingheight)
   coordinate (timing@dstart) at (\x1,\timingheight/2) (\x1,\y1)
  }%
}
\tikztimingchar{H}{++(0,\height)}{[\style] -- ++(#1,0)}

\tikztimingdef{HH}{
  -- ++(#1,0)
}

\tikztimingdef{LH}{
  --  +(\slope, \height)
  -- ++(#1, \height)
}

\tikztimingdef{ZH}{
    \newdraw [\style]
  -- ++(\zslope,+\height/2.)
  -- ++($ (#1,0) - (\zslope,0) $)
}

\tikztimingdef{DH}{
  \tikztiming@oldnodecenter@%
  \newdraw [\style]
  --  +(\dslope/2.,\height/2.)
  --   ($ (timing@ref) + (#1,\height/2) $)
}

\tikztimingdef{DL}{
  \tikztiming@oldnodecenter@
  \newdraw [\style]
  --  +(\dslope/2.,-\height/2.)
  --   ($ (timing@ref) + (#1,-\height/2) $)
}


\tikztimingchar{L}{++(0,0)}{[\style] -- ++(#1,0)}

\tikztimingchar{Z}{++(0,\height/2.)}{%
  \newdraw [\style]
  -- ++(#1,0)
}

\tikztimingchar{D}{++(0,\height/2.)}{
  node [timing/save] (timing@save) {}; \path [\bgstyle] (timing@save) ++(0,0)
  -- +(#1,0)
  -- +($ (#1,0) + 0.5*(\dslope,\height) $)
  -- +(#1,\height)
  -- +(0,\height)
  -- cycle;
  \draw [timing/restore,\style] (timing@save) ++(0,0)
  node [timing/save] (timing@dstart) at +(-\dslope/2.,\height/2.0) {}
  --  +(#1,0) ++(0,+\height)
  -- ++(#1,0) ++(0,-\height)
}

\def\tikztiming@triple@D{}%
\def\tikztiming@triple@D@edge@{}%
\def\tikztiming@nocombine@D@edge@{}%
\def\tikztiming@alias@D@edge@{D}%
\def\tikztiming@trans@D@fill#1#2{%
  node [timing/save] (timing@save) {}; \path [\bgstyle] (timing@save) ++(0,0)
  -- +(0.5*\dslope,-0.5*\height)
  -- ++($ (#1,-0.5*\height) - (#2,0) $)
  -- +(0.5*\dslope,0.5*\height)
  -- +(0,\height)
  -- ++($ (#2,\height) - (#1,0) + (0.5*\dslope,0) $)
  -- cycle;
  \draw [timing/restore,\style] (timing@save) ++(0,0)
  node [timing/save] (timing@dstart) {}
}
\tikztimingdef{LL}{
  -- ++(#1,0)
}

\tikztimingdef{HL}{
  -- ++(\slope,-\height)
  \tikztiminguse{HH}{#1-\slope}
}

\tikztimingdef{LZ}{
  \newdraw [\style]
  -- ++(\zslope,+\height/2.)
  -- ++($ (#1,0) - (\zslope,0) $)
}
\tikztimingdef{HZ}{%
  \newdraw [\style]
  -- ++(\zslope,-\height/2.)
  -- ++($ (#1,0) - (\zslope,0) $)
}
\tikztimingdef{ZL}{%
  \newdraw [\style]
  -- ++(\zslope,-\height/2.)
  -- ++($ (#1,0) - (\zslope,0) $)
}

\tikztimingdef{DZ}{
  \tikztiming@oldnodecenter@
  \newdraw [\style]
  -- ($ (timing@ref) + (#1,0) $)
}

\def\tikztiming@chard#1{%
  \newdraw [\style,preaction={\bgstyle}]
  coordinate (timing@dstart)
  -- +(\dslope/2,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
  -- +(\dslope/2,-\height/2)
  -- +(0,-\height)
  --  ($ (timing@dstart) + (\dslope/2,-\height/2) $)
  --  (timing@dstart)
      ($ (timing@ref) + (#1,0) $)
  coordinate (timing@ref)
    ++(\dslope/2,0)
  coordinate (timing@dend)
  \tikztiming@oldnodecenter{%
    (-\dslope/2,-\height/2)
  }%
  \newdraw [timing/every char]
}

\def\tikztiming@chard@#1{%
  \newdraw [\bgstyle]
  -- +(\dslope/2,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
  -- +(0,-\height)%
  --  ($ (timing@save) + (\dslope/2,-\height/2) $)
  --  (timing@save)
  \newdraw [\style]
     coordinate (timing@dstart)
  -- +(\dslope/2,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
     +(0,-\height)%
  --  ($ (timing@save) + (\dslope/2,-\height/2) $)
  --  (timing@save)
      ($ (timing@ref) + (#1,0) $)
     coordinate (timing@ref)
     \tikztiming@setref{timing@dend}{\dslope/2,0}
  \tikztiming@oldnodecenter{%
    (0,-\height/2)
  }%
  \newdraw [timing/every char]
}

\def\tikztiming@@chard#1{%
    ++(0,\height/2)
  \newdraw [\bgstyle]
  -- +(0,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
  -- +(\dslope/2,-\height/2)
  -- +(0,-\height)
  --  ($ (timing@save) + (0,-\height/2) $)
  --  (timing@save)
  \newdraw [\style]
     +(0,0)
     coordinate (timing/start)
     +(-\dslope/2,0)
     coordinate (timing@dstart)
     +(0,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
  -- +(\dslope/2,-\height/2)
  -- +(0,-\height)
  --  ($ (timing@save) + (0,-\height/2) $)
      ($ (timing@ref) + (#1,0) $)
     coordinate (timing@ref)
    ++(\dslope/2,0)
     coordinate (timing@dend)
  \tikztiming@oldnodecenter{%
    (-\dslope/2,-\height/2)
  }%
  \newdraw [timing/every char]
}

\def\tikztiming@@chard@#1{%
    ++(0,\height/2)
  \newdraw [\bgstyle]
  -- +(0,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
  -- +(0,-\height)
  --  ($ (timing@save) + (0,-\height/2) $)
  --  (timing@save)
  \newdraw [\style]
     +(0,0)
     coordinate (timing/start)
     coordinate (timing@ref)
     \tikztiming@setref{timing@dstart}{-\dslope/2,0}
     +(0,\height/2)
  -- +(#1,\height/2)
     +(#1,-\height/2)
  --  ($ (timing@save) + (0,-\height/2) $)
    ++(#1,\height/2)
     coordinate (timing@ref)
     \tikztiming@setref{timing@dend}{\dslope/2,0}
  \tikztiming@oldnodecenter{%
    (0,-\height/2)
  }%
  \newdraw [timing/every char]
}

\def\tikztiming@dchardu#1{%
  \tikztiming@oldnodecenter@
  \newdraw [\bgstyle]
  -- +(0,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
  -- +(\dslope/2,-\height/2)
  -- +(0,-\height)
  --  ($ (timing@save) + (0,-\height/2) $)
  --  (timing@save)
  \newdraw [\style]
     +(0,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
  -- +(\dslope/2,-\height/2)
  -- +(0,-\height)
  --  ($ (timing@save) + (0,-\height/2) $)
      ($ (timing@ref) + (#1,0) $)
     coordinate (timing@ref)
    ++(\dslope/2,0)
     coordinate (timing@dend)
  \tikztiming@oldnodecenter{%
    (-\dslope/2,-\height/2)
  }%
  \newdraw [timing/every char]
}

\def\tikztiming@uchardd#1{%
  \tikztiming@oldnodecenter@
  \newdraw [\bgstyle]
  -- +(\dslope/2,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
  -- +(0,-\height)
  --  ($ (timing@save) + (\dslope/2,-\height/2) $)
  --  (timing@save)
  \newdraw [\style]
     coordinate (timing@dstart)
  -- +(\dslope/2,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
     +(0,-\height)
  --  ($ (timing@save) + (\dslope/2,-\height/2) $)
  --  (timing@save)
      ($ (timing@ref) + (#1,0) $)
     coordinate (timing@ref)
     coordinate [shift={(\dslope/2,0)}](timing@dend)
  \tikztiming@oldnodecenter{%
      ($ (0,0) - (0,\height/2) $)
  }%
  \newdraw [timing/every char]
}

\tikztimingdef{DD}{%
  \tikztiming@dchardu{#1}%
}

\tikztimingdef{UU}{%
  \tikztiming@dchardu{#1}%
}

\def\tikztiming@dchard@#1{%
  \tikztiming@oldnodecenter@
  \newdraw [\bgstyle]
  -- +(0,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
  -- +(0,-\height)
  --  ($ (timing@save) + (0,-\height/2) $)
  --  (timing@save)
  \newdraw [\style]
     +(0,\height/2)
  --  ($ (timing@ref) + (#1,\height/2) $)
     +(0,-\height)
  --  ($ (timing@save) + (0,-\height/2) $)
      ($ (timing@ref) + (#1,0) $)
    coordinate (timing@ref)
    \tikztiming@setref{timing@dend}{\dslope/2,0}
  \tikztiming@oldnodecenter{%
    (0,-\height/2)
  }%
  \newdraw [timing/every char]
}

\tikztimingdef{DD@}{
  \tikztiming@dchard@{#1}%
}

\tikztimingcpy{DDD}{DD@}
\tikztimingcpy{UUU}{DDD}

\tikztimingdef{{D@edge@}{D@edge@}}{%
  \tikztiming@oldnodecenter@
  \tikztiming@chard{#1}%
}%

\tikztimingdef{@{D@edge@}}{%
  \tikztiming@@chard@{#1}%
}%

\tikztimingdef{@{D@edge@}@}{%
  \tikztiming@@chard@{#1}%
}%

\tikztimingdef{@{D@edge@}D}{%
  \tikztiming@@chard{#1}%
}

\tikztimingdef{D{D@edge@}}{%
  \tikztiming@dchardu{#1}%
}

\tikztimingdef{U{U@edge@}}{%
  \tikztiming@dchardu{#1}%
}

\tikztimingdef{U{D@edge@}}{%
  \tikztiming@oldnodecenter@
  \tikztiming@chard{#1}%
}

\tikztimingdef{U{D@edge@}@}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard@{#1}%
}

\tikztimingdef{D{U@edge@}}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard{#1}%
}

\tikztimingdef{D{U@edge@}@}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard@{#1}%
}

\tikztimingdef{D{D@edge@}@}{%
  \tikztiming@dchard@{#1}%
}%

\tikztimingdef{U{U@edge@}@}{%
  \tikztiming@dchard@{#1}%
}%

\tikztimingdef{{D@edge@}{D@edge@}@}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard@{#1}%
}%

\tikztimingdef{@{D@edge@}}{%
  \tikztiming@@chard{#1}%
}%

\tikztimingdef{{D@edge@}D}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard{#1}%
}%

\tikztimingdef{{D@edge@}D@}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard@{#1}%
}%

\tikztimingdef{ZDZ}{
  coordinate (timing@ref)
  \tikztiming@chard{#1}
}
\tikztimingcpy{ZDX}{ZDZ}
\tikztimingcpy{XDX}{ZDZ}
\tikztimingcpy{XDZ}{ZDZ}

\tikztimingdef{ZDD}{
  coordinate (timing@ref)
  \tikztiming@chard@{#1}
}

\tikztimingdef{ZDU}{
  coordinate (timing@ref)
  \tikztiming@chard{#1}
}

\tikztimingcpy{ZUD}{ZDU}
\tikztimingcpy{ZUU}{ZDD}

\tikztimingdef{ZD}{
  coordinate (timing@ref)
  \tikztiming@chard{#1}
}

\tikztimingdef{@DD}{%
  \tikztiming@@chard@{#1}%
}

\tikztimingdef{ZD@}{%
  coordinate (timing@ref)
  \tikztiming@chard@{#1}%
}

\tikztimingdef{HD@}{%
  \tikztiming@setref{timing@ref}{0,-\height/2}
  -- ++(\dslope/2, -\height/2)
  \tikztiming@chard@{#1}%
}

\tikztimingdef{TD@}{%
  \tikztiming@setref{timing@ref}{0,-\height/2 * \value{tikztimingtrans}}
  -- ++(\dslope/2, -\height/2 * \value{tikztimingtrans})
  \tikztiming@chard@{#1}%
}

\tikztimingdef{TD}{%
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  \tikztiming@setref{timing@ref}{0,\height/2 * \value{tikztimingtrans}}
  -- ++(\dslope/2, \height/2 * \value{tikztimingtrans})
  \tikztiming@chard{#1}%
}

\tikztimingdef{TDD}{%
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  \tikztiming@setref{timing@ref}{0,\height/2 * \value{tikztimingtrans}}
  -- ++(\dslope/2, \height/2 * \value{tikztimingtrans})
  \tikztiming@chard@{#1}%
}

\tikztimingdef{TUD}{%
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  \tikztiming@setref{timing@ref}{0,\height/2 * \value{tikztimingtrans}}
  -- ++(\dslope/2, \height/2 * \value{tikztimingtrans})
  \tikztiming@chard{#1}%
}

\tikztimingcpy{TDU}{TUD}
\tikztimingcpy{TUU}{TDD}

\tikztimingdef{LD@}{%
  \tikztiming@setref{timing@ref}{0,\height/2}
  -- ++(\dslope/2, \height/2)
  \tikztiming@chard@{#1}%
}

\tikztimingdef{@D}{%
  \tikztiming@@chard@{#1}%
}

\tikztimingdef{@D@}{%
  \tikztiming@@chard@{#1}%
}

\tikztimingcpy{H{D@edge@}@}{HD@}
\tikztimingcpy{L{D@edge@}@}{LD@}
\tikztimingcpy{Z{D@edge@}@}{ZD@}
\tikztimingcpy{T{D@edge@}@}{TD@}

\tikztimingdef{@DZ}{%
  \tikztiming@@chard{#1}%
}
\tikztimingdef{@DH}{%
  \tikztiming@@chard{#1}%
}
\tikztimingdef{@DL}{%
  \tikztiming@@chard{#1}%
}
\tikztimingdef{@DT}{%
  \tikztiming@@chard{#1}%
}

\tikztimingdef{LD}{
  \tikztiming@setref{timing@ref}{0,\height/2}
  -- ++(\dslope/2, \height/2)
  \tikztiming@chard{#1}%
}

\tikztimingdef{LDD}{
  \tikztiming@setref{timing@ref}{0,\height/2}
  -- ++(\dslope/2, \height/2)
  \tikztiming@chard@{#1}
}

\tikztimingdef{LDU}{
  \tikztiming@setref{timing@ref}{0,\height/2}
  -- ++(\dslope/2, \height/2)
  \tikztiming@chard{#1}
}

\tikztimingcpy{LUD}{LDU}
\tikztimingcpy{LUU}{LDD}

\tikztimingdef{HD}{
  \tikztiming@setref{timing@ref}{0,-\height/2}
  -- ++(\dslope/2, -\height/2)
  \tikztiming@chard{#1}
}

\tikztimingdef{HDD}{
  \tikztiming@setref{timing@ref}{0,-\height/2}
  -- ++(\dslope/2, -\height/2)
  \tikztiming@chard@{#1}
}

\tikztimingdef{HDU}{
  \tikztiming@setref{timing@ref}{0,-\height/2}
  -- ++(\dslope/2, -\height/2)
  \tikztiming@chard{#1}
}
\tikztimingcpy{HUD}{HDU}
\tikztimingcpy{HUU}{HDD}

\tikztimingecopy{M}{Z}
\tikztimingchar{M}{++(0,\height/2.)}{
  \newdraw [\style]
  -- ++(#1,0)
  \newdraw [\style/base]
}

\tikztimingdef{ZM}{
  \newdraw [\style]
  -- ++(#1,0)
  \newdraw [\style/base]
}

\tikztimingdef{LM}{
  \newdraw [\style/base]
  -- ++($ (1/8,0) + (0,\height/2) $)
  \newdraw [\style]
  -- ++($ (-1/8,0) + (#1,0) $)
  \newdraw [\style/base]
}

\tikztimingdef{HM}{
  \newdraw [\style/base]
  -- ++($ (1/8,0) + (0,-1*\height/2) $)
  \newdraw [\style]
  -- ++($ (-1/8,0) + (#1,0) $)
  \newdraw [\style/base]
}

\tikztimingdef{DM}{
  \tikztiming@oldnodecenter@%
  \newdraw [\style]
  -- ($ (timing@ref) + (#1,0) $)
  \newdraw [\style/base]
}

\newcounter{tikztimingtrans}
\newcounter{tikztimingtranspos}

\tikztimingchar{T}{++(0,0)}{
  -- ++(#1,0)
}
\def\tikztiming@nocombine@T{}%

\tikztimingdef{HT}{%
  {[\style]
  \code{\setcounter{tikztimingtrans}{-1}}
  -- ++(\slope,\value{tikztimingtrans}*\height) -- ++($ (#1,0) - (\slope,0) $)
  }
}

\tikztimingdef{LT}{%
  {[\style]
  \code{\setcounter{tikztimingtrans}{+1}}
  -- ++(\slope,\value{tikztimingtrans}*\height) -- ++($ (#1,0) - (\slope,0) $)
  }
}

\tikztimingdef{TL}{%
  \code{\setcounter{tikztimingtranspos}{\value{tikztimingtrans}}%
  \addtocounter{tikztimingtranspos}{+1}}
  -- ++(\slope, -0.5*\value{tikztimingtranspos}*\height) -- ++($ (#1,0) - (\slope,0) $)
}

\tikztimingdef{TH}{%
  \code{\setcounter{tikztimingtranspos}{\value{tikztimingtrans}}%
  \addtocounter{tikztimingtranspos}{-1}}
  -- ++(\slope, -0.5*\value{tikztimingtranspos}*\height) -- ++($ (#1,0) - (\slope,0) $)
}

\tikztimingdef{TZ}{%
  \newdraw [\style]
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  -- ++(\zslope,\value{tikztimingtrans}*\height/2.)
  -- ++($ (#1,0) - (\zslope,0) $)
}

\tikztimingdef{ZT}{%
  \newdraw [timing/every char] {[\style]
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  -- ++(\zslope,\value{tikztimingtrans}*\height/2.)
  -- ++($ (#1,0) - (\zslope,0) $)
  }
}

\tikztimingdef{TT}{%
  {[\style]
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  -- ++(\slope,\value{tikztimingtrans}*\height)
  -- ++($ (#1,0) - (\slope,0) $)
  }
}

\tikztimingdef{DT}{
  \code{\setcounter{tikztimingtrans}{-1}}
  \tikztiming@oldnodecenter@%
  \newdraw [timing/every char] {[\style]
  --  +(\dslope/2.,-\height/2)
  --   ($ (timing@ref) + (#1,-\height/2) $)
  }
}

\tikztimingdef{TM}{%
  \newdraw [\style/base]
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  -- ++($ (1/8,0) + (0,\value{tikztimingtrans}*\height/2) $)
  \newdraw [\style]
  -- ++($ (-1/8,0) + (#1,0) $)
  \newdraw [\style/base]
}
\tikztimingecopy{C}{T}
\tikztimingecopy{U}{D}

\def\tikztiming@triple@U@edge@{}%
\def\tikztiming@nocombine@U@edge@{}%
\def\tikztiming@alias@U@edge@{D@edge@}%

\tikztimingcpy{UU@}{DD@}%

\tikztimingdef{UDU}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard{#1}%
}
\tikztimingcpy{DUD}{UDU}%

\tikztimingdef{UDD}{%
  \tikztiming@uchardd{#1}%
}

\tikztimingcpy{{D@edge@}DD}{UDD}
\tikztimingcpy{{U@edge@}UU}{{D@edge@}DD}

\tikztimingdef{H{D@edge@}}{
  \tikztiming@setref{timing@ref}{0,-\height/2}
  -- ++(\dslope/2, -\height/2)
  \tikztiming@chard{#1}%
}

\tikztimingdef{L{D@edge@}}{
  \tikztiming@setref{timing@ref}{0,\height/2}
  -- ++(\dslope/2, \height/2)
  \tikztiming@chard{#1}%
}

\tikztimingdef{Z{D@edge@}}{
  coordinate (timing@ref)
  \tikztiming@chard{#1}%
}

\tikztimingdef{T{D@edge@}}{
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  \tikztiming@setref{timing@ref}{0,\height/2 * \value{tikztimingtrans}}
  -- ++(\dslope/2, \height/2 * \value{tikztimingtrans})
  \tikztiming@chard{#1}%
}

\tikztimingdef{{D@edge@}DU}{
  \tikztiming@oldnodecenter@
  \tikztiming@chard{#1}
}
\tikztimingcpy{{U@edge@}UD}{{D@edge@}DU}

\tikztimingdef{DDU}{%
  \tikztiming@dchardu{#1}
}

\tikztimingcpy{DUU}{UDD}%
\tikztimingcpy{UUD}{DDU}%

\tikztimingdef{@UU}{%
  \tikztiming@@chard@{#1}%
}

\tikztimingdef{@UD}{%
  \tikztiming@@chard{#1}%
}

\tikztimingdef{@DU}{%
  \tikztiming@@chard{#1}%
}

\tikztimingdef{UD}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard{#1}%
}

\tikztimingdef{DU}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard{#1}%
}

\tikztimingdef{UD@}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard@{#1}%
}

\tikztimingdef{DU@}{%
  \tikztiming@oldnodecenter@%
  \tikztiming@chard@{#1}%
}

\tikztimingecopy{X}{Z}
\let\tikztiming@chars@default\tikztiming@chars
\newcommand*\usetikztiminglibrary[2][]{%
  \edef\tikztiming@library@options{#1}%
  \@ifnextchar{[}%]
    {\tikztiming@library{#2}}%
    {\tikztiming@library{#2}[]}%
}
\def\tikztiming@library#1[#2]{%
  \edef\tikztiming@library@date{#2}%
  \tikztiming@library@#1,\relax
}
\def\tikztiming@zap@space#1 \@empty{#1}

\def\tikztiming@library@#1,{%
  \IfFileExists{tikz-timing-#1.sty}%
    { \let\tikztiming@orig@zap@space\zap@space
      \let\zap@space\tikztiming@zap@space
      \RequirePackage
        [\tikztiming@library@options]%
        {tikz-timing-#1}%
        [\tikztiming@library@date]%
      \let\zap@space\tikztiming@orig@zap@space
    }%
    {\PackageError{tikz-timing}%
      {No tikz-timing library `#1' found!}{}%
    }%
  \@ifnextchar\relax{}{\tikztiming@library@}%
}
\endinput
%%
%% End of file `tikz-timing.sty'.
