TIKZ:带有点和垂直列标题的矩阵

TIKZ:带有点和垂直列标题的矩阵

我完全被 tikz 中的这个图表难住了:

在此处输入图片描述

尤其是我不知道如何制作这些点。另一个问题是矩阵的标题。我实际上想用垂直文本标记每列。

任何帮助或想法都将不胜感激!

谢谢

马塞尔

答案1

这是 tikz 的代码

    \documentclass[a4paper]{article}
    \usepackage[left=0.2cm,right=1cm]{geometry}
    \usepackage{tikz,xcolor}
    \usepackage{amsmath}
    \usepackage{graphicx}
    \usepackage{scalerel}
    \usetikzlibrary{matrix,positioning,shapes}
    \tikzstyle{square}=[minimum size=0.5cm,draw]
    \tikzstyle{myrec}=[rectangle, minimum width=3.1cm, minimum height=1.6cm, text centered, draw=black,text width=3cm]

  \newcommand{\mydot}{\raisebox{-0.2ex}{\hspace*{-0.5mm}\LARGE\bfseries ...}}
  \newcommand\xdownarrow[1][2ex]{\mathrel{\rotatebox{90}{$\xleftarrow{\rule{#1}{0pt}}$}}}


   \begin{document}
   \begin{center}
     \begin{tikzpicture}
     \def\square;{\node[square](a1){};\node[square,right of=a1,xshift=-5mm](a2){};\node[square,right of=a2,xshift=-5mm](a3){};\node[right of=a3,scale=0.7mm,xshift=-2.0mm](d1){...};\node[square,right of=d1,xshift=-4mm](d2){};\node[square,right of=d2,xshift=-5mm]{};}
           \node[] at (-6.7,3.3) (b1) {$\overbrace{~~~~~~~~~~~~~~~~~~~~~~~~~~~}$};
           \node[right of=b1,xshift=2.5cm] (b2) {$\overbrace{~~~~~~~~~~~~~~~~~~~~~~~~~~~}$};
           \node[right of=b2,xshift=2.7cm] (b3) {$\overbrace{~~~~~~~~~~~~~~~~~~~~~~~~~~~}$};
           \node[right of=b3,xshift=2.5cm] (b4) {$\overbrace{~~~~~~~~~~~~~~~~~~~~~~~~~~~}$};
           \node[rotate=-90] at (6.5,0) (c) {$\overbrace{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}$};
           \node[right of=c,scale=1.5,xshift=0.3cm]  {Op-Code};
           \node[scale=1.5,xshift=0.3cm] at (-9,0)  {~~~~~~~~~~~~~};
           \node[above of=b2,yshift=1cm,xshift=2cm,scale=2] {\bfseries Control Table};
           \node[above of=b1,yshift=-0.3cm,text width=1.5cm,text centered] {Control Signals};
           \node[above of=b2,yshift=-0.3cm,text width=2.6cm,text centered] {Micro-Sequenzer Instruction};
           \node[above of=b3,yshift=-0.3cm,text width=2.6cm,text centered] {Condition Selector};
           \node[above of=b4,yshift=-0.3cm,text width=2.0cm,text centered] {Branch Address};
           \draw[->] (-9,1.5)-- (-8,1.5);
           \node at (-10.0,1.5) {\bfseries\large Micro-PC};

           \matrix (M)[matrix of math nodes,rectangle,draw,xshift=-1.3cm]
            {
             \square;  &\hspace{-0.5mm}& \square; &\hspace*{-3.5mm}& \square;&\hspace{-0.5mm}&\square; \\
             \square;  &\hspace{-0.5mm}& \square; &\hspace*{-3.5mm}& \square;&\hspace{-0.5mm}&\square; \\
             \square;  &\hspace{-0.5mm}& \square; &\hspace*{-3.5mm}& \square;&\hspace{-0.5mm}&\square; \\
             \square;  &\hspace{-0.5mm}& \square; &\hspace*{-3.5mm}& \square;&\hspace{-0.5mm}&\square; \\
               & & & \node[scale=0.7mm] {\vdots};  &   &         &         \\ 
             \square;  &\hspace{-0.5mm}& \square; &\hspace*{-3.5mm}& \square;&\hspace{-0.5mm}&\square; \\
             \square;  &\hspace{-0.5mm}& \square; &\hspace*{-3.5mm}& \square;&\hspace{-0.5mm}&\square; \\
             \square;  &\hspace{-0.5mm}& \square; &\hspace*{-3.5mm}& \square;&\hspace{-0.5mm}&\square; \\
             \square;  &\hspace{-0.5mm}& \square; &\hspace*{-3.5mm}& \square;&\hspace{-0.5mm}&\square; \\           
             };

     \end{tikzpicture}
     \vspace{-0.7mm}
     $\xdownarrow[1cm]$

      \begin{tikzpicture}
     \def\square;{\node[square](a1){};\node[square,right of=a1,xshift=-5mm](a2){};\node[square,right of=a2,xshift=-5mm](a3){};\node[right of=a3,scale=0.7mm,xshift=-2.0mm](d1){...};\node[square,right of=d1,xshift=-4mm](d2){};\node[square,right of=d2,xshift=-5mm]{};}

           \matrix (N)[matrix of math nodes,rectangle,draw]
            {
             \square;  &\hspace{-0.5mm}& \square; &\hspace{-0.5mm}& \square;&\hspace{-0.5mm}&\square; \\
            };
            \node[myrec] at (-5.2,-2.5) (r1) {Datapath};
            \node[myrec,right of=r1,xshift=2.5cm] (r2) {Micro Sequenzer Instruction};
            \node[myrec,right of=r2,xshift=2.5cm] (r3) {Condition Selector};
            \node[myrec,right of=r3,xshift=2.5cm] (r4) {Branch Address};
            \node[above of=r1,yshift=0.5cm] {$\xdownarrow[1cm]$};
            \node[above of=r2,yshift=0.5cm] {$\xdownarrow[1cm]$};
            \node[above of=r3,yshift=0.5cm] {$\xdownarrow[1cm]$};
            \node[above of=r4,yshift=0.5cm] (side) {$\xdownarrow[1cm]$};
            \node[text width=3.5cm,text centered] at (9,0) {Active Control Signals};
            \node[text width=3.5cm,text centered] at (-8,0) {~~~};
            \end{tikzpicture}
    \end{center}
     \end{document}

在此处输入图片描述

答案2

解决方案tikz。我使用两个循环来定位 3+2 个小方块的块。在每个块中,最左侧和最右侧的节点都有名称,可用于定位箭头和其他东西。

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing,fit,positioning}
\begin{document}
\begin{tikzpicture}[%
  node distance=1mm and 1mm,
  SmallSq/.style={inner sep=0mm,minimum size=5mm,draw},
  CurlyBrace/.style={decorate,decoration={brace,amplitude=5pt}},
  CurlyBraceMirror/.style={decorate,decoration={brace,amplitude=5pt,mirror}},
  TextBox/.style={pos=0.5,yshift=3mm,anchor=west,rotate=90,text width=3cm},
  FrameTextBox/.style={draw,text width=2.5cm, minimum width=2.8cm,minimum height=1.5cm,below,align=center},
  ]
  \newcommand\SqRowDist{3.3}
  \foreach \x in {0,1,2,3}{
    \foreach \y in {-2,1,2,3,4,6,7,8,9}{
      \node[SmallSq] (SqL\x\y) at (\x*\SqRowDist,\y*0.6){};
      \node[SmallSq] at (\x*\SqRowDist+0.5,\y*0.6){};
      \node[SmallSq] at (\x*\SqRowDist+1,\y*0.6){};
      \node at (\x*\SqRowDist+1.5,\y*0.6){$\cdots$};
      \node[SmallSq] at (\x*\SqRowDist+2,\y*0.6){};
      \node[SmallSq] (SqR\x\y) at (\x*\SqRowDist+2.5,\y*0.6){};
    }
  }
  \node[draw,fit=(SqL01)(SqR39)](BigSq){};
  \node[draw,fit=(SqL0-2)(SqR3-2)](LowSq){};
  \node at ($(SqR14.north east)!0.5!(SqL26.south west)$){$\vdots$};
  %%
  \draw[latex-] (SqL07.west) -- +(-1,0)node[left]{Micro PC};
  \draw[CurlyBrace] ($(SqL09.north west)+(0,0.2)$)--($(SqR09.north east)+(0,0.2)$) node[TextBox]{Control signal};
  \draw[CurlyBrace] ($(SqL19.north west)+(0,0.2)$)--($(SqR19.north east)+(0,0.2)$) node[TextBox]{Micro-Sequencer Instruction};
  \draw[CurlyBrace] ($(SqL29.north west)+(0,0.2)$)--($(SqR29.north east)+(0,0.2)$) node[TextBox]{Condition Selector};
  \draw[CurlyBrace] ($(SqL39.north west)+(0,0.2)$)--($(SqR39.north east)+(0,0.2)$) node[TextBox]{Branch Address};
  %%
  \draw[-latex]({$(SqL0-2)!0.5!(SqR0-2)$} |- LowSq.south) -- +(0,-1) node[FrameTextBox]{Datapath};
  \draw[-latex]({$(SqL1-2)!0.5!(SqR1-2)$} |- LowSq.south) -- +(0,-1) node[FrameTextBox]{Micro-Sequencer Instruction};
  \draw[-latex]({$(SqL2-2)!0.5!(SqR2-2)$} |- LowSq.south) -- +(0,-1) node[FrameTextBox]{Condition Selector};
  \draw[-latex]({$(SqL3-2)!0.5!(SqR3-2)$} |- LowSq.south) -- +(0,-1) node[FrameTextBox]{Branch Address};
  %%
  \draw[CurlyBraceMirror] ($(SqR32.south east)+(0.2,0)$)--($(SqR37.north east)+(0.2,0)$) node[pos=0.5,xshift=3mm,right]{OP code};
  \node[right] at ($(LowSq.east)+(0.2,0)$){Active Control Signals}; 
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容