LaTeX package tikZ-timing
created by Martin Scharrer allows easy typing of timing diagrams (digital waveforms) in offline documents.
With the aid of QuickLaTeX tikZ-timing
diagrams can be used seamlessly in the WordPress blogs (or any other website). You can just paste tikZ-timing
commands directly in the text – QuickLaTeX will compile them into images and embed in the published page.
Let’s consider how we can do this (examples are taken from tikz-timing examples).
tikZ-timing
commands can be used inside \begin{tikzpicture} ... \end{tikzpicture}
:
\begin{tikzpicture} [+preamble] \usepackage{tikz-timing} [/preamble] \timing [ yscale=2.0, timing/wscale=3.0, timing/inline node/.style={rectangle,below left,font=\sffamily} ] at (0,0) {H N {D7} L H N {D6} L H N {D5} L H N {D4} L H N {D3} L H N {D2} L H N {D1} L H N {D0} L H N[xscale=.8]{ACK} L}; \end{tikzpicture}
QuickLaTeX renders it as
For more complex diagrams we can use \begin{tikztimingtable} ... \end{tikztimingtable}
. QuickLaTeX supports them inserted directly on the page:
\begin{tikztimingtable} [+preamble] \usepackage{tikz-timing} \def\degr{${}^\circ$} [/preamble] Clock 128\,MHz 0\degr & H 2C N(A1) 8{2C} N(A5) 3{2C} G\\ Clock 128\,MHz 90\degr & [C] 2{2C} N(A2) 8{2C} N(A6) 2{2C} C\\ Clock 128\,MHz 180\degr & C 2{2C} N(A3) 8{2C} N(A7) 2{2C} G\\ Clock 128\,MHz 270\degr & 3{2C} N(A4) 8{2C} N(A8) 2C C\\ Coarse Pulse & 3L 16H 6L \\ Coarse Pulse - Delayed 1 & 4L N(B2) 16H N(B6) 5L \\ Coarse Pulse - Delayed 2 & 5L N(B3) 16H N(B7) 4L \\ Coarse Pulse - Delayed 3 & 6L 16H 3L \\ \\ Final Pulse Set & 3L 16H N(B5) 6L \\ Final Pulse $\overline{\mbox{Reset}}$ & 6L N(B4) 16H 3L \\ Final Pulse & 3L N(B1) 19H N(B8) 3L \\ \extracode \tablerules \begin{pgfonlayer}{background} \foreach \n in {1,...,8} \draw [help lines] (A\n) -- (B\n); \end{pgfonlayer} \end{tikztimingtable}
QuickLaTeX compiles this code and places on the page as:
Here are several other examples.
SPI Timing Diagram:
\begin{tikztimingtable} [timing/d/background/.style={fill=white}, timing/lslope=0.2 xscale=1.5,yscale=1.5, % scale diagrams] [+preamble] \usepackage{tikz-timing} \usetikztiminglibrary[new={char=Q,reset char=R}]{counters} [/preamble] CPOL=0 & LL 15{T} LL \\ CPOL=1 & HH 15{T} HH \\ & H 17L H \\ \\ Cycle \# & U R 8{2Q} 2U \\ MISO & D{z} R 8{2Q} 2D{z} \\ MOSI & D{z} R 8{2Q} 2D{z} \\ \\ Cycle \# & UU R 8{2Q} U \\ MISO & D{z}U R 8{2Q} D{z} \\ MOSI & D{z}U R 8{2Q} D{z} \\ \extracode % Add vertical lines in two colors \begin{pgfonlayer}{background} \begin{scope}[semitransparent,semithick] \vertlines[red]{2.1,4.1,...,17.1} \vertlines[blue]{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,-9) {CPHA=0}; \node at (1ex,-17) {CPHA=1}; \end{scope} \end{tikztimingtable}
2 Comments
Can you please tell me how I can just “add” a timing diagram as part of a larger document? All the above examples render a PDF with just the timing diagram. I am looking for an example, where the timing diagram is included as part of a bigger text.
Could you show an example – I am not quite understand what you mean.