目标

目标

我正在尝试重新创建 AHB-lite 和 APB 的时序图,但在重新创建“瞬态”和“高/低到高”时序字符时遇到了一些问题。

在此处输入图片描述

目标

ARM 的版本

当前解决方案

我的 AHB-Lite 版本读

代码

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{tikz-timing}
\usetikztiminglibrary{either}

\newcommand{\timingaxis}[1][]{%
  \begin{scope}[#1]
  \draw [timing/table/axis] (0,+1) -- (\twidth+1,+1);
  \foreach \n in {0,1,...,\twidth} {
    \draw [timing/table/axis ticks]
        (\n,+1) -- +(0,-.2)
        node [below,inner sep=2pt] {\scalebox{.75}{\tiny\n}};
  }
  \draw [timing/table/axis] (0,-\rowdist*\nrows+1.5*\rowdist) -- (\twidth+1,-\rowdist*\nrows+1.5*\rowdist);
  \foreach \n in {0,1,...,\twidth} {
    \draw [timing/table/axis ticks]
        (\n,-\rowdist*\nrows+1.5*\rowdist) -- +(0,-.2)
        node [below,inner sep=2pt] {\scalebox{.75}{\tiny\n}};
  }
  \end{scope}
}
\tikzset{%
    timing/table/axis/.style={->,>=latex},
    timing/table/axis ticks/.style={},
}

\begin{document}

% Defining foreground (fg) and background (bg) colors
\definecolor{bgblue}{rgb}{0.41961,0.80784,0.80784}%
\definecolor{bgred}{rgb}{1,0.61569,0.61569}%
\definecolor{fgblue}{rgb}{0,0,0.6}%
\definecolor{fgred}{rgb}{0.6,0,0}%

\begin{figure}
    \centering
    \begin{tikztimingtable}[
        timing/coldist=4pt,     % column distance
        xscale=2.05,yscale=1.1, % scale diagrams
        semithick               % set line width
      ]
      \\
      HCLK          & 4H 3{4C}  [[timing/slope=0]] H\\
      \\
      HADDR[31:0]   & 0.2D 0.4U {7.6D{A}} 0.4U {7.6D{B}} 0.4U 0.4D \\
      HWRITE        & 0.4H 0.4e 7.7L 0.2E0H 7.7E 0.4U 0.4D \\
      HDATA[31:0]   & 0.2D 0.4U 7.6D 5U {3D{Data (A)}} 0.4U 0.4D \\
      HREADY        & 0.4H [| timing/e/background/ ={ fill=gray } |]0.2e 7.8H 0.2e 8H 0.2E0H 0.4E \\
      \\
    \begin{extracode}
      \begin{pgfonlayer}{background}
        \begin{scope}[semitransparent,semithick, loosely dotted]
          \vertlines[red]{0,2,4,...,16}
          \vertlines[blue]{1,3,5,...,16}
        \end{scope}
      \end{pgfonlayer}
        \timingaxis\relax
      \tablerules
      % \begin{pgfonlayer}{background}
      %   \foreach \n in {1,...,8}
      %     \draw [help lines] (A\n) -- (B\n);
      % \end{pgfonlayer}
    \end{extracode}
    \end{tikztimingtable}
    \caption{AHB-Lite Read transfer}
    \label{fig:ahbl1}
\end{figure}

\end{document}

答案1

我不太熟悉,tikz但我正在尝试解决你的问题。我认为你已经接近目标了。你所需要的只是阅读手册,尝试不同的想法,多思考,永不放弃!在此处输入图片描述 以下是我的想法:

  1. 看起来有些多边形没有正确填充,只需将其设为timing/e/background/.style={fill=gray}全局,现在所有多边形都填充为灰色:Timing/e/background/.style={fill=gray} 设置为全局
  2. HWRITE改变后,这一排看起来很奇怪,HWRITE& 0.4H 0.4e 7.7L 0.2E 0H 7.7D 0.4U 0.4D看起来很接近我们的目标。在此处输入图片描述然后看了tikz-timing手册4.3 Overlays,我们用覆盖层来覆盖奇怪的路径,改成HWRITE & 0.4H 0.4e 7.7L 0.2E 0H O{0D} 7.7D 0.4U 0.4D,看起来更糟糕!在此处输入图片描述不过不用担心,因为tikz-timing一直在控制之下tikz,给覆盖层加一个偏移量HWRITE & 0.4H 0.4e 7.7L 0.2E 0H O{[yshift=-3.9]0D} 7.7D{} 0.4U 0.4D在此处输入图片描述
  3. 用同样的方法解决最后一行HREADY & 0.4H 0.2e 7.8H 0.2e 8H 0.2E 0L O{[yshift=3.9]0D} 0.4D在此处输入图片描述 最终的代码应该是:
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{tikz-timing}
\usetikztiminglibrary{either}

\newcommand{\timingaxis}[1][]{%
  \begin{scope}[#1]
  \draw [timing/table/axis] (0,+1) -- (\twidth+1,+1);
  \foreach \n in {0,1,...,\twidth} {
    \draw [timing/table/axis ticks]
        (\n,+1) -- +(0,-.2)
        node [below,inner sep=2pt] {\scalebox{.75}{\tiny\n}};
  }
  \draw [timing/table/axis] (0,-\rowdist*\nrows+1.5*\rowdist) -- (\twidth+1,-\rowdist*\nrows+1.5*\rowdist);
  \foreach \n in {0,1,...,\twidth} {
    \draw [timing/table/axis ticks]
        (\n,-\rowdist*\nrows+1.5*\rowdist) -- +(0,-.2)
        node [below,inner sep=2pt] {\scalebox{.75}{\tiny\n}};
  }
  \end{scope}
}
\tikzset{%
    timing/table/axis/.style={->,>=latex},
    timing/table/axis ticks/.style={},
}

\begin{document}

% Defining foreground (fg) and background (bg) colors
\definecolor{bgblue}{rgb}{0.41961,0.80784,0.80784}%
\definecolor{bgred}{rgb}{1,0.61569,0.61569}%
\definecolor{fgblue}{rgb}{0,0,0.6}%
\definecolor{fgred}{rgb}{0.6,0,0}%

\begin{figure}
    \centering
    \begin{tikztimingtable}[
        timing/coldist=4pt,     % column distance
        xscale=2.05,yscale=1.1, % scale diagrams
        semithick,               % set line width
        timing/e/background/.style={fill=gray},
      ]
      \\
      HCLK          & 4H 3{4C}  [[timing/slope=0]] H\\
      \\
      HADDR[31:0]   & 0.2D 0.4U {7.6D{A}} 0.4U {7.6D{B}} 0.4U 0.4D \\
      HWRITE        & 0.4H 0.4e 7.7L 0.2E 0H O{[yshift=-3.9]0D} 7.7D{} 0.4U 0.4D \\
      HDATA[31:0]   & 0.2D 0.4U 7.6D 5U {3D{Data (A)}} 0.4U 0.4D \\
      HREADY        & 0.4H 0.2e 7.8H 0.2e 8H 0.2E 0L O{[yshift=3.9]0D} 0.4D\\
      \\
    \begin{extracode}
      \begin{pgfonlayer}{background}
        \begin{scope}[semitransparent,semithick, loosely dotted]
          \vertlines[red]{0,2,4,...,16}
          \vertlines[blue]{1,3,5,...,16}
        \end{scope}
      \end{pgfonlayer}
        \timingaxis\relax
      \tablerules
      % \begin{pgfonlayer}{background}
      %   \foreach \n in {1,...,8}
      %     \draw [help lines] (A\n) -- (B\n);
      % \end{pgfonlayer}
    \end{extracode}
    \end{tikztimingtable}
    \caption{AHB-Lite Read transfer}
    \label{fig:ahbl1}
\end{figure}

\end{document}

相关内容